From 781ad46206ddaee74e40d7dbc68840fae1c0cc7c Mon Sep 17 00:00:00 2001 From: Peter Lundkvist Date: Fri, 29 Jun 2018 05:44:58 +0200 Subject: [PATCH] ath79: add support for TP-Link RE450 v2 TP-Link RE450 v2 is a dual band router/range-extender based on Qualcomm/Atheros QCA9563 + QCA9880. Specification: - 775 MHz CPU - 64 MB of RAM (DDR2) - 8 MB of FLASH (SPI NOR) - 3T3R 2.4 GHz - 3T3R 5 GHz - 1x 10/100/1000 Mbps Ethernet (AR8033 PHY) - 7x LED, 4x button - UART header on PCB (needs unmounted R64 & R69 0201 resistors/jumpers) Flash instruction: Apply factory image in OEM firmware web-gui. U-Boot does not seem to have any recovery functions, so debricking requires connection via UART. Signed-off-by: Peter Lundkvist --- .../ath79/base-files/etc/board.d/01_leds | 4 + .../ath79/base-files/etc/board.d/02_network | 1 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 4 + .../linux/ath79/dts/qca9563_tl-re450-v2.dts | 195 ++++++++++++++++++ target/linux/ath79/image/common-tp-link.mk | 2 +- target/linux/ath79/image/generic-tp-link.mk | 18 ++ tools/firmware-utils/src/tplink-safeloader.c | 40 ++++ 7 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 target/linux/ath79/dts/qca9563_tl-re450-v2.dts diff --git a/target/linux/ath79/base-files/etc/board.d/01_leds b/target/linux/ath79/base-files/etc/board.d/01_leds index 3edffaff74..d8312a9b89 100755 --- a/target/linux/ath79/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/base-files/etc/board.d/01_leds @@ -28,6 +28,10 @@ case "$board" in ucidef_set_led_switch "lan1" "LAN1" "netgear:green:lan1" "switch0" "0x02" "0x0f" ucidef_set_led_switch "lan2" "LAN2" "netgear:green:lan2" "switch0" "0x04" "0x0f" ;; +"tplink,re450-v2") + ucidef_set_led_netdev "lan_data" "LAN Data" "tp-link:green:lan_data" "eth0" "tx rx" + ucidef_set_led_netdev "lan_link" "LAN Link" "tp-link:green:lan_link" "eth0" "link" + ;; "tplink,tl-mr3020-v1") ucidef_set_led_switch "lan" "LAN" "tp-link:green:lan" "switch0" "0x02" ;; 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 26b3752824..10a1bbd9ec 100755 --- a/target/linux/ath79/base-files/etc/board.d/02_network +++ b/target/linux/ath79/base-files/etc/board.d/02_network @@ -13,6 +13,7 @@ ath79_setup_interfaces() ucidef_set_interface_lan "eth0" "dhcp" ;; "avm,fritz300e"|\ + "tplink,re450-v2"|\ "tplink,tl-mr10u"|\ "tplink,tl-wr703n"|\ "ubnt,unifiac-lite"|\ diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index c27b4111de..28cfa25f4d 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -91,6 +91,10 @@ case "$FIRMWARE" in ath10kcal_extract "ART" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16) ;; + "tplink,re450-v2") + ath10kcal_extract "art" 20480 2116 + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1) + ;; "tplink,tl-archer-c7-v2") ath10kcal_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2) diff --git a/target/linux/ath79/dts/qca9563_tl-re450-v2.dts b/target/linux/ath79/dts/qca9563_tl-re450-v2.dts new file mode 100644 index 0000000000..646cdf2975 --- /dev/null +++ b/target/linux/ath79/dts/qca9563_tl-re450-v2.dts @@ -0,0 +1,195 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "qca956x.dtsi" + +/ { + compatible = "tplink,re450-v2", "qca,qca9563"; + model = "TP-Link RE450 v2"; + + chosen { + bootargs = "console=ttyS0,115200n8"; + }; + + aliases { + led-status = &system; + mdio-gpio0 = &mdio2; + }; + + leds { + compatible = "gpio-leds"; + + system: power { + label = "tp-link:blue:power"; + gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + }; + + wlan2g { + label = "tp-link:blue:wlan2g"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + default-state = "off"; + linux,default-trigger = "phy1tpt"; + }; + + wlan5g { + label = "tp-link:blue:wlan5g"; + gpios = <&gpio 5 GPIO_ACTIVE_LOW>; + default-state = "off"; + linux,default-trigger = "phy0tpt"; + }; + + lan_link { + label = "tp-link:green:lan_link"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + lan_data { + label = "tp-link:green:lan_data"; + gpios = <&gpio 9 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + wps_blue { + label = "tp-link:blue:wps"; + gpios = <&gpio 17 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + wps_red { + label = "tp-link:red:wps"; + gpios = <&gpio 20 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + }; + + keys { + compatible = "gpio-keys"; + #address-cells = <1>; + #size-cells = <0>; + + reset { + label = "Reset button"; + linux,code = ; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + power { + label = "Power button"; + linux,code = ; + gpios = <&gpio 2 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + leds { + label = "LED control button"; + linux,code = ; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + wps { + label = "WPS button"; + linux,code = ; + gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; + + mdio2: mdio { + compatible = "virtual,mdio-gpio"; + + gpios = <&gpio 3 GPIO_ACTIVE_HIGH>, /* MDC */ + <&gpio 4 GPIO_ACTIVE_HIGH>; /* MDIO */ + #address-cells = <1>; + #size-cells = <0>; + + phy0: ethernet-phy@4 { + reg = <4>; + device_type = "ethernet-phy"; + reset-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&uart { + status = "okay"; +}; + +&gpio { + status = "okay"; +}; + +&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>; + + partition@0 { + label = "u-boot"; + reg = <0x000000 0x020000>; + read-only; + }; + + partition@20000 { + label = "firmware"; + reg = <0x020000 0x5e0000>; + }; + + partition@600000 { + label = "partition-table"; + reg = <0x600000 0x010000>; + read-only; + }; + + info: partition@610000 { + label = "product-info"; + reg = <0x610000 0x020000>; + read-only; + }; + + partition@630000 { + label = "config"; + reg = <0x630000 0x020000>; + read-only; + }; + + art: partition@7f0000 { + label = "art"; + reg = <0x7f0000 0x010000>; + read-only; + }; + }; + }; +}; + +ð0 { + status = "okay"; + mtd-mac-address = <&info 0x8>; + phy-handle = <&phy0>; +}; + +&wmac { + status = "okay"; + mtd-cal-data = <&art 0x1000>; + mtd-mac-address = <&info 0x8>; +}; diff --git a/target/linux/ath79/image/common-tp-link.mk b/target/linux/ath79/image/common-tp-link.mk index f816308a9d..7490aeb1f3 100644 --- a/target/linux/ath79/image/common-tp-link.mk +++ b/target/linux/ath79/image/common-tp-link.mk @@ -1,4 +1,4 @@ -DEVICE_VARS += TPLINK_HWID TPLINK_HWREV TPLINK_FLASHLAYOUT TPLINK_HEADER_VERSION TPLINK_BOARD_NAME +DEVICE_VARS += TPLINK_HWID TPLINK_HWREV TPLINK_FLASHLAYOUT TPLINK_HEADER_VERSION TPLINK_BOARD_NAME TPLINK_BOARD_ID define rootfs_align $(patsubst %-256k,0x40000,$(patsubst %-128k,0x20000,$(patsubst %-64k,0x10000,$(patsubst squashfs%,0x4,$(patsubst root.%,%,$(1)))))) diff --git a/target/linux/ath79/image/generic-tp-link.mk b/target/linux/ath79/image/generic-tp-link.mk index 28fac6a631..537dafa152 100644 --- a/target/linux/ath79/image/generic-tp-link.mk +++ b/target/linux/ath79/image/generic-tp-link.mk @@ -13,6 +13,24 @@ define Device/tl-archer-c7-v2 endef TARGET_DEVICES += tl-archer-c7-v2 +define Device/tl-re450-v2 + $(Device/tplink) + ATH_SOC := qca9563 + IMAGE_SIZE := 6016k + DEVICE_TITLE := TP-LINK RE450 v2 + DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x + TPLINK_HWID := 0x0 + TPLINK_HWREV := 0 + TPLINK_BOARD_ID := RE450-V2 + LOADER_TYPE := elf + KERNEL := kernel-bin | append-dtb | lzma | tplink-v1-header -O + IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | \ + append-metadata | check-size $$$$(IMAGE_SIZE) + IMAGE/factory.bin := append-rootfs | tplink-safeloader factory + SUPPORTED_DEVICES := tplink,re450-v2 +endef +TARGET_DEVICES += tl-re450-v2 + define Device/tl-wdr3600 $(Device/tplink-8mlzma) ATH_SOC := ar9344 diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c index f1883cd636..b567b2950c 100644 --- a/tools/firmware-utils/src/tplink-safeloader.c +++ b/tools/firmware-utils/src/tplink-safeloader.c @@ -1079,6 +1079,46 @@ static struct device_info boards[] = { .last_sysupgrade_partition = "file-system" }, + /** Firmware layout for the RE450 v2 */ + { + .id = "RE450-V2", + .vendor = "", + .support_list = + "SupportList:\r\n" + "{product_name:RE450,product_ver:2.0.0,special_id:00000000}\r\n" + "{product_name:RE450,product_ver:2.0.0,special_id:55530000}\r\n" + "{product_name:RE450,product_ver:2.0.0,special_id:45550000}\r\n" + "{product_name:RE450,product_ver:2.0.0,special_id:4A500000}\r\n" + "{product_name:RE450,product_ver:2.0.0,special_id:43410000}\r\n" + "{product_name:RE450,product_ver:2.0.0,special_id:41550000}\r\n" + "{product_name:RE450,product_ver:2.0.0,special_id:41530000}\r\n" + "{product_name:RE450,product_ver:2.0.0,special_id:4B520000}\r\n" + "{product_name:RE450,product_ver:2.0.0,special_id:42520000}\r\n", + .support_trail = '\x00', + .soft_ver = NULL, + + /* We're using a dynamic kernel/rootfs split here */ + .partitions = { + {"fs-uboot", 0x00000, 0x20000}, + {"firmware", 0x20000, 0x5e0000}, + {"partition-table", 0x600000, 0x02000}, + {"default-mac", 0x610000, 0x00020}, + {"pin", 0x610100, 0x00020}, + {"product-info", 0x611100, 0x01000}, + {"soft-version", 0x620000, 0x01000}, + {"support-list", 0x621000, 0x01000}, + {"profile", 0x622000, 0x08000}, + {"user-config", 0x630000, 0x10000}, + {"default-config", 0x640000, 0x10000}, + {"radio", 0x7f0000, 0x10000}, + + {NULL, 0, 0} + }, + + .first_sysupgrade_partition = "os-image", + .last_sysupgrade_partition = "file-system" + }, + {} }; -- 2.30.2