2 * Flash on Cirrus CDB89712
4 * $Id: cdb89712.c,v 1.10 2004/11/04 13:24:14 gleixner Exp $
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/ioport.h>
11 #include <linux/init.h>
13 #include <asm/arch/hardware.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/map.h>
16 #include <linux/mtd/partitions.h>
21 static struct mtd_info
*flash_mtd
;
23 struct map_info cdb89712_flash_map
= {
26 .bankwidth
= FLASH_WIDTH
,
30 struct resource cdb89712_flash_resource
= {
33 .end
= FLASH_START
+ FLASH_SIZE
- 1,
34 .flags
= IORESOURCE_IO
| IORESOURCE_BUSY
,
37 static int __init
init_cdb89712_flash (void)
41 if (request_resource (&ioport_resource
, &cdb89712_flash_resource
)) {
42 printk(KERN_NOTICE
"Failed to reserve Cdb89712 FLASH space\n");
47 cdb89712_flash_map
.virt
= ioremap(FLASH_START
, FLASH_SIZE
);
48 if (!cdb89712_flash_map
.virt
) {
49 printk(KERN_NOTICE
"Failed to ioremap Cdb89712 FLASH space\n");
53 simple_map_init(&cdb89712_flash_map
);
54 flash_mtd
= do_map_probe("cfi_probe", &cdb89712_flash_map
);
56 flash_mtd
= do_map_probe("map_rom", &cdb89712_flash_map
);
58 flash_mtd
->erasesize
= 0x10000;
61 printk("FLASH probe failed\n");
66 flash_mtd
->owner
= THIS_MODULE
;
68 if (add_mtd_device(flash_mtd
)) {
69 printk("FLASH device addition failed\n");
77 map_destroy(flash_mtd
);
80 iounmap((void *)cdb89712_flash_map
.virt
);
82 release_resource (&cdb89712_flash_resource
);
91 static struct mtd_info
*sram_mtd
;
93 struct map_info cdb89712_sram_map
= {
96 .bankwidth
= SRAM_WIDTH
,
100 struct resource cdb89712_sram_resource
= {
103 .end
= SRAM_START
+ SRAM_SIZE
- 1,
104 .flags
= IORESOURCE_IO
| IORESOURCE_BUSY
,
107 static int __init
init_cdb89712_sram (void)
111 if (request_resource (&ioport_resource
, &cdb89712_sram_resource
)) {
112 printk(KERN_NOTICE
"Failed to reserve Cdb89712 SRAM space\n");
117 cdb89712_sram_map
.virt
= ioremap(SRAM_START
, SRAM_SIZE
);
118 if (!cdb89712_sram_map
.virt
) {
119 printk(KERN_NOTICE
"Failed to ioremap Cdb89712 SRAM space\n");
123 simple_map_init(&cdb89712_sram_map
);
124 sram_mtd
= do_map_probe("map_ram", &cdb89712_sram_map
);
126 printk("SRAM probe failed\n");
131 sram_mtd
->owner
= THIS_MODULE
;
132 sram_mtd
->erasesize
= 16;
134 if (add_mtd_device(sram_mtd
)) {
135 printk("SRAM device addition failed\n");
143 map_destroy(sram_mtd
);
146 iounmap((void *)cdb89712_sram_map
.virt
);
148 release_resource (&cdb89712_sram_resource
);
159 static struct mtd_info
*bootrom_mtd
;
161 struct map_info cdb89712_bootrom_map
= {
163 .size
= BOOTROM_SIZE
,
164 .bankwidth
= BOOTROM_WIDTH
,
165 .phys
= BOOTROM_START
,
168 struct resource cdb89712_bootrom_resource
= {
170 .start
= BOOTROM_START
,
171 .end
= BOOTROM_START
+ BOOTROM_SIZE
- 1,
172 .flags
= IORESOURCE_IO
| IORESOURCE_BUSY
,
175 static int __init
init_cdb89712_bootrom (void)
179 if (request_resource (&ioport_resource
, &cdb89712_bootrom_resource
)) {
180 printk(KERN_NOTICE
"Failed to reserve Cdb89712 BOOTROM space\n");
185 cdb89712_bootrom_map
.virt
= ioremap(BOOTROM_START
, BOOTROM_SIZE
);
186 if (!cdb89712_bootrom_map
.virt
) {
187 printk(KERN_NOTICE
"Failed to ioremap Cdb89712 BootROM space\n");
191 simple_map_init(&cdb89712_bootrom_map
);
192 bootrom_mtd
= do_map_probe("map_rom", &cdb89712_bootrom_map
);
194 printk("BootROM probe failed\n");
199 bootrom_mtd
->owner
= THIS_MODULE
;
200 bootrom_mtd
->erasesize
= 0x10000;
202 if (add_mtd_device(bootrom_mtd
)) {
203 printk("BootROM device addition failed\n");
211 map_destroy(bootrom_mtd
);
214 iounmap((void *)cdb89712_bootrom_map
.virt
);
216 release_resource (&cdb89712_bootrom_resource
);
225 static int __init
init_cdb89712_maps(void)
228 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",
229 FLASH_SIZE
, FLASH_START
, SRAM_SIZE
, SRAM_START
, BOOTROM_SIZE
, BOOTROM_START
);
231 init_cdb89712_flash();
232 init_cdb89712_sram();
233 init_cdb89712_bootrom();
239 static void __exit
cleanup_cdb89712_maps(void)
242 del_mtd_device(sram_mtd
);
243 map_destroy(sram_mtd
);
244 iounmap((void *)cdb89712_sram_map
.virt
);
245 release_resource (&cdb89712_sram_resource
);
249 del_mtd_device(flash_mtd
);
250 map_destroy(flash_mtd
);
251 iounmap((void *)cdb89712_flash_map
.virt
);
252 release_resource (&cdb89712_flash_resource
);
256 del_mtd_device(bootrom_mtd
);
257 map_destroy(bootrom_mtd
);
258 iounmap((void *)cdb89712_bootrom_map
.virt
);
259 release_resource (&cdb89712_bootrom_resource
);
263 module_init(init_cdb89712_maps
);
264 module_exit(cleanup_cdb89712_maps
);
266 MODULE_AUTHOR("Ray L");
267 MODULE_DESCRIPTION("ARM CDB89712 map driver");
268 MODULE_LICENSE("GPL");