ar71xx: add support for TP-LINK WR1043ND v4
authorLudwig Thomeczek <ledesrc@wxorx.net>
Fri, 16 Dec 2016 11:50:34 +0000 (12:50 +0100)
committerMatthias Schiffer <mschiffer@universe-factory.net>
Tue, 20 Dec 2016 13:38:48 +0000 (14:38 +0100)
Signed-off-by: Ludwig Thomeczek <ledesrc@wxorx.net>
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-wr1043nd-v4.c [new file with mode: 0644]
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 a840e2f4cb6a571fd42911f7c03cfaf6e0a27214..8db964fc6bde3a90b0c52005610929919f716341 100755 (executable)
@@ -629,6 +629,15 @@ tl-wr1043nd-v2)
        ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
        ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
        ;;
+tl-wr1043nd-v4)
+       ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
+       ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
+       ucidef_set_led_switch "wan" "WAN" "tp-link:green:wan" "switch0" "0x20"
+       ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x10"
+       ucidef_set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x08"
+       ucidef_set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x04"
+       ucidef_set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x02"
+       ;;
 tl-wr2543n)
        ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
        ;;
index 89076055c31180d4f389032495822955fde8d5a8..d163f6035f7d00ad0b933fa7cabd7cb99297dffe 100755 (executable)
@@ -299,7 +299,8 @@ ar71xx_setup_interfaces()
                ;;
        dir-869-a1|\
        epg5000|\
-       esr1750)
+       esr1750|\
+       tl-wr1043nd-v4)
                ucidef_add_switch "switch0" \
                        "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
                ;;
@@ -459,6 +460,9 @@ ar71xx_setup_macs()
                lan_mac=$(mtd_get_mac_binary caldata 0)
                wan_mac=$(mtd_get_mac_binary caldata 6)
                ;;
+       tl-wr1043nd-v4)
+               wan_mac=$(mtd_get_mac_binary config 0x1017c)
+               ;;
        esr900)
                wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
                ;;
index d9d8a2953e364832f9aca45c00f4d631b0df08e2..ff605ae0c415e13306d0e4431f4185c64e1caeca 100644 (file)
@@ -346,6 +346,7 @@ get_status_led() {
        tl-wr1041n-v2|\
        tl-wr1043nd|\
        tl-wr1043nd-v2|\
+       tl-wr1043nd-v4|\
        tl-wr741nd|\
        tl-wr741nd-v4|\
        tl-wa801nd-v3|\
index 2cfd017be954fb3ac70848c691c6234eb0cb9050..104b1de05c43556ab6d97cf562c2891da1995d0b 100755 (executable)
@@ -909,6 +909,9 @@ ar71xx_board_detect() {
        *"TL-WR1043ND v2")
                name="tl-wr1043nd-v2"
                ;;
+       *"TL-WR1043ND v4")
+               name="tl-wr1043nd-v4"
+               ;;
        *TL-WR2543N*)
                name="tl-wr2543n"
                ;;
index 42cc1dd94787abc6554234a5c247885254c0bf56..d4b141046780ba8e4cbb4fc0c929aad715d73e9d 100755 (executable)
@@ -378,6 +378,7 @@ platform_check_image() {
        tl-wpa8630|\
        tl-wr1041n-v2|\
        tl-wr1043nd-v2|\
+       tl-wr1043nd-v4|\
        tl-wr1043nd|\
        tl-wr2543n|\
        tl-wr703n|\
index 58d39ad3102e3f54f8d8011d32483250325362ef..3dad21a8860be98a1fd248242cb031c2340f0d16 100644 (file)
@@ -175,6 +175,7 @@ CONFIG_ATH79_MACH_TL_WPA8630=y
 CONFIG_ATH79_MACH_TL_WR1041N_V2=y
 CONFIG_ATH79_MACH_TL_WR1043ND=y
 CONFIG_ATH79_MACH_TL_WR1043ND_V2=y
+CONFIG_ATH79_MACH_TL_WR1043ND_V4=y
 CONFIG_ATH79_MACH_TL_WR2543N=y
 CONFIG_ATH79_MACH_TL_WR703N=y
 CONFIG_ATH79_MACH_TL_WR720N_V3=y
index 824f47fc73b675a319a15c09a9d77aab116906dd..5bfb1624ba4551e6e9a12a47f79ac7fbc8c9022c 100644 (file)
@@ -1532,6 +1532,17 @@ config ATH79_MACH_TL_WR1043ND_V2
        select ATH79_DEV_USB
        select ATH79_DEV_WMAC
 
+config ATH79_MACH_TL_WR1043ND_V4
+       bool "TP-LINK TL-WR1043ND v4 support"
+       select SOC_QCA956X
+       select ATH79_DEV_AP9X_PCI if PCI
+       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_WR2543N
        bool "TP-LINK TL-WR2543N/ND support"
        select SOC_AR724X
@@ -1814,4 +1825,3 @@ config ATH79_MACH_TL_WPA8630
        select ATH79_DEV_LEDS_GPIO
        select ATH79_DEV_M25P80
        select ATH79_DEV_WMAC
-
index 6d558ec8a875bab555985ac0429af0f3500feeab..30657016932acff7b5e1c9b3f2cea658a282f849 100644 (file)
@@ -179,6 +179,7 @@ obj-$(CONFIG_ATH79_MACH_TL_WPA8630)         += mach-tl-wpa8630.o
 obj-$(CONFIG_ATH79_MACH_TL_WR1041N_V2)         += mach-tl-wr1041n-v2.o
 obj-$(CONFIG_ATH79_MACH_TL_WR1043ND)           += mach-tl-wr1043nd.o
 obj-$(CONFIG_ATH79_MACH_TL_WR1043ND_V2)                += mach-tl-wr1043nd-v2.o
+obj-$(CONFIG_ATH79_MACH_TL_WR1043ND_V4)                += mach-tl-wr1043nd-v4.o
 obj-$(CONFIG_ATH79_MACH_TL_WR2543N)            += mach-tl-wr2543n.o
 obj-$(CONFIG_ATH79_MACH_TL_WR703N)             += mach-tl-wr703n.o
 obj-$(CONFIG_ATH79_MACH_TL_WR720N_V3)          += mach-tl-wr720n-v3.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c
new file mode 100644 (file)
index 0000000..cb224f4
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ *  TP-LINK WR1043 V4 support
+ *
+ *  Copyright (C) 2015-2016 P. Wassi <p.wassi at gmx.at>
+ *  Copyright (C) 2016 Matthias Schiffer <mschiffer@universe-factory.net>
+ *  Copyright (C) 2016 Andreas Ziegler <github@andreas-ziegler.de>
+ *  Copyright (C) 2016 Ludwig Thomeczek <ledesrc@wxorx.net>
+ *
+ *  Derived from: mach-dir-869-a1.c
+ *
+ *  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 <linux/init.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/ath9k_platform.h>
+
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/irq.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+#include <linux/platform_data/phy-at803x.h>
+#include <linux/ar8216_platform.h>
+
+#include "common.h"
+#include "dev-ap9x-pci.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-wmac.h"
+#include "dev-usb.h"
+#include "machtypes.h"
+#include "nvram.h"
+
+#define TL_WR1043_V4_GPIO_BTN_RESET            2
+#define TL_WR1043_V4_GPIO_BTN_RFKILL           5
+
+#define TL_WR1043_V4_GPIO_LED_WLAN             19
+#define TL_WR1043_V4_GPIO_LED_USB              7
+#define TL_WR1043_V4_GPIO_LED_WPS              1
+#define TL_WR1043_V4_GPIO_LED_SYSTEM           6
+
+#define TL_WR1043_V4_GPIO_USB_POWER            8
+
+#define TL_WR1043_V4_GPIO_LED_WAN              15
+#define TL_WR1043_V4_GPIO_LED_LAN1             9
+#define TL_WR1043_V4_GPIO_LED_LAN2             14
+#define TL_WR1043_V4_GPIO_LED_LAN3             21
+#define TL_WR1043_V4_GPIO_LED_LAN4             20
+
+#define TL_WR1043_V4_KEYS_POLL_INTERVAL                20 /* msecs */
+#define TL_WR1043_V4_KEYS_DEBOUNCE_INTERVAL    (3 * TL_WR1043_V4_KEYS_POLL_INTERVAL)
+
+#define TL_WR1043_V4_MAC_LOCATION              0x1ff80174
+
+#define TL_WR1043_V4_EEPROM_ADDR               0x1fff0000
+#define TL_WR1043_V4_WMAC_CALDATA_OFFSET       0x1000
+
+static struct gpio_led tl_wr1043nd_v4_leds_gpio[] __initdata = {
+       {
+               .name           = "tp-link:green:wps",
+               .gpio           = TL_WR1043_V4_GPIO_LED_WPS,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:system",
+               .gpio           = TL_WR1043_V4_GPIO_LED_SYSTEM,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:wlan",
+               .gpio           = TL_WR1043_V4_GPIO_LED_WLAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:usb",
+               .gpio           = TL_WR1043_V4_GPIO_LED_USB,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:wan",
+               .gpio           = TL_WR1043_V4_GPIO_LED_WAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:lan1",
+               .gpio           = TL_WR1043_V4_GPIO_LED_LAN1,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:lan2",
+               .gpio           = TL_WR1043_V4_GPIO_LED_LAN2,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:lan3",
+               .gpio           = TL_WR1043_V4_GPIO_LED_LAN3,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:lan4",
+               .gpio           = TL_WR1043_V4_GPIO_LED_LAN4,
+               .active_low     = 1,
+       },
+};
+
+static struct gpio_keys_button tl_wr1043nd_v4_gpio_keys[] __initdata = {
+       {
+               .desc           = "Reset button",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = TL_WR1043_V4_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = TL_WR1043_V4_GPIO_BTN_RESET,
+               .active_low     = 1,
+       },
+       {
+               .desc           = "RFKILL button",
+               .type           = EV_KEY,
+               .code           = KEY_RFKILL,
+               .debounce_interval = TL_WR1043_V4_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = TL_WR1043_V4_GPIO_BTN_RFKILL,
+               .active_low     = 1,
+       },
+};
+
+static struct ar8327_pad_cfg tl_wr1043nd_v4_ar8327_pad0_cfg = {
+       .mode = AR8327_PAD_MAC_SGMII,
+       .sgmii_delay_en = true,
+};
+
+static struct ar8327_platform_data tl_wr1043nd_v4_ar8327_data = {
+       .pad0_cfg = &tl_wr1043nd_v4_ar8327_pad0_cfg,
+       .port0_cfg = {
+               .force_link = 1,
+               .speed = AR8327_PORT_SPEED_1000,
+               .duplex = 1,
+               .txpause = 1,
+               .rxpause = 1,
+       },
+};
+
+static struct mdio_board_info tl_wr1043nd_v4_mdio0_info[] = {
+       {
+               .bus_id = "ag71xx-mdio.0",
+               .phy_addr = 0,
+               .platform_data = &tl_wr1043nd_v4_ar8327_data,
+       },
+};
+
+static void __init tl_wr1043nd_v4_setup(void)
+{
+       u8 *mac = (u8 *) KSEG1ADDR(TL_WR1043_V4_MAC_LOCATION);
+       u8 *eeprom = (u8 *) KSEG1ADDR(TL_WR1043_V4_EEPROM_ADDR);
+
+       ath79_register_m25p80(NULL);
+
+       ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
+       ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
+       ath79_eth0_data.phy_mask = BIT(0);
+
+       mdiobus_register_board_info(tl_wr1043nd_v4_mdio0_info,
+                                   ARRAY_SIZE(tl_wr1043nd_v4_mdio0_info));
+
+       ath79_register_usb();
+       ath79_register_mdio(0, 0);
+       ath79_register_eth(0);
+
+       ath79_register_wmac(eeprom + TL_WR1043_V4_WMAC_CALDATA_OFFSET, mac);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1043nd_v4_leds_gpio),
+                                tl_wr1043nd_v4_leds_gpio);
+
+       ath79_register_gpio_keys_polled(-1, TL_WR1043_V4_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(tl_wr1043nd_v4_gpio_keys),
+                                       tl_wr1043nd_v4_gpio_keys);
+
+       gpio_request_one(TL_WR1043_V4_GPIO_USB_POWER,
+                        GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
+                        "USB power");
+}
+
+MIPS_MACHINE(ATH79_MACH_TL_WR1043ND_V4, "TL-WR1043ND-v4",
+            "TP-LINK TL-WR1043ND v4", tl_wr1043nd_v4_setup);
index ea218d77c59f39446e8ef62a7be9b65504ecbdcb..6ead9117eb9ddc567cc522cace74273df1d436e6 100644 (file)
@@ -208,6 +208,7 @@ enum ath79_mach_type {
        ATH79_MACH_TL_WR1041N_V2,               /* TP-LINK TL-WR1041N v2 */
        ATH79_MACH_TL_WR1043ND,                 /* TP-LINK TL-WR1043ND */
        ATH79_MACH_TL_WR1043ND_V2,              /* TP-LINK TL-WR1043ND v2 */
+       ATH79_MACH_TL_WR1043ND_V4,              /* TP-LINK TL-WR1043ND v4 */
        ATH79_MACH_TL_WR2543N,                  /* TP-LINK TL-WR2543N/ND */
        ATH79_MACH_TL_WR703N,                   /* TP-LINK TL-WR703N */
        ATH79_MACH_TL_WR710N,                   /* TP-LINK TL-WR710N */
index f6c1f5b1930cc7ff71be20ec63f02dad2243005d..394f2ecbc458722d11e7fb770af56c20fd328d03 100644 (file)
@@ -768,7 +768,24 @@ define Device/tl-wr1043nd-v3
     DEVICE_PROFILE := TLWR1043
     TPLINK_HWID := 0x10430003
 endef
-TARGET_DEVICES += tl-wr1043nd-v1 tl-wr1043nd-v2 tl-wr1043nd-v3
+
+define Device/tl-wr1043nd-v4
+    $(Device/tplink)
+    DEVICE_TITLE := TP-LINK TL-WR1043N/ND v4
+    DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport
+    BOARDNAME := TL-WR1043ND-v4
+    DEVICE_PROFILE := TLWR1043
+    TPLINK_HWID :=  0x10430004
+    TPLINK_FLASHLAYOUT := 16Msafeloader
+    MTDPARTS := spi0.0:128k(u-boot)ro,1536k(kernel),14016k(rootfs),128k(product-info)ro,320k(config)ro,64k(partition-table)ro,128k(logs)ro,64k(ART)ro,15552k@0x20000(firmware)
+    IMAGE_SIZE := 15552k
+    TPLINK_BOARD_NAME := TLWR1043NDV4
+    KERNEL := kernel-bin | patch-cmdline | lzma | mktplinkfw-combined -j
+    IMAGES := sysupgrade.bin factory.bin
+    IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade
+    IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
+endef
+TARGET_DEVICES += tl-wr1043nd-v1 tl-wr1043nd-v2 tl-wr1043nd-v3 tl-wr1043nd-v4
 
 define Device/tl-wr2543-v1
     $(Device/tplink-8mlzma)
index d8a694ae29eb11aadf88dbd281a6b41f890d8f66..e980c2f38c12e7abf28cb8866713459ff3fb0cba 100644 (file)
@@ -89,6 +89,7 @@ CONFIG_ATH79_MACH_RBSXTLITE=y
 # CONFIG_ATH79_MACH_TL_WR1041N_V2 is not set
 # CONFIG_ATH79_MACH_TL_WR1043ND is not set
 # CONFIG_ATH79_MACH_TL_WR1043ND_V2 is not set
+# CONFIG_ATH79_MACH_TL_WR1043ND_V4 is not set
 # CONFIG_ATH79_MACH_TL_WR2543N is not set
 # CONFIG_ATH79_MACH_TL_WR703N is not set
 # CONFIG_ATH79_MACH_TL_WR720N_V3 is not set
index 7a1d080f8cb39be369149636ea7ceaff5b1c1c5c..a6871825b71e36d287c459c97b08c2aa86088547 100644 (file)
@@ -50,6 +50,7 @@
 # CONFIG_ATH79_MACH_TL_WDR4300 is not set
 # CONFIG_ATH79_MACH_TL_WR1041N_V2 is not set
 # CONFIG_ATH79_MACH_TL_WR1043ND is not set
+# CONFIG_ATH79_MACH_TL_WR1043ND_V4 is not set
 # CONFIG_ATH79_MACH_TL_WR2543N is not set
 # CONFIG_ATH79_MACH_TL_WR703N is not set
 # CONFIG_ATH79_MACH_TL_WR720N_V3 is not set