[source] ramips: add support for TP-Link RE350

LEDE Commits lede-commits at lists.infradead.org
Tue Jul 25 12:04:09 PDT 2017


mkresin pushed a commit to source.git, branch master:
https://git.lede-project.org/f683385e73f09c13fd08c3d352f3f1739c1944c4

commit f683385e73f09c13fd08c3d352f3f1739c1944c4
Author: Alex Maclean <monkeh at monkeh.net>
AuthorDate: Sun Jul 23 20:06:44 2017 +0100

    ramips: add support for TP-Link RE350
    
    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 at monkeh.net>
---
 target/linux/ramips/base-files/etc/board.d/01_leds |   6 +
 .../linux/ramips/base-files/etc/board.d/02_network |   4 +
 target/linux/ramips/base-files/etc/diag.sh         |   1 +
 target/linux/ramips/base-files/lib/ramips.sh       |   3 +
 .../ramips/base-files/lib/upgrade/platform.sh      |   7 +
 target/linux/ramips/dts/RE350.dts                  | 164 +++++++++++++++++++++
 target/linux/ramips/image/mt7621.mk                |  18 +++
 target/linux/ramips/mt7621/config-4.4              |   2 +
 target/linux/ramips/mt7621/config-4.9              |   2 +
 9 files changed, 207 insertions(+)

diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/board.d/01_leds
index 83141de..8ea4645 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -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"
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network
index d0f3fce..5cc7119 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -270,6 +270,10 @@ ramips_setup_interfaces()
 		ucidef_add_switch "switch0" \
 		"1:lan:2" "2:lan:1" "4:wan" "6 at eth0"
 		;;
+	re350-v1)
+		ucidef_add_switch "switch0" \
+			"0:lan" "6 at eth0"
+		;;
 	re6500)
 		ucidef_add_switch "switch0" \
 			"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6 at eth0"
diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh
index 1349c00..3933357 100644
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -119,6 +119,7 @@ get_status_led() {
 	dap-1350|\
 	na930|\
 	pbr-m1|\
+	re350-v1|\
 	rt-ac51u|\
 	rt-n13u|\
 	rt-n14u|\
diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
index e2d7b07..0fd871a 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -427,6 +427,9 @@ ramips_board_detect() {
 	*"RB750Gr3")
 		name="rb750gr3"
 		;;
+	*"RE350 v1")
+		name="re350-v1"
+		;;
 	*"RE6500")
 		name="re6500"
 		;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index 36469ca..830e129 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -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
index 0000000..2f3bb12
--- /dev/null
+++ b/target/linux/ramips/dts/RE350.dts
@@ -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 at 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 at 0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+		m25p,chunked-io = <32>;
+
+		partition at 0 {
+			label = "u-boot";
+			reg = <0x0 0x20000>;
+			read-only;
+		};
+
+		partition at 20000 {
+			label = "firmware";
+			reg = <0x20000 0x5e0000>;
+		};
+
+		config: partition at 600000 {
+			label = "config";
+			reg = <0x600000 0x50000>;
+			read-only;
+		};
+
+		radio: partition at 7f0000 {
+			label = "radio";
+			reg = <0x7f0000 0x10000>;
+			read-only;
+		};
+	};
+};
+
+&pcie {
+	status = "okay";
+
+	pcie0 {
+		mt76 at 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 at 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";
+		};
+	};
+};
diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
index 103534e..bf0e292 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -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
diff --git a/target/linux/ramips/mt7621/config-4.4 b/target/linux/ramips/mt7621/config-4.4
index 3f5c5cd..427553d 100644
--- a/target/linux/ramips/mt7621/config-4.4
+++ b/target/linux/ramips/mt7621/config-4.4
@@ -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
diff --git a/target/linux/ramips/mt7621/config-4.9 b/target/linux/ramips/mt7621/config-4.9
index a3c0fc7..f9765ed 100644
--- a/target/linux/ramips/mt7621/config-4.9
+++ b/target/linux/ramips/mt7621/config-4.9
@@ -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



More information about the lede-commits mailing list