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 / microtronix.c
blobdb299a3fcf2fef3302b69dbfe7f3033850ce22a3
1 /*
2 * Normal mappings of Microtronix ukit flash in physical memory
3 * Derived from physmap.c, by Microtronix Datacom Ltd.
4 */
6 #include <linux/module.h>
7 #include <linux/types.h>
8 #include <linux/kernel.h>
9 #include <linux/init.h>
10 #include <linux/slab.h>
11 #include <asm/io.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/map.h>
14 #include <linux/mtd/partitions.h>
15 #include <asm/nios.h>
17 /* map solutions */
18 #define WINDOW_ADDR na_flash_kernel
19 #define WINDOW_SIZE na_flash_kernel_size
20 #define BUSWIDTH 2
22 static struct mtd_info *mymtd;
25 struct map_info microtronix_map = {
26 .name = "Microtronix map",
27 .size = WINDOW_SIZE,
28 .bankwidth = BUSWIDTH,
29 .phys = WINDOW_ADDR,
32 #ifdef CONFIG_MTD_PARTITIONS
33 static struct mtd_partition *mtd_parts;
34 static int mtd_parts_nb;
36 static struct mtd_partition microtronix_partitions[] = {
38 .name = "romfs",
39 .size = 0x600000,
40 .offset = 0x200000,
41 },{
42 .name = "loader/kernel",
43 .size = 0x200000,
44 .offset = 0,
48 #define NUM_PARTITIONS (sizeof(microtronix_partitions)/sizeof(struct mtd_partition))
49 const char *part_probes[] = {"cmdlinepart", "RedBoot", NULL};
51 #endif /* CONFIG_MTD_PARTITIONS */
53 int __init init_microtronix_map(void)
55 static const char *flash_probe_types[] = {"cfi_probe", "jedec_probe", 0 };
56 const char **type;
58 microtronix_map.virt = (unsigned long *)ioremap_nocache(WINDOW_ADDR, WINDOW_SIZE);
60 if (!microtronix_map.virt) {
61 printk("Failed to ioremap\n");
62 return -EIO;
65 simple_map_init(&microtronix_map);
67 mymtd = 0;
68 type = flash_probe_types;
69 for(; !mymtd && *type; type++) {
70 mymtd = do_map_probe(*type, &microtronix_map);
72 if (mymtd) {
73 mymtd->owner = THIS_MODULE;
75 #ifdef CONFIG_MTD_PARTITIONS
76 mtd_parts_nb = parse_mtd_partitions(mymtd, part_probes,
77 &mtd_parts, 0);
79 if (mtd_parts_nb > 0)
81 add_mtd_partitions (mymtd, mtd_parts, mtd_parts_nb);
82 return 0;
85 if (NUM_PARTITIONS != 0)
87 printk(KERN_NOTICE
88 "Using Microtronix development partition definition\n");
89 add_mtd_partitions (mymtd, microtronix_partitions, NUM_PARTITIONS);
90 return 0;
93 #endif
94 add_mtd_device(mymtd);
96 return 0;
99 iounmap((void *)microtronix_map.virt);
100 return -ENXIO;
103 static void __exit cleanup_microtronix_map(void)
105 #ifdef CONFIG_MTD_PARTITIONS
106 if (mtd_parts_nb) {
107 del_mtd_partitions(mymtd);
108 kfree(mtd_parts);
109 } else if (NUM_PARTITIONS) {
110 del_mtd_partitions(mymtd);
111 } else {
112 del_mtd_device(mymtd);
114 #else
115 del_mtd_device(mymtd);
116 #endif
117 map_destroy(mymtd);
119 iounmap((void *)microtronix_map.virt);
120 microtronix_map.virt = 0;
123 module_init(init_microtronix_map);
124 module_exit(cleanup_microtronix_map);
127 MODULE_LICENSE("GPL");
128 MODULE_AUTHOR("Microtronix Datacom");
129 MODULE_DESCRIPTION("MTD map driver for Microtronix ukit");