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>
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/map.h>
17 #include <linux/mtd/partitions.h>
22 #define DBG(x...) printk(x)
27 #ifdef CONFIG_MIPS_PB1000
28 #define BOARD_MAP_NAME "Pb1000 Flash"
29 #define BOARD_FLASH_SIZE 0x00800000 /* 8MB */
30 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
33 #ifdef CONFIG_MIPS_PB1500
34 #define BOARD_MAP_NAME "Pb1500 Flash"
35 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
36 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
39 #ifdef CONFIG_MIPS_PB1100
40 #define BOARD_MAP_NAME "Pb1100 Flash"
41 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
42 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
45 #ifdef CONFIG_MIPS_PB1550
46 #define BOARD_MAP_NAME "Pb1550 Flash"
47 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
48 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
51 #ifdef CONFIG_MIPS_PB1200
52 #define BOARD_MAP_NAME "Pb1200 Flash"
53 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
54 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
57 #ifdef CONFIG_MIPS_DB1000
58 #define BOARD_MAP_NAME "Db1000 Flash"
59 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
60 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
63 #ifdef CONFIG_MIPS_DB1500
64 #define BOARD_MAP_NAME "Db1500 Flash"
65 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
66 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
69 #ifdef CONFIG_MIPS_DB1100
70 #define BOARD_MAP_NAME "Db1100 Flash"
71 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
72 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
75 #ifdef CONFIG_MIPS_DB1550
76 #define BOARD_MAP_NAME "Db1550 Flash"
77 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
78 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
81 #ifdef CONFIG_MIPS_DB1200
82 #define BOARD_MAP_NAME "Db1200 Flash"
83 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
84 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
87 #ifdef CONFIG_MIPS_HYDROGEN3
88 #define BOARD_MAP_NAME "Hydrogen3 Flash"
89 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
90 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
91 #define USE_LOCAL_ACCESSORS /* why? */
94 #ifdef CONFIG_MIPS_BOSPORUS
95 #define BOARD_MAP_NAME "Bosporus Flash"
96 #define BOARD_FLASH_SIZE 0x01000000 /* 16MB */
97 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
100 #ifdef CONFIG_MIPS_MIRAGE
101 #define BOARD_MAP_NAME "Mirage Flash"
102 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
103 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
104 #define USE_LOCAL_ACCESSORS /* why? */
107 static struct map_info alchemy_map
= {
108 .name
= BOARD_MAP_NAME
,
111 static struct mtd_partition alchemy_partitions
[] = {
114 .size
= BOARD_FLASH_SIZE
- 0x00400000,
119 .offset
= MTDPART_OFS_APPEND
,
120 .mask_flags
= MTD_WRITEABLE
122 .name
= "raw kernel",
123 .size
= (0x300000 - 0x40000), /* last 256KB is yamon env */
124 .offset
= MTDPART_OFS_APPEND
,
128 static struct mtd_info
*mymtd
;
130 int __init
alchemy_mtd_init(void)
132 struct mtd_partition
*parts
;
134 unsigned long window_addr
;
135 unsigned long window_size
;
137 /* Default flash buswidth */
138 alchemy_map
.bankwidth
= BOARD_FLASH_WIDTH
;
140 window_addr
= 0x20000000 - BOARD_FLASH_SIZE
;
141 window_size
= BOARD_FLASH_SIZE
;
142 #ifdef CONFIG_MIPS_MIRAGE_WHY
143 /* Boot ROM flash bank only; no user bank */
144 window_addr
= 0x1C000000;
145 window_size
= 0x04000000;
146 /* USERFS from 0x1C00 0000 to 0x1FC00000 */
147 alchemy_partitions
[0].size
= 0x03C00000;
151 * Static partition definition selection
153 parts
= alchemy_partitions
;
154 nb_parts
= ARRAY_SIZE(alchemy_partitions
);
155 alchemy_map
.size
= window_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 BOARD_MAP_NAME
": probing %d-bit flash bus\n",
162 alchemy_map
.bankwidth
*8);
163 alchemy_map
.virt
= ioremap(window_addr
, window_size
);
164 mymtd
= do_map_probe("cfi_probe", &alchemy_map
);
166 iounmap(alchemy_map
.virt
);
169 mymtd
->owner
= THIS_MODULE
;
171 add_mtd_partitions(mymtd
, parts
, nb_parts
);
175 static void __exit
alchemy_mtd_cleanup(void)
178 del_mtd_partitions(mymtd
);
180 iounmap(alchemy_map
.virt
);
184 module_init(alchemy_mtd_init
);
185 module_exit(alchemy_mtd_cleanup
);
187 MODULE_AUTHOR("Embedded Alley Solutions, Inc");
188 MODULE_DESCRIPTION(BOARD_MAP_NAME
" MTD driver");
189 MODULE_LICENSE("GPL");