1 /****************************************************************************/
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)
10 /****************************************************************************/
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/types.h>
15 #include <linux/kernel.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>
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",
46 static struct mtd_partition sg_partitions
[] = {
48 .name
= "SnapGear kernel",
53 .name
= "SnapGear filesystem",
57 .name
= "SnapGear config",
62 .name
= "SnapGear Intel/StrataFlash",
66 .name
= "SnapGear BIOS Config",
71 .name
= "SnapGear BIOS",
77 #define PROBE "cfi_probe"
79 /****************************************************************************/
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",
96 static struct mtd_partition sg_partitions
[] = {
98 .name
= "SnapGear BIOS config",
103 .name
= "SnapGear BIOS",
108 .name
= "SnapGear AMD/Flash",
113 #define PROBE "jedec_probe"
115 /****************************************************************************/
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
;
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
);
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");
165 simple_map_init(&sg_map
);
167 if ((sg_mtd
= do_map_probe(PROBE
, &sg_map
)) == NULL
)
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);
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
);
205 del_mtd_partitions(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 /****************************************************************************/