GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / mtd / maps / cdb89712.c
blob8d92d8db9a98c0a3c5625ce74fd27a4268070ba4
1 /*
2 * Flash on Cirrus CDB89712
4 */
6 #include <linux/module.h>
7 #include <linux/types.h>
8 #include <linux/kernel.h>
9 #include <linux/ioport.h>
10 #include <linux/init.h>
11 #include <asm/io.h>
12 #include <mach/hardware.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/map.h>
15 #include <linux/mtd/partitions.h>
17 /* dynamic ioremap() areas */
18 #define FLASH_START 0x00000000
19 #define FLASH_SIZE 0x800000
20 #define FLASH_WIDTH 4
22 #define SRAM_START 0x60000000
23 #define SRAM_SIZE 0xc000
24 #define SRAM_WIDTH 4
26 #define BOOTROM_START 0x70000000
27 #define BOOTROM_SIZE 0x80
28 #define BOOTROM_WIDTH 4
31 static struct mtd_info *flash_mtd;
33 struct map_info cdb89712_flash_map = {
34 .name = "flash",
35 .size = FLASH_SIZE,
36 .bankwidth = FLASH_WIDTH,
37 .phys = FLASH_START,
40 struct resource cdb89712_flash_resource = {
41 .name = "Flash",
42 .start = FLASH_START,
43 .end = FLASH_START + FLASH_SIZE - 1,
44 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
47 static int __init init_cdb89712_flash (void)
49 int err;
51 if (request_resource (&ioport_resource, &cdb89712_flash_resource)) {
52 printk(KERN_NOTICE "Failed to reserve Cdb89712 FLASH space\n");
53 err = -EBUSY;
54 goto out;
57 cdb89712_flash_map.virt = ioremap(FLASH_START, FLASH_SIZE);
58 if (!cdb89712_flash_map.virt) {
59 printk(KERN_NOTICE "Failed to ioremap Cdb89712 FLASH space\n");
60 err = -EIO;
61 goto out_resource;
63 simple_map_init(&cdb89712_flash_map);
64 flash_mtd = do_map_probe("cfi_probe", &cdb89712_flash_map);
65 if (!flash_mtd) {
66 flash_mtd = do_map_probe("map_rom", &cdb89712_flash_map);
67 if (flash_mtd)
68 flash_mtd->erasesize = 0x10000;
70 if (!flash_mtd) {
71 printk("FLASH probe failed\n");
72 err = -ENXIO;
73 goto out_ioremap;
76 flash_mtd->owner = THIS_MODULE;
78 if (add_mtd_device(flash_mtd)) {
79 printk("FLASH device addition failed\n");
80 err = -ENOMEM;
81 goto out_probe;
84 return 0;
86 out_probe:
87 map_destroy(flash_mtd);
88 flash_mtd = 0;
89 out_ioremap:
90 iounmap((void *)cdb89712_flash_map.virt);
91 out_resource:
92 release_resource (&cdb89712_flash_resource);
93 out:
94 return err;
101 static struct mtd_info *sram_mtd;
103 struct map_info cdb89712_sram_map = {
104 .name = "SRAM",
105 .size = SRAM_SIZE,
106 .bankwidth = SRAM_WIDTH,
107 .phys = SRAM_START,
110 struct resource cdb89712_sram_resource = {
111 .name = "SRAM",
112 .start = SRAM_START,
113 .end = SRAM_START + SRAM_SIZE - 1,
114 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
117 static int __init init_cdb89712_sram (void)
119 int err;
121 if (request_resource (&ioport_resource, &cdb89712_sram_resource)) {
122 printk(KERN_NOTICE "Failed to reserve Cdb89712 SRAM space\n");
123 err = -EBUSY;
124 goto out;
127 cdb89712_sram_map.virt = ioremap(SRAM_START, SRAM_SIZE);
128 if (!cdb89712_sram_map.virt) {
129 printk(KERN_NOTICE "Failed to ioremap Cdb89712 SRAM space\n");
130 err = -EIO;
131 goto out_resource;
133 simple_map_init(&cdb89712_sram_map);
134 sram_mtd = do_map_probe("map_ram", &cdb89712_sram_map);
135 if (!sram_mtd) {
136 printk("SRAM probe failed\n");
137 err = -ENXIO;
138 goto out_ioremap;
141 sram_mtd->owner = THIS_MODULE;
142 sram_mtd->erasesize = 16;
144 if (add_mtd_device(sram_mtd)) {
145 printk("SRAM device addition failed\n");
146 err = -ENOMEM;
147 goto out_probe;
150 return 0;
152 out_probe:
153 map_destroy(sram_mtd);
154 sram_mtd = 0;
155 out_ioremap:
156 iounmap((void *)cdb89712_sram_map.virt);
157 out_resource:
158 release_resource (&cdb89712_sram_resource);
159 out:
160 return err;
169 static struct mtd_info *bootrom_mtd;
171 struct map_info cdb89712_bootrom_map = {
172 .name = "BootROM",
173 .size = BOOTROM_SIZE,
174 .bankwidth = BOOTROM_WIDTH,
175 .phys = BOOTROM_START,
178 struct resource cdb89712_bootrom_resource = {
179 .name = "BootROM",
180 .start = BOOTROM_START,
181 .end = BOOTROM_START + BOOTROM_SIZE - 1,
182 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
185 static int __init init_cdb89712_bootrom (void)
187 int err;
189 if (request_resource (&ioport_resource, &cdb89712_bootrom_resource)) {
190 printk(KERN_NOTICE "Failed to reserve Cdb89712 BOOTROM space\n");
191 err = -EBUSY;
192 goto out;
195 cdb89712_bootrom_map.virt = ioremap(BOOTROM_START, BOOTROM_SIZE);
196 if (!cdb89712_bootrom_map.virt) {
197 printk(KERN_NOTICE "Failed to ioremap Cdb89712 BootROM space\n");
198 err = -EIO;
199 goto out_resource;
201 simple_map_init(&cdb89712_bootrom_map);
202 bootrom_mtd = do_map_probe("map_rom", &cdb89712_bootrom_map);
203 if (!bootrom_mtd) {
204 printk("BootROM probe failed\n");
205 err = -ENXIO;
206 goto out_ioremap;
209 bootrom_mtd->owner = THIS_MODULE;
210 bootrom_mtd->erasesize = 0x10000;
212 if (add_mtd_device(bootrom_mtd)) {
213 printk("BootROM device addition failed\n");
214 err = -ENOMEM;
215 goto out_probe;
218 return 0;
220 out_probe:
221 map_destroy(bootrom_mtd);
222 bootrom_mtd = 0;
223 out_ioremap:
224 iounmap((void *)cdb89712_bootrom_map.virt);
225 out_resource:
226 release_resource (&cdb89712_bootrom_resource);
227 out:
228 return err;
235 static int __init init_cdb89712_maps(void)
238 printk(KERN_INFO "Cirrus CDB89712 MTD mappings:\n Flash 0x%x at 0x%x\n SRAM 0x%x at 0x%x\n BootROM 0x%x at 0x%x\n",
239 FLASH_SIZE, FLASH_START, SRAM_SIZE, SRAM_START, BOOTROM_SIZE, BOOTROM_START);
241 init_cdb89712_flash();
242 init_cdb89712_sram();
243 init_cdb89712_bootrom();
245 return 0;
249 static void __exit cleanup_cdb89712_maps(void)
251 if (sram_mtd) {
252 del_mtd_device(sram_mtd);
253 map_destroy(sram_mtd);
254 iounmap((void *)cdb89712_sram_map.virt);
255 release_resource (&cdb89712_sram_resource);
258 if (flash_mtd) {
259 del_mtd_device(flash_mtd);
260 map_destroy(flash_mtd);
261 iounmap((void *)cdb89712_flash_map.virt);
262 release_resource (&cdb89712_flash_resource);
265 if (bootrom_mtd) {
266 del_mtd_device(bootrom_mtd);
267 map_destroy(bootrom_mtd);
268 iounmap((void *)cdb89712_bootrom_map.virt);
269 release_resource (&cdb89712_bootrom_resource);
273 module_init(init_cdb89712_maps);
274 module_exit(cleanup_cdb89712_maps);
276 MODULE_AUTHOR("Ray L");
277 MODULE_DESCRIPTION("ARM CDB89712 map driver");
278 MODULE_LICENSE("GPL");