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 / uc7110.c
blob7a535a65c3db8744012a899578e5d05804f19966
1 /*
2 * UC-7110-LX Version 2 Flash mapping driver
3 */
5 //#include <linux/config.h>
6 #include <asm/arch/moxa.h>
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <linux/ioport.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/map.h>
15 #include <linux/mtd/partitions.h>
17 #include <asm/io.h>
19 #define WINDOW_ADDR CONFIG_FLASH_MEM_BASE
20 #define WINDOW_SIZE CONFIG_FLASH_SIZE
21 //#define WINDOW_SIZE 0x00800000
22 //#define UC7110_FLASH_SIZE 0x00800000
24 #define RW_PART0_OF 0x0
25 #define RW_PART0_SZ 0x40000 /* Bootloader */
26 #define RW_PART1_OF (RW_PART0_OF+RW_PART0_SZ)
28 #if (WINDOW_SIZE > 0x00800000 )
29 #define RW_PART1_SZ 0x300000 /* Kernel */
30 #define RW_PART2_SZ 0x400000 /* root file system use JFFS2 */
31 #else
32 #define RW_PART1_SZ 0x200000 /* Kernel */
33 #define RW_PART2_SZ (0x280000-RW_PART0_SZ) /* root file system use JFFS2 */
34 #endif
36 #define RW_PART2_OF (RW_PART1_OF+RW_PART1_SZ)
37 #define RW_PART3_OF (RW_PART2_OF+RW_PART2_SZ)
38 //#define RW_PART3_SZ (UC7110_FLASH_SIZE-RW_PART3_OF) /* user disk use JFFS2 */
39 #define RW_PART3_SZ (WINDOW_SIZE-RW_PART3_OF) /* user disk use JFFS2 */
41 static struct mtd_partition moxart_flash_partitions[] = {
43 .name = "Bootloader",
44 .offset = RW_PART0_OF,
45 .size = RW_PART0_SZ
48 .name = "LinuxKernel",
49 .offset = RW_PART1_OF,
50 .size = RW_PART1_SZ,
51 //.mask_flags = MTD_WRITEABLE
54 .name = "RootFileSystem",
55 .offset = RW_PART2_OF,
56 .size = RW_PART2_SZ,
57 //.mask_flags = MTD_WRITEABLE
60 .name = "UserDisk",
61 .offset = RW_PART3_OF,
62 .size = RW_PART3_SZ
65 struct map_info moxart_flash_map = {
66 .name = "UC7110LX V2 FLASH",
67 .size = WINDOW_SIZE,
68 .bankwidth = 2,
69 .phys = WINDOW_ADDR,
70 .virt = IO_ADDRESS(WINDOW_ADDR),
74 #define NUM_MOXART_FLASH_PARTITIONS ARRAY_SIZE(moxart_flash_partitions)
76 static struct mtd_info *moxart_mtd;
78 int __init init_moxart_flash(void)
80 printk(KERN_NOTICE "moxart: flash mapping: 0x%x at 0x%x\n",
81 WINDOW_SIZE, WINDOW_ADDR);
83 simple_map_init(&moxart_flash_map);
85 moxart_mtd = do_map_probe("cfi_probe",&moxart_flash_map);
87 if (moxart_mtd) {
88 moxart_mtd->owner = THIS_MODULE;
89 return add_mtd_partitions(moxart_mtd,
90 moxart_flash_partitions,
91 NUM_MOXART_FLASH_PARTITIONS);
94 return -ENXIO;
97 static void __exit cleanup_moxart_flash(void)
99 if (moxart_mtd) {
100 del_mtd_partitions(moxart_mtd);
101 /* moved iounmap after map_destroy - armin */
102 map_destroy(moxart_mtd);
106 module_init(init_moxart_flash);
107 module_exit(cleanup_moxart_flash);
109 MODULE_LICENSE("GPL");
110 MODULE_AUTHOR("Jimmy_chen@moxa.com.tw");
111 MODULE_DESCRIPTION("MTD map driver for the UC-7110-LX Version 2");