ramips: add support for TP-Link RE350
authorAlex Maclean <monkeh@monkeh.net>
Sun, 23 Jul 2017 19:06:44 +0000 (20:06 +0100)
committerMathias Kresin <dev@kresin.me>
Tue, 25 Jul 2017 19:02:53 +0000 (21:02 +0200)
The TP-Link RE350 is a wall-wart AC1200 range extender/access point with
a single gigabit ethernet port and two non-detachable antennas, based on
the MT7621A SoC with MT7603E and MT7612E radios.

Firmware wise it is very similar to the QCA based RE450.

SoC: MediaTek MT7621A (880MHz)
Flash: 8MiB (Winbond W25Q64)
RAM:   64MiB (DDR2)
Ethernet: 1x 1Gbit
Wireless: 2T2R 2.4Ghz (MT7603E) and 5GHz (MT7612E)
LEDs: Power, 2.4G, 5G (blue), WPS (red and blue), ethernet link/act
(green)
Buttons: On/off, LED, reset, WPS

Serial header at J1, 57600 8n1:
Pin 1 TX
Pin 2 RX
Pin 3 GND
Pin 4 3.3V

Factory image can be uploaded directly through the stock UI.

Signed-off-by: Alex Maclean <monkeh@monkeh.net>
target/linux/ramips/base-files/etc/board.d/01_leds
target/linux/ramips/base-files/etc/board.d/02_network
target/linux/ramips/base-files/etc/diag.sh
target/linux/ramips/base-files/lib/ramips.sh
target/linux/ramips/base-files/lib/upgrade/platform.sh
target/linux/ramips/dts/RE350.dts [new file with mode: 0644]
target/linux/ramips/image/mt7621.mk
target/linux/ramips/mt7621/config-4.4
target/linux/ramips/mt7621/config-4.9

index 83141dedd8db3aa45ec0be7fb9b7e37c651d0e30..8ea464516c50cda7d113a3f145650fb7b4279614 100755 (executable)
@@ -308,6 +308,12 @@ r6220)
        set_wifi_led "$board:green:wifi"
        set_usb_led "$board:green:usb"
        ;;
+re350-v1)
+       ucidef_set_led_netdev "wifi2g" "Wifi 2.4G" "$board:blue:wifi2G" "wlan0"
+       ucidef_set_led_netdev "wifi5g" "Wifi 5G" "$board:blue:wifi5G" "wlan1"
+       ucidef_set_led_netdev "eth_act" "LAN act" "$board:green:eth_act" "eth0" "tx rx"
+       ucidef_set_led_switch "eth_link" "LAN link" "$board:green:eth_link" "switch0" "0x01"
+       ;;
 re6500)
        ucidef_set_led_default "power" "power" "$board:white:power" "1"
        ucidef_set_led_default "wifi" "wifi" "$board:orange:wifi" "1"
index d0f3fce135907857e93f9ad5a63d28fb8536c34c..5cc711949fe40f1fca763d3b11834a0a5d5f8552 100755 (executable)
@@ -270,6 +270,10 @@ ramips_setup_interfaces()
                ucidef_add_switch "switch0" \
                "1:lan:2" "2:lan:1" "4:wan" "6@eth0"
                ;;
+       re350-v1)
+               ucidef_add_switch "switch0" \
+                       "0:lan" "6@eth0"
+               ;;
        re6500)
                ucidef_add_switch "switch0" \
                        "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
index 1349c00b321dbcd83a68a7ac7a14e35d614262d9..3933357aad8378f6e7bc815fae361c35fcb4771b 100644 (file)
@@ -119,6 +119,7 @@ get_status_led() {
        dap-1350|\
        na930|\
        pbr-m1|\
+       re350-v1|\
        rt-ac51u|\
        rt-n13u|\
        rt-n14u|\
index e2d7b07ecb59b3d91b1bd5453dc2dff1de264e72..0fd871a5d60b0ed3bdd7f7b9efb92e11f53ed198 100755 (executable)
@@ -427,6 +427,9 @@ ramips_board_detect() {
        *"RB750Gr3")
                name="rb750gr3"
                ;;
+       *"RE350 v1")
+               name="re350-v1"
+               ;;
        *"RE6500")
                name="re6500"
                ;;
index 36469ca704cd177213b4cd2ac396f62ec2f9fedf..830e129115cb16d47a0f65d8c05d475b30440fa0 100755 (executable)
@@ -253,6 +253,13 @@ platform_check_image() {
                # these boards use metadata images
                return 0
                ;;
+       re350-v1)
+               [ "$magic" != "01000000" ] && {
+                       echo "Invalid image type."
+                       return 1
+               }
+               return 0
+               ;;
        ubnt-erx|\
        ubnt-erx-sfp)
                nand_do_platform_check "$board" "$1"
diff --git a/target/linux/ramips/dts/RE350.dts b/target/linux/ramips/dts/RE350.dts
new file mode 100644 (file)
index 0000000..2f3bb12
--- /dev/null
@@ -0,0 +1,164 @@
+/dts-v1/;
+
+#include "mt7621.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "tplink,re350-v1", "mediatek,mt7621-soc";
+       model = "TP-LINK RE350 v1";
+
+       memory@0 {
+               device_type = "memory";
+               reg = <0x0 0x4000000>;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,57600";
+       };
+
+       gpio-leds {
+               compatible = "gpio-leds";
+
+               power {
+                       label = "re350-v1:blue:power";
+                       gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
+               };
+
+               wifi2g {
+                       label = "re350-v1:blue:wifi2G";
+                       gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
+               };
+
+               wifi5g {
+                       label = "re350-v1:blue:wifi5G";
+                       gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
+               };
+
+               wps_r {
+                       label = "re350-v1:red:wps";
+                       gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
+               };
+
+               wps_b {
+                       label = "re350-v1:blue:wps";
+                       gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>;
+               };
+
+               eth {
+                       label = "re350-v1:green:eth_act";
+                       gpios = <&gpio0 28 GPIO_ACTIVE_LOW>;
+               };
+
+               eth2 {
+                       label = "re350-v1:green:eth_link";
+                       gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       gpio-keys-polled {
+               compatible = "gpio-keys-polled";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               poll-interval = <20>;
+
+               led {
+                       label = "led";
+                       gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
+                       linux,code = <BTN_0>;
+               };
+
+               reset {
+                       label = "reset";
+                       gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+
+               power {
+                       label = "power";
+                       gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_POWER>;
+               };
+
+               wps {
+                       label = "wps";
+                       gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_WPS_BUTTON>;
+               };
+       };
+};
+
+&spi0 {
+       status = "okay";
+
+       w25q64@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "jedec,spi-nor";
+               reg = <0>;
+               spi-max-frequency = <10000000>;
+               m25p,chunked-io = <32>;
+
+               partition@0 {
+                       label = "u-boot";
+                       reg = <0x0 0x20000>;
+                       read-only;
+               };
+
+               partition@20000 {
+                       label = "firmware";
+                       reg = <0x20000 0x5e0000>;
+               };
+
+               config: partition@600000 {
+                       label = "config";
+                       reg = <0x600000 0x50000>;
+                       read-only;
+               };
+
+               radio: partition@7f0000 {
+                       label = "radio";
+                       reg = <0x7f0000 0x10000>;
+                       read-only;
+               };
+       };
+};
+
+&pcie {
+       status = "okay";
+
+       pcie0 {
+               mt76@0,0 {
+                       reg = <0x0000 0 0 0 0>;
+                       device_type = "pci";
+                       mediatek,mtd-eeprom = <&radio 0>;
+                       mtd-mac-address = <&config 0x10008>;
+                       mtd-mac-address-increment = <1>;
+               };
+       };
+
+       pcie1 {
+               mt76@1,0 {
+                       reg = <0x0000 0 0 0 0>;
+                       device_type = "pci";
+                       mediatek,mtd-eeprom = <&radio 0x8000>;
+                       ieee80211-freq-limit = <5000000 6000000>;
+                       mtd-mac-address = <&config 0x10008>;
+                       mtd-mac-address-increment = <2>;
+               };
+       };
+};
+
+&ethernet {
+       mtd-mac-address = <&config 0x10008>;
+};
+
+&pinctrl {
+       state_default: pinctrl0 {
+               gpio {
+                       ralink,group = "rgmii2", "wdt";
+                       ralink,function = "gpio";
+               };
+       };
+};
index 103534e060ca0b38618448bb14b3efee060bd0d6..bf0e292286ba34835f9226a4948499ae5a242119 100644 (file)
@@ -2,6 +2,8 @@
 # MT7621 Profiles
 #
 
+DEVICE_VARS += TPLINK_BOARD_ID TPLINK_HEADER_VERSION TPLINK_HWID TPLINK_HWREV
+
 define Build/ubnt-erx-factory-image
        if [ -e $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) -a "$$(stat -c%s $@)" -lt "$(KERNEL_SIZE)" ]; then \
                echo '21001:6' > $(1).compat; \
@@ -148,6 +150,22 @@ define Device/rb750gr3
 endef
 TARGET_DEVICES += rb750gr3
 
+define Device/re350-v1
+  DTS := RE350
+  DEVICE_TITLE := TP-LINK RE350 v1
+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 wpad-mini
+  TPLINK_BOARD_ID := RE350-V1
+  TPLINK_HWID := 0x0
+  TPLINK_HWREV := 0
+  TPLINK_HEADER_VERSION := 1
+  IMAGE_SIZE := 6016k
+  KERNEL := $(KERNEL_DTB) | tplink-v1-header -e
+  IMAGES := sysupgrade.bin factory.bin
+  IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | append-metadata | check-size $$$$(IMAGE_SIZE)
+  IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
+endef
+TARGET_DEVICES += re350-v1
+
 define Device/re6500
   DTS := RE6500
   DEVICE_TITLE := Linksys RE6500
index 3f5c5cd3323a975209ce1db130a222e786b39395..427553d10ef49ffc809b5e2260dfd5cf828b0906 100644 (file)
@@ -163,6 +163,7 @@ CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_SPLIT_SEAMA_FW=y
+CONFIG_MTD_SPLIT_TPLINK_FW=y
 CONFIG_MTD_SPLIT_TRX_FW=y
 CONFIG_MTD_SPLIT_UIMAGE_FW=y
 CONFIG_MTD_UBI=y
@@ -237,6 +238,7 @@ CONFIG_SPI_MT7621=y
 # CONFIG_SPI_RT2880 is not set
 CONFIG_SRCU=y
 CONFIG_SWCONFIG=y
+CONFIG_SWCONFIG_LEDS=y
 CONFIG_SYNC_R4K=y
 CONFIG_SYSCTL_EXCEPTION_TRACE=y
 CONFIG_SYS_HAS_CPU_MIPS32_R1=y
index a3c0fc7a7701356df358a0270bf614062a56e987..f9765edaf2373fd5d85b71912a20e93389ae357f 100644 (file)
@@ -172,6 +172,7 @@ CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_SPLIT_SEAMA_FW=y
+CONFIG_MTD_SPLIT_TPLINK_FW=y
 CONFIG_MTD_SPLIT_TRX_FW=y
 CONFIG_MTD_SPLIT_UIMAGE_FW=y
 CONFIG_MTD_UBI=y
@@ -251,6 +252,7 @@ CONFIG_SPI_MASTER=y
 CONFIG_SPI_MT7621=y
 # CONFIG_SPI_RT2880 is not set
 CONFIG_SRCU=y
+CONFIG_SWCONFIG_LEDS=y
 CONFIG_SWCONFIG=y
 CONFIG_SWPHY=y
 CONFIG_SYNC_R4K=y