Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[sfrench/cifs-2.6.git] / drivers / mtd / maps / alchemy-flash.c
1 /*
2  * Flash memory access on AMD Alchemy evaluation boards
3  *
4  * (C) 2003, 2004 Pete Popov <ppopov@embeddedalley.com>
5  */
6
7 #include <linux/init.h>
8 #include <linux/module.h>
9 #include <linux/types.h>
10 #include <linux/kernel.h>
11
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/map.h>
14 #include <linux/mtd/partitions.h>
15
16 #include <asm/io.h>
17
18 #ifdef CONFIG_MIPS_PB1000
19 #define BOARD_MAP_NAME "Pb1000 Flash"
20 #define BOARD_FLASH_SIZE 0x00800000 /* 8MB */
21 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
22 #endif
23
24 #ifdef CONFIG_MIPS_PB1500
25 #define BOARD_MAP_NAME "Pb1500 Flash"
26 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
27 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
28 #endif
29
30 #ifdef CONFIG_MIPS_PB1100
31 #define BOARD_MAP_NAME "Pb1100 Flash"
32 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
33 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
34 #endif
35
36 #ifdef CONFIG_MIPS_PB1550
37 #define BOARD_MAP_NAME "Pb1550 Flash"
38 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
39 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
40 #endif
41
42 #ifdef CONFIG_MIPS_PB1200
43 #define BOARD_MAP_NAME "Pb1200 Flash"
44 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
45 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
46 #endif
47
48 #ifdef CONFIG_MIPS_DB1000
49 #define BOARD_MAP_NAME "Db1000 Flash"
50 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
51 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
52 #endif
53
54 #ifdef CONFIG_MIPS_DB1500
55 #define BOARD_MAP_NAME "Db1500 Flash"
56 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
57 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
58 #endif
59
60 #ifdef CONFIG_MIPS_DB1100
61 #define BOARD_MAP_NAME "Db1100 Flash"
62 #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
63 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
64 #endif
65
66 #ifdef CONFIG_MIPS_DB1550
67 #define BOARD_MAP_NAME "Db1550 Flash"
68 #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
69 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
70 #endif
71
72 #ifdef CONFIG_MIPS_DB1200
73 #define BOARD_MAP_NAME "Db1200 Flash"
74 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
75 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
76 #endif
77
78 #ifdef CONFIG_MIPS_BOSPORUS
79 #define BOARD_MAP_NAME "Bosporus Flash"
80 #define BOARD_FLASH_SIZE 0x01000000 /* 16MB */
81 #define BOARD_FLASH_WIDTH 2 /* 16-bits */
82 #endif
83
84 #ifdef CONFIG_MIPS_MIRAGE
85 #define BOARD_MAP_NAME "Mirage Flash"
86 #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
87 #define BOARD_FLASH_WIDTH 4 /* 32-bits */
88 #define USE_LOCAL_ACCESSORS /* why? */
89 #endif
90
91 static struct map_info alchemy_map = {
92         .name = BOARD_MAP_NAME,
93 };
94
95 static struct mtd_partition alchemy_partitions[] = {
96         {
97                 .name = "User FS",
98                 .size = BOARD_FLASH_SIZE - 0x00400000,
99                 .offset = 0x0000000
100         },{
101                 .name = "YAMON",
102                 .size = 0x0100000,
103                 .offset = MTDPART_OFS_APPEND,
104                 .mask_flags = MTD_WRITEABLE
105         },{
106                 .name = "raw kernel",
107                 .size = (0x300000 - 0x40000), /* last 256KB is yamon env */
108                 .offset = MTDPART_OFS_APPEND,
109         }
110 };
111
112 static struct mtd_info *mymtd;
113
114 int __init alchemy_mtd_init(void)
115 {
116         struct mtd_partition *parts;
117         int nb_parts = 0;
118         unsigned long window_addr;
119         unsigned long window_size;
120
121         /* Default flash buswidth */
122         alchemy_map.bankwidth = BOARD_FLASH_WIDTH;
123
124         window_addr = 0x20000000 - BOARD_FLASH_SIZE;
125         window_size = BOARD_FLASH_SIZE;
126
127         /*
128          * Static partition definition selection
129          */
130         parts = alchemy_partitions;
131         nb_parts = ARRAY_SIZE(alchemy_partitions);
132         alchemy_map.size = window_size;
133
134         /*
135          * Now let's probe for the actual flash.  Do it here since
136          * specific machine settings might have been set above.
137          */
138         printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",
139                         alchemy_map.bankwidth*8);
140         alchemy_map.virt = ioremap(window_addr, window_size);
141         mymtd = do_map_probe("cfi_probe", &alchemy_map);
142         if (!mymtd) {
143                 iounmap(alchemy_map.virt);
144                 return -ENXIO;
145         }
146         mymtd->owner = THIS_MODULE;
147
148         add_mtd_partitions(mymtd, parts, nb_parts);
149         return 0;
150 }
151
152 static void __exit alchemy_mtd_cleanup(void)
153 {
154         if (mymtd) {
155                 del_mtd_partitions(mymtd);
156                 map_destroy(mymtd);
157                 iounmap(alchemy_map.virt);
158         }
159 }
160
161 module_init(alchemy_mtd_init);
162 module_exit(alchemy_mtd_cleanup);
163
164 MODULE_AUTHOR("Embedded Alley Solutions, Inc");
165 MODULE_DESCRIPTION(BOARD_MAP_NAME " MTD driver");
166 MODULE_LICENSE("GPL");