[OpenWrt-Devel] [PATCH] ath79: Add support for TL-WR740N/NDv2,TL-MR3220v1,TL-MR3420v1

Deoptim dioptimizer at hotmail.com
Tue Jun 26 10:01:47 EDT 2018


Its common AP99(AR7241) platform with following devices:
TP-Link TL-WR740N/ND v2 (SoC AR7241 / Wifi AR9287 / without USB)
TP-Link TL-MR3220 v1 (SoC AR7241 / Wifi AR9285 / USB support)
TP-Link TL-MR3420 v1 (SoC AR7241 / Wifi AR9287 / USB support)

File ar7241_ap99.dtsi have common architecture with those devices
and dts files include it as common configuration.

Signed-off-by: Deoptim <dioptimizer at hotmail.com>
---
 .../ath79/base-files/etc/board.d/02_network   |   7 +
 .../etc/hotplug.d/firmware/10-ath9k-eeprom    |   3 +
 target/linux/ath79/dts/ar7241_ap99.dtsi       | 144 ++++++++++++++++++
 .../linux/ath79/dts/ar7241_tl-mr3220-v1.dts   | 108 +++++++++++++
 .../linux/ath79/dts/ar7241_tl-mr3420-v1.dts   |  44 ++++++
 target/linux/ath79/dts/ar7241_tl-wr841-v7.dts |  12 ++
 target/linux/ath79/image/tiny-tp-link.mk      |  29 ++++
 7 files changed, 347 insertions(+)
 create mode 100644 target/linux/ath79/dts/ar7241_ap99.dtsi
 create mode 100644 target/linux/ath79/dts/ar7241_tl-mr3220-v1.dts
 create mode 100644 target/linux/ath79/dts/ar7241_tl-mr3420-v1.dts
 create mode 100644 target/linux/ath79/dts/ar7241_tl-wr841-v7.dts

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 e2a45b0526..689ae82ffb 100755
--- a/target/linux/ath79/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/base-files/etc/board.d/02_network
@@ -98,6 +98,13 @@ ath79_setup_interfaces()
 		ucidef_add_switch "switch0" \
 			"0 at eth0" "3:lan:1" "5:lan:2" "4:wan"
 		;;
+	"tplink,tl-wr841-v7"|\
+	"tplink,tl-mr3220-v1"|\
+	"tplink,tl-mr3420-v1")
+		ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
+		ucidef_add_switch "switch0" \
+			"0 at eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
+		;;
 	*)
 		ucidef_set_interfaces_lan_wan "eth0" "eth1"
 		;;
diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 7023fa5e58..e5e2b1f8d3 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -54,6 +54,9 @@ case "$FIRMWARE" in
 	"tplink,tl-wdr4300")
 		ath9k_eeprom_extract "art" 20480 1088
 		;;
+	"tplink,tl-wr841-v7"|\
+	"tplink,tl-mr3220-v1"|\
+	"tplink,tl-mr3420-v1"|\
 	"netgear,wnr612-v2"|\
 	"on,n150r"|\
 	"tplink,tl-wr740n-v2"|\
diff --git a/target/linux/ath79/dts/ar7241_ap99.dtsi b/target/linux/ath79/dts/ar7241_ap99.dtsi
new file mode 100644
index 0000000000..d3834b4915
--- /dev/null
+++ b/target/linux/ath79/dts/ar7241_ap99.dtsi
@@ -0,0 +1,144 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "ar7241.dtsi"
+
+/ {
+	aliases {
+		led-status = &led_system;
+	};
+
+	memory at 0 {
+		device_type = "memory";
+		reg = <0x0 0x2000000>;
+	};
+
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <20>;
+
+		reset {
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+
+		qss {
+			label = "qss";
+			linux,code = <KEY_WPS_BUTTON>;
+			gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+
+		led_system: system {
+			label = "tp-link:green:system";
+			gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "heartbeat";
+		};
+
+		qss {
+			label = "tp-link:green:qss";
+			gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	ath9k-leds {
+		compatible = "gpio-leds";
+
+		wlan {
+			label = "ath9k-phy0";
+			gpios = <&ath9k 0 GPIO_ACTIVE_LOW>;
+			default-state = "off";
+			linux,default-trigger = "phy0tpt";
+		};
+	};
+};
+
+&spi {
+	status = "okay";
+	num-cs = <1>;
+
+	flash at 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 at 0 {
+				reg = <0x0 0x20000>;
+				label = "u-boot";
+				read-only;
+			};
+
+			firmware: partition at 20000 {
+				reg = <0x20000 0x3d0000>;
+				label = "firmware";
+			};
+
+			art: partition at 3f0000 {
+				reg = <0x3f0000 0x10000>;
+				label = "art";
+				read-only;
+			};
+		};
+	};
+};
+
+&pcie {
+	status = "okay";
+
+	ath9k: wifi at 0 {
+		reg = <0x0000 0 0 0 0>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		qca,no-eeprom;
+		mtd-mac-address = <&uboot 0x1fc00>;
+	};
+};
+
+&eth0 {
+	status = "okay";
+
+	mtd-mac-address = <&uboot 0x1fc00>;
+	mtd-mac-address-increment = <(-1)>;
+	phy-handle = <&phy4>;
+};
+
+&eth1 {
+	status = "okay";
+
+	mtd-mac-address = <&uboot 0x1fc00>;
+	mtd-mac-address-increment = <1>;
+};
+
+&mdio0 {
+	status = "okay";
+
+	phy4: ethernet-phy at 4 {
+		reg = <4>;
+		phy-mode = "mii";
+	};
+};
+
+&gpio {
+	status = "okay";
+};
+
+&uart {
+	status = "okay";
+};
diff --git a/target/linux/ath79/dts/ar7241_tl-mr3220-v1.dts b/target/linux/ath79/dts/ar7241_tl-mr3220-v1.dts
new file mode 100644
index 0000000000..a5d577749e
--- /dev/null
+++ b/target/linux/ath79/dts/ar7241_tl-mr3220-v1.dts
@@ -0,0 +1,108 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include "ar7241_ap99.dtsi"
+
+/ {
+	compatible = "tplink,tl-mr3220-v1", "qca,ar7241";
+	model = "TP-Link TL-MR3220 v1";
+
+	usb-leds {
+		compatible = "gpio-leds";
+
+		led3g {
+			label = "tp-link:green:3g";
+			gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+			default-state = "off";
+			trigger-sources = <&hub_port>;
+			linux,default-trigger = "usbport";
+		};
+	};
+
+	ath9k-leds {
+		compatible = "gpio-leds";
+
+		wlan {
+			label = "ath9k-phy0";
+			gpios = <&ath9k 1 GPIO_ACTIVE_LOW>;
+			default-state = "off";
+			linux,default-trigger = "phy0tpt";
+		};
+	};
+
+	reg_usb_vbus: reg_usb_vbus {
+		compatible = "regulator-fixed";
+		regulator-name = "usb_vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&gpio 6 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+};
+
+&spi {
+	status = "okay";
+	num-cs = <2>;
+	// First value is default pin for flash, second value
+	// (via comma) the GPIO number for sdcard. But we used
+	// gpio 2 and it equivalent of internal CS0 line. And
+	// we use it because we use common bus SPI0.0 for two
+	// devices (default Low polarity chip-select, custom
+	// High polarity chip-select).
+	// In its core, this is a dummy, because internal CS0 line
+	// is locked by HW and SPI driver, and we can not use it at all.
+	// We use this to simply switch SPI bus to another device.
+	cs-gpios = <0>, <&gpio 2 GPIO_ACTIVE_HIGH>;
+
+	flash at 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 at 0 {
+				reg = <0x0 0x20000>;
+				label = "u-boot";
+				read-only;
+			};
+
+			firmware: partition at 20000 {
+				reg = <0x20000 0x3d0000>;
+				label = "firmware";
+			};
+
+			art: partition at 3f0000 {
+				reg = <0x3f0000 0x10000>;
+				label = "art";
+				read-only;
+			};
+		};
+	};
+
+	sdcard at 0 {
+		compatible = "mmc-spi-slot";
+		reg = <1>;
+		spi-max-frequency = <25000000>;
+		voltage-ranges = <3200 3400>;
+	};
+};
+
+&usb {
+	vbus-supply = <&reg_usb_vbus>;
+	status = "okay";
+
+	hub_port: port at 1 {
+		reg = <1>;
+		#trigger-source-cells = <0>;
+	};
+};
+
+&usb_phy {
+	status = "okay";
+};
diff --git a/target/linux/ath79/dts/ar7241_tl-mr3420-v1.dts b/target/linux/ath79/dts/ar7241_tl-mr3420-v1.dts
new file mode 100644
index 0000000000..de2a237d06
--- /dev/null
+++ b/target/linux/ath79/dts/ar7241_tl-mr3420-v1.dts
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include "ar7241_ap99.dtsi"
+
+/ {
+	compatible = "tplink,tl-mr3420-v1", "qca,ar7241";
+	model = "TP-Link TL-MR3420 v1";
+
+	usb-leds {
+		compatible = "gpio-leds";
+
+		led3g {
+			label = "tp-link:green:3g";
+			gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+			default-state = "off";
+			trigger-sources = <&hub_port>;
+			linux,default-trigger = "usbport";
+		};
+	};
+
+	reg_usb_vbus: reg_usb_vbus {
+		compatible = "regulator-fixed";
+		regulator-name = "usb_vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&gpio 6 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+};
+
+&usb {
+	vbus-supply = <&reg_usb_vbus>;
+	status = "okay";
+
+	hub_port: port at 1 {
+		reg = <1>;
+		#trigger-source-cells = <0>;
+	};
+};
+
+&usb_phy {
+	status = "okay";
+};
diff --git a/target/linux/ath79/dts/ar7241_tl-wr841-v7.dts b/target/linux/ath79/dts/ar7241_tl-wr841-v7.dts
new file mode 100644
index 0000000000..ecf0fb5577
--- /dev/null
+++ b/target/linux/ath79/dts/ar7241_tl-wr841-v7.dts
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "ar7241_ap99.dtsi"
+
+/ {
+	compatible = "tplink,tl-wr841-v7", "qca,ar7241";
+	model = "TP-LINK TL-WR841N/ND v7";
+};
\ No newline at end of file
diff --git a/target/linux/ath79/image/tiny-tp-link.mk b/target/linux/ath79/image/tiny-tp-link.mk
index 1dfed48dba..e4d07143ed 100644
--- a/target/linux/ath79/image/tiny-tp-link.mk
+++ b/target/linux/ath79/image/tiny-tp-link.mk
@@ -39,3 +39,32 @@ define Device/tl-wr740n-v2
   SUPPORTED_DEVICES := tplink,tl-wr740n-v2 tl-wr740n-v2
 endef
 TARGET_DEVICES += tl-wr740n-v2
+
+define Device/tl-wr841-v7
+  $(Device/tplink-4m)
+  ATH_SOC := ar7241
+  DEVICE_TITLE := TP-LINK TL-WR841N/ND v7
+  TPLINK_HWID := 0x08410007
+  SUPPORTED_DEVICES := tplink,tl-wr841-v7 tl-wr841-v7
+endef
+TARGET_DEVICES += tl-wr841-v7
+
+define Device/tl-mr3220-v1
+  $(Device/tplink-4m)
+  ATH_SOC := ar7241
+  DEVICE_TITLE := TP-Link TL-MR3220 v1
+  TPLINK_HWID := 0x32200001
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport
+  SUPPORTED_DEVICES := tplink,tl-mr3220-v1 tl-mr3220-v1
+endef
+TARGET_DEVICES += tl-mr3220-v1
+
+define Device/tl-mr3420-v1
+  $(Device/tplink-4m)
+  ATH_SOC := ar7241
+  DEVICE_TITLE := TP-Link TL-MR3420 v1
+  TPLINK_HWID := 0x34200001
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport
+  SUPPORTED_DEVICES := tplink,tl-mr3420-v1 tl-mr3420-v1
+endef
+TARGET_DEVICES += tl-mr3420-v1
-- 
2.17.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/listinfo/openwrt-devel



More information about the openwrt-devel mailing list