2 * Flash memory access on Alchemy Pb1xxx boards
4 * (C) 2001 Pete Popov <ppopov@mvista.com>
6 * $Id: pb1xxx-flash.c,v 1.9 2003/06/23 11:48:18 dwmw2 Exp $
9 #include <linux/config.h>
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/map.h>
17 #include <linux/mtd/partitions.h>
20 #include <asm/au1000.h>
23 #define DBG(x...) printk(x)
28 #ifdef CONFIG_MIPS_PB1000
29 #define WINDOW_ADDR 0x1F800000
30 #define WINDOW_SIZE 0x800000
34 static struct map_info pb1xxx_map = {
35 .name = "Pb1xxx flash",
39 #ifdef CONFIG_MIPS_PB1000
41 static unsigned long flash_size = 0x00800000;
42 static unsigned char flash_buswidth = 4;
43 static struct mtd_partition pb1xxx_partitions[] = {
48 .mask_flags = MTD_WRITEABLE
57 .mask_flags = MTD_WRITEABLE
65 #elif defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1100)
67 static unsigned char flash_buswidth = 4;
68 #if defined(CONFIG_MTD_PB1500_BOOT) && defined(CONFIG_MTD_PB1500_USER)
69 /* both 32MiB banks will be used. Combine the first 32MiB bank and the
70 * first 28MiB of the second bank together into a single jffs/jffs2
73 static unsigned long flash_size = 0x04000000;
74 #define WINDOW_ADDR 0x1C000000
75 #define WINDOW_SIZE 0x4000000
76 static struct mtd_partition pb1xxx_partitions[] = {
85 .mask_flags = MTD_WRITEABLE
92 #elif defined(CONFIG_MTD_PB1500_BOOT) && !defined(CONFIG_MTD_PB1500_USER)
93 static unsigned long flash_size = 0x02000000;
94 #define WINDOW_ADDR 0x1E000000
95 #define WINDOW_SIZE 0x2000000
96 static struct mtd_partition pb1xxx_partitions[] = {
105 .mask_flags = MTD_WRITEABLE
107 .name = "raw kernel",
112 #elif !defined(CONFIG_MTD_PB1500_BOOT) && defined(CONFIG_MTD_PB1500_USER)
113 static unsigned long flash_size = 0x02000000;
114 #define WINDOW_ADDR 0x1C000000
115 #define WINDOW_SIZE 0x2000000
116 static struct mtd_partition pb1xxx_partitions[] = {
122 .name = "raw kernel",
128 #error MTD_PB1500 define combo error /* should never happen */
131 #error Unsupported board
134 static struct mtd_partition *parsed_parts;
135 static struct mtd_info *mymtd;
137 int __init pb1xxx_mtd_init(void)
139 struct mtd_partition *parts;
143 /* Default flash buswidth */
144 pb1xxx_map.buswidth = flash_buswidth;
147 * Static partition definition selection
149 part_type = "static";
150 parts = pb1xxx_partitions;
151 nb_parts = ARRAY_SIZE(pb1xxx_partitions);
152 pb1xxx_map.size = flash_size;
155 * Now let's probe for the actual flash. Do it here since
156 * specific machine settings might have been set above.
158 printk(KERN_NOTICE "Pb1xxx flash: probing %d-bit flash bus\n",
159 pb1xxx_map.buswidth*8);
160 pb1xxx_map.phys = WINDOW_ADDR;
161 pb1xxx_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
163 simple_map_init(&pb1xxx_map);
165 mymtd = do_map_probe("cfi_probe", &pb1xxx_map);
167 iounmap(pb1xxx_map.virt);
170 mymtd->owner = THIS_MODULE;
172 add_mtd_partitions(mymtd, parts, nb_parts);
176 static void __exit pb1xxx_mtd_cleanup(void)
179 del_mtd_partitions(mymtd);
185 iounmap(pb1xxx_map.virt);
188 module_init(pb1xxx_mtd_init);
189 module_exit(pb1xxx_mtd_cleanup);
191 MODULE_AUTHOR("Pete Popov");
192 MODULE_DESCRIPTION("Pb1xxx CFI map driver");
193 MODULE_LICENSE("GPL");