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 <asm/arch/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 = {
25 .bankwidth = FLASH_WIDTH,
29 struct resource cdb89712_flash_resource = {
32 .end = FLASH_START + FLASH_SIZE - 1,
33 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
36 static int __init init_cdb89712_flash (void)
40 if (request_resource (&ioport_resource, &cdb89712_flash_resource)) {
41 printk(KERN_NOTICE "Failed to reserve Cdb89712 FLASH space\n");
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");
52 simple_map_init(&cdb89712_flash_map);
53 flash_mtd = do_map_probe("cfi_probe", &cdb89712_flash_map);
55 flash_mtd = do_map_probe("map_rom", &cdb89712_flash_map);
57 flash_mtd->erasesize = 0x10000;
60 printk("FLASH probe failed\n");
65 flash_mtd->owner = THIS_MODULE;
67 if (add_mtd_device(flash_mtd)) {
68 printk("FLASH device addition failed\n");
76 map_destroy(flash_mtd);
79 iounmap((void *)cdb89712_flash_map.virt);
81 release_resource (&cdb89712_flash_resource);
90 static struct mtd_info *sram_mtd;
92 struct map_info cdb89712_sram_map = {
95 .bankwidth = SRAM_WIDTH,
99 struct resource cdb89712_sram_resource = {
102 .end = SRAM_START + SRAM_SIZE - 1,
103 .flags = IORESOURCE_IO | IORESOURCE_BUSY,
106 static int __init init_cdb89712_sram (void)
110 if (request_resource (&ioport_resource, &cdb89712_sram_resource)) {
111 printk(KERN_NOTICE "Failed to reserve Cdb89712 SRAM space\n");
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");
122 simple_map_init(&cdb89712_sram_map);
123 sram_mtd = do_map_probe("map_ram", &cdb89712_sram_map);
125 printk("SRAM probe failed\n");
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");
142 map_destroy(sram_mtd);
145 iounmap((void *)cdb89712_sram_map.virt);
147 release_resource (&cdb89712_sram_resource);
158 static struct mtd_info *bootrom_mtd;
160 struct map_info cdb89712_bootrom_map = {
162 .size = BOOTROM_SIZE,
163 .bankwidth = BOOTROM_WIDTH,
164 .phys = BOOTROM_START,
167 struct resource cdb89712_bootrom_resource = {
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)
178 if (request_resource (&ioport_resource, &cdb89712_bootrom_resource)) {
179 printk(KERN_NOTICE "Failed to reserve Cdb89712 BOOTROM space\n");
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");
190 simple_map_init(&cdb89712_bootrom_map);
191 bootrom_mtd = do_map_probe("map_rom", &cdb89712_bootrom_map);
193 printk("BootROM probe failed\n");
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");
210 map_destroy(bootrom_mtd);
213 iounmap((void *)cdb89712_bootrom_map.virt);
215 release_resource (&cdb89712_bootrom_resource);
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();
238 static void __exit cleanup_cdb89712_maps(void)
241 del_mtd_device(sram_mtd);
242 map_destroy(sram_mtd);
243 iounmap((void *)cdb89712_sram_map.virt);
244 release_resource (&cdb89712_sram_resource);
248 del_mtd_device(flash_mtd);
249 map_destroy(flash_mtd);
250 iounmap((void *)cdb89712_flash_map.virt);
251 release_resource (&cdb89712_flash_resource);
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");