From b1a173d7c396c0a9e6bb0078a1a061eb9fdd0316 Mon Sep 17 00:00:00 2001 From: Lucian Cristian Date: Mon, 18 Jun 2018 19:22:13 +0200 Subject: [PATCH] ath79: add support for tl-wr1043nd v2/v3 Signed-off-by: Lucian Cristian --- .../ath79/base-files/etc/board.d/02_network | 6 + target/linux/ath79/dts/qca9557.dtsi | 120 ++++++++--- .../ath79/dts/qca9558_tl-wr1043nd-v2.dts | 12 ++ .../ath79/dts/qca9558_tl-wr1043nd-v3.dts | 12 ++ .../linux/ath79/dts/qca9558_tl-wr1043nd.dtsi | 194 ++++++++++++++++++ target/linux/ath79/image/generic-tp-link.mk | 20 ++ 6 files changed, 341 insertions(+), 23 deletions(-) create mode 100644 target/linux/ath79/dts/qca9558_tl-wr1043nd-v2.dts create mode 100644 target/linux/ath79/dts/qca9558_tl-wr1043nd-v3.dts create mode 100644 target/linux/ath79/dts/qca9558_tl-wr1043nd.dtsi diff --git a/target/linux/ath79/base-files/etc/board.d/02_network b/target/linux/ath79/base-files/etc/board.d/02_network index bfea621c125..f734518f697 100755 --- a/target/linux/ath79/base-files/etc/board.d/02_network +++ b/target/linux/ath79/base-files/etc/board.d/02_network @@ -57,6 +57,12 @@ ath79_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" ;; + "tplink,tl-wr1043nd-v2"|\ + "tplink,tl-wr1043nd-v3") + ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2" + ucidef_add_switch "switch0" \ + "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0" + ;; "netgear,wndr3800") ucidef_set_interfaces_lan_wan "eth0" "eth1" ucidef_add_switch "switch0" \ diff --git a/target/linux/ath79/dts/qca9557.dtsi b/target/linux/ath79/dts/qca9557.dtsi index 60585523724..3600d69cab4 100644 --- a/target/linux/ath79/dts/qca9557.dtsi +++ b/target/linux/ath79/dts/qca9557.dtsi @@ -14,12 +14,19 @@ cpu@0 { device_type = "cpu"; - compatible = "mips,mips24Kc"; + compatible = "mips,mips74Kc"; clocks = <&pll ATH79_CLK_CPU>; reg = <0>; }; }; + extosc: ref { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "ref"; + clock-frequency = <40000000>; + }; + ahb { apb { ddr_ctrl: memory-controller@18000000 { @@ -46,6 +53,28 @@ status = "disabled"; }; + usb_phy0: usb-phy@18030000 { + compatible ="qca,qca9550-usb-phy", "qca,ar7200-usb-phy"; + + reset-names = "usb-phy", "usb-suspend-override"; + resets = <&rst 4>, <&rst 3>; + + #phy-cells = <0>; + + status = "disabled"; + }; + + usb_phy1: usb-phy { + compatible = "qca,qca9550-usb-phy", "qca,ar7200-usb-phy"; + + reset-names = "usb-phy", "usb-suspend-override"; + resets = <&rst2 4>, <&rst2 3>; + + #phy-cells = <0>; + + status = "disabled"; + }; + gpio: gpio@18040000 { compatible = "qca,ar9557-gpio", "qca,ar9340-gpio"; @@ -81,10 +110,12 @@ pll: pll-controller@18050000 { compatible = "qca,ar9557-pll", "qca,qca9550-pll"; - reg = <0x18050000 0x20>; + reg = <0x18050000 0x50>; #clock-cells = <1>; clock-output-names = "cpu", "ddr", "ahb"; + + clocks = <&extosc>; }; wdt: wdt@18060008 { @@ -98,7 +129,7 @@ }; rst: reset-controller@1806001c { - compatible = "qca,ar9557-reset", + compatible = "qca,qca9550-reset", "qca,ar7100-reset", "simple-bus"; reg = <0x1806001c 0x4>; @@ -106,18 +137,6 @@ #reset-cells = <1>; interrupt-parent = <&cpuintc>; - intc2: interrupt-controller@2 { - compatible = "qcom,qca9556-intc"; - - interrupts = <2>; - - interrupt-controller; - #interrupt-cells = <1>; - - qcom,pending-bits = <0x1f0>, /* pcie rc1 */ - <0xf>; /* wmac */ - }; - intc3: interrupt-controller@3 { compatible = "qcom,qca9556-intc"; @@ -126,35 +145,90 @@ interrupt-controller; #interrupt-cells = <1>; - qcom,pending-bits = <0x1f000>, /* pcie rc2 */ + qcom,pending-bits = <0x1f000>, /* pcie rc */ <0x1000000>, /* usb1 */ <0x10000000>; /* usb2 */ }; }; - pcie0: pcie-controller@180c0000 { + rst2: reset-controller@180600c0 { + compatible = "qca,qca9550-reset", + "qca,ar7100-reset", + "simple-bus"; + reg = <0x180600c0 0x4>; + + #reset-cells = <1>; + }; + + pcie: pcie-controller@18250000 { compatible = "qcom,ar7240-pci"; #address-cells = <3>; #size-cells = <2>; bus-range = <0x0 0x0>; - reg = <0x180c0000 0x1000>, /* CRP */ - <0x180f0000 0x100>, /* CTRL */ - <0x14000000 0x1000>; /* CFG */ + reg = <0x18250000 0x1000>, /* CRP */ + <0x18280000 0x100>, /* CTRL */ + <0x16000000 0x1000>; /* CFG */ reg-names = "crp_base", "ctrl_base", "cfg_base"; - ranges = <0x2000000 0 0x10000000 0x10000000 0 0x04000000 /* pci memory */ + ranges = <0x2000000 0 0x12000000 0x12000000 0 0x02000000 /* pci memory */ 0x1000000 0 0x00000000 0x0000000 0 0x000001>; /* io space */ - interrupt-parent = <&intc2>; + interrupt-parent = <&intc3>; interrupts = <0>; interrupt-controller; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 1>; - interrupt-map = <0 0 0 0 &pcie0 0>; + interrupt-map = <0 0 0 0 &pcie 0>; + status = "disabled"; + }; + + wmac: wmac@18100000 { + compatible = "qca,qca9550-wmac"; + reg = <0x18100000 0x10000>; + + interrupt-parent = <&cpuintc>; + interrupts = <2>; + status = "disabled"; }; }; + usb0: usb@1b000000 { + compatible = "generic-ehci"; + reg = <0x1b000000 0x1fc>; + + interrupt-parent = <&intc3>; + interrupts = <1>; + resets = <&rst 5>; + reset-names = "usb-host"; + + has-transaction-translator; + caps-offset = <0x100>; + + phy-names = "usb-phy0"; + phys = <&usb_phy0>; + + status = "disabled"; + }; + + usb1: usb@1b400000 { + compatible = "generic-ehci"; + reg = <0x1b400000 0x1fc>; + + interrupt-parent = <&intc3>; + interrupts = <2>; + resets = <&rst2 5>; + reset-names = "usb-host"; + + has-transaction-translator; + caps-offset = <0x100>; + + phy-names = "usb-phy1"; + phys = <&usb_phy1>; + + status = "disabled"; + }; + spi: spi@1f000000 { compatible = "qca,ar9557-spi", "qca,ar7100-spi"; reg = <0x1f000000 0x10>; diff --git a/target/linux/ath79/dts/qca9558_tl-wr1043nd-v2.dts b/target/linux/ath79/dts/qca9558_tl-wr1043nd-v2.dts new file mode 100644 index 00000000000..0cfc486883a --- /dev/null +++ b/target/linux/ath79/dts/qca9558_tl-wr1043nd-v2.dts @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "qca9558_tl-wr1043nd.dtsi" + +/ { + compatible = "tplink,tl-wr1043nd-v2", "qca,qca9557"; + model = "TP-Link TL-WR1043ND Version 2"; +}; diff --git a/target/linux/ath79/dts/qca9558_tl-wr1043nd-v3.dts b/target/linux/ath79/dts/qca9558_tl-wr1043nd-v3.dts new file mode 100644 index 00000000000..c41129837ca --- /dev/null +++ b/target/linux/ath79/dts/qca9558_tl-wr1043nd-v3.dts @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "qca9558_tl-wr1043nd.dtsi" + +/ { + compatible = "tplink,tl-wr1043nd-v3", "qca,qca9557"; + model = "TP-Link TL-WR1043ND Version 3"; +}; diff --git a/target/linux/ath79/dts/qca9558_tl-wr1043nd.dtsi b/target/linux/ath79/dts/qca9558_tl-wr1043nd.dtsi new file mode 100644 index 00000000000..1abee23b50d --- /dev/null +++ b/target/linux/ath79/dts/qca9558_tl-wr1043nd.dtsi @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "qca9557.dtsi" + +/ { + memory@0 { + device_type = "memory"; + reg = <0x0 0x4000000>; + }; + + chosen { + bootargs = "console=ttyS0,115200n8"; + }; + + aliases { + led-status = &system; + }; + + leds { + compatible = "gpio-leds"; + + system: system { + label = "tp-link:green:system"; + gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + linux,default-trigger = "heartbeat"; + }; + + usb { + label = "tp-link:green:usb"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + default-state = "off"; + trigger-sources = <&hub_port0>; + linux,default-trigger = "usbport"; + }; + + wifi_green { + label = "tp-link:green:wlan"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + default-state = "off"; + linux,default-trigger = "phy0tpt"; + }; + + wifi_wps { + label = "tp-link:green:wps"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + }; + + keys { + compatible = "gpio-keys"; + #address-cells = <1>; + #size-cells = <0>; + + reset { + label = "Reset button"; + linux,code = ; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + wifi { + label = "RFKILL button"; + linux,code = ; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; + + gpio-export { + compatible = "gpio-export"; + #size-cells = <0>; + + gpio_usb_power { + gpio-export,name = "tp-link:power:usb"; + gpio-export,output = <1>; + gpios = <&gpio 21 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&uart { + status = "okay"; +}; + +&gpio { + status = "okay"; +}; + +&usb_phy0 { + status = "okay"; +}; + +&usb0 { + status = "okay"; + + hub_port0: port@1 { + reg = <1>; + #trigger-source-cells = <0>; + }; +}; + +&spi { + status = "okay"; + num-cs = <1>; + + flash@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + uboot: partition@0 { + label = "u-boot"; + reg = <0x000000 0x020000>; + read-only; + }; + + partition@20000 { + label = "firmware"; + reg = <0x020000 0x7d0000>; + }; + + art: partition@7f0000 { + label = "art"; + reg = <0x7f0000 0x010000>; + read-only; + }; + }; + }; +}; + +&mdio0 { + status = "okay"; + + phy0: ethernet-phy@0 { + reg = <0>; + qca,ar8327-initvals = < + 0x04 0x00080080 /* PORT0 PAD MODE CTRL */ + 0x0c 0x07600000 /* PORT6 PAD MODE CTRL */ + 0x10 0x81000080 /* POWER_ON_STRIP */ + 0x50 0xcc35cc35 /* LED_CTRL0 */ + 0x54 0xca35ca35 /* LED_CTRL1 */ + 0x58 0xc935c935 /* LED_CTRL2 */ + 0x5c 0x03ffff00 /* LED_CTRL3 */ + 0x7c 0x0000007e /* PORT0_STATUS */ + 0x94 0x0000007e /* PORT6 STATUS */ + >; + }; +}; + +&mdio1 { + status = "okay"; + + phy1: ethernet-phy@1 { + reg = <1>; + }; +}; + +ð0 { + status = "okay"; + + mtd-mac-address = <&uboot 0x1fc00>; + mtd-mac-address-increment = <1>; + phy-handle = <&phy0>; +}; + +ð1 { + status = "okay"; + + mtd-mac-address = <&uboot 0x1fc00>; + phy-handle = <&phy1>; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&wmac { + status = "okay"; + mtd-cal-data = <&art 0x1000>; + mtd-mac-address = <&uboot 0x1fc00>; +}; diff --git a/target/linux/ath79/image/generic-tp-link.mk b/target/linux/ath79/image/generic-tp-link.mk index c9469708181..467e2c4c42c 100644 --- a/target/linux/ath79/image/generic-tp-link.mk +++ b/target/linux/ath79/image/generic-tp-link.mk @@ -28,6 +28,26 @@ define Device/tl-wr1043nd-v1 endef TARGET_DEVICES += tl-wr1043nd-v1 +define Device/tl-wr1043nd-v2 + $(Device/tplink-8mlzma) + ATH_SOC := qca9558 + DEVICE_TITLE := TP-LINK TL-WR1043N/ND v2 + DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport + TPLINK_HWID := 0x10430002 + SUPPORTED_DEVICES := tplink,tl-wr1043nd-v2 tl-wr1043nd-v2 +endef +TARGET_DEVICES += tl-wr1043nd-v2 + +define Device/tl-wr1043nd-v3 + $(Device/tplink-8mlzma) + ATH_SOC := qca9558 + DEVICE_TITLE := TP-LINK TL-WR1043N/ND v3 + DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport + TPLINK_HWID := 0x10430003 + SUPPORTED_DEVICES := tplink,tl-wr1043nd-v3 tl-wr1043nd-v3 +endef +TARGET_DEVICES += tl-wr1043nd-v3 + define Device/tl-wr1043nd-v4 $(Device/tplink) ATH_SOC := qca9563 -- 2.30.2