2 * UC-711X-LX Version 2 Flash mapping driver
5 //#include <linux/config.h>
6 //#include <asm/arch/moxa.h>
7 #include <mach/hardware.h>
9 #include <linux/module.h>
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/ioport.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/map.h>
17 #include <linux/mtd/partitions.h>
21 //#define WINDOW_SIZE 0x00800000
22 //#define UC7110_FLASH_SIZE 0x00800000
24 #define RW_PART0_OF 0x0
25 #define RW_PART0_SZ 0x40000 /* Bootloader */
27 #define RW_PART1_OF (RW_PART0_OF+RW_PART0_SZ)
28 #define RW_PART1_SZ (0x200000-RW_PART0_SZ) /* Kernel */
30 #define RW_PART2_OF (RW_PART1_OF+RW_PART1_SZ)
31 #define RW_PART2_SZ 0x800000 /* root file system use JFFS2 */
33 #define RW_PART3_OF (RW_PART2_OF+RW_PART2_SZ)
34 //#define RW_PART3_SZ (UC7110_FLASH_SIZE-RW_PART3_OF) /* user disk use JFFS2 */
35 #define RW_PART3_SZ 0x600000 /* user disk use JFFS2 */
37 #define CONFIG_FLASH_MEM_BASE 0x80000000
38 #define CONFIG_FLASH_SIZE 0x01000000
40 static struct map_info moxart_flash_map
= {
41 .name
= "UC-7112-LX-PLUS",
43 .phys
= CONFIG_FLASH_MEM_BASE
,
44 .size
= CONFIG_FLASH_SIZE
,
45 .virt
= IO_ADDRESS(CONFIG_FLASH_MEM_BASE
),
46 // .virt = 0xf4000000, //MTD: Unable to init map for flash
49 static struct mtd_partition moxart_flash_partitions
[] = {
52 .offset
= RW_PART0_OF
,
56 .name
= "LinuxKernel",
57 .offset
= RW_PART1_OF
,
59 //.mask_flags = MTD_WRITEABLE
62 .name
= "RootFileSystem",
63 .offset
= RW_PART2_OF
,
65 // .mask_flags = MTD_WRITEABLE
69 .offset
= RW_PART3_OF
,
74 /*struct map_info moxart_flash_map = {
75 .name = "UC7110LX V2 FLASH",
76 .size = CONFIG_FLASH_SIZE,
78 .phys = CONFIG_FLASH_MEM_BASE,
79 .virt = IO_ADDRESS(CONFIG_FLASH_MEM_BASE),
82 static int mtd_reboot(struct notifier_block
*n
, unsigned long code
, void *p
)
84 if(code
!= SYS_RESTART
)
87 *( u16
*)(IO_ADDRESS(CONFIG_FLASH_MEM_BASE
) + (0x55 * 2)) = 0xb0;
88 *( u16
*)(IO_ADDRESS(CONFIG_FLASH_MEM_BASE
) + (0x55 * 2)) = 0xff;
92 static struct notifier_block mtd_notifier
= {
93 notifier_call
: mtd_reboot
,
98 static struct mtd_info
*moxart_mtd
;
100 int __init
init_flash(void)
103 printk(KERN_NOTICE
"MTD: MOXART CPU flash: probing %d-bit flash bus, flash mapping: 0x%x at 0x%x\n", moxart_flash_map
.bankwidth
*8, CONFIG_FLASH_SIZE
, CONFIG_FLASH_MEM_BASE
);
104 simple_map_init(&moxart_flash_map
);
106 moxart_mtd
= do_map_probe("cfi_probe",&moxart_flash_map
);
108 moxart_mtd
->owner
= THIS_MODULE
;
109 printk(KERN_NOTICE
"MTD: Using static partition definition\n");
110 add_mtd_partitions(moxart_mtd
, moxart_flash_partitions
, ARRAY_SIZE(moxart_flash_partitions
));
112 printk(KERN_ERR
"MTD: map probe failed for flash\n");
113 iounmap(moxart_flash_map
.virt
);
122 int __init
init_moxart_flash(void)
126 if ((status
= init_flash())) {
127 printk(KERN_ERR
"MTD: Unable to init map for flash\n");
129 //register_reboot_notifier(&mtd_notifier);
135 static void __exit
cleanup_moxart_flash(void)
138 //unregister_reboot_notifier(&mtd_notifier);
139 del_mtd_partitions(moxart_mtd
);
140 map_destroy(moxart_mtd
);
144 module_init(init_moxart_flash
);
145 module_exit(cleanup_moxart_flash
);
147 MODULE_LICENSE("GPL");
148 MODULE_AUTHOR("Jimmy_chen@moxa.com.tw");
149 MODULE_DESCRIPTION("MTD map driver for the UC-7110-LX Version 2");