aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/alchemy/devboards/platform.c
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2009-10-19 06:53:37 -0400
committerRalf Baechle <ralf@linux-mips.org>2010-02-27 06:52:59 -0500
commit206aa6cdadad8bbedee5649f1346fe47e922a039 (patch)
tree1b66e9d98b65d7afe962bb6c6989f3ad212f2e6d /arch/mips/alchemy/devboards/platform.c
parent8facefd0907ae16f96a35bef7ce654206d87c2fc (diff)
MIPS: Alchemy: physmap-flash for all devboards
Replace the devboard NOR MTD mapping driver with physmap-flash support. Also honor the "swapboot" switch settings wrt. to the layout of the NOR partitions. Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com> Cc: Linux-MIPS <linux-mips@linux-mips.org> Acked-By: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/alchemy/devboards/platform.c')
-rw-r--r--arch/mips/alchemy/devboards/platform.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/arch/mips/alchemy/devboards/platform.c b/arch/mips/alchemy/devboards/platform.c
index 48c537cc8efb..7f2bcee7ac34 100644
--- a/arch/mips/alchemy/devboards/platform.c
+++ b/arch/mips/alchemy/devboards/platform.c
@@ -3,6 +3,9 @@
3 */ 3 */
4 4
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/mtd/mtd.h>
7#include <linux/mtd/map.h>
8#include <linux/mtd/physmap.h>
6#include <linux/slab.h> 9#include <linux/slab.h>
7#include <linux/platform_device.h> 10#include <linux/platform_device.h>
8 11
@@ -87,3 +90,104 @@ out:
87 kfree(sr); 90 kfree(sr);
88 return ret; 91 return ret;
89} 92}
93
94#define YAMON_SIZE 0x00100000
95#define YAMON_ENV_SIZE 0x00040000
96
97int __init db1x_register_norflash(unsigned long size, int width,
98 int swapped)
99{
100 struct physmap_flash_data *pfd;
101 struct platform_device *pd;
102 struct mtd_partition *parts;
103 struct resource *res;
104 int ret, i;
105
106 if (size < (8 * 1024 * 1024))
107 return -EINVAL;
108
109 ret = -ENOMEM;
110 parts = kzalloc(sizeof(struct mtd_partition) * 5, GFP_KERNEL);
111 if (!parts)
112 goto out;
113
114 res = kzalloc(sizeof(struct resource), GFP_KERNEL);
115 if (!res)
116 goto out1;
117
118 pfd = kzalloc(sizeof(struct physmap_flash_data), GFP_KERNEL);
119 if (!pfd)
120 goto out2;
121
122 pd = platform_device_alloc("physmap-flash", 0);
123 if (!pd)
124 goto out3;
125
126 /* NOR flash ends at 0x20000000, regardless of size */
127 res->start = 0x20000000 - size;
128 res->end = 0x20000000 - 1;
129 res->flags = IORESOURCE_MEM;
130
131 /* partition setup. Most Develboards have a switch which allows
132 * to swap the physical locations of the 2 NOR flash banks.
133 */
134 i = 0;
135 if (!swapped) {
136 /* first NOR chip */
137 parts[i].offset = 0;
138 parts[i].name = "User FS";
139 parts[i].size = size / 2;
140 i++;
141 }
142
143 parts[i].offset = MTDPART_OFS_APPEND;
144 parts[i].name = "User FS 2";
145 parts[i].size = (size / 2) - (0x20000000 - 0x1fc00000);
146 i++;
147
148 parts[i].offset = MTDPART_OFS_APPEND;
149 parts[i].name = "YAMON";
150 parts[i].size = YAMON_SIZE;
151 parts[i].mask_flags = MTD_WRITEABLE;
152 i++;
153
154 parts[i].offset = MTDPART_OFS_APPEND;
155 parts[i].name = "raw kernel";
156 parts[i].size = 0x00400000 - YAMON_SIZE - YAMON_ENV_SIZE;
157 i++;
158
159 parts[i].offset = MTDPART_OFS_APPEND;
160 parts[i].name = "YAMON Env";
161 parts[i].size = YAMON_ENV_SIZE;
162 parts[i].mask_flags = MTD_WRITEABLE;
163 i++;
164
165 if (swapped) {
166 parts[i].offset = MTDPART_OFS_APPEND;
167 parts[i].name = "User FS";
168 parts[i].size = size / 2;
169 i++;
170 }
171
172 pfd->width = width;
173 pfd->parts = parts;
174 pfd->nr_parts = 5;
175
176 pd->dev.platform_data = pfd;
177 pd->resource = res;
178 pd->num_resources = 1;
179
180 ret = platform_device_add(pd);
181 if (!ret)
182 return ret;
183
184 platform_device_put(pd);
185out3:
186 kfree(pfd);
187out2:
188 kfree(res);
189out1:
190 kfree(parts);
191out:
192 return ret;
193}