2 * Copyright (c) 2006, emlix, Thomas Brinker <tb@emlix.com>
4 * Handle mapping of the flash on the COBRA5329 boards
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/map.h>
14 #include <linux/mtd/partitions.h>
16 #define NB_OF(x) (sizeof(x)/sizeof(x[0]))
18 #define WINDOW_ADDR 0x00000000
19 #define WINDOW_SIZE 0x01000000
21 static struct mtd_info
*mymtd
;
23 static struct map_info cobra5329_map
= {
24 .name
= "COBRA5329Flash",
30 static struct mtd_partition cobra5329_partitions
[] =
36 .mask_flags
= MTD_WRITEABLE
40 .offset
= MTDPART_OFS_APPEND
,
41 //.mask_flags = MTD_WRITEABLE
44 .size
= MTDPART_SIZ_FULL
,
45 .offset
= MTDPART_OFS_APPEND
49 int __init
init_cobra5329mtd(void)
51 printk(KERN_NOTICE
"Cobra5329 flash device: %x at %x\n", WINDOW_SIZE
, WINDOW_ADDR
);
52 cobra5329_map
.virt
= ioremap(WINDOW_ADDR
, WINDOW_SIZE
);
54 Because of the odd place of flash we cannot check if ioremap has succeded
55 if (!cobra5329_map.virt) {
56 printk("Failed to ioremap\n");
60 simple_map_init(&cobra5329_map
);
61 mymtd
= do_map_probe("cfi_probe", &cobra5329_map
);
64 mymtd
->owner
= THIS_MODULE
;
65 add_mtd_partitions(mymtd
, cobra5329_partitions
, NB_OF(cobra5329_partitions
));
68 printk("%s: do_map_probe() returned 0\n",__FUNCTION__
);
70 // iounmap((void *)cobra5329_map.virt);
74 static void __exit
cleanup_cobra5329mtd(void)
77 del_mtd_device(mymtd
);
80 if (cobra5329_map
.virt
) {
81 iounmap((void *)cobra5329_map
.virt
);
82 cobra5329_map
.virt
= 0;
86 module_init(init_cobra5329mtd
);
87 module_exit(cleanup_cobra5329mtd
);
89 MODULE_LICENSE("GPL");
90 MODULE_AUTHOR("Thomas Brinker <tb@emlix.com>");
91 MODULE_DESCRIPTION("MTD map driver for Cobra5329 boards");