ar71xx: add support for TP-LINK TL-WR840N v2 and v3
authorVaclav Svoboda <svoboda@neng.cz>
Thu, 16 Mar 2017 00:43:43 +0000 (01:43 +0100)
committerPiotr Dymacz <pepe2k@gmail.com>
Thu, 23 Mar 2017 08:41:15 +0000 (09:41 +0100)
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@neng.cz>
13 files changed:
target/linux/ar71xx/base-files/etc/board.d/01_leds
target/linux/ar71xx/base-files/etc/board.d/02_network
target/linux/ar71xx/base-files/etc/diag.sh
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
target/linux/ar71xx/config-4.4
target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
target/linux/ar71xx/files/arch/mips/ath79/Makefile
target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c
target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
target/linux/ar71xx/image/tp-link.mk
target/linux/ar71xx/mikrotik/config-default
target/linux/ar71xx/nand/config-default

index fdbdddd2999ccd9c2cb6604e564a477ff3e56185..082b6c478ee891270b115f01979f82f9a68189c5 100755 (executable)
@@ -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)
index 0965d717ee56e56100b3e2af9dc2abe33d513be9..08ee584480fb856f57cac58da95bf82100188f41 100755 (executable)
@@ -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|\
index c8eafa5b0bd4214bcef8e8f6f4be637208de9a9a..00f6a7db0772df0c75ae869490ed2358af73cf5a 100644 (file)
@@ -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|\
index 32f3bfbbebe62c90ec1ca8977d1944f23e42718c..267cb6ad5828275725fe26417797566e6762cb29 100755 (executable)
@@ -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"
                ;;
index 7a0bbb63b4314b83a3a2ae7286cc813680035c19..38a78830a07f074ba1c4094084c40cdec8587c8f 100755 (executable)
@@ -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|\
index 68b408a65b90b328c1a77c300872590fad9115af..09ffd8b6bf90e06eb1d39fd555472917c38a7eaa 100644 (file)
@@ -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
index 5f81ebd7d6d95f8a6e1fe947fa1292e1fb1539f5..d72c462f6e21cb46e8ef59705ecdcd3a22d53f9f 100644 (file)
@@ -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
index 73832448cd80ead9d820111f8439106e41770c8b..7e1a71b34dd0e1c3d39e10988aa86cb93dfd58e2 100644 (file)
@@ -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
index f806568f983af2f616e2612d93d83c60bfdf9546..24a1a643525246fba3ba7e4cf8fa666229bdbfa4 100644 (file)
@@ -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@universe-factory.net>
  *  Copyright (C) 2016 Cezary Jackiewicz <cezary@eko.one.pl>
  *  Copyright (C) 2016 Stijn Segers <francesco.borromini@gmail.com>
+ *  Copyright (C) 2017 Vaclav Svoboda <svoboda@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
 #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();
index 514a20d05f783b1b1fe83d4e4c89ae597d71438c..27ebd47f2987e428636a553d32235a482906241c 100644 (file)
@@ -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 */
index b251135c55f82b300a7391c75778a9387a53825f..10e254846cbfc4a1c67892c062435d9791b3c7ca 100644 (file)
@@ -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)
index cf6f754c84906ea86c33ab427b2e3c44e2d4a591..78a3fb340e64d1e50197e37925ef4e422e207676 100644 (file)
@@ -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
index 24e712c18b06f0d8c4e6eb9c903849069cd673f3..8a9b61c057a89293979ab432735595db13963cc0 100644 (file)
 # 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