use upstream MFD, GPIO patch, put everything in patches.
[openwrt/openwrt.git] / target / linux / rdc / patches-2.6.30 / 100-rdc_boards.patch
1 Index: linux-2.6.30.10/arch/x86/Makefile
2 ===================================================================
3 --- linux-2.6.30.10.orig/arch/x86/Makefile 2009-12-04 07:00:07.000000000 +0100
4 +++ linux-2.6.30.10/arch/x86/Makefile 2010-04-28 10:17:54.000000000 +0200
5 @@ -124,6 +124,9 @@
6 # Xen paravirtualization support
7 core-$(CONFIG_XEN) += arch/x86/xen/
8
9 +# RDC R-321X support
10 +core-$(CONFIG_X86_RDC321X) += arch/x86/mach-rdc321x/
11 +
12 # lguest paravirtualization support
13 core-$(CONFIG_LGUEST_GUEST) += arch/x86/lguest/
14
15 Index: linux-2.6.30.10/arch/x86/mach-rdc321x/Makefile
16 ===================================================================
17 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
18 +++ linux-2.6.30.10/arch/x86/mach-rdc321x/Makefile 2010-04-28 10:20:33.000000000 +0200
19 @@ -0,0 +1,5 @@
20 +#
21 +# Makefile for the RDC321x specific parts of the kernel
22 +#
23 +obj-$(CONFIG_X86_RDC321X) := platform.o reboot.o boards/sitecom.o boards/ar525w.o boards/bifferboard.o boards/r8610.o
24 +
25 Index: linux-2.6.30.10/arch/x86/mach-rdc321x/platform.c
26 ===================================================================
27 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
28 +++ linux-2.6.30.10/arch/x86/mach-rdc321x/platform.c 2010-04-28 10:22:23.000000000 +0200
29 @@ -0,0 +1,115 @@
30 +/*
31 + * Generic RDC321x platform devices
32 + *
33 + * Copyright (C) 2007-2009 OpenWrt.org
34 + * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
35 + * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
36 + *
37 + * This program is free software; you can redistribute it and/or
38 + * modify it under the terms of the GNU General Public License
39 + * as published by the Free Software Foundation; either version 2
40 + * of the License, or (at your option) any later version.
41 + *
42 + * This program is distributed in the hope that it will be useful,
43 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
44 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 + * GNU General Public License for more details.
46 + *
47 + * You should have received a copy of the GNU General Public License
48 + * along with this program; if not, write to the
49 + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
50 + * Boston, MA 02110-1301, USA.
51 + *
52 + */
53 +
54 +#include <linux/init.h>
55 +#include <linux/platform_device.h>
56 +#include <linux/mtd/map.h>
57 +#include <linux/mtd/mtd.h>
58 +#include <linux/mtd/physmap.h>
59 +#include <linux/root_dev.h>
60 +
61 +#include <asm/rdc_boards.h>
62 +
63 +static struct rdc_platform_data rdcplat_data;
64 +
65 +/* LEDS */
66 +static struct platform_device rdc321x_leds = {
67 + .name = "leds-gpio",
68 + .id = -1,
69 + .dev = {
70 + .platform_data = &rdcplat_data.led_data,
71 + }
72 +};
73 +
74 +/* Button */
75 +static struct platform_device rdc321x_buttons = {
76 + .name = "gpio-buttons",
77 + .id = -1,
78 + .dev = {
79 + .platform_data = &rdcplat_data.button_data,
80 + }
81 +};
82 +
83 +static __initdata struct platform_device *rdc321x_devs[] = {
84 + &rdc321x_leds,
85 + &rdc321x_buttons,
86 +};
87 +
88 +const char *__initdata boards[] = {
89 + "Sitecom",
90 + "AR525W",
91 + "Bifferboard",
92 + "R8610",
93 + 0
94 +};
95 +
96 +static struct map_info rdc_map_info = {
97 + .name = "rdc_flash",
98 + .size = 0x800000, /* 8MB */
99 + .phys = 0xFF800000, /* (u32) -rdc_map_info.size */
100 + .bankwidth = 2,
101 +};
102 +
103 +static int __init rdc_board_setup(void)
104 +{
105 + struct mtd_partition *partitions;
106 + int count, res;
107 + struct mtd_info *mtdinfo;
108 +
109 + simple_map_init(&rdc_map_info);
110 +
111 + while (1) {
112 + rdc_map_info.virt = ioremap(rdc_map_info.phys,
113 + rdc_map_info.size);
114 + if (rdc_map_info.virt == NULL)
115 + continue;
116 +
117 + mtdinfo = do_map_probe("cfi_probe", &rdc_map_info);
118 + if (mtdinfo == NULL)
119 + mtdinfo = do_map_probe("jedec_probe", &rdc_map_info);
120 + if (mtdinfo != NULL)
121 + break;
122 +
123 + iounmap(rdc_map_info.virt);
124 + if ((rdc_map_info.size >>= 1) < 0x100000) /* 1MB */
125 + panic("RDC321x: Could not find start of flash!");
126 + rdc_map_info.phys = (u32) -rdc_map_info.size;
127 + }
128 +
129 + count = parse_mtd_partitions(mtdinfo, boards, &partitions,
130 + (unsigned long) &rdcplat_data);
131 +
132 + if (count <= 0) {
133 + panic("RDC321x: can't identify board type");
134 + return -ENOSYS;
135 + }
136 +
137 + ROOT_DEV = 0;
138 + res = add_mtd_partitions(mtdinfo, partitions, count);
139 + if (res)
140 + return res;
141 +
142 + return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs));
143 +}
144 +late_initcall(rdc_board_setup);
145 Index: linux-2.6.30.10/arch/x86/mach-rdc321x/boards/ar525w.c
146 ===================================================================
147 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
148 +++ linux-2.6.30.10/arch/x86/mach-rdc321x/boards/ar525w.c 2010-04-28 10:23:52.000000000 +0200
149 @@ -0,0 +1,243 @@
150 +/*
151 + * ar525w RDC321x platform devices
152 + *
153 + * Copyright (C) 2007-2009 OpenWrt.org
154 + * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
155 + * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
156 + *
157 + * This program is free software; you can redistribute it and/or
158 + * modify it under the terms of the GNU General Public License
159 + * as published by the Free Software Foundation; either version 2
160 + * of the License, or (at your option) any later version.
161 + *
162 + * This program is distributed in the hope that it will be useful,
163 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
164 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
165 + * GNU General Public License for more details.
166 + *
167 + * You should have received a copy of the GNU General Public License
168 + * along with this program; if not, write to the
169 + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
170 + * Boston, MA 02110-1301, USA.
171 + *
172 + */
173 +
174 +#include <linux/init.h>
175 +#include <linux/mtd/physmap.h>
176 +#include <linux/input.h>
177 +#include <linux/vmalloc.h>
178 +#include <linux/mtd/mtd.h>
179 +
180 +#include <asm/rdc_boards.h>
181 +
182 +struct image_header {
183 + char magic[4]; /* ASICII: GMTK */
184 + u32 checksum; /* CRC32 */
185 + u32 version; /* x.x.x.x */
186 + u32 kernelsz; /* The size of the kernel image */
187 + u32 imagesz; /* The length of this image file ( kernel + romfs + this header) */
188 + u32 pid; /* Product ID */
189 + u32 fastcksum; /* Partial CRC32 on (First(256), medium(256), last(512)) */
190 + u32 reserved;
191 +};
192 +
193 +static struct gpio_led ar525w_leds[] = {
194 + { .name = "rdc321x:dmz", .gpio = 1, .active_low = 1},
195 +};
196 +static struct gpio_button ar525w_btns[] = {
197 + {
198 + .gpio = 6,
199 + .code = BTN_0,
200 + .desc = "Reset",
201 + .active_low = 1,
202 + }
203 +};
204 +
205 +static u32 __initdata crctab[257] = {
206 + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
207 + 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
208 + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
209 + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
210 + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
211 + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
212 + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
213 + 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
214 + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
215 + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
216 + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
217 + 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
218 + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
219 + 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
220 + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
221 + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
222 + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
223 + 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
224 + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
225 + 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
226 + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
227 + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
228 + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
229 + 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
230 + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
231 + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
232 + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
233 + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
234 + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
235 + 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
236 + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
237 + 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
238 + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
239 + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
240 + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
241 + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
242 + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
243 + 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
244 + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
245 + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
246 + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
247 + 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
248 + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
249 + 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
250 + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
251 + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
252 + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
253 + 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
254 + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
255 + 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
256 + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
257 + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
258 + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
259 + 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
260 + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
261 + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
262 + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
263 + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
264 + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
265 + 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
266 + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
267 + 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
268 + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
269 + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
270 + 0
271 +};
272 +
273 +static u32 __init crc32(u8 * buf, u32 len)
274 +{
275 + register int i;
276 + u32 sum;
277 + register u32 s0;
278 + s0 = ~0;
279 + for (i = 0; i < len; i++) {
280 + s0 = (s0 >> 8) ^ crctab[(u8) (s0 & 0xFF) ^ buf[i]];
281 + }
282 + sum = ~s0;
283 + return sum;
284 +}
285 +
286 +static int __init fixup_ar525w_header(struct mtd_info *master, struct image_header *header)
287 +{
288 + char *buffer;
289 + int res;
290 + u32 bufferlength = header->kernelsz + sizeof(struct image_header);
291 + u32 len;
292 + char crcbuf[0x400];
293 +
294 + printk(KERN_INFO "Fixing up AR525W header, old image size: %u, new image size: %u\n",
295 + header->imagesz, bufferlength);
296 +
297 + buffer = vmalloc(bufferlength);
298 + if (!buffer) {
299 + printk(KERN_ERR "Can't allocate %u bytes\n", bufferlength);
300 + return -ENOMEM;
301 + }
302 +
303 + res = master->read(master, 0x0, bufferlength, &len, buffer);
304 + if (res || len != bufferlength)
305 + goto out;
306 +
307 + header = (struct image_header *) buffer;
308 + header->imagesz = bufferlength;
309 + header->checksum = 0;
310 + header->fastcksum = 0;
311 +
312 + memcpy(crcbuf, buffer, 0x100);
313 + memcpy(crcbuf + 0x100, buffer + (bufferlength >> 1) - ((bufferlength & 0x6) >> 1), 0x100);
314 + memcpy(crcbuf + 0x200, buffer + bufferlength - 0x200, 0x200);
315 +
316 + header->fastcksum = crc32(crcbuf, sizeof(crcbuf));
317 + header->checksum = crc32(buffer, bufferlength);
318 +
319 + if (master->unlock)
320 + master->unlock(master, 0, master->erasesize);
321 + res = erase_write (master, 0, master->erasesize, buffer);
322 + if (res)
323 + printk(KERN_ERR "Can't rewrite image header\n");
324 +
325 +out:
326 + vfree(buffer);
327 + return res;
328 +}
329 +
330 +static int __init parse_ar525w_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long plat_data)
331 +{
332 + struct image_header header;
333 + int res;
334 + size_t len;
335 + struct mtd_partition *rdc_flash_parts;
336 + struct rdc_platform_data *pdata = (struct rdc_platform_data *) plat_data;
337 +
338 + if (master->size != 0x400000) //4MB
339 + return -ENOSYS;
340 +
341 + res = master->read(master, 0x0, sizeof(header), &len, (char *)&header);
342 + if (res)
343 + return res;
344 +
345 + if (strncmp(header.magic, "GMTK", 4))
346 + return -ENOSYS;
347 +
348 + if (header.kernelsz > 0x400000 || header.kernelsz < master->erasesize) {
349 + printk(KERN_ERR "AR525W image header found, but seems corrupt, kernel size %u\n", header.kernelsz);
350 + return -EINVAL;
351 + }
352 +
353 + if (header.kernelsz + sizeof(header) != header.imagesz) {
354 + res = fixup_ar525w_header(master, &header);
355 + if (res)
356 + return res;
357 + }
358 +
359 + rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 3, GFP_KERNEL);
360 +
361 + rdc_flash_parts[0].name = "firmware";
362 + rdc_flash_parts[0].offset = 0x0;
363 + rdc_flash_parts[0].size = 0x3E0000;
364 + rdc_flash_parts[1].name = "rootfs";
365 + rdc_flash_parts[1].offset = header.kernelsz + sizeof(header);
366 + rdc_flash_parts[1].size = rdc_flash_parts[0].size - rdc_flash_parts[1].offset;
367 + rdc_flash_parts[2].name = "bootloader";
368 + rdc_flash_parts[2].offset = 0x3E0000;
369 + rdc_flash_parts[2].size = 0x20000;
370 +
371 + *pparts = rdc_flash_parts;
372 +
373 + pdata->led_data.num_leds = ARRAY_SIZE(ar525w_leds);
374 + pdata->led_data.leds = ar525w_leds;
375 + pdata->button_data.nbuttons = ARRAY_SIZE(ar525w_btns);
376 + pdata->button_data.buttons = ar525w_btns;
377 +
378 + return 3;
379 +}
380 +
381 +static struct mtd_part_parser __initdata ar525w_parser = {
382 + .owner = THIS_MODULE,
383 + .parse_fn = parse_ar525w_partitions,
384 + .name = "AR525W",
385 +};
386 +
387 +static int __init ar525w_setup(void)
388 +{
389 + return register_mtd_parser(&ar525w_parser);
390 +}
391 +
392 +arch_initcall(ar525w_setup);
393 Index: linux-2.6.30.10/arch/x86/mach-rdc321x/boards/bifferboard.c
394 ===================================================================
395 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
396 +++ linux-2.6.30.10/arch/x86/mach-rdc321x/boards/bifferboard.c 2010-04-28 10:24:47.000000000 +0200
397 @@ -0,0 +1,81 @@
398 +/*
399 + * Bifferboard RDC321x platform devices
400 + *
401 + * Copyright (C) 2010 bifferos@yahoo.co.uk
402 + *
403 + * This program is free software; you can redistribute it and/or
404 + * modify it under the terms of the GNU General Public License
405 + * as published by the Free Software Foundation; either version 2
406 + * of the License, or (at your option) any later version.
407 + *
408 + * This program is distributed in the hope that it will be useful,
409 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
410 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
411 + * GNU General Public License for more details.
412 + *
413 + * You should have received a copy of the GNU General Public License
414 + * along with this program; if not, write to the
415 + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
416 + * Boston, MA 02110-1301, USA.
417 + *
418 + */
419 +
420 +#include <linux/init.h>
421 +#include <linux/mtd/physmap.h>
422 +#include <linux/input.h>
423 +
424 +#include <asm/rdc_boards.h>
425 +
426 +static int __init parse_bifferboard_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long plat_data)
427 +{
428 + int res;
429 + size_t len;
430 + struct mtd_partition *rdc_flash_parts;
431 + u32 kernel_len;
432 + u16 tmp;
433 +
434 + if (master->size == 0x100000)
435 + kernel_len = master->size - 0x10000;
436 + else {
437 + res = master->read(master, 0x4000 + 1036, 2, &len, (char *) &tmp);
438 + if (res)
439 + return res;
440 + kernel_len = tmp * master->erasesize;
441 + }
442 +
443 + rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 4, GFP_KERNEL);
444 +
445 + *pparts = rdc_flash_parts;
446 +
447 + rdc_flash_parts[0].name = "biffboot";
448 + rdc_flash_parts[0].offset = master->size - 0x10000;
449 + rdc_flash_parts[0].size = 0x10000;
450 + rdc_flash_parts[0].mask_flags = MTD_WRITEABLE;
451 + rdc_flash_parts[1].name = "firmware";
452 + rdc_flash_parts[1].offset = 0;
453 + rdc_flash_parts[1].size = rdc_flash_parts[0].offset;
454 + rdc_flash_parts[2].name = "kernel";
455 + rdc_flash_parts[2].offset = 0x00000000;
456 + rdc_flash_parts[2].size = kernel_len;
457 +
458 + if (master->size == 0x100000)
459 + return 2;
460 +
461 + rdc_flash_parts[3].name = "rootfs";
462 + rdc_flash_parts[3].offset = MTDPART_OFS_APPEND;
463 + rdc_flash_parts[3].size = rdc_flash_parts[1].size - rdc_flash_parts[2].size;
464 +
465 + return 4;
466 +}
467 +
468 +struct mtd_part_parser __initdata bifferboard_parser = {
469 + .owner = THIS_MODULE,
470 + .parse_fn = parse_bifferboard_partitions,
471 + .name = "Bifferboard",
472 +};
473 +
474 +static int __init bifferboard_setup(void)
475 +{
476 + return register_mtd_parser(&bifferboard_parser);
477 +}
478 +arch_initcall(bifferboard_setup);
479 Index: linux-2.6.30.10/arch/x86/mach-rdc321x/boards/r8610.c
480 ===================================================================
481 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
482 +++ linux-2.6.30.10/arch/x86/mach-rdc321x/boards/r8610.c 2010-04-28 10:25:46.000000000 +0200
483 @@ -0,0 +1,65 @@
484 +/*
485 + * R8610 RDC321x platform devices
486 + *
487 + * Copyright (C) 2009, Florian Fainelli <florian@openwrt.org>
488 + *
489 + * This program is free software; you can redistribute it and/or
490 + * modify it under the terms of the GNU General Public License
491 + * as published by the Free Software Foundation; either version 2
492 + * of the License, or (at your option) any later version.
493 + *
494 + * This program is distributed in the hope that it will be useful,
495 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
496 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
497 + * GNU General Public License for more details.
498 + *
499 + * You should have received a copy of the GNU General Public License
500 + * along with this program; if not, write to the
501 + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
502 + * Boston, MA 02110-1301, USA.
503 + *
504 + */
505 +
506 +#include <linux/init.h>
507 +#include <linux/mtd/physmap.h>
508 +#include <linux/input.h>
509 +
510 +#include <asm/rdc_boards.h>
511 +
512 +static int __init parse_r8610_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long plat_data)
513 +{
514 + struct mtd_partition *rdc_flash_parts;
515 +
516 + rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 4, GFP_KERNEL);
517 +
518 + *pparts = rdc_flash_parts;
519 +
520 + rdc_flash_parts[0].name = "kernel";
521 + rdc_flash_parts[0].size = 0x001f0000;
522 + rdc_flash_parts[0].offset = 0;
523 + rdc_flash_parts[1].name = "config";
524 + rdc_flash_parts[1].size = 0x10000;
525 + rdc_flash_parts[1].offset = MTDPART_OFS_APPEND;
526 + rdc_flash_parts[2].name = "rootfs";
527 + rdc_flash_parts[2].size = 0x1E0000;
528 + rdc_flash_parts[2].offset = MTDPART_OFS_APPEND;
529 + rdc_flash_parts[3].name = "redboot";
530 + rdc_flash_parts[3].size = 0x20000;
531 + rdc_flash_parts[3].offset = MTDPART_OFS_APPEND;
532 + rdc_flash_parts[3].mask_flags = MTD_WRITEABLE;
533 +
534 + return 4;
535 +}
536 +
537 +struct mtd_part_parser __initdata r8610_parser = {
538 + .owner = THIS_MODULE,
539 + .parse_fn = parse_r8610_partitions,
540 + .name = "R8610",
541 +};
542 +
543 +static int __init r8610_setup(void)
544 +{
545 + return register_mtd_parser(&r8610_parser);
546 +}
547 +
548 +arch_initcall(r8610_setup);
549 Index: linux-2.6.30.10/arch/x86/mach-rdc321x/boards/sitecom.c
550 ===================================================================
551 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
552 +++ linux-2.6.30.10/arch/x86/mach-rdc321x/boards/sitecom.c 2010-04-28 10:26:21.000000000 +0200
553 @@ -0,0 +1,111 @@
554 +/*
555 + * Sitecom RDC321x platform devices
556 + *
557 + * Copyright (C) 2007-2009 OpenWrt.org
558 + * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
559 + * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
560 + *
561 + * This program is free software; you can redistribute it and/or
562 + * modify it under the terms of the GNU General Public License
563 + * as published by the Free Software Foundation; either version 2
564 + * of the License, or (at your option) any later version.
565 + *
566 + * This program is distributed in the hope that it will be useful,
567 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
568 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
569 + * GNU General Public License for more details.
570 + *
571 + * You should have received a copy of the GNU General Public License
572 + * along with this program; if not, write to the
573 + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
574 + * Boston, MA 02110-1301, USA.
575 + *
576 + */
577 +
578 +#include <linux/init.h>
579 +#include <linux/mtd/physmap.h>
580 +#include <linux/input.h>
581 +
582 +#include <asm/rdc_boards.h>
583 +
584 +struct image_header {
585 + char magic[4];
586 + u32 kernel_length;
587 + u32 ramdisk_length;
588 + char magic2[4];
589 + u32 kernel_length2;
590 +};
591 +
592 +static struct gpio_led sitecom_leds[] = {
593 + { .name = "rdc321x:power", .gpio = 15, .active_low = 1},
594 + { .name = "rdc321x:usb0", .gpio = 0, .active_low = 1},
595 + { .name = "rdc321x:usb1", .gpio = 1, .active_low = 1},
596 +};
597 +
598 +static struct gpio_button sitecom_btns[] = {
599 + {
600 + .gpio = 6,
601 + .code = BTN_0,
602 + .desc = "Reset",
603 + .active_low = 1,
604 + }
605 +};
606 +
607 +static int __init parse_sitecom_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long plat_data)
608 +{
609 + struct image_header header;
610 + int res;
611 + size_t len;
612 + struct mtd_partition *rdc_flash_parts;
613 + struct rdc_platform_data *pdata = (struct rdc_platform_data *) plat_data;
614 +
615 + if (master->size != 0x400000) /* 4MB */
616 + return -ENOSYS;
617 +
618 + res = master->read(master, 0x8000, sizeof(header), &len, (char *)&header);
619 + if (res)
620 + return res;
621 +
622 + if (strncmp(header.magic, "CSYS", 4) || strncmp(header.magic2, "WRRM", 4))
623 + return -ENOSYS;
624 +
625 + rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 5, GFP_KERNEL);
626 +
627 + rdc_flash_parts[0].name = "firmware";
628 + rdc_flash_parts[0].offset = 0x8000;
629 + rdc_flash_parts[0].size = 0x3F0000;
630 + rdc_flash_parts[1].name = "config";
631 + rdc_flash_parts[1].offset = 0;
632 + rdc_flash_parts[1].size = 0x8000;
633 + rdc_flash_parts[2].name = "kernel";
634 + rdc_flash_parts[2].offset = 0x8014;
635 + rdc_flash_parts[2].size = header.kernel_length;
636 + rdc_flash_parts[3].name = "rootfs";
637 + rdc_flash_parts[3].offset = 0x8014 + header.kernel_length;
638 + rdc_flash_parts[3].size = 0x3F0000 - rdc_flash_parts[3].offset;
639 + rdc_flash_parts[4].name = "bootloader";
640 + rdc_flash_parts[4].offset = 0x3F0000;
641 + rdc_flash_parts[4].size = 0x10000;
642 +
643 + *pparts = rdc_flash_parts;
644 +
645 + pdata->led_data.num_leds = ARRAY_SIZE(sitecom_leds);
646 + pdata->led_data.leds = sitecom_leds;
647 + pdata->button_data.nbuttons = ARRAY_SIZE(sitecom_btns);
648 + pdata->button_data.buttons = sitecom_btns;
649 +
650 + return 5;
651 +}
652 +
653 +struct mtd_part_parser __initdata sitecom_parser = {
654 + .owner = THIS_MODULE,
655 + .parse_fn = parse_sitecom_partitions,
656 + .name = "Sitecom",
657 +};
658 +
659 +static int __init sitecom_setup(void)
660 +{
661 + return register_mtd_parser(&sitecom_parser);
662 +}
663 +
664 +arch_initcall(sitecom_setup);
665 Index: linux-2.6.30.10/arch/x86/mach-rdc321x/reboot.c
666 ===================================================================
667 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
668 +++ linux-2.6.30.10/arch/x86/mach-rdc321x/reboot.c 2010-04-28 10:26:53.000000000 +0200
669 @@ -0,0 +1,44 @@
670 +/*
671 + * This program is free software; you can redistribute it and/or
672 + * modify it under the terms of the GNU General Public License
673 + * as published by the Free Software Foundation; either version 2
674 + * of the License, or (at your option) any later version.
675 + *
676 + * This program is distributed in the hope that it will be useful,
677 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
678 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
679 + * GNU General Public License for more details.
680 + *
681 + * You should have received a copy of the GNU General Public License
682 + * along with this program; if not, write to the
683 + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
684 + * Boston, MA 02110-1301, USA.
685 + *
686 + */
687 +
688 +#include <asm/reboot.h>
689 +#include <asm/io.h>
690 +
691 +static void rdc321x_reset(void)
692 +{
693 + unsigned i;
694 +
695 + /* write to southbridge config register 0x41
696 + enable pci reset on cpu reset, make internal port 0x92 writeable
697 + and switch port 0x92 to internal */
698 + outl(0x80003840, 0xCF8);
699 + i = inl(0xCFC);
700 + i |= 0x1600;
701 + outl(i, 0xCFC);
702 +
703 + /* soft reset */
704 + outb(1, 0x92);
705 +}
706 +
707 +static int __init rdc_setup_reset(void)
708 +{
709 + machine_ops.emergency_restart = rdc321x_reset;
710 + return 0;
711 +}
712 +
713 +arch_initcall(rdc_setup_reset);
714 Index: linux-2.6.30.10/arch/x86/include/asm/rdc_boards.h
715 ===================================================================
716 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
717 +++ linux-2.6.30.10/arch/x86/include/asm/rdc_boards.h 2010-04-28 10:42:56.000000000 +0200
718 @@ -0,0 +1,36 @@
719 +/*
720 + * RDC321x boards
721 + *
722 + * Copyright (C) 2007-2009 OpenWrt.org
723 + * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
724 + * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
725 + *
726 + * This program is free software; you can redistribute it and/or
727 + * modify it under the terms of the GNU General Public License
728 + * as published by the Free Software Foundation; either version 2
729 + * of the License, or (at your option) any later version.
730 + *
731 + * This program is distributed in the hope that it will be useful,
732 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
733 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
734 + * GNU General Public License for more details.
735 + *
736 + * You should have received a copy of the GNU General Public License
737 + * along with this program; if not, write to the
738 + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
739 + * Boston, MA 02110-1301, USA.
740 + *
741 + */
742 +
743 +#ifndef _RDC_BOARDS_H__
744 +#define _RDC_BOARDS_H__
745 +
746 +#include <linux/leds.h>
747 +#include <linux/gpio_buttons.h>
748 +
749 +struct rdc_platform_data {
750 + struct gpio_led_platform_data led_data;
751 + struct gpio_buttons_platform_data button_data;
752 +};
753 +
754 +#endif