USB: Correct Sierra Wireless USB EVDO Modem Device ID
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / mtd / maps / cdb89712.c
blobe5059aa3c724b189613db3ab6a61255a91d2f3be
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>
20 static struct mtd_info *flash_mtd;
22 struct map_info cdb89712_flash_map = {
23 .name = "flash",
24 .size = FLASH_SIZE,
25 .bankwidth = FLASH_WIDTH,
26 .phys = FLASH_START,
29 struct resource cdb89712_flash_resource = {
30 .name = "Flash",
31 .start = FLASH_START,
32 .end = FLASH_START + FLASH_SIZE - 1,
33 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
36 static int __init init_cdb89712_flash (void)
38 int err;
40 if (request_resource (&ioport_resource, &cdb89712_flash_resource)) {
41 printk(KERN_NOTICE "Failed to reserve Cdb89712 FLASH space\n");
42 err = -EBUSY;
43 goto out;
46 cdb89712_flash_map.virt = ioremap(FLASH_START, FLASH_SIZE);
47 if (!cdb89712_flash_map.virt) {
48 printk(KERN_NOTICE "Failed to ioremap Cdb89712 FLASH space\n");
49 err = -EIO;
50 goto out_resource;
52 simple_map_init(&cdb89712_flash_map);
53 flash_mtd = do_map_probe("cfi_probe", &cdb89712_flash_map);
54 if (!flash_mtd) {
55 flash_mtd = do_map_probe("map_rom", &cdb89712_flash_map);
56 if (flash_mtd)
57 flash_mtd->erasesize = 0x10000;
59 if (!flash_mtd) {
60 printk("FLASH probe failed\n");
61 err = -ENXIO;
62 goto out_ioremap;
65 flash_mtd->owner = THIS_MODULE;
67 if (add_mtd_device(flash_mtd)) {
68 printk("FLASH device addition failed\n");
69 err = -ENOMEM;
70 goto out_probe;
73 return 0;
75 out_probe:
76 map_destroy(flash_mtd);
77 flash_mtd = 0;
78 out_ioremap:
79 iounmap((void *)cdb89712_flash_map.virt);
80 out_resource:
81 release_resource (&cdb89712_flash_resource);
82 out:
83 return err;
90 static struct mtd_info *sram_mtd;
92 struct map_info cdb89712_sram_map = {
93 .name = "SRAM",
94 .size = SRAM_SIZE,
95 .bankwidth = SRAM_WIDTH,
96 .phys = SRAM_START,
99 struct resource cdb89712_sram_resource = {
100 .name = "SRAM",
101 .start = SRAM_START,
102 .end = SRAM_START + SRAM_SIZE - 1,
103 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
106 static int __init init_cdb89712_sram (void)
108 int err;
110 if (request_resource (&ioport_resource, &cdb89712_sram_resource)) {
111 printk(KERN_NOTICE "Failed to reserve Cdb89712 SRAM space\n");
112 err = -EBUSY;
113 goto out;
116 cdb89712_sram_map.virt = ioremap(SRAM_START, SRAM_SIZE);
117 if (!cdb89712_sram_map.virt) {
118 printk(KERN_NOTICE "Failed to ioremap Cdb89712 SRAM space\n");
119 err = -EIO;
120 goto out_resource;
122 simple_map_init(&cdb89712_sram_map);
123 sram_mtd = do_map_probe("map_ram", &cdb89712_sram_map);
124 if (!sram_mtd) {
125 printk("SRAM probe failed\n");
126 err = -ENXIO;
127 goto out_ioremap;
130 sram_mtd->owner = THIS_MODULE;
131 sram_mtd->erasesize = 16;
133 if (add_mtd_device(sram_mtd)) {
134 printk("SRAM device addition failed\n");
135 err = -ENOMEM;
136 goto out_probe;
139 return 0;
141 out_probe:
142 map_destroy(sram_mtd);
143 sram_mtd = 0;
144 out_ioremap:
145 iounmap((void *)cdb89712_sram_map.virt);
146 out_resource:
147 release_resource (&cdb89712_sram_resource);
148 out:
149 return err;
158 static struct mtd_info *bootrom_mtd;
160 struct map_info cdb89712_bootrom_map = {
161 .name = "BootROM",
162 .size = BOOTROM_SIZE,
163 .bankwidth = BOOTROM_WIDTH,
164 .phys = BOOTROM_START,
167 struct resource cdb89712_bootrom_resource = {
168 .name = "BootROM",
169 .start = BOOTROM_START,
170 .end = BOOTROM_START + BOOTROM_SIZE - 1,
171 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
174 static int __init init_cdb89712_bootrom (void)
176 int err;
178 if (request_resource (&ioport_resource, &cdb89712_bootrom_resource)) {
179 printk(KERN_NOTICE "Failed to reserve Cdb89712 BOOTROM space\n");
180 err = -EBUSY;
181 goto out;
184 cdb89712_bootrom_map.virt = ioremap(BOOTROM_START, BOOTROM_SIZE);
185 if (!cdb89712_bootrom_map.virt) {
186 printk(KERN_NOTICE "Failed to ioremap Cdb89712 BootROM space\n");
187 err = -EIO;
188 goto out_resource;
190 simple_map_init(&cdb89712_bootrom_map);
191 bootrom_mtd = do_map_probe("map_rom", &cdb89712_bootrom_map);
192 if (!bootrom_mtd) {
193 printk("BootROM probe failed\n");
194 err = -ENXIO;
195 goto out_ioremap;
198 bootrom_mtd->owner = THIS_MODULE;
199 bootrom_mtd->erasesize = 0x10000;
201 if (add_mtd_device(bootrom_mtd)) {
202 printk("BootROM device addition failed\n");
203 err = -ENOMEM;
204 goto out_probe;
207 return 0;
209 out_probe:
210 map_destroy(bootrom_mtd);
211 bootrom_mtd = 0;
212 out_ioremap:
213 iounmap((void *)cdb89712_bootrom_map.virt);
214 out_resource:
215 release_resource (&cdb89712_bootrom_resource);
216 out:
217 return err;
224 static int __init init_cdb89712_maps(void)
227 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",
228 FLASH_SIZE, FLASH_START, SRAM_SIZE, SRAM_START, BOOTROM_SIZE, BOOTROM_START);
230 init_cdb89712_flash();
231 init_cdb89712_sram();
232 init_cdb89712_bootrom();
234 return 0;
238 static void __exit cleanup_cdb89712_maps(void)
240 if (sram_mtd) {
241 del_mtd_device(sram_mtd);
242 map_destroy(sram_mtd);
243 iounmap((void *)cdb89712_sram_map.virt);
244 release_resource (&cdb89712_sram_resource);
247 if (flash_mtd) {
248 del_mtd_device(flash_mtd);
249 map_destroy(flash_mtd);
250 iounmap((void *)cdb89712_flash_map.virt);
251 release_resource (&cdb89712_flash_resource);
254 if (bootrom_mtd) {
255 del_mtd_device(bootrom_mtd);
256 map_destroy(bootrom_mtd);
257 iounmap((void *)cdb89712_bootrom_map.virt);
258 release_resource (&cdb89712_bootrom_resource);
262 module_init(init_cdb89712_maps);
263 module_exit(cleanup_cdb89712_maps);
265 MODULE_AUTHOR("Ray L");
266 MODULE_DESCRIPTION("ARM CDB89712 map driver");
267 MODULE_LICENSE("GPL");