MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / drivers / mtd / maps / alchemy-flash.c
blob7fc8097e41d224bbf690f9b72d7fc109495b68a3
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/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>
19 #include <asm/io.h>
21 #ifdef DEBUG_RW
22 #define DBG(x...) printk(x)
23 #else
24 #define DBG(x...)
25 #endif
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 */
31 #endif
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 */
37 #endif
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 */
43 #endif
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 */
49 #endif
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 */
55 #endif
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 */
61 #endif
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 */
67 #endif
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 */
73 #endif
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 */
79 #endif
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 */
85 #endif
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? */
92 #endif
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 */
98 #endif
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? */
105 #endif
107 static struct map_info alchemy_map = {
108 .name = BOARD_MAP_NAME,
111 static struct mtd_partition alchemy_partitions[] = {
113 .name = "User FS",
114 .size = BOARD_FLASH_SIZE - 0x00400000,
115 .offset = 0x0000000
117 .name = "YAMON",
118 .size = 0x0100000,
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;
133 int nb_parts = 0;
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;
148 #endif
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);
165 if (!mymtd) {
166 iounmap(alchemy_map.virt);
167 return -ENXIO;
169 mymtd->owner = THIS_MODULE;
171 add_mtd_partitions(mymtd, parts, nb_parts);
172 return 0;
175 static void __exit alchemy_mtd_cleanup(void)
177 if (mymtd) {
178 del_mtd_partitions(mymtd);
179 map_destroy(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");