[source] ar71xx: add support for TP-LINK TL-WR840N v2 and v3

LEDE Commits lede-commits at lists.infradead.org
Thu Mar 23 14:35:36 PDT 2017


pepe2k pushed a commit to source.git, branch master:
https://git.lede-project.org/0d9adb4832e2c9ef4303b0b7aeff86c0ed4e5d89

commit 0d9adb4832e2c9ef4303b0b7aeff86c0ed4e5d89
Author: Vaclav Svoboda <svoboda at neng.cz>
AuthorDate: Thu Mar 16 01:43:43 2017 +0100

    ar71xx: add support for TP-LINK TL-WR840N v2 and v3
    
    This patch adds support for the TP-LINK TL-WR840N v2 and v3.
    
    - SoC: Qualcomm QCA9533-BL3A (650 MHz)
    - RAM: 32 MiB (Zentel A3S56D40GTP)
    - Flash: 4 MiB
       (v2: Macronix MX 25L323F)
       (v3: Winbond 25Q32FVSIG)
    - LAN: 4x 100M
    - WAN: 1x 100M
    
    Signed-off-by: Vaclav Svoboda <svoboda at neng.cz>
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |  6 ++
 .../linux/ar71xx/base-files/etc/board.d/02_network |  2 +
 target/linux/ar71xx/base-files/etc/diag.sh         |  2 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |  6 ++
 .../ar71xx/base-files/lib/upgrade/platform.sh      |  2 +
 target/linux/ar71xx/config-4.4                     |  1 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  9 +++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |  1 +
 .../files/arch/mips/ath79/mach-tl-wr841n-v9.c      | 65 +++++++++++++++++++++-
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |  2 +
 target/linux/ar71xx/image/tp-link.mk               | 19 ++++++-
 target/linux/ar71xx/mikrotik/config-default        |  1 +
 target/linux/ar71xx/nand/config-default            |  1 +
 13 files changed, 115 insertions(+), 2 deletions(-)

diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index fdbdddd..082b6c4 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -692,6 +692,12 @@ tl-wr941nd-v6)
 	ucidef_set_led_switch "lan4" "LAN4" "tp-link:blue:lan4" "switch0" "0x02"
 	ucidef_set_led_wlan "wlan" "WLAN" "tp-link:blue:wlan" "phy0tpt"
 	;;
+tl-wr840n-v2|\
+tl-wr840n-v3)
+	ucidef_set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
+	ucidef_set_led_switch "lan" "LAN" "tp-link:green:lan" "switch0" "0x1E"
+	ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
+	;;
 tl-wr841n-v9|\
 tl-wr841n-v11|\
 tl-wr842n-v3)
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
index 0965d71..08ee584 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -44,6 +44,8 @@ ar71xx_setup_interfaces()
 	tl-wdr3500|\
 	tl-wr741nd|\
 	tl-wr741nd-v4|\
+	tl-wr840n-v2|\
+	tl-wr840n-v3|\
 	tl-wr841n-v11|\
 	tl-wr841n-v9|\
 	tl-wr842n-v3|\
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index c8eafa5..00f6a7d 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -379,6 +379,8 @@ get_status_led() {
 	tl-wr741nd|\
 	tl-wr741nd-v4|\
 	tl-wa801nd-v3|\
+	tl-wr840n-v2|\
+	tl-wr840n-v3|\
 	tl-wr841n-v1|\
 	tl-wr841n-v7|\
 	tl-wr841n-v8|\
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 32f3bfb..267cb6a 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -1100,6 +1100,12 @@ ar71xx_board_detect() {
 	*"TL-WR810N")
 		name="tl-wr810n"
 		;;
+	*"TL-WR840N v2")
+		name="tl-wr840n-v2"
+		;;
+	*"TL-WR840N v3")
+		name="tl-wr840n-v3"
+		;;
 	*"TL-WR841N v1")
 		name="tl-wr841n-v1"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 7a0bbb6..38a7883 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -428,6 +428,8 @@ platform_check_image() {
 	tl-wr802n-v1|\
 	tl-wr802n-v2|\
 	tl-wr810n|\
+	tl-wr840n-v2|\
+	tl-wr840n-v3|\
 	tl-wr841n-v11|\
 	tl-wr841n-v1|\
 	tl-wr841n-v7|\
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index 68b408a..09ffd8b 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -196,6 +196,7 @@ CONFIG_ATH79_MACH_TL_WR741ND_V4=y
 CONFIG_ATH79_MACH_TL_WR802N_V1=y
 CONFIG_ATH79_MACH_TL_WR802N_V2=y
 CONFIG_ATH79_MACH_TL_WR810N=y
+CONFIG_ATH79_MACH_TL_WR840N_V2=y
 CONFIG_ATH79_MACH_TL_WR841N_V1=y
 CONFIG_ATH79_MACH_TL_WR841N_V8=y
 CONFIG_ATH79_MACH_TL_WR841N_V9=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 5f81ebd..d72c462 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1568,6 +1568,15 @@ config ATH79_MACH_TL_WR810N
 	select ATH79_DEV_USB
 	select ATH79_DEV_WMAC
 
+config ATH79_MACH_TL_WR840N_V2
+	bool "TP-LINK TL-WR840N v2/v3 support"
+	select SOC_QCA953X
+	select ATH79_DEV_ETH
+	select ATH79_DEV_GPIO_BUTTONS
+	select ATH79_DEV_LEDS_GPIO
+	select ATH79_DEV_M25P80
+	select ATH79_DEV_WMAC
+
 config ATH79_MACH_TL_WR841N_V1
 	bool "TP-LINK TL-WR841N v1 support"
 	select SOC_AR71XX
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
index 7383244..7e1a71b 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -201,6 +201,7 @@ obj-$(CONFIG_ATH79_MACH_TL_WR741ND_V4)		+= mach-tl-wr741nd-v4.o
 obj-$(CONFIG_ATH79_MACH_TL_WR802N_V1)		+= mach-tl-wr802n.o
 obj-$(CONFIG_ATH79_MACH_TL_WR802N_V2)		+= mach-tl-wr802n-v2.o
 obj-$(CONFIG_ATH79_MACH_TL_WR810N)		+= mach-tl-wr810n.o
+obj-$(CONFIG_ATH79_MACH_TL_WR840N_V2)		+= mach-tl-wr841n-v9.o
 obj-$(CONFIG_ATH79_MACH_TL_WR841N_V1)		+= mach-tl-wr841n.o
 obj-$(CONFIG_ATH79_MACH_TL_WR841N_V8)		+= mach-tl-wr841n-v8.o
 obj-$(CONFIG_ATH79_MACH_TL_WR841N_V9)		+= mach-tl-wr841n-v9.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c
index f806568..24a1a64 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c
@@ -1,9 +1,10 @@
 /*
- *  TP-LINK TL-WR841N/ND v9/v11 / TL-WR842N/ND v3
+ *  TP-LINK TL-WR840N v2/v3 / TL-WR841N/ND v9/v11 / TL-WR842N/ND v3
  *
  *  Copyright (C) 2014 Matthias Schiffer <mschiffer at universe-factory.net>
  *  Copyright (C) 2016 Cezary Jackiewicz <cezary at eko.one.pl>
  *  Copyright (C) 2016 Stijn Segers <francesco.borromini at gmail.com>
+ *  Copyright (C) 2017 Vaclav Svoboda <svoboda at neng.cz>
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
@@ -25,6 +26,14 @@
 #include "dev-wmac.h"
 #include "machtypes.h"
 
+#define TL_WR840NV2_GPIO_LED_SYSTEM	15
+#define TL_WR840NV2_GPIO_LED_WLAN	13
+#define TL_WR840NV2_GPIO_LED_WPS	3
+#define TL_WR840NV2_GPIO_LED_WAN	4
+#define TL_WR840NV2_GPIO_LED_LAN	16
+
+#define TL_WR840NV2_GPIO_BTN_RESET	12
+
 #define TL_WR841NV9_GPIO_LED_WLAN	13
 #define TL_WR841NV9_GPIO_LED_QSS	3
 #define TL_WR841NV9_GPIO_LED_WAN	4
@@ -75,6 +84,41 @@ static struct flash_platform_data tl_wr841n_v9_flash_data = {
 	.part_probes	= tl_wr841n_v9_part_probes,
 };
 
+static struct gpio_led tl_wr840n_v2_leds_gpio[] __initdata = {
+	{
+		.name		= "tp-link:green:system",
+		.gpio		= TL_WR840NV2_GPIO_LED_SYSTEM,
+		.active_low	= 1,
+	}, {
+		.name		= "tp-link:green:lan",
+		.gpio		= TL_WR840NV2_GPIO_LED_LAN,
+		.active_low	= 1,
+	}, {
+		.name		= "tp-link:green:wps",
+		.gpio		= TL_WR840NV2_GPIO_LED_WPS,
+		.active_low	= 1,
+	}, {
+		.name		= "tp-link:green:wan",
+		.gpio		= TL_WR840NV2_GPIO_LED_WAN,
+		.active_low	= 1,
+	}, {
+		.name		= "tp-link:green:wlan",
+		.gpio		= TL_WR840NV2_GPIO_LED_WLAN,
+		.active_low	= 1,
+	},
+};
+
+static struct gpio_keys_button tl_wr840n_v2_gpio_keys[] __initdata = {
+	{
+		.desc		= "Reset button",
+		.type		= EV_KEY,
+		.code		= KEY_RESTART,
+		.debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= TL_WR840NV2_GPIO_BTN_RESET,
+		.active_low	= 1,
+	}
+};
+
 static struct gpio_led tl_wr841n_v9_leds_gpio[] __initdata = {
 	{
 		.name		= "tp-link:green:lan1",
@@ -260,6 +304,25 @@ static void __init tl_ap143_setup(void)
 	ath79_register_wmac(ee, tmpmac);
 }
 
+
+static void __init tl_wr840n_v2_setup(void)
+{
+	tl_ap143_setup();
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr840n_v2_leds_gpio),
+				 tl_wr840n_v2_leds_gpio);
+
+	ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(tl_wr840n_v2_gpio_keys),
+					tl_wr840n_v2_gpio_keys);
+}
+
+MIPS_MACHINE(ATH79_MACH_TL_WR840N_V2, "TL-WR840N-v2", "TP-LINK TL-WR840N v2",
+	     tl_wr840n_v2_setup);
+
+MIPS_MACHINE(ATH79_MACH_TL_WR840N_V3, "TL-WR840N-v3", "TP-LINK TL-WR840N v3",
+	     tl_wr840n_v2_setup);
+
 static void __init tl_wr841n_v9_setup(void)
 {
 	tl_ap143_setup();
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index 514a20d..27ebd47 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -242,6 +242,8 @@ enum ath79_mach_type {
 	ATH79_MACH_TL_WR802N_V1,		/* TP-LINK TL-WR802N v1 */
 	ATH79_MACH_TL_WR802N_V2,		/* TP-LINK TL-WR802N v2 */
 	ATH79_MACH_TL_WR810N,			/* TP-LINK TL-WR810N */
+	ATH79_MACH_TL_WR840N_V2,		/* TP-LINK TL-WR840N v2 */
+	ATH79_MACH_TL_WR840N_V3,		/* TP-LINK TL-WR840N v3 */
 	ATH79_MACH_TL_WR841N_V1,		/* TP-LINK TL-WR841N v1 */
 	ATH79_MACH_TL_WR841N_V11,		/* TP-LINK TL-WR841N/ND v11 */
 	ATH79_MACH_TL_WR841N_V7,		/* TP-LINK TL-WR841N/ND v7 */
diff --git a/target/linux/ar71xx/image/tp-link.mk b/target/linux/ar71xx/image/tp-link.mk
index b251135..10e2548 100644
--- a/target/linux/ar71xx/image/tp-link.mk
+++ b/target/linux/ar71xx/image/tp-link.mk
@@ -650,6 +650,23 @@ define Device/tl-wr802n-v2
 endef
 TARGET_DEVICES += tl-wr802n-v1 tl-wr802n-v2
 
+define Device/tl-wr840n-v2
+    $(Device/tplink-4mlzma)
+    DEVICE_TITLE := TP-LINK TL-WR840N v2
+    BOARDNAME := TL-WR840N-v2
+    DEVICE_PROFILE := TLWR840
+    TPLINK_HWID := 0x08400002
+    IMAGES += factory-eu.bin
+    IMAGE/factory-eu.bin := append-rootfs | mktplinkfw factory -C EU
+endef
+
+define Device/tl-wr840n-v3
+    $(Device/tl-wr840n-v2)
+    DEVICE_TITLE := TP-LINK TL-WR840N v3
+    BOARDNAME := TL-WR840N-v3
+    TPLINK_HWID := 0x08400003
+endef
+
 define Device/tl-wr841-v1.5
     $(Device/tplink-4m)
     DEVICE_TITLE := TP-LINK TL-WR841N/ND v1.5
@@ -761,7 +778,7 @@ define Device/tl-wr847n-v8
     DEVICE_PROFILE := TLWR841
     TPLINK_HWID := 0x08470008
 endef
-TARGET_DEVICES += tl-wr841-v1.5 tl-wr841-v3 tl-wr841-v5 tl-wr841-v7 tl-wr841-v8 tl-wr841-v9 tl-wr841-v10 tl-wr841-v11 tl-wr842n-v1 tl-wr842n-v2 tl-wr842n-v3 tl-wr843nd-v1 tl-wr847n-v8
+TARGET_DEVICES += tl-wr840n-v2 tl-wr840n-v3 tl-wr841-v1.5 tl-wr841-v3 tl-wr841-v5 tl-wr841-v7 tl-wr841-v8 tl-wr841-v9 tl-wr841-v10 tl-wr841-v11 tl-wr842n-v1 tl-wr842n-v2 tl-wr842n-v3 tl-wr843nd-v1 tl-wr847n-v8
 
 define Device/tl-wr941nd-v2
     $(Device/tplink-4m)
diff --git a/target/linux/ar71xx/mikrotik/config-default b/target/linux/ar71xx/mikrotik/config-default
index cf6f754..78a3fb3 100644
--- a/target/linux/ar71xx/mikrotik/config-default
+++ b/target/linux/ar71xx/mikrotik/config-default
@@ -161,6 +161,7 @@ CONFIG_ATH79_MACH_RBSXTLITE=y
 # CONFIG_ATH79_MACH_TL_WR802N_V1 is not set
 # CONFIG_ATH79_MACH_TL_WR802N_V2 is not set
 # CONFIG_ATH79_MACH_TL_WR810N is not set
+# CONFIG_ATH79_MACH_TL_WR840N_V2 is not set
 # CONFIG_ATH79_MACH_TL_WR841N_V1 is not set
 # CONFIG_ATH79_MACH_TL_WR841N_V8 is not set
 # CONFIG_ATH79_MACH_TL_WR841N_V9 is not set
diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default
index 24e712c..8a9b61c 100644
--- a/target/linux/ar71xx/nand/config-default
+++ b/target/linux/ar71xx/nand/config-default
@@ -147,6 +147,7 @@
 # CONFIG_ATH79_MACH_TL_WR741ND_V4 is not set
 # CONFIG_ATH79_MACH_TL_WR802N_V1 is not set
 # CONFIG_ATH79_MACH_TL_WR810N is not set
+# CONFIG_ATH79_MACH_TL_WR840N_V2 is not set
 # CONFIG_ATH79_MACH_TL_WR841N_V1 is not set
 # CONFIG_ATH79_MACH_TL_WR841N_V8 is not set
 # CONFIG_ATH79_MACH_TL_WR841N_V9 is not set



More information about the lede-commits mailing list