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/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>
23 #define DBG(x...) printk(x)
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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? */
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 */
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? */
108 static struct map_info alchemy_map
= {
109 .name
= BOARD_MAP_NAME
,
112 static struct mtd_partition alchemy_partitions
[] = {
115 .size
= BOARD_FLASH_SIZE
- 0x00400000,
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 static struct mtd_info
*mymtd
;
131 int __init
alchemy_mtd_init(void)
133 struct mtd_partition
*parts
;
135 unsigned long window_addr
;
136 unsigned long window_size
;
138 /* Default flash buswidth */
139 alchemy_map
.bankwidth
= BOARD_FLASH_WIDTH
;
141 window_addr
= 0x20000000 - BOARD_FLASH_SIZE
;
142 window_size
= BOARD_FLASH_SIZE
;
143 #ifdef CONFIG_MIPS_MIRAGE_WHY
144 /* Boot ROM flash bank only; no user bank */
145 window_addr
= 0x1C000000;
146 window_size
= 0x04000000;
147 /* USERFS from 0x1C00 0000 to 0x1FC00000 */
148 alchemy_partitions
[0].size
= 0x03C00000;
152 * Static partition definition selection
154 parts
= alchemy_partitions
;
155 nb_parts
= ARRAY_SIZE(alchemy_partitions
);
156 alchemy_map
.size
= window_size
;
159 * Now let's probe for the actual flash. Do it here since
160 * specific machine settings might have been set above.
162 printk(KERN_NOTICE BOARD_MAP_NAME
": probing %d-bit flash bus\n",
163 alchemy_map
.bankwidth
*8);
164 alchemy_map
.virt
= ioremap(window_addr
, window_size
);
165 mymtd
= do_map_probe("cfi_probe", &alchemy_map
);
167 iounmap(alchemy_map
.virt
);
170 mymtd
->owner
= THIS_MODULE
;
172 add_mtd_partitions(mymtd
, parts
, nb_parts
);
176 static void __exit
alchemy_mtd_cleanup(void)
179 del_mtd_partitions(mymtd
);
181 iounmap(alchemy_map
.virt
);
185 module_init(alchemy_mtd_init
);
186 module_exit(alchemy_mtd_cleanup
);
188 MODULE_AUTHOR("Embedded Alley Solutions, Inc");
189 MODULE_DESCRIPTION(BOARD_MAP_NAME
" MTD driver");
190 MODULE_LICENSE("GPL");