2 * Flash memory access on Alchemy Pb1xxx boards
4 * (C) 2001 Pete Popov <ppopov@mvista.com>
6 * $Id: pb1xxx-flash.c,v 1.8 2003/05/21 12:45:19 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
135 #define NB_OF(x) (sizeof(x)/sizeof(x[0]))
137 static struct mtd_partition *parsed_parts;
138 static struct mtd_info *mymtd;
140 int __init pb1xxx_mtd_init(void)
142 struct mtd_partition *parts;
146 /* Default flash buswidth */
147 pb1xxx_map.buswidth = flash_buswidth;
150 * Static partition definition selection
152 part_type = "static";
153 parts = pb1xxx_partitions;
154 nb_parts = NB_OF(pb1xxx_partitions);
155 pb1xxx_map.size = flash_size;
158 * Now let's probe for the actual flash. Do it here since
159 * specific machine settings might have been set above.
161 printk(KERN_NOTICE "Pb1xxx flash: probing %d-bit flash bus\n",
162 pb1xxx_map.buswidth*8);
163 pb1xxx_map.phys = WINDOW_ADDR;
164 pb1xxx_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
166 simple_map_init(&pb1xxx_map);
168 mymtd = do_map_probe("cfi_probe", &pb1xxx_map);
170 iounmap(pb1xxx_map.virt);
173 mymtd->owner = THIS_MODULE;
175 add_mtd_partitions(mymtd, parts, nb_parts);
179 static void __exit pb1xxx_mtd_cleanup(void)
182 del_mtd_partitions(mymtd);
188 iounmap(pb1xxx_map.virt);
191 module_init(pb1xxx_mtd_init);
192 module_exit(pb1xxx_mtd_cleanup);
194 MODULE_AUTHOR("Pete Popov");
195 MODULE_DESCRIPTION("Pb1xxx CFI map driver");
196 MODULE_LICENSE("GPL");