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