[OpenWrt-Devel] [PATCH] added support for TL-WA701ND v2

Luigi Tarenga luigi.tarenga at gmail.com
Tue Jan 13 05:42:43 EST 2015


hello everybody,
I'm happy to write you my first patch to add support for a new device.

I started from the support for WR703N as template and corrected
the gpio leds and buttons. I remove a couple of command the take
online the USB power (I think is not needed since no USB port is available
and I don't see USB pinout on the board, maybe I will check better).

I hope someone can take a review of this patch and commit it against
the official tree.

There is just one thing I still have to check: return back to original
firmware and see if you can upload the factory image in the firmware
upgrade toolbox and it pass the hwid/verid checks. I think yes since
I used the same values as found in the stock firmware. I will update you
in a couple of day about this. Until now I used uboot to flash it.

looking for your feedback
regards
Luigi

here follow the patch against git 0484ab40b5f6783e1e155f46be3afb4a94d41670  :

Signed-off-by: Luigi Tarenga <luigi.tarenga at gmail.com>
---

diff --git a/target/linux/ar71xx/base-files/etc/diag.sh
b/target/linux/ar71xx/base-files/etc/diag.sh
index fa07f39..eb96338 100755
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -195,6 +195,7 @@ get_status_led() {
     tl-mr3220-v2 | \
     tl-mr3420 | \
     tl-mr3420-v2 | \
+    tl-wa701nd-v2 | \
     tl-wa801nd-v2 | \
     tl-wa901nd | \
     tl-wa901nd-v2 | \
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
index 5b9dbe7..51c2bca 100755
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
@@ -275,7 +275,11 @@ tl-wa850re)
     ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "tp-link:blue:signal5"
"wlan0" "80" "100" "-79" "13"
     ;;

-tl-wa860re)
+tl-wa701nd-v2 | \
+tl-wa830re-v2 | \
+tl-wa860re | \
+tl-wa801nd-v2 | \
+tl-wa901nd-v3)
     ucidef_set_led_netdev "lan" "LAN" "tp-link:green:lan" "eth0"
     ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
     ;;
@@ -333,11 +337,6 @@ tl-wr841n-v8)
     ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
     ;;

-tl-wa830re-v2)
-    ucidef_set_led_netdev "lan" "LAN" "tp-link:green:lan" "eth0"
-    ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
-    ;;
-
 tl-wr841n-v9)
     ucidef_set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
     ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x10"
@@ -357,12 +356,6 @@ tl-wr842n-v2)
     ucidef_set_led_usbdev "usb" "USB" "tp-link:green:3g" "1-1"
     ;;

-tl-wa801nd-v2 | \
-tl-wa901nd-v3)
-    ucidef_set_led_netdev "lan" "LAN" "tp-link:green:lan" "eth0"
-    ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
-    ;;
-
 tl-wr941nd | \
 tl-wr1041n-v2)
     ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
index c5cfd67..4be30b8 100755
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
@@ -301,6 +301,7 @@ tl-mr13u |\
 tl-mr3020 |\
 tl-mr3040 |\
 tl-mr3040-v2 |\
+tl-wa701nd-v2 |\
 tl-wa750re |\
 tl-wa850re |\
 tl-wa830re-v2 |\
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 1e96b6d..df35775 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -571,6 +571,9 @@ ar71xx_board_detect() {
     *"TL-MR3420 v2")
         name="tl-mr3420-v2"
         ;;
+    *"TL-WA701ND v2")
+        name="tl-wa701nd-v2"
+        ;;
     *TL-WA750RE)
         name="tl-wa750re"
         ;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 846954c..eeaac6a 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -269,6 +269,7 @@ platform_check_image() {
     tl-mr3220-v2 | \
     tl-mr3420 | \
     tl-mr3420-v2 | \
+    tl-wa701nd-v2 | \
     tl-wa7510n | \
     tl-wa750re | \
     tl-wa850re | \
diff --git a/target/linux/ar71xx/config-3.10 b/target/linux/ar71xx/config-3.10
index 9a8378a..482914a 100644
--- a/target/linux/ar71xx/config-3.10
+++ b/target/linux/ar71xx/config-3.10
@@ -88,6 +88,7 @@ CONFIG_ATH79_MACH_TL_MR11U=y
 CONFIG_ATH79_MACH_TL_MR13U=y
 CONFIG_ATH79_MACH_TL_MR3020=y
 CONFIG_ATH79_MACH_TL_MR3X20=y
+CONFIG_ATH79_MACH_TL_WA701ND_V2=y
 CONFIG_ATH79_MACH_TL_WA830RE_V2=y
 CONFIG_ATH79_MACH_TL_WA901ND=y
 CONFIG_ATH79_MACH_TL_WA901ND_V2=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa701nd-v2.c
b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa701nd-v2.c
new file mode 100644
index 0000000..aab92b3
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa701nd-v2.c
@@ -0,0 +1,116 @@
+/*
+ *  TP-LINK TL-WA701ND v2 board support
+ *
+ *  Copyright (C) 2015 Luigi Tarenga <luigi.tarenga at gmail.com>
+ *
+ *  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
+ *  by the Free Software Foundation.
+ */
+
+#include <linux/gpio.h>
+
+#include <asm/mach-ath79/ath79.h>
+
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+
+#define TL_WA701NDV2_GPIO_LED_WLAN    0
+#define TL_WA701NDV2_GPIO_LED_QSS    1
+#define TL_WA701NDV2_GPIO_LED_LAN    17
+#define TL_WA701NDV2_GPIO_LED_SYSTEM    27
+
+#define TL_WA701NDV2_GPIO_BTN_RESET    11
+#define TL_WA701NDV2_GPIO_BTN_QSS    26
+
+#define TL_WA701NDV2_GPIO_USB_POWER    8
+
+#define TL_WA701NDV2_KEYS_POLL_INTERVAL    20    /* msecs */
+#define TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL    (3 *
TL_WA701NDV2_KEYS_POLL_INTERVAL)
+
+static const char *tl_wa701ndv2_part_probes[] = {
+    "tp-link",
+    NULL,
+};
+
+static struct flash_platform_data tl_wa701ndv2_flash_data = {
+    .part_probes    = tl_wa701ndv2_part_probes,
+};
+
+static struct gpio_led tl_wa701ndv2_leds_gpio[] __initdata = {
+    {
+        .name        = "tp-link:green:wlan",
+        .gpio        = TL_WA701NDV2_GPIO_LED_WLAN,
+        .active_low    = 0,
+    }, {
+        .name        = "tp-link:green:qss",
+        .gpio        = TL_WA701NDV2_GPIO_LED_QSS,
+        .active_low    = 0,
+    }, {
+        .name        = "tp-link:green:lan",
+        .gpio        = TL_WA701NDV2_GPIO_LED_LAN,
+        .active_low    = 1,
+    }, {
+        .name        = "tp-link:green:system",
+        .gpio        = TL_WA701NDV2_GPIO_LED_SYSTEM,
+        .active_low    = 1,
+        }
+};
+
+static struct gpio_keys_button tl_wa701ndv2_gpio_keys[] __initdata = {
+    {
+        .desc        = "reset",
+        .type        = EV_KEY,
+        .code        = KEY_RESTART,
+        .debounce_interval = TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL,
+        .gpio        = TL_WA701NDV2_GPIO_BTN_RESET,
+        .active_low    = 0,
+    } , {
+                .desc        = "qss",
+                .type        = EV_KEY,
+                .code        = KEY_WPS_BUTTON,
+                .debounce_interval = TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL,
+                .gpio        = TL_WA701NDV2_GPIO_BTN_QSS,
+                .active_low    = 0,
+        }
+
+};
+
+static void __init tl_wa701ndv2_setup(void)
+{
+    u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
+    u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
+
+    /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
+    ath79_setup_ar933x_phy4_switch(false, false);
+
+    ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa701ndv2_leds_gpio),
+                 tl_wa701ndv2_leds_gpio);
+
+    ath79_register_gpio_keys_polled(-1, TL_WA701NDV2_KEYS_POLL_INTERVAL,
+                    ARRAY_SIZE(tl_wa701ndv2_gpio_keys),
+                    tl_wa701ndv2_gpio_keys);
+
+    gpio_request_one(TL_WA701NDV2_GPIO_USB_POWER,
+             GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
+             "USB power");
+    ath79_register_usb();
+
+    ath79_register_m25p80(&tl_wa701ndv2_flash_data);
+    ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+    /* ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1); */
+
+    ath79_register_mdio(0, 0x0);
+    ath79_register_eth(0);
+    ath79_register_eth(1);
+
+    ath79_register_wmac(ee, mac);
+}
+
+MIPS_MACHINE(ATH79_MACH_TL_WA701ND_V2, "TL-WA701ND-v2",
+         "TP-LINK TL-WA701ND v2", tl_wa701ndv2_setup);
diff --git a/target/linux/ar71xx/image/Makefile
b/target/linux/ar71xx/image/Makefile
index 683c238..425fcc5 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -1163,7 +1163,7 @@ $(eval $(call
SingleProfile,TPLINKOLD,squashfs-only,TLWR841NV15,tl-wr841nd-v1.5,
 $(eval $(call SingleProfile,TPLINK,64kraw,RNXN360RT,rnx-n360rt,TL-WR941ND,ttyS0,115200,0x09410002,0x00420001,4M))
 $(eval $(call SingleProfile,TPLINK,64kraw,TLMR3220V1,tl-mr3220-v1,TL-MR3220,ttyS0,115200,0x32200001,1,4M))
 $(eval $(call SingleProfile,TPLINK,64kraw,TLMR3420V1,tl-mr3420-v1,TL-MR3420,ttyS0,115200,0x34200001,1,4M))
-$(eval $(call SingleProfile,TPLINK,64kraw,TLWA701,tl-wa701n-v1,TL-WA901ND,ttyS0,115200,0x07010001,1,4M))
+$(eval $(call SingleProfile,TPLINK,64kraw,TLWA701NV1,tl-wa701n-v1,TL-WA901ND,ttyS0,115200,0x07010001,1,4M))
 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA730REV1,tl-wa730rev1,TL-WA901ND,ttyS0,115200,0x07300001,1,4M))
 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA7510NV1,tl-wa7510n,TL-WA7510N,ttyS0,115200,0x75100001,1,4M))
 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA801NV1,tl-wa801nd-v1,TL-WA901ND,ttyS0,115200,0x08010001,1,4M))
@@ -1199,6 +1199,7 @@ $(eval $(call
SingleProfile,TPLINK-LZMA,64kraw,TLMR3040V1,tl-mr3040-v1,TL-MR3040
 $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLMR3040V2,tl-mr3040-v2,TL-MR3040-v2,ttyATH0,115200,0x30400002,1,4Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLMR3220V2,tl-mr3220-v2,TL-MR3220-v2,ttyATH0,115200,0x32200002,1,4Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLMR3420V2,tl-mr3420-v2,TL-MR3420-v2,ttyS0,115200,0x34200002,1,4Mlzma))
+$(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWA701NV2,tl-wa701nd-v2,TL-WA701ND-v2,ttyATH0,115200,0x07010002,1,4Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR703,tl-wr703n-v1,TL-WR703N,ttyATH0,115200,0x07030101,1,4Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR710,tl-wr710n-v1,TL-WR710N,ttyATH0,115200,0x07100001,1,8Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR720NV3,tl-wr720n-v3,TL-WR720N-v3,ttyATH0,115200,0x07200103,1,4Mlzma))
@@ -1276,6 +1277,7 @@ $(eval $(call MultiProfile,TLMR11U,TLMR11UV1 TLMR11UV2))
 $(eval $(call MultiProfile,TLMR3040,TLMR3040V1 TLMR3040V2))
 $(eval $(call MultiProfile,TLMR3220,TLMR3220V1 TLMR3220V2))
 $(eval $(call MultiProfile,TLMR3420,TLMR3420V1 TLMR3420V2))
+$(eval $(call MultiProfile,TLWA701,TLWA701NV1 TLWA701NV2))
 $(eval $(call MultiProfile,TLWA730RE,TLWA730REV1))
 $(eval $(call MultiProfile,TLWA801,TLWA801NV1 TLWA801NV2))
 $(eval $(call MultiProfile,TLWA830,TLWA830RV1 TLWA830RV2))
diff --git a/target/linux/ar71xx/patches-3.10/729-MIPS-ath79-add-TL-WA701NDv2-support.patch
b/target/linux/ar71xx/patches-3.10/729-MIPS-ath79-add-TL-WA701NDv2-support.patch
new file mode 100644
index 0000000..b0de43f
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.10/729-MIPS-ath79-add-TL-WA701NDv2-support.patch
@@ -0,0 +1,45 @@
+Index: linux-3.10.49/arch/mips/ath79/machtypes.h
+===================================================================
+--- linux-3.10.49.orig/arch/mips/ath79/machtypes.h
++++ linux-3.10.49/arch/mips/ath79/machtypes.h
+@@ -118,6 +118,7 @@ enum ath79_mach_type {
+     ATH79_MACH_TL_MR3220_V2,    /* TP-LINK TL-MR3220 v2 */
+     ATH79_MACH_TL_MR3420,        /* TP-LINK TL-MR3420 */
+     ATH79_MACH_TL_MR3420_V2,    /* TP-LINK TL-MR3420 v2 */
++    ATH79_MACH_TL_WA701ND_V2,    /* TP-LINK TL-WA701ND v2 */
+     ATH79_MACH_TL_WA750RE,        /* TP-LINK TL-WA750RE */
+     ATH79_MACH_TL_WA7510N_V1,    /* TP-LINK TL-WA7510N v1*/
+     ATH79_MACH_TL_WA850RE,        /* TP-LINK TL-WA850RE */
+Index: linux-3.10.49/arch/mips/ath79/Kconfig
+===================================================================
+--- linux-3.10.49.orig/arch/mips/ath79/Kconfig
++++ linux-3.10.49/arch/mips/ath79/Kconfig
+@@ -713,6 +713,16 @@ config ATH79_MACH_TL_MR3X20
+     select ATH79_DEV_M25P80
+     select ATH79_DEV_USB
+
++config ATH79_MACH_TL_WA701ND_V2
++    bool "TP-LINK TL-WA701ND v2 support"
++    select SOC_AR933X
++    select ATH79_DEV_ETH
++    select ATH79_DEV_GPIO_BUTTONS
++    select ATH79_DEV_LEDS_GPIO
++    select ATH79_DEV_M25P80
++    select ATH79_DEV_USB
++    select ATH79_DEV_WMAC
++
+ config ATH79_MACH_TL_WAX50RE
+     bool "TP-LINK TL-WA750/850RE support"
+     select SOC_AR934X
+Index: linux-3.10.49/arch/mips/ath79/Makefile
+===================================================================
+--- linux-3.10.49.orig/arch/mips/ath79/Makefile
++++ linux-3.10.49/arch/mips/ath79/Makefile
+@@ -101,6 +101,7 @@ obj-$(CONFIG_ATH79_MACH_TL_MR11U)    += mac
+ obj-$(CONFIG_ATH79_MACH_TL_MR13U)    += mach-tl-mr13u.o
+ obj-$(CONFIG_ATH79_MACH_TL_MR3020)    += mach-tl-mr3020.o
+ obj-$(CONFIG_ATH79_MACH_TL_MR3X20)    += mach-tl-mr3x20.o
++obj-$(CONFIG_ATH79_MACH_TL_WA701ND_V2)    += mach-tl-wa701nd-v2.o
+ obj-$(CONFIG_ATH79_MACH_TL_WAX50RE)     += mach-tl-wax50re.o
+ obj-$(CONFIG_ATH79_MACH_TL_WA830RE_V2)    += mach-tl-wa830re-v2.o
+ obj-$(CONFIG_ATH79_MACH_TL_WA901ND)    += mach-tl-wa901nd.o
diff --git a/tools/firmware-utils/src/mktplinkfw.c
b/tools/firmware-utils/src/mktplinkfw.c
index a6aab59..0a5e4c3 100644
--- a/tools/firmware-utils/src/mktplinkfw.c
+++ b/tools/firmware-utils/src/mktplinkfw.c
@@ -40,6 +40,7 @@
 #define HWID_TL_MR3420_V1    0x34200001
 #define HWID_TL_MR3420_V2    0x34200002
 #define HWID_TL_WA701N_V1    0x07010001
+#define HWID_TL_WA701N_V2    0x07010002
 #define HWID_TL_WA7510N_V1    0x75100001
 #define HWID_TL_WA801ND_V1    0x08010001
 #define HWID_TL_WA830RE_V1    0x08300010
@@ -254,6 +255,11 @@ static struct board_info boards[] = {
         .hw_rev        = 1,
         .layout_id    = "4M",
     }, {
+        .id        = "TL-WA701Nv2",
+        .hw_id        = HWID_TL_WA701N_V2,
+        .hw_rev        = 1,
+        .layout_id    = "4Mlzma",
+    }, {
         .id        = "TL-WA7510N",
         .hw_id        = HWID_TL_WA7510N_V1,
         .hw_rev        = 1,
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list