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