Root/target/linux/x86/patches-3.3/100-rdc_boards.patch

1--- a/arch/x86/Makefile
2+++ b/arch/x86/Makefile
3@@ -136,6 +136,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-buttons",
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,247 @@
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_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 = master->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+ if (master->unlock)
314+ master->unlock(master, 0, master->erasesize);
315+ res = erase_write (master, 0, master->erasesize, buffer);
316+ if (res)
317+ printk(KERN_ERR "Can't rewrite image header\n");
318+
319+out:
320+ vfree(buffer);
321+ return res;
322+}
323+
324+static int __init
325+parse_ar525w_partitions(struct mtd_info *master, struct mtd_partition **pparts,
326+ struct mtd_part_parser_data *plat_data)
327+{
328+ struct image_header header;
329+ int res;
330+ size_t len;
331+ struct mtd_partition *rdc_flash_parts;
332+ struct rdc_platform_data *pdata = (struct rdc_platform_data *) plat_data;
333+
334+ if (master->size != 0x400000) //4MB
335+ return -ENOSYS;
336+
337+ res = master->read(master, 0x0, sizeof(header), &len, (char *)&header);
338+ if (res)
339+ return res;
340+
341+ if (strncmp(header.magic, "GMTK", 4))
342+ return -ENOSYS;
343+
344+ if (header.kernelsz > 0x400000 || header.kernelsz < master->erasesize) {
345+ printk(KERN_ERR "AR525W image header found, but seems corrupt, kernel size %u\n", header.kernelsz);
346+ return -EINVAL;
347+ }
348+
349+ if (header.kernelsz + sizeof(header) != header.imagesz) {
350+ res = fixup_ar525w_header(master, &header);
351+ if (res)
352+ return res;
353+ }
354+
355+ rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 3, GFP_KERNEL);
356+
357+ rdc_flash_parts[0].name = "firmware";
358+ rdc_flash_parts[0].offset = 0x0;
359+ rdc_flash_parts[0].size = 0x3E0000;
360+ rdc_flash_parts[1].name = "rootfs";
361+ rdc_flash_parts[1].offset = header.kernelsz + sizeof(header);
362+ rdc_flash_parts[1].size = rdc_flash_parts[0].size - rdc_flash_parts[1].offset;
363+ rdc_flash_parts[2].name = "bootloader";
364+ rdc_flash_parts[2].offset = 0x3E0000;
365+ rdc_flash_parts[2].size = 0x20000;
366+
367+ *pparts = rdc_flash_parts;
368+
369+ pdata->led_data.num_leds = ARRAY_SIZE(ar525w_leds);
370+ pdata->led_data.leds = ar525w_leds;
371+ pdata->button_data.nbuttons = ARRAY_SIZE(ar525w_btns);
372+ pdata->button_data.buttons = ar525w_btns;
373+
374+ return 3;
375+}
376+
377+static struct mtd_part_parser __initdata ar525w_parser = {
378+ .owner = THIS_MODULE,
379+ .parse_fn = parse_ar525w_partitions,
380+ .name = "AR525W",
381+};
382+
383+static int __init ar525w_setup(void)
384+{
385+ return register_mtd_parser(&ar525w_parser);
386+}
387+
388+arch_initcall(ar525w_setup);
389--- /dev/null
390+++ b/arch/x86/mach-rdc321x/boards/bifferboard.c
391@@ -0,0 +1,74 @@
392+/*
393+ * Bifferboard RDC321x platform devices
394+ *
395+ * Copyright (C) 2010 bifferos@yahoo.co.uk
396+ *
397+ * This program is free software; you can redistribute it and/or
398+ * modify it under the terms of the GNU General Public License
399+ * as published by the Free Software Foundation; either version 2
400+ * of the License, or (at your option) any later version.
401+ *
402+ * This program is distributed in the hope that it will be useful,
403+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
404+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
405+ * GNU General Public License for more details.
406+ *
407+ * You should have received a copy of the GNU General Public License
408+ * along with this program; if not, write to the
409+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
410+ * Boston, MA 02110-1301, USA.
411+ *
412+ */
413+
414+#include <linux/init.h>
415+#include <linux/module.h>
416+#include <linux/mtd/physmap.h>
417+#include <linux/input.h>
418+#include <linux/slab.h>
419+
420+#include <asm/rdc_boards.h>
421+
422+static int __init
423+parse_bifferboard_partitions(struct mtd_info *master,
424+ struct mtd_partition **pparts,
425+ struct mtd_part_parser_data *plat_data)
426+{
427+ int res;
428+ size_t len;
429+ struct mtd_partition *rdc_flash_parts;
430+ u32 kernel_len;
431+ u16 tmp;
432+
433+ res = master->read(master, 0x4000 + 1036, 2, &len, (char *) &tmp);
434+ if (res)
435+ return res;
436+ kernel_len = tmp * master->erasesize;
437+
438+ rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 3, GFP_KERNEL);
439+
440+ *pparts = rdc_flash_parts;
441+
442+ rdc_flash_parts[0].name = "kernel";
443+ rdc_flash_parts[0].offset = 0;
444+ rdc_flash_parts[0].size = kernel_len;
445+ rdc_flash_parts[1].name = "rootfs";
446+ rdc_flash_parts[1].offset = kernel_len;
447+ rdc_flash_parts[1].size = master->size - kernel_len - 0x10000;
448+ rdc_flash_parts[2].name = "biffboot";
449+ rdc_flash_parts[2].offset = master->size - 0x10000;
450+ rdc_flash_parts[2].size = 0x10000;
451+
452+ return 3;
453+}
454+
455+struct mtd_part_parser __initdata bifferboard_parser = {
456+ .owner = THIS_MODULE,
457+ .parse_fn = parse_bifferboard_partitions,
458+ .name = "Bifferboard",
459+};
460+
461+static int __init bifferboard_setup(void)
462+{
463+ return register_mtd_parser(&bifferboard_parser);
464+}
465+arch_initcall(bifferboard_setup);
466--- /dev/null
467+++ b/arch/x86/mach-rdc321x/boards/r8610.c
468@@ -0,0 +1,69 @@
469+/*
470+ * R8610 RDC321x platform devices
471+ *
472+ * Copyright (C) 2009, Florian Fainelli <florian@openwrt.org>
473+ *
474+ * This program is free software; you can redistribute it and/or
475+ * modify it under the terms of the GNU General Public License
476+ * as published by the Free Software Foundation; either version 2
477+ * of the License, or (at your option) any later version.
478+ *
479+ * This program is distributed in the hope that it will be useful,
480+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
481+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
482+ * GNU General Public License for more details.
483+ *
484+ * You should have received a copy of the GNU General Public License
485+ * along with this program; if not, write to the
486+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
487+ * Boston, MA 02110-1301, USA.
488+ *
489+ */
490+
491+#include <linux/init.h>
492+#include <linux/module.h>
493+#include <linux/mtd/physmap.h>
494+#include <linux/input.h>
495+#include <linux/slab.h>
496+
497+#include <asm/rdc_boards.h>
498+
499+static int __init
500+parse_r8610_partitions(struct mtd_info *master, struct mtd_partition **pparts,
501+ struct mtd_part_parser_data *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,115 @@
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/module.h>
567+#include <linux/mtd/physmap.h>
568+#include <linux/input.h>
569+#include <linux/slab.h>
570+
571+#include <asm/rdc_boards.h>
572+
573+struct image_header {
574+ char magic[4];
575+ u32 kernel_length;
576+ u32 ramdisk_length;
577+ char magic2[4];
578+ u32 kernel_length2;
579+};
580+
581+static struct gpio_led sitecom_leds[] = {
582+ { .name = "rdc321x:power", .gpio = 15, .active_low = 1},
583+ { .name = "rdc321x:usb0", .gpio = 0, .active_low = 1},
584+ { .name = "rdc321x:usb1", .gpio = 1, .active_low = 1},
585+};
586+
587+static struct gpio_button sitecom_btns[] = {
588+ {
589+ .gpio = 6,
590+ .code = BTN_0,
591+ .desc = "Reset",
592+ .active_low = 1,
593+ }
594+};
595+
596+static int __init
597+parse_sitecom_partitions(struct mtd_info *master, struct mtd_partition **pparts,
598+ struct mtd_part_parser_data *plat_data)
599+{
600+ struct image_header header;
601+ int res;
602+ size_t len;
603+ struct mtd_partition *rdc_flash_parts;
604+ struct rdc_platform_data *pdata = (struct rdc_platform_data *) plat_data;
605+
606+ if (master->size != 0x400000) /* 4MB */
607+ return -ENOSYS;
608+
609+ res = master->read(master, 0x8000, sizeof(header), &len, (char *)&header);
610+ if (res)
611+ return res;
612+
613+ if (strncmp(header.magic, "CSYS", 4) || strncmp(header.magic2, "WRRM", 4))
614+ return -ENOSYS;
615+
616+ rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 5, GFP_KERNEL);
617+
618+ rdc_flash_parts[0].name = "firmware";
619+ rdc_flash_parts[0].offset = 0x8000;
620+ rdc_flash_parts[0].size = 0x3F0000 - 0x8000;
621+ rdc_flash_parts[1].name = "config";
622+ rdc_flash_parts[1].offset = 0;
623+ rdc_flash_parts[1].size = 0x8000;
624+ rdc_flash_parts[2].name = "kernel";
625+ rdc_flash_parts[2].offset = 0x8014;
626+ rdc_flash_parts[2].size = header.kernel_length;
627+ rdc_flash_parts[3].name = "rootfs";
628+ rdc_flash_parts[3].offset = 0x8014 + header.kernel_length;
629+ rdc_flash_parts[3].size = 0x3F0000 - rdc_flash_parts[3].offset;
630+ rdc_flash_parts[4].name = "bootloader";
631+ rdc_flash_parts[4].offset = 0x3F0000;
632+ rdc_flash_parts[4].size = 0x10000;
633+
634+ *pparts = rdc_flash_parts;
635+
636+ pdata->led_data.num_leds = ARRAY_SIZE(sitecom_leds);
637+ pdata->led_data.leds = sitecom_leds;
638+ pdata->button_data.nbuttons = ARRAY_SIZE(sitecom_btns);
639+ pdata->button_data.buttons = sitecom_btns;
640+
641+ return 5;
642+}
643+
644+struct mtd_part_parser __initdata sitecom_parser = {
645+ .owner = THIS_MODULE,
646+ .parse_fn = parse_sitecom_partitions,
647+ .name = "Sitecom",
648+};
649+
650+static int __init sitecom_setup(void)
651+{
652+ return register_mtd_parser(&sitecom_parser);
653+}
654+
655+arch_initcall(sitecom_setup);
656--- /dev/null
657+++ b/arch/x86/mach-rdc321x/reboot.c
658@@ -0,0 +1,44 @@
659+/*
660+ * This program is free software; you can redistribute it and/or
661+ * modify it under the terms of the GNU General Public License
662+ * as published by the Free Software Foundation; either version 2
663+ * of the License, or (at your option) any later version.
664+ *
665+ * This program is distributed in the hope that it will be useful,
666+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
667+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
668+ * GNU General Public License for more details.
669+ *
670+ * You should have received a copy of the GNU General Public License
671+ * along with this program; if not, write to the
672+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
673+ * Boston, MA 02110-1301, USA.
674+ *
675+ */
676+
677+#include <asm/reboot.h>
678+#include <asm/io.h>
679+
680+static void rdc321x_reset(void)
681+{
682+ unsigned i;
683+
684+ /* write to southbridge config register 0x41
685+ enable pci reset on cpu reset, make internal port 0x92 writeable
686+ and switch port 0x92 to internal */
687+ outl(0x80003840, 0xCF8);
688+ i = inl(0xCFC);
689+ i |= 0x1600;
690+ outl(i, 0xCFC);
691+
692+ /* soft reset */
693+ outb(1, 0x92);
694+}
695+
696+static int __init rdc_setup_reset(void)
697+{
698+ machine_ops.emergency_restart = rdc321x_reset;
699+ return 0;
700+}
701+
702+arch_initcall(rdc_setup_reset);
703--- /dev/null
704+++ b/arch/x86/include/asm/rdc_boards.h
705@@ -0,0 +1,36 @@
706+/*
707+ * RDC321x boards
708+ *
709+ * Copyright (C) 2007-2009 OpenWrt.org
710+ * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
711+ * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
712+ *
713+ * This program is free software; you can redistribute it and/or
714+ * modify it under the terms of the GNU General Public License
715+ * as published by the Free Software Foundation; either version 2
716+ * of the License, or (at your option) any later version.
717+ *
718+ * This program is distributed in the hope that it will be useful,
719+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
720+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
721+ * GNU General Public License for more details.
722+ *
723+ * You should have received a copy of the GNU General Public License
724+ * along with this program; if not, write to the
725+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
726+ * Boston, MA 02110-1301, USA.
727+ *
728+ */
729+
730+#ifndef _RDC_BOARDS_H__
731+#define _RDC_BOARDS_H__
732+
733+#include <linux/leds.h>
734+#include <linux/gpio_buttons.h>
735+
736+struct rdc_platform_data {
737+ struct gpio_led_platform_data led_data;
738+ struct gpio_buttons_platform_data button_data;
739+};
740+
741+#endif
742

Archive Download this file



interactive