Linux v2.6.15-rc7
[pohmelfs.git] / drivers / mtd / maps / alchemy-flash.c
bloba57791a6ce402a754e32f6dec0b40523ffe11eda
1 /*
2 * Flash memory access on AMD Alchemy evaluation boards
4 * $Id: alchemy-flash.c,v 1.2 2005/11/07 11:14:26 gleixner Exp $
6 * (C) 2003, 2004 Pete Popov <ppopov@embeddedalley.com>
8 */
10 #include <linux/config.h>
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/kernel.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/partitions.h>
20 #include <asm/io.h>
22 #ifdef DEBUG_RW
23 #define DBG(x...) printk(x)
24 #else
25 #define DBG(x...)
26 #endif
28 #ifdef CONFIG_MIPS_PB1000
29 #define BOARD_MAP_NAME "Pb1000 Flash"
30 #define BOARD_FLASH_SIZE 0x00800000 /* 8MB */
31 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
32 #endif
34 #ifdef CONFIG_MIPS_PB1500
35 #define BOARD_MAP_NAME "Pb1500 Flash"
36 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
37 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
38 #endif
40 #ifdef CONFIG_MIPS_PB1100
41 #define BOARD_MAP_NAME "Pb1100 Flash"
42 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
43 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
44 #endif
46 #ifdef CONFIG_MIPS_PB1550
47 #define BOARD_MAP_NAME "Pb1550 Flash"
48 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
49 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
50 #endif
52 #ifdef CONFIG_MIPS_PB1200
53 #define BOARD_MAP_NAME "Pb1200 Flash"
54 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
55 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
56 #endif
58 #ifdef CONFIG_MIPS_DB1000
59 #define BOARD_MAP_NAME "Db1000 Flash"
60 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
61 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
62 #endif
64 #ifdef CONFIG_MIPS_DB1500
65 #define BOARD_MAP_NAME "Db1500 Flash"
66 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
67 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
68 #endif
70 #ifdef CONFIG_MIPS_DB1100
71 #define BOARD_MAP_NAME "Db1100 Flash"
72 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
73 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
74 #endif
76 #ifdef CONFIG_MIPS_DB1550
77 #define BOARD_MAP_NAME "Db1550 Flash"
78 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
79 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
80 #endif
82 #ifdef CONFIG_MIPS_DB1200
83 #define BOARD_MAP_NAME "Db1200 Flash"
84 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
85 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
86 #endif
88 #ifdef CONFIG_MIPS_HYDROGEN3
89 #define BOARD_MAP_NAME "Hydrogen3 Flash"
90 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
91 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
92 #define USE_LOCAL_ACCESSORS /* why? */
93 #endif
95 #ifdef CONFIG_MIPS_BOSPORUS
96 #define BOARD_MAP_NAME "Bosporus Flash"
97 #define BOARD_FLASH_SIZE 0x01000000 /* 16MB */
98 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
99 #endif
101 #ifdef CONFIG_MIPS_MIRAGE
102 #define BOARD_MAP_NAME "Mirage Flash"
103 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
104 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
105 #define USE_LOCAL_ACCESSORS /* why? */
106 #endif
108 static struct map_info alchemy_map = {
109 .name = BOARD_MAP_NAME,
112 static struct mtd_partition alchemy_partitions[] = {
114 .name = "User FS",
115 .size = BOARD_FLASH_SIZE - 0x00400000,
116 .offset = 0x0000000
118 .name = "YAMON",
119 .size = 0x0100000,
120 .offset = MTDPART_OFS_APPEND,
121 .mask_flags = MTD_WRITEABLE
123 .name = "raw kernel",
124 .size = (0x300000 - 0x40000), /* last 256KB is yamon env */
125 .offset = MTDPART_OFS_APPEND,
129 #define NB_OF(x) (sizeof(x)/sizeof(x[0]))
131 static struct mtd_info *mymtd;
133 int __init alchemy_mtd_init(void)
135 struct mtd_partition *parts;
136 int nb_parts = 0;
137 unsigned long window_addr;
138 unsigned long window_size;
140 /* Default flash buswidth */
141 alchemy_map.bankwidth = BOARD_FLASH_WIDTH;
143 window_addr = 0x20000000 - BOARD_FLASH_SIZE;
144 window_size = BOARD_FLASH_SIZE;
145 #ifdef CONFIG_MIPS_MIRAGE_WHY
146 /* Boot ROM flash bank only; no user bank */
147 window_addr = 0x1C000000;
148 window_size = 0x04000000;
149 /* USERFS from 0x1C00 0000 to 0x1FC00000 */
150 alchemy_partitions[0].size = 0x03C00000;
151 #endif
154 * Static partition definition selection
156 parts = alchemy_partitions;
157 nb_parts = NB_OF(alchemy_partitions);
158 alchemy_map.size = window_size;
161 * Now let's probe for the actual flash. Do it here since
162 * specific machine settings might have been set above.
164 printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",
165 alchemy_map.bankwidth*8);
166 alchemy_map.virt = ioremap(window_addr, window_size);
167 mymtd = do_map_probe("cfi_probe", &alchemy_map);
168 if (!mymtd) {
169 iounmap(alchemy_map.virt);
170 return -ENXIO;
172 mymtd->owner = THIS_MODULE;
174 add_mtd_partitions(mymtd, parts, nb_parts);
175 return 0;
178 static void __exit alchemy_mtd_cleanup(void)
180 if (mymtd) {
181 del_mtd_partitions(mymtd);
182 map_destroy(mymtd);
183 iounmap(alchemy_map.virt);
187 module_init(alchemy_mtd_init);
188 module_exit(alchemy_mtd_cleanup);
190 MODULE_AUTHOR("Embedded Alley Solutions, Inc");
191 MODULE_DESCRIPTION(BOARD_MAP_NAME " MTD driver");
192 MODULE_LICENSE("GPL");