2 * Flash on Cirrus CDB89712
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>
12 #include <mach/hardware.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/map.h>
15 #include <linux/mtd/partitions.h>
18 #define FLASH_START 0x00000000
19 #define FLASH_SIZE 0x800000
22 static struct mtd_info *flash_mtd;
24 struct map_info cdb89712_flash_map = {
27 .bankwidth = FLASH_WIDTH,
31 struct resource cdb89712_flash_resource = {
34 .end = FLASH_START + FLASH_SIZE - 1,
35 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
38 static int __init init_cdb89712_flash (void)
42 if (request_resource (&ioport_resource, &cdb89712_flash_resource)) {
43 printk(KERN_NOTICE "Failed to reserve Cdb89712 FLASH space\n");
48 cdb89712_flash_map.virt = ioremap(FLASH_START, FLASH_SIZE);
49 if (!cdb89712_flash_map.virt) {
50 printk(KERN_NOTICE "Failed to ioremap Cdb89712 FLASH space\n");
54 simple_map_init(&cdb89712_flash_map);
55 flash_mtd = do_map_probe("cfi_probe", &cdb89712_flash_map);
57 flash_mtd = do_map_probe("map_rom", &cdb89712_flash_map);
59 flash_mtd->erasesize = 0x10000;
62 printk("FLASH probe failed\n");
67 flash_mtd->owner = THIS_MODULE;
69 if (add_mtd_device(flash_mtd)) {
70 printk("FLASH device addition failed\n");
78 map_destroy(flash_mtd);
81 iounmap((void *)cdb89712_flash_map.virt);
83 release_resource (&cdb89712_flash_resource);
92 static struct mtd_info *sram_mtd;
94 struct map_info cdb89712_sram_map = {
97 .bankwidth = SRAM_WIDTH,
101 struct resource cdb89712_sram_resource = {
104 .end = SRAM_START + SRAM_SIZE - 1,
105 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
108 static int __init init_cdb89712_sram (void)
112 if (request_resource (&ioport_resource, &cdb89712_sram_resource)) {
113 printk(KERN_NOTICE "Failed to reserve Cdb89712 SRAM space\n");
118 cdb89712_sram_map.virt = ioremap(SRAM_START, SRAM_SIZE);
119 if (!cdb89712_sram_map.virt) {
120 printk(KERN_NOTICE "Failed to ioremap Cdb89712 SRAM space\n");
124 simple_map_init(&cdb89712_sram_map);
125 sram_mtd = do_map_probe("map_ram", &cdb89712_sram_map);
127 printk("SRAM probe failed\n");
132 sram_mtd->owner = THIS_MODULE;
133 sram_mtd->erasesize = 16;
135 if (add_mtd_device(sram_mtd)) {
136 printk("SRAM device addition failed\n");
144 map_destroy(sram_mtd);
147 iounmap((void *)cdb89712_sram_map.virt);
149 release_resource (&cdb89712_sram_resource);
160 static struct mtd_info *bootrom_mtd;
162 struct map_info cdb89712_bootrom_map = {
164 .size = BOOTROM_SIZE,
165 .bankwidth = BOOTROM_WIDTH,
166 .phys = BOOTROM_START,
169 struct resource cdb89712_bootrom_resource = {
171 .start = BOOTROM_START,
172 .end = BOOTROM_START + BOOTROM_SIZE - 1,
173 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
176 static int __init init_cdb89712_bootrom (void)
180 if (request_resource (&ioport_resource, &cdb89712_bootrom_resource)) {
181 printk(KERN_NOTICE "Failed to reserve Cdb89712 BOOTROM space\n");
186 cdb89712_bootrom_map.virt = ioremap(BOOTROM_START, BOOTROM_SIZE);
187 if (!cdb89712_bootrom_map.virt) {
188 printk(KERN_NOTICE "Failed to ioremap Cdb89712 BootROM space\n");
192 simple_map_init(&cdb89712_bootrom_map);
193 bootrom_mtd = do_map_probe("map_rom", &cdb89712_bootrom_map);
195 printk("BootROM probe failed\n");
200 bootrom_mtd->owner = THIS_MODULE;
201 bootrom_mtd->erasesize = 0x10000;
203 if (add_mtd_device(bootrom_mtd)) {
204 printk("BootROM device addition failed\n");
212 map_destroy(bootrom_mtd);
215 iounmap((void *)cdb89712_bootrom_map.virt);
217 release_resource (&cdb89712_bootrom_resource);
226 static int __init init_cdb89712_maps(void)
229 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",
230 FLASH_SIZE, FLASH_START, SRAM_SIZE, SRAM_START, BOOTROM_SIZE, BOOTROM_START);
232 init_cdb89712_flash();
233 init_cdb89712_sram();
234 init_cdb89712_bootrom();
240 static void __exit cleanup_cdb89712_maps(void)
243 del_mtd_device(sram_mtd);
244 map_destroy(sram_mtd);
245 iounmap((void *)cdb89712_sram_map.virt);
246 release_resource (&cdb89712_sram_resource);
250 del_mtd_device(flash_mtd);
251 map_destroy(flash_mtd);
252 iounmap((void *)cdb89712_flash_map.virt);
253 release_resource (&cdb89712_flash_resource);
257 del_mtd_device(bootrom_mtd);
258 map_destroy(bootrom_mtd);
259 iounmap((void *)cdb89712_bootrom_map.virt);
260 release_resource (&cdb89712_bootrom_resource);
264 module_init(init_cdb89712_maps);
265 module_exit(cleanup_cdb89712_maps);
267 MODULE_AUTHOR("Ray L");
268 MODULE_DESCRIPTION("ARM CDB89712 map driver");
269 MODULE_LICENSE("GPL");