lua: Fixed some cross-platform issues for PPC (and probably other architectures)
[openwrt.git] / target / linux / pxa / patches-2.6.21 / 007-flash.patch
1 Index: linux-2.6.21.7/drivers/mtd/maps/gumstix-flash.c
2 ===================================================================
3 --- /dev/null
4 +++ linux-2.6.21.7/drivers/mtd/maps/gumstix-flash.c
5 @@ -0,0 +1,136 @@
6 +/*
7 + * Map driver for the Gumstix platform
8 + *
9 + * Author: Craig Hughes
10 + *
11 + * This program is free software; you can redistribute it and/or modify
12 + * it under the terms of the GNU General Public License version 2 as
13 + * published by the Free Software Foundation.
14 + */
15 +
16 +#include <linux/module.h>
17 +#include <linux/types.h>
18 +#include <linux/kernel.h>
19 +#include <linux/init.h>
20 +#include <linux/mtd/mtd.h>
21 +#include <linux/mtd/map.h>
22 +#include <linux/mtd/partitions.h>
23 +#include <asm/io.h>
24 +#include <asm/hardware.h>
25 +#include <asm/arch/gumstix.h>
26 +
27 +
28 +#define ROM_ADDR 0x00000000
29 +#define FLASH_ADDR 0x00000000
30 +
31 +#define WINDOW_SIZE 64*1024*1024
32 +
33 +static struct map_info gumstix_flash_maps[1] = { {
34 + .name = "Gumstix Flash ROM",
35 + .size = WINDOW_SIZE,
36 + .phys = FLASH_ADDR,
37 + .bankwidth = 2,
38 +} };
39 +
40 +static struct mtd_partition gumstix_flash_partitions[] = {
41 + {
42 + .name = "Bootloader",
43 + .size = 0x00040000,
44 + .offset = FLASH_ADDR
45 + },{
46 + .name = "RootFS",
47 + .size = MTDPART_SIZ_FULL,
48 + .offset = MTDPART_OFS_APPEND
49 + }
50 +};
51 +
52 +static struct mtd_info *mymtds[1];
53 +static struct mtd_partition *parsed_parts[1];
54 +static int nr_parsed_parts[1];
55 +
56 +static const char *probes[] = { NULL };
57 +
58 +static int __init gumstix_flashmap_init(void)
59 +{
60 + int ret = 0, i;
61 +
62 + for (i = 0; i < 1; i++) {
63 + gumstix_flash_maps[i].virt = ioremap(gumstix_flash_maps[i].phys, WINDOW_SIZE);
64 + if (!gumstix_flash_maps[i].virt) {
65 + printk(KERN_WARNING "Failed to ioremap %s\n", gumstix_flash_maps[i].name);
66 + if (!ret)
67 + ret = -ENOMEM;
68 + continue;
69 + }
70 + simple_map_init(&gumstix_flash_maps[i]);
71 +
72 + printk(KERN_NOTICE "Probing %s at physical address 0x%08lx (%d-bit bankwidth)\n",
73 + gumstix_flash_maps[i].name, gumstix_flash_maps[i].phys,
74 + gumstix_flash_maps[i].bankwidth * 8);
75 +
76 + mymtds[i] = do_map_probe("cfi_probe", &gumstix_flash_maps[i]);
77 +
78 + if (!mymtds[i]) {
79 + iounmap((void *)gumstix_flash_maps[i].virt);
80 + if (gumstix_flash_maps[i].cached)
81 + iounmap(gumstix_flash_maps[i].cached);
82 + if (!ret)
83 + ret = -EIO;
84 + continue;
85 + }
86 + mymtds[i]->owner = THIS_MODULE;
87 +
88 + ret = parse_mtd_partitions(mymtds[i], probes,
89 + &parsed_parts[i], 0);
90 +
91 + if (ret > 0)
92 + nr_parsed_parts[i] = ret;
93 + }
94 +
95 + if (!mymtds[0])
96 + return ret;
97 +
98 + for (i = 0; i < 1; i++) {
99 + if (!mymtds[i]) {
100 + printk(KERN_WARNING "%s is absent. Skipping\n", gumstix_flash_maps[i].name);
101 + } else if (nr_parsed_parts[i]) {
102 + add_mtd_partitions(mymtds[i], parsed_parts[i], nr_parsed_parts[i]);
103 + } else if (!i) {
104 + printk("Using static partitions on %s\n", gumstix_flash_maps[i].name);
105 + add_mtd_partitions(mymtds[i], gumstix_flash_partitions, ARRAY_SIZE(gumstix_flash_partitions));
106 + } else {
107 + printk("Registering %s as whole device\n", gumstix_flash_maps[i].name);
108 + add_mtd_device(mymtds[i]);
109 + }
110 + }
111 + return 0;
112 +}
113 +
114 +static void __exit gumstix_flashmap_cleanup(void)
115 +{
116 + int i;
117 + for (i = 0; i < 1; i++) {
118 + if (!mymtds[i])
119 + continue;
120 +
121 + if (nr_parsed_parts[i] || !i)
122 + del_mtd_partitions(mymtds[i]);
123 + else
124 + del_mtd_device(mymtds[i]);
125 +
126 + map_destroy(mymtds[i]);
127 + iounmap((void *)gumstix_flash_maps[i].virt);
128 + if (gumstix_flash_maps[i].cached)
129 + iounmap(gumstix_flash_maps[i].cached);
130 +
131 + if (parsed_parts[i])
132 + kfree(parsed_parts[i]);
133 + }
134 +}
135 +
136 +module_init(gumstix_flashmap_init);
137 +module_exit(gumstix_flashmap_cleanup);
138 +
139 +MODULE_LICENSE("GPL");
140 +MODULE_AUTHOR("Gumstix, Inc. <gumstix-users@lists.sf.net>");
141 +MODULE_DESCRIPTION("MTD map driver for the Gumstix Platform");
142 Index: linux-2.6.21.7/drivers/mtd/maps/Kconfig
143 ===================================================================
144 --- linux-2.6.21.7.orig/drivers/mtd/maps/Kconfig
145 +++ linux-2.6.21.7/drivers/mtd/maps/Kconfig
146 @@ -131,6 +131,13 @@ config MTD_SBC_GXX
147 More info at
148 <http://www.arcomcontrols.com/products/icp/pc104/processors/SBC_GX1.htm>.
149
150 +config MTD_GUMSTIX
151 + tristate "CFI Flash device mapped on Gumstix"
152 + depends on ARCH_GUMSTIX && MTD_CFI_INTELEXT && MTD_PARTITIONS
153 + help
154 + This provides a driver for the on-board flash of the Gumstix
155 + single board computers.
156 +
157 config MTD_LUBBOCK
158 tristate "CFI Flash device mapped on Intel Lubbock XScale eval board"
159 depends on ARCH_LUBBOCK && MTD_CFI_INTELEXT && MTD_PARTITIONS
160 Index: linux-2.6.21.7/drivers/mtd/maps/Makefile
161 ===================================================================
162 --- linux-2.6.21.7.orig/drivers/mtd/maps/Makefile
163 +++ linux-2.6.21.7/drivers/mtd/maps/Makefile
164 @@ -21,6 +21,7 @@ obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o
165 obj-$(CONFIG_MTD_CK804XROM) += ck804xrom.o
166 obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o
167 obj-$(CONFIG_MTD_LUBBOCK) += lubbock-flash.o
168 +obj-$(CONFIG_MTD_GUMSTIX) += gumstix-flash.o
169 obj-$(CONFIG_MTD_MAINSTONE) += mainstone-flash.o
170 obj-$(CONFIG_MTD_MBX860) += mbx860.o
171 obj-$(CONFIG_MTD_CEIVA) += ceiva.o
This page took 0.057599 seconds and 5 git commands to generate.