1 From 406d86e5990ac171f18ef6e2973672d8fbfe1556 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Wed, 20 Feb 2013 08:40:33 +0100
4 Subject: [PATCH] powerpc: 85xx: add support for the TP-Link TL-WDR4900 v1
7 This patch adds support for the TP-Link TL-WDR4900 v1
8 concurrent dual-band wireless router. The devices uses
9 the Freescale P1014 SoC.
11 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
13 arch/powerpc/boot/Makefile | 3 +
14 arch/powerpc/boot/cuboot-tl-wdr4900-v1.c | 164 +++++++++++++++++++++
15 arch/powerpc/boot/dts/tl-wdr4900-v1.dts | 212 ++++++++++++++++++++++++++++
16 arch/powerpc/boot/wrapper | 4 +
17 arch/powerpc/platforms/85xx/Kconfig | 11 ++
18 arch/powerpc/platforms/85xx/Makefile | 1 +
19 arch/powerpc/platforms/85xx/tl_wdr4900_v1.c | 145 +++++++++++++++++++
20 7 files changed, 540 insertions(+)
21 create mode 100644 arch/powerpc/boot/cuboot-tl-wdr4900-v1.c
22 create mode 100644 arch/powerpc/boot/dts/tl-wdr4900-v1.dts
23 create mode 100644 arch/powerpc/platforms/85xx/tl_wdr4900_v1.c
25 --- a/arch/powerpc/boot/Makefile
26 +++ b/arch/powerpc/boot/Makefile
27 @@ -112,6 +112,7 @@ src-plat-$(CONFIG_PPC_POWERNV) += pserie
28 src-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += pseries-head.S
29 src-plat-$(CONFIG_PPC_CELLEB) += pseries-head.S
30 src-plat-$(CONFIG_PPC_CELL_QPACE) += pseries-head.S
31 +src-plat-$(CONFIG_TL_WDR4900_V1) += cuboot-tl-wdr4900-v1.c
33 src-wlib := $(sort $(src-wlib-y))
34 src-plat := $(sort $(src-plat-y))
35 @@ -296,6 +297,7 @@ image-$(CONFIG_TQM8555) += cuImage.tqm
36 image-$(CONFIG_TQM8560) += cuImage.tqm8560
37 image-$(CONFIG_SBC8548) += cuImage.sbc8548
38 image-$(CONFIG_KSI8560) += cuImage.ksi8560
39 +image-$(CONFIG_TL_WDR4900_V1) += cuImage.tl-wdr4900-v1
41 # Board ports in arch/powerpc/platform/embedded6xx/Kconfig
42 image-$(CONFIG_STORCENTER) += cuImage.storcenter
44 +++ b/arch/powerpc/boot/cuboot-tl-wdr4900-v1.c
47 + * U-Boot compatibility wrapper for the TP-Link TL-WDR4900 v1 board
49 + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
53 + * Author: Scott Wood <scottwood@freescale.com>
54 + * Copyright (c) 2007 Freescale Semiconductor, Inc.
57 + * Authors: Scott Wood <scottwood@freescale.com>
58 + * Grant Likely <grant.likely@secretlab.ca>
59 + * Copyright (c) 2007 Freescale Semiconductor, Inc.
60 + * Copyright (c) 2008 Secret Lab Technologies Ltd.
62 + * This program is free software; you can redistribute it and/or modify it
63 + * under the terms of the GNU General Public License version 2 as published
64 + * by the Free Software Foundation.
75 +static unsigned long bus_freq;
76 +static unsigned long int_freq;
78 +static unsigned char enetaddr[6];
80 +static void process_boot_dtb(void *boot_dtb)
82 + const u32 *na, *ns, *reg, *val32;
87 + /* Make sure FDT blob is sane */
88 + if (fdt_check_header(boot_dtb) != 0)
89 + fatal("Invalid device tree blob\n");
91 + /* Find the #address-cells and #size-cells properties */
92 + node = fdt_path_offset(boot_dtb, "/");
94 + fatal("Cannot find root node\n");
95 + na = fdt_getprop(boot_dtb, node, "#address-cells", &size);
96 + if (!na || (size != 4))
97 + fatal("Cannot find #address-cells property");
99 + ns = fdt_getprop(boot_dtb, node, "#size-cells", &size);
100 + if (!ns || (size != 4))
101 + fatal("Cannot find #size-cells property");
103 + /* Find the memory range */
104 + node = fdt_node_offset_by_prop_value(boot_dtb, -1, "device_type",
105 + "memory", sizeof("memory"));
107 + fatal("Cannot find memory node\n");
108 + reg = fdt_getprop(boot_dtb, node, "reg", &size);
109 + if (size < (*na+*ns) * sizeof(u32))
110 + fatal("cannot get memory range\n");
112 + /* Only interested in memory based at 0 */
113 + for (i = 0; i < *na; i++)
115 + fatal("Memory range is not based at address 0\n");
117 + /* get the memsize and trucate it to under 4G on 32 bit machines */
119 + for (i = 0; i < *ns; i++)
120 + memsize64 = (memsize64 << 32) | *reg++;
121 + if (sizeof(void *) == 4 && memsize64 >= 0x100000000ULL)
122 + memsize64 = 0xffffffff;
124 + mem_size = memsize64;
126 + /* get clock frequencies */
127 + node = fdt_node_offset_by_prop_value(boot_dtb, -1, "device_type",
128 + "cpu", sizeof("cpu"));
130 + fatal("Cannot find cpu node\n");
132 + val32 = fdt_getprop(boot_dtb, node, "clock-frequency", &size);
133 + if (!val32 || (size != 4))
134 + fatal("Cannot get clock frequency");
138 + val32 = fdt_getprop(boot_dtb, node, "bus-frequency", &size);
139 + if (!val32 || (size != 4))
140 + fatal("Cannot get bus frequency");
144 + path = fdt_get_alias(boot_dtb, "ethernet0");
148 + node = fdt_path_offset(boot_dtb, path);
150 + fatal("Cannot find ethernet0 node");
152 + p = fdt_getprop(boot_dtb, node, "mac-address", &size);
153 + if (!p || (size < 6)) {
154 + printf("no mac-address property, finding local\n\r");
155 + p = fdt_getprop(boot_dtb, node, "local-mac-address", &size);
158 + if (!p || (size < 6))
159 + fatal("cannot get MAC addres");
161 + memcpy(enetaddr, p, sizeof(enetaddr));
165 +static void platform_fixups(void)
169 + dt_fixup_memory(0, mem_size);
171 + dt_fixup_mac_address_by_alias("ethernet0", enetaddr);
172 + dt_fixup_cpu_clocks(int_freq, bus_freq / 8, bus_freq);
174 + /* Unfortunately, the specific model number is encoded in the
175 + * soc node name in existing dts files -- once that is fixed,
176 + * this can do a simple path lookup.
178 + soc = find_node_by_devtype(NULL, "soc");
180 + void *serial = NULL;
182 + setprop(soc, "bus-frequency", &bus_freq, sizeof(bus_freq));
184 + while ((serial = find_node_by_devtype(serial, "serial"))) {
185 + if (get_parent(serial) != soc)
188 + setprop(serial, "clock-frequency", &bus_freq,
194 +void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
195 + unsigned long r6, unsigned long r7)
197 + mem_size = 64 * 1024 * 1024;
199 + simple_alloc_init(_end, mem_size - (u32)_end - 1024*1024, 32, 64);
201 + fdt_init(_dtb_start);
202 + serial_console_init();
204 + printf("\n\r-- TL-WDR4900 v1 boot wrapper --\n\r");
206 + process_boot_dtb((void *) r3);
208 + platform_ops.fixups = platform_fixups;
211 +++ b/arch/powerpc/boot/dts/tl-wdr4900-v1.dts
214 + * TP-Link TL-WDR4900 v1 Device Tree Source
216 + * Copyright 2013 Gabor Juhos <juhosg@openwrt.org>
218 + * This program is free software; you can redistribute it and/or modify it
219 + * under the terms of the GNU General Public License as published by the
220 + * Free Software Foundation; either version 2 of the License, or (at your
221 + * option) any later version.
224 +/include/ "fsl/p1010si-pre.dtsi"
227 + model = "TP-Link TL-WDR4900 v1";
228 + compatible = "tp-link,TL-WDR4900v1";
231 + bootargs = "console=ttyS0,115200";
233 + linux,stdout-path = "/soc@ffe00000/serial@4500";
242 + device_type = "memory";
245 + soc: soc@ffe00000 {
246 + ranges = <0x0 0x0 0xffe00000 0x100000>;
250 + #address-cells = <1>;
252 + compatible = "spansion,s25fl129p1";
254 + spi-max-frequency = <25000000>;
257 + reg = <0x0 0x0050000>;
263 + reg = <0x00050000 0x00010000>;
269 + reg = <0x00060000 0x002a0000>;
274 + reg = <0x00300000 0x00ce0000>;
279 + reg = <0x00fe0000 0x00010000>;
285 + reg = <0x00ff0000 0x00010000>;
291 + reg = <0x00060000 0x00f80000>;
292 + label = "firmware";
297 + gpio0: gpio-controller@f000 {
306 + phy0: ethernet-phy@0 {
308 + qca,ar8327-initvals = <
309 + 0x00004 0x07600000 /* PAD0_MODE */
310 + 0x00008 0x00000000 /* PAD5_MODE */
311 + 0x0000c 0x01000000 /* PAD6_MODE */
312 + 0x00010 0x40000000 /* POWER_ON_STRIP */
313 + 0x00050 0xcf35cf35 /* LED_CTRL0 */
314 + 0x00054 0xcf35cf35 /* LED_CTRL1 */
315 + 0x00058 0xcf35cf35 /* LED_CTRL2 */
316 + 0x0005c 0x03ffff00 /* LED_CTRL3 */
317 + 0x0007c 0x0000007e /* PORT0_STATUS */
323 + status = "disabled";
327 + status = "disabled";
330 + enet0: ethernet@b0000 {
331 + phy-handle = <&phy0>;
332 + phy-connection-type = "rgmii-id";
335 + enet1: ethernet@b1000 {
336 + status = "disabled";
339 + enet2: ethernet@b2000 {
340 + status = "disabled";
344 + status = "disabled";
347 + serial1: serial@4600 {
348 + status = "disabled";
352 + status = "disabled";
356 + status = "disabled";
360 + pci0: pcie@ffe09000 {
361 + reg = <0 0xffe09000 0 0x1000>;
362 + ranges = <0x2000000 0x0 0xa0000000 0 0xa0000000 0x0 0x20000000
363 + 0x1000000 0x0 0x00000000 0 0xffc10000 0x0 0x10000>;
365 + ranges = <0x2000000 0x0 0xa0000000
366 + 0x2000000 0x0 0xa0000000
375 + pci1: pcie@ffe0a000 {
376 + reg = <0 0xffe0a000 0 0x1000>;
377 + ranges = <0x2000000 0x0 0x80000000 0 0x80000000 0x0 0x20000000
378 + 0x1000000 0x0 0x00000000 0 0xffc00000 0x0 0x10000>;
380 + ranges = <0x2000000 0x0 0x80000000
381 + 0x2000000 0x0 0x80000000
390 + ifc: ifc@ffe1e000 {
391 + status = "disabled";
395 + compatible = "gpio-leds";
398 + gpios = <&gpio0 2 1>; /* active low */
399 + label = "tp-link:blue:system";
403 + gpios = <&gpio0 3 1>; /* active low */
404 + label = "tp-link:green:usb1";
408 + gpios = <&gpio0 4 1>; /* active low */
409 + label = "tp-link:green:usb2";
414 + compatible = "gpio-keys";
417 + label = "Reset button";
418 + gpios = <&gpio0 5 1>; /* active low */
419 + linux,code = <0x198>; /* KEY_RESTART */
424 +/include/ "fsl/p1010si-post.dtsi"
425 --- a/arch/powerpc/boot/wrapper
426 +++ b/arch/powerpc/boot/wrapper
427 @@ -218,6 +218,10 @@ cuboot*)
428 *-mpc85*|*-tqm85*|*-sbc85*)
429 platformo=$object/cuboot-85xx.o
432 + platformo=$object/cuboot-tl-wdr4900-v1.o
433 + link_address='0x1000000'
436 link_address='0x800000'
438 --- a/arch/powerpc/platforms/85xx/Kconfig
439 +++ b/arch/powerpc/platforms/85xx/Kconfig
440 @@ -168,6 +168,17 @@ config STX_GP3
442 select DEFAULT_UIMAGE
444 +config TL_WDR4900_V1
445 + bool "TP-Link TL-WDR4900 v1"
446 + select DEFAULT_UIMAGE
447 + select ARCH_REQUIRE_GPIOLIB
448 + select GPIO_MPC8XXX
450 + This option enables support for the TP-Link TL-WDR4900 v1 board.
452 + This board is a Concurrent Dual-Band wireless router with a
453 + Freescale P1014 SoC.
456 bool "TQ Components TQM8540"
458 --- a/arch/powerpc/platforms/85xx/Makefile
459 +++ b/arch/powerpc/platforms/85xx/Makefile
460 @@ -23,6 +23,7 @@ obj-$(CONFIG_TWR_P102x) += twr_p102x.o
461 obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o
462 obj-$(CONFIG_STX_GP3) += stx_gp3.o
463 obj-$(CONFIG_TQM85xx) += tqm85xx.o
464 +obj-$(CONFIG_TL_WDR4900_V1) += tl_wdr4900_v1.o
465 obj-$(CONFIG_SBC8548) += sbc8548.o
466 obj-$(CONFIG_PPA8548) += ppa8548.o
467 obj-$(CONFIG_SOCRATES) += socrates.o socrates_fpga_pic.o
469 +++ b/arch/powerpc/platforms/85xx/tl_wdr4900_v1.c
472 + * TL-WDR4900 v1 board setup
474 + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
478 + * P1010RDB Board Setup
479 + * Copyright 2011 Freescale Semiconductor Inc.
481 + * This program is free software; you can redistribute it and/or modify it
482 + * under the terms of the GNU General Public License as published by the
483 + * Free Software Foundation; either version 2 of the License, or (at your
484 + * option) any later version.
487 +#include <linux/stddef.h>
488 +#include <linux/kernel.h>
489 +#include <linux/pci.h>
490 +#include <linux/delay.h>
491 +#include <linux/interrupt.h>
492 +#include <linux/of_platform.h>
493 +#include <linux/ath9k_platform.h>
494 +#include <linux/leds.h>
496 +#include <asm/time.h>
497 +#include <asm/machdep.h>
498 +#include <asm/pci-bridge.h>
499 +#include <mm/mmu_decl.h>
500 +#include <asm/prom.h>
501 +#include <asm/udbg.h>
502 +#include <asm/mpic.h>
504 +#include <sysdev/fsl_soc.h>
505 +#include <sysdev/fsl_pci.h>
507 +#include "mpc85xx.h"
509 +void __init tl_wdr4900_v1_pic_init(void)
511 + struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
512 + MPIC_SINGLE_DEST_CPU,
513 + 0, 256, " OpenPIC ");
515 + BUG_ON(mpic == NULL);
521 +static struct gpio_led tl_wdr4900_v1_wmac_leds_gpio[] = {
523 + .name = "tp-link:blue:wps",
529 +static struct ath9k_platform_data tl_wdr4900_v1_wmac0_data = {
531 + .eeprom_name = "pci_wmac0.eeprom",
532 + .leds = tl_wdr4900_v1_wmac_leds_gpio,
533 + .num_leds = ARRAY_SIZE(tl_wdr4900_v1_wmac_leds_gpio),
536 +static struct ath9k_platform_data tl_wdr4900_v1_wmac1_data = {
538 + .eeprom_name = "pci_wmac1.eeprom",
541 +static void tl_wdr4900_v1_pci_wmac_fixup(struct pci_dev *dev)
543 + if (!machine_is(tl_wdr4900_v1))
546 + if (dev->bus->number == 1 &&
547 + PCI_SLOT(dev->devfn) == 0) {
548 + dev->dev.platform_data = &tl_wdr4900_v1_wmac0_data;
552 + if (dev->bus->number == 3 &&
553 + PCI_SLOT(dev->devfn) == 0 &&
554 + dev->device == 0xabcd) {
555 + dev->dev.platform_data = &tl_wdr4900_v1_wmac1_data;
558 + * The PCI header of the AR9381 chip is not programmed
559 + * correctly by the bootloader and the device uses wrong
560 + * data due to that. Replace the broken values with the
563 + dev->device = 0x30;
564 + dev->class = 0x028000;
566 + pr_info("pci %s: AR9381 fixup applied\n", pci_name(dev));
570 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID,
571 + tl_wdr4900_v1_pci_wmac_fixup);
572 +#endif /* CONFIG_PCI */
575 + * Setup the architecture
577 +static void __init tl_wdr4900_v1_setup_arch(void)
579 + if (ppc_md.progress)
580 + ppc_md.progress("tl_wdr4900_v1_setup_arch()", 0);
582 + fsl_pci_assign_primary();
584 + printk(KERN_INFO "TL-WDR4900 v1 board from TP-Link\n");
587 +machine_arch_initcall(tl_wdr4900_v1, mpc85xx_common_publish_devices);
588 +machine_arch_initcall(tl_wdr4900_v1, swiotlb_setup_bus_notifier);
591 + * Called very early, device-tree isn't unflattened
593 +static int __init tl_wdr4900_v1_probe(void)
595 + unsigned long root = of_get_flat_dt_root();
597 + if (of_flat_dt_is_compatible(root, "tp-link,TL-WDR4900v1"))
603 +define_machine(tl_wdr4900_v1) {
604 + .name = "Freescale P1014",
605 + .probe = tl_wdr4900_v1_probe,
606 + .setup_arch = tl_wdr4900_v1_setup_arch,
607 + .init_IRQ = tl_wdr4900_v1_pic_init,
609 + .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
611 + .get_irq = mpic_get_irq,
612 + .restart = fsl_rstcr_restart,
613 + .calibrate_decr = generic_calibrate_decr,
614 + .progress = udbg_progress,