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 / snapgeode.c
blobbc8bb1ee90f67bcbe31cfe6714dbb2188b902a6a
1 /****************************************************************************/
3 /*
4 * snapgeode.c -- mappings for SnapGear GEODE based boards
6 * (C) Copyright 2000-2003, Greg Ungerer (gerg@snapgear.com)
7 * (C) Copyright 2001-2003, SnapGear (www.snapgear.com)
8 */
10 /****************************************************************************/
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/fs.h>
17 #include <linux/major.h>
18 #include <linux/root_dev.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/map.h>
21 #include <linux/mtd/partitions.h>
22 #include <linux/mtd/cfi.h>
23 #include <linux/reboot.h>
24 #include <asm/io.h>
26 /****************************************************************************/
28 static struct mtd_info *sg_mtd;
30 /****************************************************************************/
31 #ifdef CONFIG_MTD_CFI_INTELEXT
32 /****************************************************************************/
35 * Intel FLASH setup. This is the only flash device, it is the entire
36 * non-volatile storage (no IDE CF or hard drive).
39 static struct map_info sg_map = {
40 .name= "SnapGear Intel/StrataFlash",
41 .phys= 0xff800000,
42 .size= 0x800000,
43 .buswidth= 1,
46 static struct mtd_partition sg_partitions[] = {
48 .name= "SnapGear kernel",
49 .offset= 0,
50 .size= 0x000e0000
53 .name= "SnapGear filesystem",
54 .offset= 0x00100000,
57 .name= "SnapGear config",
58 .offset= 0x000e0000,
59 .size= 0x00020000
62 .name= "SnapGear Intel/StrataFlash",
63 .offset= 0
66 .name= "SnapGear BIOS Config",
67 .offset= 0x007e0000,
68 .size= 0x00020000
71 .name= "SnapGear BIOS",
72 .offset= 0x007e0000,
73 .size= 0x00020000
77 #define PROBE "cfi_probe"
79 /****************************************************************************/
80 #else
81 /****************************************************************************/
84 * If only an AMD flash is fitted then it is the BIOS/boot loader.
85 * Primary non-volatile storage must be via some ither IDE mechanism
86 * (either compact flash [CF] or real hard drive).
89 static struct map_info sg_map = {
90 .name= "SnapGear AMD/Flash",
91 .phys= 0xff800000,
92 .size= 0x800000,
93 .buswidth= 1,
96 static struct mtd_partition sg_partitions[] = {
98 .name= "SnapGear BIOS config",
99 .offset= 0x000e0000,
100 .size= 0x00010000
103 .name= "SnapGear BIOS",
104 .offset= 0x000f0000,
105 .size= 0x00010000
108 .name= "SnapGear AMD/Flash",
109 .offset= 0
113 #define PROBE "jedec_probe"
115 /****************************************************************************/
116 #endif
117 /****************************************************************************/
119 #define NUM_PARTITIONS (sizeof(sg_partitions)/sizeof(sg_partitions[0]))
121 /****************************************************************************/
123 #ifdef CONFIG_MTD_CFI_INTELEXT
126 * Set the Intel flash back to read mode. Sometimes MTD leaves the
127 * flash in status mode, and if you reboot there is no code to
128 * execute (the flash devices do not get a RESET) :-(
130 static int sg_reboot_notifier(struct notifier_block *nb, unsigned long val, void *v)
132 struct cfi_private *cfi = sg_map.fldrv_priv;
133 unsigned long b;
135 /* Make sure all FLASH chips are put back into read mode */
136 for (b = 0; (b < sg_partitions[3].size); b += 0x100000) {
137 cfi_send_gen_cmd(0xff, 0x55, b, &sg_map, cfi,
138 cfi->device_type, NULL);
140 return NOTIFY_OK;
143 static struct notifier_block sg_notifier_block = {
144 sg_reboot_notifier, NULL, 0
147 #endif /* CONFIG_MTD_CFI_INTELEXT */
149 /****************************************************************************/
151 int __init sg_init(void)
153 printk("SNAPGEAR: MTD BIOS setup\n");
156 * On the GEODE the ROM CS stays mapped into high memory.
157 * So we look for it at the top of the 32bit address space.
159 sg_map.virt = (unsigned long) ioremap(0xff800000, 0x800000);
160 if (sg_map.virt == 0) {
161 printk("SNAPGEAR: failed to ioremap() ROMCS\n");
162 return -EIO;
165 simple_map_init(&sg_map);
167 if ((sg_mtd = do_map_probe(PROBE, &sg_map)) == NULL)
168 return -ENXIO;
170 printk(KERN_NOTICE "SNAPGEAR: %s device size = %dK\n",
171 sg_mtd->name, sg_mtd->size>>10);
173 sg_mtd->owner = THIS_MODULE;
174 sg_mtd->priv = &sg_map;
176 #ifdef CONFIG_MTD_CFI_INTELEXT
177 sg_partitions[1].size = sg_mtd->size -
178 (sg_partitions[1].offset + sg_mtd->erasesize);
179 if (sg_mtd->size > 0x800000) {
180 sg_partitions[4].offset += sg_mtd->size - 0x800000;
181 sg_partitions[5].offset += sg_mtd->size - 0x800000;
183 register_reboot_notifier(&sg_notifier_block);
184 #ifndef CONFIG_BLK_DEV_INITRD
185 ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, 1);
186 #endif
187 #else
188 if (sg_mtd->size > 0x100000) {
189 sg_partitions[0].offset += sg_mtd->size - 0x100000;
190 sg_partitions[1].offset += sg_mtd->size - 0x100000;
192 #endif /* !CONFIG_MTD_CFI_INTELEXT */
194 return add_mtd_partitions(sg_mtd, sg_partitions, NUM_PARTITIONS);
197 /****************************************************************************/
199 void __exit sg_cleanup(void)
201 #ifdef CONFIG_MTD_CFI_INTELEXT
202 unregister_reboot_notifier(&sg_notifier_block);
203 #endif
204 if (sg_mtd) {
205 del_mtd_partitions(sg_mtd);
206 map_destroy(sg_mtd);
208 if (sg_map.map_priv_1) {
209 iounmap((void *)sg_map.map_priv_1);
210 sg_map.map_priv_1 = 0;
214 /****************************************************************************/
216 module_init(sg_init);
217 module_exit(sg_cleanup);
219 MODULE_LICENSE("GPL");
220 MODULE_AUTHOR("Greg Ungerer <gerg@snapgear.com>");
221 MODULE_DESCRIPTION("SnapGear/GEODE flash support");
223 /****************************************************************************/