1 /* UC-7112-LX flash mapping driver
2 * Copyright (C) 2013 Jonas Jensen <jonas.jensen@gmail.com>
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2 of the License,
6 * or (at your option) any later version. */
8 #include <mach/hardware.h>
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/ioport.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/partitions.h>
21 #define RW_PART0_OF 0x0
23 /* bootloader for MOXART CPU */
24 #define RW_PART0_SZ 0x40000
26 #define RW_PART1_OF (RW_PART0_OF+RW_PART0_SZ)
27 #define RW_PART1_SZ (0x200000-RW_PART0_SZ) /* kernel */
29 #define RW_PART2_OF (RW_PART1_OF+RW_PART1_SZ)
30 #define RW_PART2_SZ 0x800000 /* root fs */
32 #define RW_PART3_OF (RW_PART2_OF+RW_PART2_SZ)
33 #define RW_PART3_SZ 0x600000 /* user fs */
35 #define CONFIG_FLASH_MEM_BASE 0x80000000
36 #define CONFIG_FLASH_SIZE 0x01000000
38 static struct map_info moxart_flash_map
= {
39 .name
= "UC-7112-LX-PLUS",
41 .phys
= CONFIG_FLASH_MEM_BASE
,
42 .size
= CONFIG_FLASH_SIZE
,
43 .virt
= (void __iomem
*)IO_ADDRESS(CONFIG_FLASH_MEM_BASE
),
45 /* MTD: Unable to init map for flash */
46 /* .virt = 0xf4000000, */
50 static struct mtd_partition moxart_flash_partitions
[] = {
53 .offset
= RW_PART0_OF
,
57 .name
= "LinuxKernel",
58 .offset
= RW_PART1_OF
,
60 /* .mask_flags = MTD_WRITEABLE */
63 .name
= "RootFileSystem",
64 .offset
= RW_PART2_OF
,
66 /* .mask_flags = MTD_WRITEABLE */
70 .offset
= RW_PART3_OF
,
75 /*struct map_info moxart_flash_map = {
76 .name = "UC7110LX V2 FLASH",
77 .size = CONFIG_FLASH_SIZE,
79 .phys = CONFIG_FLASH_MEM_BASE,
80 .virt = IO_ADDRESS(CONFIG_FLASH_MEM_BASE),
83 static int mtd_reboot(struct notifier_block *n, unsigned long code, void *p)
85 if(code != SYS_RESTART)
88 *( u16 *)(IO_ADDRESS(CONFIG_FLASH_MEM_BASE) + (0x55 * 2)) = 0xb0;
89 *( u16 *)(IO_ADDRESS(CONFIG_FLASH_MEM_BASE) + (0x55 * 2)) = 0xff;
93 static struct notifier_block mtd_notifier = {
94 notifier_call: mtd_reboot,
99 static struct mtd_info
*moxart_mtd
;
101 int __init
init_flash(void)
104 "MTD: MOXART flash: %d-bit bus, mapping: 0x%x at 0x%x\n",
105 moxart_flash_map
.bankwidth
*8,
106 CONFIG_FLASH_SIZE
, CONFIG_FLASH_MEM_BASE
);
107 simple_map_init(&moxart_flash_map
);
109 moxart_mtd
= do_map_probe("cfi_probe", &moxart_flash_map
);
111 moxart_mtd
->owner
= THIS_MODULE
;
112 pr_notice("MTD: Using static partition definition\n");
113 add_mtd_partitions(moxart_mtd
, moxart_flash_partitions
,
114 ARRAY_SIZE(moxart_flash_partitions
));
116 pr_err("MTD: map probe failed for flash\n");
117 iounmap(moxart_flash_map
.virt
);
125 int __init
init_moxart_flash(void)
129 status
= init_flash();
131 pr_err("MTD: Unable to init map for flash\n");
133 register_reboot_notifier(&mtd_notifier); */
138 static void __exit
cleanup_moxart_flash(void)
141 /* unregister_reboot_notifier(&mtd_notifier); */
142 del_mtd_partitions(moxart_mtd
);
143 map_destroy(moxart_mtd
);
147 module_init(init_moxart_flash
);
148 module_exit(cleanup_moxart_flash
);
150 MODULE_LICENSE("GPL");
151 MODULE_AUTHOR("Jonas Jensen");
152 MODULE_DESCRIPTION("MTD map driver for UC-7112-LX");