100-rdc_boards.patch 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  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. +# RDC R-321X support
  7. +core-$(CONFIG_X86_RDC321X) += arch/x86/mach-rdc321x/
  8. +
  9. # drivers-y are linked after core-y
  10. drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/
  11. drivers-$(CONFIG_PCI) += arch/x86/pci/
  12. --- /dev/null
  13. +++ b/arch/x86/mach-rdc321x/Makefile
  14. @@ -0,0 +1,5 @@
  15. +#
  16. +# Makefile for the RDC321x specific parts of the kernel
  17. +#
  18. +obj-$(CONFIG_X86_RDC321X) := platform.o reboot.o boards/sitecom.o boards/ar525w.o boards/bifferboard.o boards/r8610.o
  19. +
  20. --- /dev/null
  21. +++ b/arch/x86/mach-rdc321x/platform.c
  22. @@ -0,0 +1,115 @@
  23. +/*
  24. + * Generic RDC321x platform devices
  25. + *
  26. + * Copyright (C) 2007-2009 OpenWrt.org
  27. + * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
  28. + * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
  29. + *
  30. + * This program is free software; you can redistribute it and/or
  31. + * modify it under the terms of the GNU General Public License
  32. + * as published by the Free Software Foundation; either version 2
  33. + * of the License, or (at your option) any later version.
  34. + *
  35. + * This program is distributed in the hope that it will be useful,
  36. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  38. + * GNU General Public License for more details.
  39. + *
  40. + * You should have received a copy of the GNU General Public License
  41. + * along with this program; if not, write to the
  42. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  43. + * Boston, MA 02110-1301, USA.
  44. + *
  45. + */
  46. +
  47. +#include <linux/init.h>
  48. +#include <linux/platform_device.h>
  49. +#include <linux/mtd/map.h>
  50. +#include <linux/mtd/mtd.h>
  51. +#include <linux/mtd/physmap.h>
  52. +#include <linux/root_dev.h>
  53. +
  54. +#include <asm/rdc_boards.h>
  55. +
  56. +static struct rdc_platform_data rdcplat_data;
  57. +
  58. +/* LEDS */
  59. +static struct platform_device rdc321x_leds = {
  60. + .name = "leds-gpio",
  61. + .id = -1,
  62. + .dev = {
  63. + .platform_data = &rdcplat_data.led_data,
  64. + }
  65. +};
  66. +
  67. +/* Button */
  68. +static struct platform_device rdc321x_buttons = {
  69. + .name = "gpio-keys-polled",
  70. + .id = -1,
  71. + .dev = {
  72. + .platform_data = &rdcplat_data.button_data,
  73. + }
  74. +};
  75. +
  76. +static __initdata struct platform_device *rdc321x_devs[] = {
  77. + &rdc321x_leds,
  78. + &rdc321x_buttons,
  79. +};
  80. +
  81. +const char *__initdata boards[] = {
  82. + "Sitecom",
  83. + "AR525W",
  84. + "Bifferboard",
  85. + "R8610",
  86. + 0
  87. +};
  88. +
  89. +static struct map_info rdc_map_info = {
  90. + .name = "rdc_flash",
  91. + .size = 0x800000, /* 8MB */
  92. + .phys = 0xFF800000, /* (u32) -rdc_map_info.size */
  93. + .bankwidth = 2,
  94. +};
  95. +
  96. +static int __init rdc_board_setup(void)
  97. +{
  98. + struct mtd_info *mtdinfo;
  99. + struct mtd_part_parser_data *ppdata;
  100. + int res;
  101. +
  102. + simple_map_init(&rdc_map_info);
  103. +
  104. + while (1) {
  105. + rdc_map_info.virt = ioremap(rdc_map_info.phys,
  106. + rdc_map_info.size);
  107. + if (rdc_map_info.virt == NULL)
  108. + continue;
  109. +
  110. + mtdinfo = do_map_probe("cfi_probe", &rdc_map_info);
  111. + if (mtdinfo == NULL)
  112. + mtdinfo = do_map_probe("jedec_probe", &rdc_map_info);
  113. + if (mtdinfo != NULL)
  114. + break;
  115. +
  116. + iounmap(rdc_map_info.virt);
  117. + if ((rdc_map_info.size >>= 1) < 0x100000) /* 1MB */
  118. + panic("RDC321x: Could not find start of flash!");
  119. + rdc_map_info.phys = (u32) -rdc_map_info.size;
  120. + }
  121. +
  122. + /*
  123. + * TODO: add a new field to mtd_part_parser_data, and use that
  124. + * instead of this ugly casting
  125. + */
  126. + ppdata = (struct mtd_part_parser_data *) &rdcplat_data;
  127. + res = mtd_device_parse_register(mtdinfo, boards, ppdata, NULL, 0);
  128. + if (res) {
  129. + panic("RDC321x: can't identify board type");
  130. + return -ENOSYS;
  131. + }
  132. +
  133. + ROOT_DEV = 0;
  134. +
  135. + return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs));
  136. +}
  137. +late_initcall(rdc_board_setup);
  138. --- /dev/null
  139. +++ b/arch/x86/mach-rdc321x/boards/ar525w.c
  140. @@ -0,0 +1,251 @@
  141. +/*
  142. + * ar525w RDC321x platform devices
  143. + *
  144. + * Copyright (C) 2007-2009 OpenWrt.org
  145. + * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
  146. + * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
  147. + *
  148. + * This program is free software; you can redistribute it and/or
  149. + * modify it under the terms of the GNU General Public License
  150. + * as published by the Free Software Foundation; either version 2
  151. + * of the License, or (at your option) any later version.
  152. + *
  153. + * This program is distributed in the hope that it will be useful,
  154. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  155. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  156. + * GNU General Public License for more details.
  157. + *
  158. + * You should have received a copy of the GNU General Public License
  159. + * along with this program; if not, write to the
  160. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  161. + * Boston, MA 02110-1301, USA.
  162. + *
  163. + */
  164. +
  165. +#include <linux/init.h>
  166. +#include <linux/module.h>
  167. +#include <linux/mtd/physmap.h>
  168. +#include <linux/input.h>
  169. +#include <linux/vmalloc.h>
  170. +#include <linux/mtd/mtd.h>
  171. +#include <linux/slab.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_keys_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. + static 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 = mtd_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. + res = mtd_unlock(master, 0, master->erasesize);
  313. + if (res != 0 && res != -EOPNOTSUPP) {
  314. + printk(KERN_ERR "Can't unlock image header\n");
  315. + goto out;
  316. + }
  317. +
  318. + res = erase_write (master, 0, master->erasesize, buffer);
  319. + if (res)
  320. + printk(KERN_ERR "Can't rewrite image header\n");
  321. +
  322. +out:
  323. + vfree(buffer);
  324. + return res;
  325. +}
  326. +
  327. +static int __init
  328. +parse_ar525w_partitions(struct mtd_info *master, struct mtd_partition **pparts,
  329. + struct mtd_part_parser_data *plat_data)
  330. +{
  331. + struct image_header header;
  332. + int res;
  333. + size_t len;
  334. + struct mtd_partition *rdc_flash_parts;
  335. + struct rdc_platform_data *pdata = (struct rdc_platform_data *) plat_data;
  336. +
  337. + if (master->size != 0x400000) //4MB
  338. + return -ENOSYS;
  339. +
  340. + res = mtd_read(master, 0x0, sizeof(header), &len, (char *)&header);
  341. + if (res)
  342. + return res;
  343. +
  344. + if (strncmp(header.magic, "GMTK", 4))
  345. + return -ENOSYS;
  346. +
  347. + if (header.kernelsz > 0x400000 || header.kernelsz < master->erasesize) {
  348. + printk(KERN_ERR "AR525W image header found, but seems corrupt, kernel size %u\n", header.kernelsz);
  349. + return -EINVAL;
  350. + }
  351. +
  352. + if (header.kernelsz + sizeof(header) != header.imagesz) {
  353. + res = fixup_ar525w_header(master, &header);
  354. + if (res)
  355. + return res;
  356. + }
  357. +
  358. + rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 3, GFP_KERNEL);
  359. +
  360. + rdc_flash_parts[0].name = "firmware";
  361. + rdc_flash_parts[0].offset = 0x0;
  362. + rdc_flash_parts[0].size = 0x3E0000;
  363. + rdc_flash_parts[1].name = "rootfs";
  364. + rdc_flash_parts[1].offset = header.kernelsz + sizeof(header);
  365. + rdc_flash_parts[1].size = rdc_flash_parts[0].size - rdc_flash_parts[1].offset;
  366. + rdc_flash_parts[2].name = "bootloader";
  367. + rdc_flash_parts[2].offset = 0x3E0000;
  368. + rdc_flash_parts[2].size = 0x20000;
  369. +
  370. + *pparts = rdc_flash_parts;
  371. +
  372. + pdata->led_data.num_leds = ARRAY_SIZE(ar525w_leds);
  373. + pdata->led_data.leds = ar525w_leds;
  374. + pdata->button_data.nbuttons = ARRAY_SIZE(ar525w_btns);
  375. + pdata->button_data.buttons = ar525w_btns;
  376. +
  377. + return 3;
  378. +}
  379. +
  380. +static struct mtd_part_parser __initdata ar525w_parser = {
  381. + .owner = THIS_MODULE,
  382. + .parse_fn = parse_ar525w_partitions,
  383. + .name = "AR525W",
  384. +};
  385. +
  386. +static int __init ar525w_setup(void)
  387. +{
  388. + return register_mtd_parser(&ar525w_parser);
  389. +}
  390. +
  391. +arch_initcall(ar525w_setup);
  392. --- /dev/null
  393. +++ b/arch/x86/mach-rdc321x/boards/bifferboard.c
  394. @@ -0,0 +1,74 @@
  395. +/*
  396. + * Bifferboard RDC321x platform devices
  397. + *
  398. + * Copyright (C) 2010 bifferos@yahoo.co.uk
  399. + *
  400. + * This program is free software; you can redistribute it and/or
  401. + * modify it under the terms of the GNU General Public License
  402. + * as published by the Free Software Foundation; either version 2
  403. + * of the License, or (at your option) any later version.
  404. + *
  405. + * This program is distributed in the hope that it will be useful,
  406. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  407. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  408. + * GNU General Public License for more details.
  409. + *
  410. + * You should have received a copy of the GNU General Public License
  411. + * along with this program; if not, write to the
  412. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  413. + * Boston, MA 02110-1301, USA.
  414. + *
  415. + */
  416. +
  417. +#include <linux/init.h>
  418. +#include <linux/module.h>
  419. +#include <linux/mtd/physmap.h>
  420. +#include <linux/input.h>
  421. +#include <linux/slab.h>
  422. +
  423. +#include <asm/rdc_boards.h>
  424. +
  425. +static int __init
  426. +parse_bifferboard_partitions(struct mtd_info *master,
  427. + struct mtd_partition **pparts,
  428. + struct mtd_part_parser_data *plat_data)
  429. +{
  430. + int res;
  431. + size_t len;
  432. + struct mtd_partition *rdc_flash_parts;
  433. + u32 kernel_len;
  434. + u16 tmp;
  435. +
  436. + res = mtd_read(master, 0x4000 + 1036, 2, &len, (char *) &tmp);
  437. + if (res)
  438. + return res;
  439. + kernel_len = tmp * master->erasesize;
  440. +
  441. + rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 3, GFP_KERNEL);
  442. +
  443. + *pparts = rdc_flash_parts;
  444. +
  445. + rdc_flash_parts[0].name = "kernel";
  446. + rdc_flash_parts[0].offset = 0;
  447. + rdc_flash_parts[0].size = kernel_len;
  448. + rdc_flash_parts[1].name = "rootfs";
  449. + rdc_flash_parts[1].offset = kernel_len;
  450. + rdc_flash_parts[1].size = master->size - kernel_len - 0x10000;
  451. + rdc_flash_parts[2].name = "biffboot";
  452. + rdc_flash_parts[2].offset = master->size - 0x10000;
  453. + rdc_flash_parts[2].size = 0x10000;
  454. +
  455. + return 3;
  456. +}
  457. +
  458. +struct mtd_part_parser __initdata bifferboard_parser = {
  459. + .owner = THIS_MODULE,
  460. + .parse_fn = parse_bifferboard_partitions,
  461. + .name = "Bifferboard",
  462. +};
  463. +
  464. +static int __init bifferboard_setup(void)
  465. +{
  466. + return register_mtd_parser(&bifferboard_parser);
  467. +}
  468. +arch_initcall(bifferboard_setup);
  469. --- /dev/null
  470. +++ b/arch/x86/mach-rdc321x/boards/r8610.c
  471. @@ -0,0 +1,69 @@
  472. +/*
  473. + * R8610 RDC321x platform devices
  474. + *
  475. + * Copyright (C) 2009, Florian Fainelli <florian@openwrt.org>
  476. + *
  477. + * This program is free software; you can redistribute it and/or
  478. + * modify it under the terms of the GNU General Public License
  479. + * as published by the Free Software Foundation; either version 2
  480. + * of the License, or (at your option) any later version.
  481. + *
  482. + * This program is distributed in the hope that it will be useful,
  483. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  484. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  485. + * GNU General Public License for more details.
  486. + *
  487. + * You should have received a copy of the GNU General Public License
  488. + * along with this program; if not, write to the
  489. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  490. + * Boston, MA 02110-1301, USA.
  491. + *
  492. + */
  493. +
  494. +#include <linux/init.h>
  495. +#include <linux/module.h>
  496. +#include <linux/mtd/physmap.h>
  497. +#include <linux/input.h>
  498. +#include <linux/slab.h>
  499. +
  500. +#include <asm/rdc_boards.h>
  501. +
  502. +static int __init
  503. +parse_r8610_partitions(struct mtd_info *master, struct mtd_partition **pparts,
  504. + struct mtd_part_parser_data *plat_data)
  505. +{
  506. + struct mtd_partition *rdc_flash_parts;
  507. +
  508. + rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 4, GFP_KERNEL);
  509. +
  510. + *pparts = rdc_flash_parts;
  511. +
  512. + rdc_flash_parts[0].name = "kernel";
  513. + rdc_flash_parts[0].size = 0x001f0000;
  514. + rdc_flash_parts[0].offset = 0;
  515. + rdc_flash_parts[1].name = "config";
  516. + rdc_flash_parts[1].size = 0x10000;
  517. + rdc_flash_parts[1].offset = MTDPART_OFS_APPEND;
  518. + rdc_flash_parts[2].name = "rootfs";
  519. + rdc_flash_parts[2].size = 0x1E0000;
  520. + rdc_flash_parts[2].offset = MTDPART_OFS_APPEND;
  521. + rdc_flash_parts[3].name = "redboot";
  522. + rdc_flash_parts[3].size = 0x20000;
  523. + rdc_flash_parts[3].offset = MTDPART_OFS_APPEND;
  524. + rdc_flash_parts[3].mask_flags = MTD_WRITEABLE;
  525. +
  526. + return 4;
  527. +}
  528. +
  529. +struct mtd_part_parser __initdata r8610_parser = {
  530. + .owner = THIS_MODULE,
  531. + .parse_fn = parse_r8610_partitions,
  532. + .name = "R8610",
  533. +};
  534. +
  535. +static int __init r8610_setup(void)
  536. +{
  537. + return register_mtd_parser(&r8610_parser);
  538. +}
  539. +
  540. +arch_initcall(r8610_setup);
  541. --- /dev/null
  542. +++ b/arch/x86/mach-rdc321x/boards/sitecom.c
  543. @@ -0,0 +1,115 @@
  544. +/*
  545. + * Sitecom RDC321x platform devices
  546. + *
  547. + * Copyright (C) 2007-2009 OpenWrt.org
  548. + * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
  549. + * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
  550. + *
  551. + * This program is free software; you can redistribute it and/or
  552. + * modify it under the terms of the GNU General Public License
  553. + * as published by the Free Software Foundation; either version 2
  554. + * of the License, or (at your option) any later version.
  555. + *
  556. + * This program is distributed in the hope that it will be useful,
  557. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  558. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  559. + * GNU General Public License for more details.
  560. + *
  561. + * You should have received a copy of the GNU General Public License
  562. + * along with this program; if not, write to the
  563. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  564. + * Boston, MA 02110-1301, USA.
  565. + *
  566. + */
  567. +
  568. +#include <linux/init.h>
  569. +#include <linux/module.h>
  570. +#include <linux/mtd/physmap.h>
  571. +#include <linux/input.h>
  572. +#include <linux/slab.h>
  573. +
  574. +#include <asm/rdc_boards.h>
  575. +
  576. +struct image_header {
  577. + char magic[4];
  578. + u32 kernel_length;
  579. + u32 ramdisk_length;
  580. + char magic2[4];
  581. + u32 kernel_length2;
  582. +};
  583. +
  584. +static struct gpio_led sitecom_leds[] = {
  585. + { .name = "rdc321x:power", .gpio = 15, .active_low = 1},
  586. + { .name = "rdc321x:usb0", .gpio = 0, .active_low = 1},
  587. + { .name = "rdc321x:usb1", .gpio = 1, .active_low = 1},
  588. +};
  589. +
  590. +static struct gpio_keys_button sitecom_btns[] = {
  591. + {
  592. + .gpio = 6,
  593. + .code = BTN_0,
  594. + .desc = "Reset",
  595. + .active_low = 1,
  596. + }
  597. +};
  598. +
  599. +static int __init
  600. +parse_sitecom_partitions(struct mtd_info *master, struct mtd_partition **pparts,
  601. + struct mtd_part_parser_data *plat_data)
  602. +{
  603. + struct image_header header;
  604. + int res;
  605. + size_t len;
  606. + struct mtd_partition *rdc_flash_parts;
  607. + struct rdc_platform_data *pdata = (struct rdc_platform_data *) plat_data;
  608. +
  609. + if (master->size != 0x400000) /* 4MB */
  610. + return -ENOSYS;
  611. +
  612. + res = mtd_read(master, 0x8000, sizeof(header), &len, (char *)&header);
  613. + if (res)
  614. + return res;
  615. +
  616. + if (strncmp(header.magic, "CSYS", 4) || strncmp(header.magic2, "WRRM", 4))
  617. + return -ENOSYS;
  618. +
  619. + rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 5, GFP_KERNEL);
  620. +
  621. + rdc_flash_parts[0].name = "firmware";
  622. + rdc_flash_parts[0].offset = 0x8000;
  623. + rdc_flash_parts[0].size = 0x3F0000 - 0x8000;
  624. + rdc_flash_parts[1].name = "config";
  625. + rdc_flash_parts[1].offset = 0;
  626. + rdc_flash_parts[1].size = 0x8000;
  627. + rdc_flash_parts[2].name = "kernel";
  628. + rdc_flash_parts[2].offset = 0x8014;
  629. + rdc_flash_parts[2].size = header.kernel_length;
  630. + rdc_flash_parts[3].name = "rootfs";
  631. + rdc_flash_parts[3].offset = 0x8014 + header.kernel_length;
  632. + rdc_flash_parts[3].size = 0x3F0000 - rdc_flash_parts[3].offset;
  633. + rdc_flash_parts[4].name = "bootloader";
  634. + rdc_flash_parts[4].offset = 0x3F0000;
  635. + rdc_flash_parts[4].size = 0x10000;
  636. +
  637. + *pparts = rdc_flash_parts;
  638. +
  639. + pdata->led_data.num_leds = ARRAY_SIZE(sitecom_leds);
  640. + pdata->led_data.leds = sitecom_leds;
  641. + pdata->button_data.nbuttons = ARRAY_SIZE(sitecom_btns);
  642. + pdata->button_data.buttons = sitecom_btns;
  643. +
  644. + return 5;
  645. +}
  646. +
  647. +struct mtd_part_parser __initdata sitecom_parser = {
  648. + .owner = THIS_MODULE,
  649. + .parse_fn = parse_sitecom_partitions,
  650. + .name = "Sitecom",
  651. +};
  652. +
  653. +static int __init sitecom_setup(void)
  654. +{
  655. + return register_mtd_parser(&sitecom_parser);
  656. +}
  657. +
  658. +arch_initcall(sitecom_setup);
  659. --- /dev/null
  660. +++ b/arch/x86/mach-rdc321x/reboot.c
  661. @@ -0,0 +1,44 @@
  662. +/*
  663. + * This program is free software; you can redistribute it and/or
  664. + * modify it under the terms of the GNU General Public License
  665. + * as published by the Free Software Foundation; either version 2
  666. + * of the License, or (at your option) any later version.
  667. + *
  668. + * This program is distributed in the hope that it will be useful,
  669. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  670. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  671. + * GNU General Public License for more details.
  672. + *
  673. + * You should have received a copy of the GNU General Public License
  674. + * along with this program; if not, write to the
  675. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  676. + * Boston, MA 02110-1301, USA.
  677. + *
  678. + */
  679. +
  680. +#include <asm/reboot.h>
  681. +#include <asm/io.h>
  682. +
  683. +static void rdc321x_reset(void)
  684. +{
  685. + unsigned i;
  686. +
  687. + /* write to southbridge config register 0x41
  688. + enable pci reset on cpu reset, make internal port 0x92 writeable
  689. + and switch port 0x92 to internal */
  690. + outl(0x80003840, 0xCF8);
  691. + i = inl(0xCFC);
  692. + i |= 0x1600;
  693. + outl(i, 0xCFC);
  694. +
  695. + /* soft reset */
  696. + outb(1, 0x92);
  697. +}
  698. +
  699. +static int __init rdc_setup_reset(void)
  700. +{
  701. + machine_ops.emergency_restart = rdc321x_reset;
  702. + return 0;
  703. +}
  704. +
  705. +arch_initcall(rdc_setup_reset);
  706. --- /dev/null
  707. +++ b/arch/x86/include/asm/rdc_boards.h
  708. @@ -0,0 +1,36 @@
  709. +/*
  710. + * RDC321x boards
  711. + *
  712. + * Copyright (C) 2007-2009 OpenWrt.org
  713. + * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
  714. + * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
  715. + *
  716. + * This program is free software; you can redistribute it and/or
  717. + * modify it under the terms of the GNU General Public License
  718. + * as published by the Free Software Foundation; either version 2
  719. + * of the License, or (at your option) any later version.
  720. + *
  721. + * This program is distributed in the hope that it will be useful,
  722. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  723. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  724. + * GNU General Public License for more details.
  725. + *
  726. + * You should have received a copy of the GNU General Public License
  727. + * along with this program; if not, write to the
  728. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  729. + * Boston, MA 02110-1301, USA.
  730. + *
  731. + */
  732. +
  733. +#ifndef _RDC_BOARDS_H__
  734. +#define _RDC_BOARDS_H__
  735. +
  736. +#include <linux/leds.h>
  737. +#include <linux/gpio_keys.h>
  738. +
  739. +struct rdc_platform_data {
  740. + struct gpio_led_platform_data led_data;
  741. + struct gpio_keys_platform_data button_data;
  742. +};
  743. +
  744. +#endif