MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / drivers / mtd / maps / cobra5329.c
bloba7d236c0f794049814e145fa65a4b5d4447ee96d
1 /*
2 * Copyright (c) 2006, emlix, Thomas Brinker <tb@emlix.com>
4 * Handle mapping of the flash on the COBRA5329 boards
5 */
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <asm/io.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",
25 .size = WINDOW_SIZE,
26 .bankwidth = 2,
27 .phys = WINDOW_ADDR,
30 static struct mtd_partition cobra5329_partitions[] =
33 .name = "bootloader",
34 .size = 1*1024*1024,
35 .offset = 0x00000000,
36 .mask_flags = MTD_WRITEABLE
37 }, {
38 .name = "kernel",
39 .size = 6*1024*1024,
40 .offset = MTDPART_OFS_APPEND,
41 //.mask_flags = MTD_WRITEABLE
42 }, {
43 .name = "data",
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");
57 return -EIO;
60 simple_map_init(&cobra5329_map);
61 mymtd = do_map_probe("cfi_probe", &cobra5329_map);
63 if (mymtd) {
64 mymtd->owner = THIS_MODULE;
65 add_mtd_partitions(mymtd, cobra5329_partitions, NB_OF(cobra5329_partitions));
66 return 0;
67 } else
68 printk("%s: do_map_probe() returned 0\n",__FUNCTION__);
70 // iounmap((void *)cobra5329_map.virt);
71 return -ENXIO;
74 static void __exit cleanup_cobra5329mtd(void)
76 if (mymtd) {
77 del_mtd_device(mymtd);
78 map_destroy(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");