0032-mpc85xx-move-newly-created-files-from-patch-files-to-files-directory.patch 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Thu, 30 Apr 2015 03:21:01 +0200
  3. Subject: mpc85xx: move newly created files from patch files to files directory
  4. This will make these files much more maintainable.
  5. diff --git a/target/linux/mpc85xx/files/arch/powerpc/boot/cuboot-tl-wdr4900-v1.c b/target/linux/mpc85xx/files/arch/powerpc/boot/cuboot-tl-wdr4900-v1.c
  6. new file mode 100644
  7. index 0000000..17459ef
  8. --- /dev/null
  9. +++ b/target/linux/mpc85xx/files/arch/powerpc/boot/cuboot-tl-wdr4900-v1.c
  10. @@ -0,0 +1,168 @@
  11. +/*
  12. + * U-Boot compatibility wrapper for the TP-Link TL-WDR4900 v1 board
  13. + *
  14. + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
  15. + *
  16. + * Based on:
  17. + * cuboot-85xx.c
  18. + * Author: Scott Wood <scottwood@freescale.com>
  19. + * Copyright (c) 2007 Freescale Semiconductor, Inc.
  20. + *
  21. + * simpleboot.c
  22. + * Authors: Scott Wood <scottwood@freescale.com>
  23. + * Grant Likely <grant.likely@secretlab.ca>
  24. + * Copyright (c) 2007 Freescale Semiconductor, Inc.
  25. + * Copyright (c) 2008 Secret Lab Technologies Ltd.
  26. + *
  27. + * This program is free software; you can redistribute it and/or modify it
  28. + * under the terms of the GNU General Public License version 2 as published
  29. + * by the Free Software Foundation.
  30. + */
  31. +
  32. +#include "ops.h"
  33. +#include "types.h"
  34. +#include "io.h"
  35. +#include "stdio.h"
  36. +#include <libfdt.h>
  37. +
  38. +BSS_STACK(4*1024);
  39. +
  40. +static unsigned long bus_freq;
  41. +static unsigned long int_freq;
  42. +static u64 mem_size;
  43. +static unsigned char enetaddr[6];
  44. +
  45. +static void process_boot_dtb(void *boot_dtb)
  46. +{
  47. + const u32 *na, *ns, *reg, *val32;
  48. + const char *path;
  49. + u64 memsize64;
  50. + int node, size, i;
  51. +
  52. + /* Make sure FDT blob is sane */
  53. + if (fdt_check_header(boot_dtb) != 0)
  54. + fatal("Invalid device tree blob\n");
  55. +
  56. + /* Find the #address-cells and #size-cells properties */
  57. + node = fdt_path_offset(boot_dtb, "/");
  58. + if (node < 0)
  59. + fatal("Cannot find root node\n");
  60. + na = fdt_getprop(boot_dtb, node, "#address-cells", &size);
  61. + if (!na || (size != 4))
  62. + fatal("Cannot find #address-cells property");
  63. +
  64. + ns = fdt_getprop(boot_dtb, node, "#size-cells", &size);
  65. + if (!ns || (size != 4))
  66. + fatal("Cannot find #size-cells property");
  67. +
  68. + /* Find the memory range */
  69. + node = fdt_node_offset_by_prop_value(boot_dtb, -1, "device_type",
  70. + "memory", sizeof("memory"));
  71. + if (node < 0)
  72. + fatal("Cannot find memory node\n");
  73. + reg = fdt_getprop(boot_dtb, node, "reg", &size);
  74. + if (size < (*na+*ns) * sizeof(u32))
  75. + fatal("cannot get memory range\n");
  76. +
  77. + /* Only interested in memory based at 0 */
  78. + for (i = 0; i < *na; i++)
  79. + if (*reg++ != 0)
  80. + fatal("Memory range is not based at address 0\n");
  81. +
  82. + /* get the memsize and trucate it to under 4G on 32 bit machines */
  83. + memsize64 = 0;
  84. + for (i = 0; i < *ns; i++)
  85. + memsize64 = (memsize64 << 32) | *reg++;
  86. + if (sizeof(void *) == 4 && memsize64 >= 0x100000000ULL)
  87. + memsize64 = 0xffffffff;
  88. +
  89. + mem_size = memsize64;
  90. +
  91. + /* get clock frequencies */
  92. + node = fdt_node_offset_by_prop_value(boot_dtb, -1, "device_type",
  93. + "cpu", sizeof("cpu"));
  94. + if (!node)
  95. + fatal("Cannot find cpu node\n");
  96. +
  97. + val32 = fdt_getprop(boot_dtb, node, "clock-frequency", &size);
  98. + if (!val32 || (size != 4))
  99. + fatal("Cannot get clock frequency");
  100. +
  101. + int_freq = *val32;
  102. +
  103. + val32 = fdt_getprop(boot_dtb, node, "bus-frequency", &size);
  104. + if (!val32 || (size != 4))
  105. + fatal("Cannot get bus frequency");
  106. +
  107. + bus_freq = *val32;
  108. +
  109. + path = fdt_get_alias(boot_dtb, "ethernet0");
  110. + if (path) {
  111. + const void *p;
  112. +
  113. + node = fdt_path_offset(boot_dtb, path);
  114. + if (node < 0)
  115. + fatal("Cannot find ethernet0 node");
  116. +
  117. + p = fdt_getprop(boot_dtb, node, "mac-address", &size);
  118. + if (!p || (size < 6)) {
  119. + printf("no mac-address property, finding local\n\r");
  120. + p = fdt_getprop(boot_dtb, node, "local-mac-address", &size);
  121. + }
  122. +
  123. + if (!p || (size < 6))
  124. + fatal("cannot get MAC addres");
  125. +
  126. + memcpy(enetaddr, p, sizeof(enetaddr));
  127. + }
  128. +}
  129. +
  130. +static void platform_fixups(void)
  131. +{
  132. + void *soc, *mpic;
  133. +
  134. + dt_fixup_memory(0, mem_size);
  135. +
  136. + dt_fixup_mac_address_by_alias("ethernet0", enetaddr);
  137. + dt_fixup_cpu_clocks(int_freq, bus_freq / 8, bus_freq);
  138. +
  139. + /* Unfortunately, the specific model number is encoded in the
  140. + * soc node name in existing dts files -- once that is fixed,
  141. + * this can do a simple path lookup.
  142. + */
  143. + soc = find_node_by_devtype(NULL, "soc");
  144. + if (soc) {
  145. + void *serial = NULL;
  146. +
  147. + setprop(soc, "bus-frequency", &bus_freq, sizeof(bus_freq));
  148. +
  149. + while ((serial = find_node_by_devtype(serial, "serial"))) {
  150. + if (get_parent(serial) != soc)
  151. + continue;
  152. +
  153. + setprop(serial, "clock-frequency", &bus_freq,
  154. + sizeof(bus_freq));
  155. + }
  156. + }
  157. +
  158. + mpic = find_node_by_compatible(NULL, "fsl,mpic");
  159. + if (mpic)
  160. + setprop(mpic, "clock-frequency", &bus_freq, sizeof(bus_freq));
  161. +}
  162. +
  163. +void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  164. + unsigned long r6, unsigned long r7)
  165. +{
  166. + mem_size = 64 * 1024 * 1024;
  167. +
  168. + simple_alloc_init(_end, mem_size - (u32)_end - 1024*1024, 32, 64);
  169. +
  170. + fdt_init(_dtb_start);
  171. + serial_console_init();
  172. +
  173. + printf("\n\r-- TL-WDR4900 v1 boot wrapper --\n\r");
  174. +
  175. + process_boot_dtb((void *) r3);
  176. +
  177. + platform_ops.fixups = platform_fixups;
  178. +}
  179. diff --git a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts
  180. new file mode 100644
  181. index 0000000..49e516c
  182. --- /dev/null
  183. +++ b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts
  184. @@ -0,0 +1,212 @@
  185. +/*
  186. + * TP-Link TL-WDR4900 v1 Device Tree Source
  187. + *
  188. + * Copyright 2013 Gabor Juhos <juhosg@openwrt.org>
  189. + *
  190. + * This program is free software; you can redistribute it and/or modify it
  191. + * under the terms of the GNU General Public License as published by the
  192. + * Free Software Foundation; either version 2 of the License, or (at your
  193. + * option) any later version.
  194. + */
  195. +
  196. +/include/ "fsl/p1010si-pre.dtsi"
  197. +
  198. +/ {
  199. + model = "TP-Link TL-WDR4900 v1";
  200. + compatible = "tp-link,TL-WDR4900v1";
  201. +
  202. + chosen {
  203. + bootargs = "console=ttyS0,115200";
  204. +/*
  205. + linux,stdout-path = "/soc@ffe00000/serial@4500";
  206. +*/
  207. + };
  208. +
  209. + aliases {
  210. + spi0 = &spi0;
  211. + };
  212. +
  213. + memory {
  214. + device_type = "memory";
  215. + };
  216. +
  217. + soc: soc@ffe00000 {
  218. + ranges = <0x0 0x0 0xffe00000 0x100000>;
  219. +
  220. + spi0: spi@7000 {
  221. + flash@0 {
  222. + #address-cells = <1>;
  223. + #size-cells = <1>;
  224. + compatible = "spansion,s25fl129p1";
  225. + reg = <0>;
  226. + spi-max-frequency = <25000000>;
  227. +
  228. + u-boot@0 {
  229. + reg = <0x0 0x0050000>;
  230. + label = "u-boot";
  231. + read-only;
  232. + };
  233. +
  234. + dtb@50000 {
  235. + reg = <0x00050000 0x00010000>;
  236. + label = "dtb";
  237. + read-only;
  238. + };
  239. +
  240. + kernel@60000 {
  241. + reg = <0x00060000 0x002a0000>;
  242. + label = "kernel";
  243. + };
  244. +
  245. + rootfs@300000 {
  246. + reg = <0x00300000 0x00ce0000>;
  247. + label = "rootfs";
  248. + };
  249. +
  250. + config@fe0000 {
  251. + reg = <0x00fe0000 0x00010000>;
  252. + label = "config";
  253. + read-only;
  254. + };
  255. +
  256. + caldata@ff0000 {
  257. + reg = <0x00ff0000 0x00010000>;
  258. + label = "caldata";
  259. + read-only;
  260. + };
  261. +
  262. + firmware@60000 {
  263. + reg = <0x00060000 0x00f80000>;
  264. + label = "firmware";
  265. + };
  266. + };
  267. + };
  268. +
  269. + gpio0: gpio-controller@f000 {
  270. + };
  271. +
  272. + usb@22000 {
  273. + phy_type = "utmi";
  274. + dr_mode = "host";
  275. + };
  276. +
  277. + mdio@24000 {
  278. + phy0: ethernet-phy@0 {
  279. + reg = <0x0>;
  280. + qca,ar8327-initvals = <
  281. + 0x00004 0x07600000 /* PAD0_MODE */
  282. + 0x00008 0x00000000 /* PAD5_MODE */
  283. + 0x0000c 0x01000000 /* PAD6_MODE */
  284. + 0x00010 0x40000000 /* POWER_ON_STRIP */
  285. + 0x00050 0xcf35cf35 /* LED_CTRL0 */
  286. + 0x00054 0xcf35cf35 /* LED_CTRL1 */
  287. + 0x00058 0xcf35cf35 /* LED_CTRL2 */
  288. + 0x0005c 0x03ffff00 /* LED_CTRL3 */
  289. + 0x0007c 0x0000007e /* PORT0_STATUS */
  290. + >;
  291. + };
  292. + };
  293. +
  294. + mdio@25000 {
  295. + status = "disabled";
  296. + };
  297. +
  298. + mdio@26000 {
  299. + status = "disabled";
  300. + };
  301. +
  302. + enet0: ethernet@b0000 {
  303. + phy-handle = <&phy0>;
  304. + phy-connection-type = "rgmii-id";
  305. + };
  306. +
  307. + enet1: ethernet@b1000 {
  308. + status = "disabled";
  309. + };
  310. +
  311. + enet2: ethernet@b2000 {
  312. + status = "disabled";
  313. + };
  314. +
  315. + sdhc@2e000 {
  316. + status = "disabled";
  317. + };
  318. +
  319. + serial1: serial@4600 {
  320. + status = "disabled";
  321. + };
  322. +
  323. + can0: can@1c000 {
  324. + status = "disabled";
  325. + };
  326. +
  327. + can1: can@1d000 {
  328. + status = "disabled";
  329. + };
  330. + };
  331. +
  332. + pci0: pcie@ffe09000 {
  333. + reg = <0 0xffe09000 0 0x1000>;
  334. + ranges = <0x2000000 0x0 0xa0000000 0 0xa0000000 0x0 0x20000000
  335. + 0x1000000 0x0 0x00000000 0 0xffc10000 0x0 0x10000>;
  336. + pcie@0 {
  337. + ranges = <0x2000000 0x0 0xa0000000
  338. + 0x2000000 0x0 0xa0000000
  339. + 0x0 0x20000000
  340. +
  341. + 0x1000000 0x0 0x0
  342. + 0x1000000 0x0 0x0
  343. + 0x0 0x100000>;
  344. + };
  345. + };
  346. +
  347. + pci1: pcie@ffe0a000 {
  348. + reg = <0 0xffe0a000 0 0x1000>;
  349. + ranges = <0x2000000 0x0 0x80000000 0 0x80000000 0x0 0x20000000
  350. + 0x1000000 0x0 0x00000000 0 0xffc00000 0x0 0x10000>;
  351. + pcie@0 {
  352. + ranges = <0x2000000 0x0 0x80000000
  353. + 0x2000000 0x0 0x80000000
  354. + 0x0 0x20000000
  355. +
  356. + 0x1000000 0x0 0x0
  357. + 0x1000000 0x0 0x0
  358. + 0x0 0x100000>;
  359. + };
  360. + };
  361. +
  362. + ifc: ifc@ffe1e000 {
  363. + status = "disabled";
  364. + };
  365. +
  366. + leds {
  367. + compatible = "gpio-leds";
  368. +
  369. + system {
  370. + gpios = <&gpio0 2 1>; /* active low */
  371. + label = "tp-link:blue:system";
  372. + };
  373. +
  374. + usb1 {
  375. + gpios = <&gpio0 3 1>; /* active low */
  376. + label = "tp-link:green:usb1";
  377. + };
  378. +
  379. + usb2 {
  380. + gpios = <&gpio0 4 1>; /* active low */
  381. + label = "tp-link:green:usb2";
  382. + };
  383. + };
  384. +
  385. + buttons {
  386. + compatible = "gpio-keys";
  387. +
  388. + reset {
  389. + label = "Reset button";
  390. + gpios = <&gpio0 5 1>; /* active low */
  391. + linux,code = <0x198>; /* KEY_RESTART */
  392. + };
  393. + };
  394. +};
  395. +
  396. +/include/ "fsl/p1010si-post.dtsi"
  397. diff --git a/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/tl_wdr4900_v1.c b/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/tl_wdr4900_v1.c
  398. new file mode 100644
  399. index 0000000..95afa4d
  400. --- /dev/null
  401. +++ b/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/tl_wdr4900_v1.c
  402. @@ -0,0 +1,145 @@
  403. +/*
  404. + * TL-WDR4900 v1 board setup
  405. + *
  406. + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
  407. + *
  408. + * Based on:
  409. + * p1010rdb.c:
  410. + * P1010RDB Board Setup
  411. + * Copyright 2011 Freescale Semiconductor Inc.
  412. + *
  413. + * This program is free software; you can redistribute it and/or modify it
  414. + * under the terms of the GNU General Public License as published by the
  415. + * Free Software Foundation; either version 2 of the License, or (at your
  416. + * option) any later version.
  417. + */
  418. +
  419. +#include <linux/stddef.h>
  420. +#include <linux/kernel.h>
  421. +#include <linux/pci.h>
  422. +#include <linux/delay.h>
  423. +#include <linux/interrupt.h>
  424. +#include <linux/of_platform.h>
  425. +#include <linux/ath9k_platform.h>
  426. +#include <linux/leds.h>
  427. +
  428. +#include <asm/time.h>
  429. +#include <asm/machdep.h>
  430. +#include <asm/pci-bridge.h>
  431. +#include <mm/mmu_decl.h>
  432. +#include <asm/prom.h>
  433. +#include <asm/udbg.h>
  434. +#include <asm/mpic.h>
  435. +
  436. +#include <sysdev/fsl_soc.h>
  437. +#include <sysdev/fsl_pci.h>
  438. +
  439. +#include "mpc85xx.h"
  440. +
  441. +void __init tl_wdr4900_v1_pic_init(void)
  442. +{
  443. + struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
  444. + MPIC_SINGLE_DEST_CPU,
  445. + 0, 256, " OpenPIC ");
  446. +
  447. + BUG_ON(mpic == NULL);
  448. +
  449. + mpic_init(mpic);
  450. +}
  451. +
  452. +#ifdef CONFIG_PCI
  453. +static struct gpio_led tl_wdr4900_v1_wmac_leds_gpio[] = {
  454. + {
  455. + .name = "tp-link:blue:wps",
  456. + .gpio = 1,
  457. + .active_low = 1,
  458. + },
  459. +};
  460. +
  461. +static struct ath9k_platform_data tl_wdr4900_v1_wmac0_data = {
  462. + .led_pin = 0,
  463. + .eeprom_name = "pci_wmac0.eeprom",
  464. + .leds = tl_wdr4900_v1_wmac_leds_gpio,
  465. + .num_leds = ARRAY_SIZE(tl_wdr4900_v1_wmac_leds_gpio),
  466. +};
  467. +
  468. +static struct ath9k_platform_data tl_wdr4900_v1_wmac1_data = {
  469. + .led_pin = 0,
  470. + .eeprom_name = "pci_wmac1.eeprom",
  471. +};
  472. +
  473. +static void tl_wdr4900_v1_pci_wmac_fixup(struct pci_dev *dev)
  474. +{
  475. + if (!machine_is(tl_wdr4900_v1))
  476. + return;
  477. +
  478. + if (dev->bus->number == 1 &&
  479. + PCI_SLOT(dev->devfn) == 0) {
  480. + dev->dev.platform_data = &tl_wdr4900_v1_wmac0_data;
  481. + return;
  482. + }
  483. +
  484. + if (dev->bus->number == 3 &&
  485. + PCI_SLOT(dev->devfn) == 0 &&
  486. + dev->device == 0xabcd) {
  487. + dev->dev.platform_data = &tl_wdr4900_v1_wmac1_data;
  488. +
  489. + /*
  490. + * The PCI header of the AR9381 chip is not programmed
  491. + * correctly by the bootloader and the device uses wrong
  492. + * data due to that. Replace the broken values with the
  493. + * correct ones.
  494. + */
  495. + dev->device = 0x30;
  496. + dev->class = 0x028000;
  497. +
  498. + pr_info("pci %s: AR9381 fixup applied\n", pci_name(dev));
  499. + }
  500. +}
  501. +
  502. +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID,
  503. + tl_wdr4900_v1_pci_wmac_fixup);
  504. +#endif /* CONFIG_PCI */
  505. +
  506. +/*
  507. + * Setup the architecture
  508. + */
  509. +static void __init tl_wdr4900_v1_setup_arch(void)
  510. +{
  511. + if (ppc_md.progress)
  512. + ppc_md.progress("tl_wdr4900_v1_setup_arch()", 0);
  513. +
  514. + fsl_pci_assign_primary();
  515. +
  516. + printk(KERN_INFO "TL-WDR4900 v1 board from TP-Link\n");
  517. +}
  518. +
  519. +machine_arch_initcall(tl_wdr4900_v1, mpc85xx_common_publish_devices);
  520. +machine_arch_initcall(tl_wdr4900_v1, swiotlb_setup_bus_notifier);
  521. +
  522. +/*
  523. + * Called very early, device-tree isn't unflattened
  524. + */
  525. +static int __init tl_wdr4900_v1_probe(void)
  526. +{
  527. + unsigned long root = of_get_flat_dt_root();
  528. +
  529. + if (of_flat_dt_is_compatible(root, "tp-link,TL-WDR4900v1"))
  530. + return 1;
  531. +
  532. + return 0;
  533. +}
  534. +
  535. +define_machine(tl_wdr4900_v1) {
  536. + .name = "Freescale P1014",
  537. + .probe = tl_wdr4900_v1_probe,
  538. + .setup_arch = tl_wdr4900_v1_setup_arch,
  539. + .init_IRQ = tl_wdr4900_v1_pic_init,
  540. +#ifdef CONFIG_PCI
  541. + .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  542. +#endif
  543. + .get_irq = mpic_get_irq,
  544. + .restart = fsl_rstcr_restart,
  545. + .calibrate_decr = generic_calibrate_decr,
  546. + .progress = udbg_progress,
  547. +};
  548. diff --git a/target/linux/mpc85xx/patches-3.10/140-powerpc-85xx-tl-wdr4900-v1-support.patch b/target/linux/mpc85xx/patches-3.10/140-powerpc-85xx-tl-wdr4900-v1-support.patch
  549. index 8407176..dae2305 100644
  550. --- a/target/linux/mpc85xx/patches-3.10/140-powerpc-85xx-tl-wdr4900-v1-support.patch
  551. +++ b/target/linux/mpc85xx/patches-3.10/140-powerpc-85xx-tl-wdr4900-v1-support.patch
  552. @@ -11,16 +11,9 @@ the Freescale P1014 SoC.
  553. Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
  554. ---
  555. arch/powerpc/boot/Makefile | 3 +
  556. - arch/powerpc/boot/cuboot-tl-wdr4900-v1.c | 164 ++++++++++++++++++++++++++
  557. - arch/powerpc/boot/dts/tl-wdr4900-v1.dts | 166 +++++++++++++++++++++++++++
  558. arch/powerpc/boot/wrapper | 4 +
  559. arch/powerpc/platforms/85xx/Kconfig | 11 ++
  560. arch/powerpc/platforms/85xx/Makefile | 1 +
  561. - arch/powerpc/platforms/85xx/tl_wdr4900_v1.c | 145 +++++++++++++++++++++++
  562. - 7 files changed, 494 insertions(+)
  563. - create mode 100644 arch/powerpc/boot/cuboot-tl-wdr4900-v1.c
  564. - create mode 100644 arch/powerpc/boot/dts/tl-wdr4900-v1.dts
  565. - create mode 100644 arch/powerpc/platforms/85xx/tl_wdr4900_v1.c
  566. --- a/arch/powerpc/boot/Makefile
  567. +++ b/arch/powerpc/boot/Makefile
  568. @@ -41,388 +34,6 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
  569. # Board ports in arch/powerpc/platform/embedded6xx/Kconfig
  570. image-$(CONFIG_STORCENTER) += cuImage.storcenter
  571. ---- /dev/null
  572. -+++ b/arch/powerpc/boot/cuboot-tl-wdr4900-v1.c
  573. -@@ -0,0 +1,164 @@
  574. -+/*
  575. -+ * U-Boot compatibility wrapper for the TP-Link TL-WDR4900 v1 board
  576. -+ *
  577. -+ * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
  578. -+ *
  579. -+ * Based on:
  580. -+ * cuboot-85xx.c
  581. -+ * Author: Scott Wood <scottwood@freescale.com>
  582. -+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
  583. -+ *
  584. -+ * simpleboot.c
  585. -+ * Authors: Scott Wood <scottwood@freescale.com>
  586. -+ * Grant Likely <grant.likely@secretlab.ca>
  587. -+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
  588. -+ * Copyright (c) 2008 Secret Lab Technologies Ltd.
  589. -+ *
  590. -+ * This program is free software; you can redistribute it and/or modify it
  591. -+ * under the terms of the GNU General Public License version 2 as published
  592. -+ * by the Free Software Foundation.
  593. -+ */
  594. -+
  595. -+#include "ops.h"
  596. -+#include "types.h"
  597. -+#include "io.h"
  598. -+#include "stdio.h"
  599. -+#include <libfdt.h>
  600. -+
  601. -+BSS_STACK(4*1024);
  602. -+
  603. -+static unsigned long bus_freq;
  604. -+static unsigned long int_freq;
  605. -+static u64 mem_size;
  606. -+static unsigned char enetaddr[6];
  607. -+
  608. -+static void process_boot_dtb(void *boot_dtb)
  609. -+{
  610. -+ const u32 *na, *ns, *reg, *val32;
  611. -+ const char *path;
  612. -+ u64 memsize64;
  613. -+ int node, size, i;
  614. -+
  615. -+ /* Make sure FDT blob is sane */
  616. -+ if (fdt_check_header(boot_dtb) != 0)
  617. -+ fatal("Invalid device tree blob\n");
  618. -+
  619. -+ /* Find the #address-cells and #size-cells properties */
  620. -+ node = fdt_path_offset(boot_dtb, "/");
  621. -+ if (node < 0)
  622. -+ fatal("Cannot find root node\n");
  623. -+ na = fdt_getprop(boot_dtb, node, "#address-cells", &size);
  624. -+ if (!na || (size != 4))
  625. -+ fatal("Cannot find #address-cells property");
  626. -+
  627. -+ ns = fdt_getprop(boot_dtb, node, "#size-cells", &size);
  628. -+ if (!ns || (size != 4))
  629. -+ fatal("Cannot find #size-cells property");
  630. -+
  631. -+ /* Find the memory range */
  632. -+ node = fdt_node_offset_by_prop_value(boot_dtb, -1, "device_type",
  633. -+ "memory", sizeof("memory"));
  634. -+ if (node < 0)
  635. -+ fatal("Cannot find memory node\n");
  636. -+ reg = fdt_getprop(boot_dtb, node, "reg", &size);
  637. -+ if (size < (*na+*ns) * sizeof(u32))
  638. -+ fatal("cannot get memory range\n");
  639. -+
  640. -+ /* Only interested in memory based at 0 */
  641. -+ for (i = 0; i < *na; i++)
  642. -+ if (*reg++ != 0)
  643. -+ fatal("Memory range is not based at address 0\n");
  644. -+
  645. -+ /* get the memsize and trucate it to under 4G on 32 bit machines */
  646. -+ memsize64 = 0;
  647. -+ for (i = 0; i < *ns; i++)
  648. -+ memsize64 = (memsize64 << 32) | *reg++;
  649. -+ if (sizeof(void *) == 4 && memsize64 >= 0x100000000ULL)
  650. -+ memsize64 = 0xffffffff;
  651. -+
  652. -+ mem_size = memsize64;
  653. -+
  654. -+ /* get clock frequencies */
  655. -+ node = fdt_node_offset_by_prop_value(boot_dtb, -1, "device_type",
  656. -+ "cpu", sizeof("cpu"));
  657. -+ if (!node)
  658. -+ fatal("Cannot find cpu node\n");
  659. -+
  660. -+ val32 = fdt_getprop(boot_dtb, node, "clock-frequency", &size);
  661. -+ if (!val32 || (size != 4))
  662. -+ fatal("Cannot get clock frequency");
  663. -+
  664. -+ int_freq = *val32;
  665. -+
  666. -+ val32 = fdt_getprop(boot_dtb, node, "bus-frequency", &size);
  667. -+ if (!val32 || (size != 4))
  668. -+ fatal("Cannot get bus frequency");
  669. -+
  670. -+ bus_freq = *val32;
  671. -+
  672. -+ path = fdt_get_alias(boot_dtb, "ethernet0");
  673. -+ if (path) {
  674. -+ const void *p;
  675. -+
  676. -+ node = fdt_path_offset(boot_dtb, path);
  677. -+ if (node < 0)
  678. -+ fatal("Cannot find ethernet0 node");
  679. -+
  680. -+ p = fdt_getprop(boot_dtb, node, "mac-address", &size);
  681. -+ if (!p || (size < 6)) {
  682. -+ printf("no mac-address property, finding local\n\r");
  683. -+ p = fdt_getprop(boot_dtb, node, "local-mac-address", &size);
  684. -+ }
  685. -+
  686. -+ if (!p || (size < 6))
  687. -+ fatal("cannot get MAC addres");
  688. -+
  689. -+ memcpy(enetaddr, p, sizeof(enetaddr));
  690. -+ }
  691. -+}
  692. -+
  693. -+static void platform_fixups(void)
  694. -+{
  695. -+ void *soc;
  696. -+
  697. -+ dt_fixup_memory(0, mem_size);
  698. -+
  699. -+ dt_fixup_mac_address_by_alias("ethernet0", enetaddr);
  700. -+ dt_fixup_cpu_clocks(int_freq, bus_freq / 8, bus_freq);
  701. -+
  702. -+ /* Unfortunately, the specific model number is encoded in the
  703. -+ * soc node name in existing dts files -- once that is fixed,
  704. -+ * this can do a simple path lookup.
  705. -+ */
  706. -+ soc = find_node_by_devtype(NULL, "soc");
  707. -+ if (soc) {
  708. -+ void *serial = NULL;
  709. -+
  710. -+ setprop(soc, "bus-frequency", &bus_freq, sizeof(bus_freq));
  711. -+
  712. -+ while ((serial = find_node_by_devtype(serial, "serial"))) {
  713. -+ if (get_parent(serial) != soc)
  714. -+ continue;
  715. -+
  716. -+ setprop(serial, "clock-frequency", &bus_freq,
  717. -+ sizeof(bus_freq));
  718. -+ }
  719. -+ }
  720. -+}
  721. -+
  722. -+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  723. -+ unsigned long r6, unsigned long r7)
  724. -+{
  725. -+ mem_size = 64 * 1024 * 1024;
  726. -+
  727. -+ simple_alloc_init(_end, mem_size - (u32)_end - 1024*1024, 32, 64);
  728. -+
  729. -+ fdt_init(_dtb_start);
  730. -+ serial_console_init();
  731. -+
  732. -+ printf("\n\r-- TL-WDR4900 v1 boot wrapper --\n\r");
  733. -+
  734. -+ process_boot_dtb((void *) r3);
  735. -+
  736. -+ platform_ops.fixups = platform_fixups;
  737. -+}
  738. ---- /dev/null
  739. -+++ b/arch/powerpc/boot/dts/tl-wdr4900-v1.dts
  740. -@@ -0,0 +1,212 @@
  741. -+/*
  742. -+ * TP-Link TL-WDR4900 v1 Device Tree Source
  743. -+ *
  744. -+ * Copyright 2013 Gabor Juhos <juhosg@openwrt.org>
  745. -+ *
  746. -+ * This program is free software; you can redistribute it and/or modify it
  747. -+ * under the terms of the GNU General Public License as published by the
  748. -+ * Free Software Foundation; either version 2 of the License, or (at your
  749. -+ * option) any later version.
  750. -+ */
  751. -+
  752. -+/include/ "fsl/p1010si-pre.dtsi"
  753. -+
  754. -+/ {
  755. -+ model = "TP-Link TL-WDR4900 v1";
  756. -+ compatible = "tp-link,TL-WDR4900v1";
  757. -+
  758. -+ chosen {
  759. -+ bootargs = "console=ttyS0,115200";
  760. -+/*
  761. -+ linux,stdout-path = "/soc@ffe00000/serial@4500";
  762. -+*/
  763. -+ };
  764. -+
  765. -+ aliases {
  766. -+ spi0 = &spi0;
  767. -+ };
  768. -+
  769. -+ memory {
  770. -+ device_type = "memory";
  771. -+ };
  772. -+
  773. -+ soc: soc@ffe00000 {
  774. -+ ranges = <0x0 0x0 0xffe00000 0x100000>;
  775. -+
  776. -+ spi0: spi@7000 {
  777. -+ flash@0 {
  778. -+ #address-cells = <1>;
  779. -+ #size-cells = <1>;
  780. -+ compatible = "spansion,s25fl129p1";
  781. -+ reg = <0>;
  782. -+ spi-max-frequency = <25000000>;
  783. -+
  784. -+ u-boot@0 {
  785. -+ reg = <0x0 0x0050000>;
  786. -+ label = "u-boot";
  787. -+ read-only;
  788. -+ };
  789. -+
  790. -+ dtb@50000 {
  791. -+ reg = <0x00050000 0x00010000>;
  792. -+ label = "dtb";
  793. -+ read-only;
  794. -+ };
  795. -+
  796. -+ kernel@60000 {
  797. -+ reg = <0x00060000 0x002a0000>;
  798. -+ label = "kernel";
  799. -+ };
  800. -+
  801. -+ rootfs@300000 {
  802. -+ reg = <0x00300000 0x00ce0000>;
  803. -+ label = "rootfs";
  804. -+ };
  805. -+
  806. -+ config@fe0000 {
  807. -+ reg = <0x00fe0000 0x00010000>;
  808. -+ label = "config";
  809. -+ read-only;
  810. -+ };
  811. -+
  812. -+ caldata@ff0000 {
  813. -+ reg = <0x00ff0000 0x00010000>;
  814. -+ label = "caldata";
  815. -+ read-only;
  816. -+ };
  817. -+
  818. -+ firmware@60000 {
  819. -+ reg = <0x00060000 0x00f80000>;
  820. -+ label = "firmware";
  821. -+ };
  822. -+ };
  823. -+ };
  824. -+
  825. -+ gpio0: gpio-controller@f000 {
  826. -+ };
  827. -+
  828. -+ usb@22000 {
  829. -+ phy_type = "utmi";
  830. -+ dr_mode = "host";
  831. -+ };
  832. -+
  833. -+ mdio@24000 {
  834. -+ phy0: ethernet-phy@0 {
  835. -+ reg = <0x0>;
  836. -+ qca,ar8327-initvals = <
  837. -+ 0x00004 0x07600000 /* PAD0_MODE */
  838. -+ 0x00008 0x00000000 /* PAD5_MODE */
  839. -+ 0x0000c 0x01000000 /* PAD6_MODE */
  840. -+ 0x00010 0x40000000 /* POWER_ON_STRIP */
  841. -+ 0x00050 0xcf35cf35 /* LED_CTRL0 */
  842. -+ 0x00054 0xcf35cf35 /* LED_CTRL1 */
  843. -+ 0x00058 0xcf35cf35 /* LED_CTRL2 */
  844. -+ 0x0005c 0x03ffff00 /* LED_CTRL3 */
  845. -+ 0x0007c 0x0000007e /* PORT0_STATUS */
  846. -+ >;
  847. -+ };
  848. -+ };
  849. -+
  850. -+ mdio@25000 {
  851. -+ status = "disabled";
  852. -+ };
  853. -+
  854. -+ mdio@26000 {
  855. -+ status = "disabled";
  856. -+ };
  857. -+
  858. -+ enet0: ethernet@b0000 {
  859. -+ phy-handle = <&phy0>;
  860. -+ phy-connection-type = "rgmii-id";
  861. -+ };
  862. -+
  863. -+ enet1: ethernet@b1000 {
  864. -+ status = "disabled";
  865. -+ };
  866. -+
  867. -+ enet2: ethernet@b2000 {
  868. -+ status = "disabled";
  869. -+ };
  870. -+
  871. -+ sdhc@2e000 {
  872. -+ status = "disabled";
  873. -+ };
  874. -+
  875. -+ serial1: serial@4600 {
  876. -+ status = "disabled";
  877. -+ };
  878. -+
  879. -+ can0: can@1c000 {
  880. -+ status = "disabled";
  881. -+ };
  882. -+
  883. -+ can1: can@1d000 {
  884. -+ status = "disabled";
  885. -+ };
  886. -+ };
  887. -+
  888. -+ pci0: pcie@ffe09000 {
  889. -+ reg = <0 0xffe09000 0 0x1000>;
  890. -+ ranges = <0x2000000 0x0 0xa0000000 0 0xa0000000 0x0 0x20000000
  891. -+ 0x1000000 0x0 0x00000000 0 0xffc10000 0x0 0x10000>;
  892. -+ pcie@0 {
  893. -+ ranges = <0x2000000 0x0 0xa0000000
  894. -+ 0x2000000 0x0 0xa0000000
  895. -+ 0x0 0x20000000
  896. -+
  897. -+ 0x1000000 0x0 0x0
  898. -+ 0x1000000 0x0 0x0
  899. -+ 0x0 0x100000>;
  900. -+ };
  901. -+ };
  902. -+
  903. -+ pci1: pcie@ffe0a000 {
  904. -+ reg = <0 0xffe0a000 0 0x1000>;
  905. -+ ranges = <0x2000000 0x0 0x80000000 0 0x80000000 0x0 0x20000000
  906. -+ 0x1000000 0x0 0x00000000 0 0xffc00000 0x0 0x10000>;
  907. -+ pcie@0 {
  908. -+ ranges = <0x2000000 0x0 0x80000000
  909. -+ 0x2000000 0x0 0x80000000
  910. -+ 0x0 0x20000000
  911. -+
  912. -+ 0x1000000 0x0 0x0
  913. -+ 0x1000000 0x0 0x0
  914. -+ 0x0 0x100000>;
  915. -+ };
  916. -+ };
  917. -+
  918. -+ ifc: ifc@ffe1e000 {
  919. -+ status = "disabled";
  920. -+ };
  921. -+
  922. -+ leds {
  923. -+ compatible = "gpio-leds";
  924. -+
  925. -+ system {
  926. -+ gpios = <&gpio0 2 1>; /* active low */
  927. -+ label = "tp-link:blue:system";
  928. -+ };
  929. -+
  930. -+ usb1 {
  931. -+ gpios = <&gpio0 3 1>; /* active low */
  932. -+ label = "tp-link:green:usb1";
  933. -+ };
  934. -+
  935. -+ usb2 {
  936. -+ gpios = <&gpio0 4 1>; /* active low */
  937. -+ label = "tp-link:green:usb2";
  938. -+ };
  939. -+ };
  940. -+
  941. -+ buttons {
  942. -+ compatible = "gpio-keys";
  943. -+
  944. -+ reset {
  945. -+ label = "Reset button";
  946. -+ gpios = <&gpio0 5 1>; /* active low */
  947. -+ linux,code = <0x198>; /* KEY_RESTART */
  948. -+ };
  949. -+ };
  950. -+};
  951. -+
  952. -+/include/ "fsl/p1010si-post.dtsi"
  953. --- a/arch/powerpc/boot/wrapper
  954. +++ b/arch/powerpc/boot/wrapper
  955. @@ -197,6 +197,10 @@ cuboot*)
  956. @@ -466,151 +77,3 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
  957. obj-$(CONFIG_SBC8548) += sbc8548.o
  958. obj-$(CONFIG_PPA8548) += ppa8548.o
  959. obj-$(CONFIG_SOCRATES) += socrates.o socrates_fpga_pic.o
  960. ---- /dev/null
  961. -+++ b/arch/powerpc/platforms/85xx/tl_wdr4900_v1.c
  962. -@@ -0,0 +1,145 @@
  963. -+/*
  964. -+ * TL-WDR4900 v1 board setup
  965. -+ *
  966. -+ * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
  967. -+ *
  968. -+ * Based on:
  969. -+ * p1010rdb.c:
  970. -+ * P1010RDB Board Setup
  971. -+ * Copyright 2011 Freescale Semiconductor Inc.
  972. -+ *
  973. -+ * This program is free software; you can redistribute it and/or modify it
  974. -+ * under the terms of the GNU General Public License as published by the
  975. -+ * Free Software Foundation; either version 2 of the License, or (at your
  976. -+ * option) any later version.
  977. -+ */
  978. -+
  979. -+#include <linux/stddef.h>
  980. -+#include <linux/kernel.h>
  981. -+#include <linux/pci.h>
  982. -+#include <linux/delay.h>
  983. -+#include <linux/interrupt.h>
  984. -+#include <linux/of_platform.h>
  985. -+#include <linux/ath9k_platform.h>
  986. -+#include <linux/leds.h>
  987. -+
  988. -+#include <asm/time.h>
  989. -+#include <asm/machdep.h>
  990. -+#include <asm/pci-bridge.h>
  991. -+#include <mm/mmu_decl.h>
  992. -+#include <asm/prom.h>
  993. -+#include <asm/udbg.h>
  994. -+#include <asm/mpic.h>
  995. -+
  996. -+#include <sysdev/fsl_soc.h>
  997. -+#include <sysdev/fsl_pci.h>
  998. -+
  999. -+#include "mpc85xx.h"
  1000. -+
  1001. -+void __init tl_wdr4900_v1_pic_init(void)
  1002. -+{
  1003. -+ struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
  1004. -+ MPIC_SINGLE_DEST_CPU,
  1005. -+ 0, 256, " OpenPIC ");
  1006. -+
  1007. -+ BUG_ON(mpic == NULL);
  1008. -+
  1009. -+ mpic_init(mpic);
  1010. -+}
  1011. -+
  1012. -+#ifdef CONFIG_PCI
  1013. -+static struct gpio_led tl_wdr4900_v1_wmac_leds_gpio[] = {
  1014. -+ {
  1015. -+ .name = "tp-link:blue:wps",
  1016. -+ .gpio = 1,
  1017. -+ .active_low = 1,
  1018. -+ },
  1019. -+};
  1020. -+
  1021. -+static struct ath9k_platform_data tl_wdr4900_v1_wmac0_data = {
  1022. -+ .led_pin = 0,
  1023. -+ .eeprom_name = "pci_wmac0.eeprom",
  1024. -+ .leds = tl_wdr4900_v1_wmac_leds_gpio,
  1025. -+ .num_leds = ARRAY_SIZE(tl_wdr4900_v1_wmac_leds_gpio),
  1026. -+};
  1027. -+
  1028. -+static struct ath9k_platform_data tl_wdr4900_v1_wmac1_data = {
  1029. -+ .led_pin = 0,
  1030. -+ .eeprom_name = "pci_wmac1.eeprom",
  1031. -+};
  1032. -+
  1033. -+static void tl_wdr4900_v1_pci_wmac_fixup(struct pci_dev *dev)
  1034. -+{
  1035. -+ if (!machine_is(tl_wdr4900_v1))
  1036. -+ return;
  1037. -+
  1038. -+ if (dev->bus->number == 1 &&
  1039. -+ PCI_SLOT(dev->devfn) == 0) {
  1040. -+ dev->dev.platform_data = &tl_wdr4900_v1_wmac0_data;
  1041. -+ return;
  1042. -+ }
  1043. -+
  1044. -+ if (dev->bus->number == 3 &&
  1045. -+ PCI_SLOT(dev->devfn) == 0 &&
  1046. -+ dev->device == 0xabcd) {
  1047. -+ dev->dev.platform_data = &tl_wdr4900_v1_wmac1_data;
  1048. -+
  1049. -+ /*
  1050. -+ * The PCI header of the AR9381 chip is not programmed
  1051. -+ * correctly by the bootloader and the device uses wrong
  1052. -+ * data due to that. Replace the broken values with the
  1053. -+ * correct ones.
  1054. -+ */
  1055. -+ dev->device = 0x30;
  1056. -+ dev->class = 0x028000;
  1057. -+
  1058. -+ pr_info("pci %s: AR9381 fixup applied\n", pci_name(dev));
  1059. -+ }
  1060. -+}
  1061. -+
  1062. -+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID,
  1063. -+ tl_wdr4900_v1_pci_wmac_fixup);
  1064. -+#endif /* CONFIG_PCI */
  1065. -+
  1066. -+/*
  1067. -+ * Setup the architecture
  1068. -+ */
  1069. -+static void __init tl_wdr4900_v1_setup_arch(void)
  1070. -+{
  1071. -+ if (ppc_md.progress)
  1072. -+ ppc_md.progress("tl_wdr4900_v1_setup_arch()", 0);
  1073. -+
  1074. -+ fsl_pci_assign_primary();
  1075. -+
  1076. -+ printk(KERN_INFO "TL-WDR4900 v1 board from TP-Link\n");
  1077. -+}
  1078. -+
  1079. -+machine_arch_initcall(tl_wdr4900_v1, mpc85xx_common_publish_devices);
  1080. -+machine_arch_initcall(tl_wdr4900_v1, swiotlb_setup_bus_notifier);
  1081. -+
  1082. -+/*
  1083. -+ * Called very early, device-tree isn't unflattened
  1084. -+ */
  1085. -+static int __init tl_wdr4900_v1_probe(void)
  1086. -+{
  1087. -+ unsigned long root = of_get_flat_dt_root();
  1088. -+
  1089. -+ if (of_flat_dt_is_compatible(root, "tp-link,TL-WDR4900v1"))
  1090. -+ return 1;
  1091. -+
  1092. -+ return 0;
  1093. -+}
  1094. -+
  1095. -+define_machine(tl_wdr4900_v1) {
  1096. -+ .name = "Freescale P1014",
  1097. -+ .probe = tl_wdr4900_v1_probe,
  1098. -+ .setup_arch = tl_wdr4900_v1_setup_arch,
  1099. -+ .init_IRQ = tl_wdr4900_v1_pic_init,
  1100. -+#ifdef CONFIG_PCI
  1101. -+ .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  1102. -+#endif
  1103. -+ .get_irq = mpic_get_irq,
  1104. -+ .restart = fsl_rstcr_restart,
  1105. -+ .calibrate_decr = generic_calibrate_decr,
  1106. -+ .progress = udbg_progress,
  1107. -+};