[LEDE-DEV] [PATCH] ar71xx: add support for TP-Link TL-WDR7500v6

Bizon bizongod at gmail.com
Tue Oct 31 11:22:26 PDT 2017


Hi!

2017-10-31 15:43 GMT+01:00 Chuanhong Guo <gch981213 at gmail.com>:
> Hello!
>
> 2017-10-31 3:32 GMT+08:00 Bizon <bizongod at gmail.com>:
>> Add support for TP-Link TL-WDR7500 V6.
>>
>> Specifications:
>> - WiSoC: QCA9563 - 3x3 2.4GHz
>> - Radio2: QCA9880 - 3x3 5GHz
>> - RAM: 64MB DDR2
>> - Storage: 8MB NOR SPI flash, can be replaced with 16M
>> - Switch: RTL8367S, now unmanaged
> Do you mean that this device support is incomplete and the network
> switch is currently broken?
> I noticed that there is nothing about this switch in
> mach-tl-wdr7500-v6.c and in board.d/02_network you've placed this
> device with WR703N which has only one ethernet port.

That's correct. Now it works, but is unmanaged.
RTL8367S is very rare and I did not found exacly it in any sources.
Datasheet is also unavailable.
RTL and QCA is connected using single SGMII.

During analysis of device, after disconnecting MDIO between QCA and
RTL I found that without proper initialization switch keeps shutdown.

So using oscillocope I captured transmission on MDIO bus during boot and
analyzed it.

As You can see in:
https://github.com/bizongod/u-boot_wdr7500v6/blob/master/board/atheros/common/athrs17_phy.c
there are substituted functions:
void athrs17_reg_init()
BOOL athrs17_phy_setup(int ethUnit)
int athrs17_phy_is_fdx(int ethUnit)
int athrs17_phy_is_up(int ethUnit)

First one perform data exchange with RTL like original u-boot.
Other three, due to SGMII is used have no more usage, so they
returns const.

RTL needs special frame format, which is constructed using functions:
uint32_t rtl_reg_read(uint32_t reg_addr);
void rtl_reg_write(uint32_t reg_addr, uint32_t reg_val);

What is important, in this way switch is initialized correctly and is usable.
Only VLANs are not set.


After futher research I found, that captured data transmission looks very
similar to those found in sources for RTL8367C.

I think, that most of code for RTL8367C can be adapted for RTL8367S.
Major differences are in SDS settings, but I think that once this is done on
boot, don't need any more changes.

If this patch would take effect I would like to start porting
switch manageability to LEDE.

>> - Ethernet: 5x1G
>> - Misc: 2x button, 2x LED
>>
>> Signed-off-by: Karol Bizewski <bizongod at gmail.com>
>> ---
>>  package/boot/uboot-envtools/files/ar71xx                |  2 ++
>>  target/linux/ar71xx/base-files/etc/board.d/02_network   |  2 ++
>>  target/linux/ar71xx/base-files/etc/diag.sh              |  4 ++++
>>  .../base-files/etc/hotplug.d/firmware/11-ath10k-caldata |  5 +++++
>>  target/linux/ar71xx/base-files/lib/ar71xx.sh            |  6 ++++++
>>  target/linux/ar71xx/config-4.4                          |  1 +
>>  target/linux/ar71xx/config-4.9                          |  1 +
>>  .../linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt  | 10 ++++++++++
>>  target/linux/ar71xx/files/arch/mips/ath79/Makefile      |  1 +
>>  target/linux/ar71xx/files/arch/mips/ath79/machtypes.h   |  1 +
>>  target/linux/ar71xx/image/generic.mk                    | 17 +++++++++++++++++
>>  .../files/arch/mips/ath79/mach-tl-wdr7500-v6.c          | 112
>> +++++++++++++++++++++
>>  12 files changed, 162 insertions(+)
>>  create mode 100644
>> target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>>
>>  diff --git a/package/boot/uboot-envtools/files/ar71xx
>> b/package/boot/uboot-envtools/files/ar71xx
>> index 0bdb6de..789c317 100644
>> --- a/package/boot/uboot-envtools/files/ar71xx
>> +++ b/package/boot/uboot-envtools/files/ar71xx
>> @@ -46,6 +46,8 @@ om5p-acv2|\
>>  om5p-an|\
>>  sr3200|\
>>  tube2h|\
>> +tl-wdr7500-v6|\
>> +tl-wdr7500-v6-16M|\
>>  wndr3700|\
>>  xd3200)
>>   ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
>> 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 d838352..6cdd2fe 100755
>> --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
>> +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
>> @@ -122,6 +122,8 @@ ar71xx_setup_interfaces()
>>   tl-wa901nd-v2|\
>>   tl-wa901nd-v3|\
>>   tl-wa901nd-v4|\
>> + tl-wdr7500-v6|\
>> + tl-wdr7500-v6-16M|\
>>   tl-wr703n|\
>>   tl-wr802n-v1|\
>>   tl-wr802n-v2|\
>> diff --git a/target/linux/ar71xx/base-files/etc/diag.sh
>> b/target/linux/ar71xx/base-files/etc/diag.sh
>> index ade726f..f0ec9e6 100644
>> --- a/target/linux/ar71xx/base-files/etc/diag.sh
>> +++ b/target/linux/ar71xx/base-files/etc/diag.sh
>> @@ -20,6 +20,10 @@ get_status_led() {
>>   all0305)
>>   status_led="eap7660d:green:ds4"
>>   ;;
>> + tl-wdr7500-v6|\
>> + tl-wdr7500-v6-16M)
>> + status_led="$board:blue:system"
>> + ;;
>>   antminer-s1|\
>>   antminer-s3|\
>>   antminer-r1|\
>> diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
>> b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
>> index 85a2a63..bd0cf2e 100644
>> --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
>> +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
>> @@ -98,6 +98,11 @@ case "$FIRMWARE" in
>>   rb-952ui-5ac2nd)
>>   ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
>>   ;;
>> + tl-wdr7500-v6|\
>> + tl-wdr7500-v6-16M)
>> + ath10kcal_extract "art" 8192 2116
>> + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +2)
>> + ;;
>>   re450|\
>>   tl-wr902ac-v1)
>>   ath10kcal_extract "art" 20480 2116
>> diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> b/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> index 835ced6..dbf132b 100755
>> --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> @@ -1109,6 +1109,12 @@ ar71xx_board_detect() {
>>   *"TL-WDR6500 v2")
>>   name="tl-wdr6500-v2"
>>   ;;
>> + *"TL-WDR7500 v6")
>> +                local size="$(mtd_get_part_size 'firmware')"
>> +
>> +                [ "$size" = "8060928" ] && name="tl-wdr7500-v6"
>> +                [ "$size" = "16449536" ] && name="tl-wdr7500-v6-16M"
> Actually you needn't specify two different "name" here as both of them
> apply the same default configuration.

Shall I remove second one?

>> + ;;
>>   *"TL-WPA8630")
>>   name="tl-wpa8630"
>>   ;;
>> diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
>> index 0e77560..32b7fbe 100644
>> --- a/target/linux/ar71xx/config-4.4
>> +++ b/target/linux/ar71xx/config-4.4
>> @@ -196,6 +196,7 @@ CONFIG_ATH79_MACH_TL_WDR3320_V2=y
>>  CONFIG_ATH79_MACH_TL_WDR3500=y
>>  CONFIG_ATH79_MACH_TL_WDR4300=y
>>  CONFIG_ATH79_MACH_TL_WDR6500_V2=y
>> +CONFIG_ATH79_MACH_TL_WDR7500_V6=y
>>  CONFIG_ATH79_MACH_TL_WPA8630=y
>>  CONFIG_ATH79_MACH_TL_WR1041N_V2=y
>>  CONFIG_ATH79_MACH_TL_WR1043ND=y
>> diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9
>> index c5b8908..5f74076 100644
>> --- a/target/linux/ar71xx/config-4.9
>> +++ b/target/linux/ar71xx/config-4.9
>> @@ -194,6 +194,7 @@ CONFIG_ATH79_MACH_TL_WDR3320_V2=y
>>  CONFIG_ATH79_MACH_TL_WDR3500=y
>>  CONFIG_ATH79_MACH_TL_WDR4300=y
>>  CONFIG_ATH79_MACH_TL_WDR6500_V2=y
>> +CONFIG_ATH79_MACH_TL_WDR7500_V6=y
>>  CONFIG_ATH79_MACH_TL_WPA8630=y
>>  CONFIG_ATH79_MACH_TL_WR1041N_V2=y
>>  CONFIG_ATH79_MACH_TL_WR1043ND=y
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
>> b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
>> index 454aee6..c6e75db 100644
>> --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
>> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
>> @@ -1613,6 +1613,16 @@ config ATH79_MACH_TL_WDR6500_V2
>>   select ATH79_DEV_USB
>>   select ATH79_DEV_WMAC
>>
>> +config ATH79_MACH_TL_WDR7500_V6
>> + bool "TP-LINK TL-WDR7500 v6 board 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_WMAC
>> +
>>  config ATH79_MACH_TL_WR703N
>>   bool "TP-LINK TL-WR703N/TL-WR710N/TL-MR10U support"
>>   select SOC_AR933X
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
>> b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
>> index 0975aac..49686ed 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_WDR3320_V2) +=
>> mach-tl-wdr3320-v2.o
>>  obj-$(CONFIG_ATH79_MACH_TL_WDR3500) += mach-tl-wdr3500.o
>>  obj-$(CONFIG_ATH79_MACH_TL_WDR4300) += mach-tl-wdr4300.o
>>  obj-$(CONFIG_ATH79_MACH_TL_WDR6500_V2) += mach-tl-wdr6500-v2.o
>> +obj-$(CONFIG_ATH79_MACH_TL_WDR7500_V6) += mach-tl-wdr7500-v6.o
>>  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
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
>> b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
>> index 756d406..fb27498 100644
>> --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
>> +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
>> @@ -241,6 +241,7 @@ enum ath79_mach_type {
>>   ATH79_MACH_TL_WDR4300, /* TP-LINK TL-WDR4300 */
>>   ATH79_MACH_TL_WDR4900_V2, /* TP-LINK TL-WDR4900 v2 */
>>   ATH79_MACH_TL_WDR6500_V2, /* TP-LINK TL-WDR6500 v2 */
>> + ATH79_MACH_TL_WDR7500_V6,               /* TP-LINK TL-WDR7500 v6 */
>>   ATH79_MACH_TL_WPA8630, /* TP-Link TL-WPA8630 */
>>   ATH79_MACH_TL_WR1041N_V2, /* TP-LINK TL-WR1041N v2 */
>>   ATH79_MACH_TL_WR1043ND, /* TP-LINK TL-WR1043ND */
>> diff --git a/target/linux/ar71xx/image/generic.mk
>> b/target/linux/ar71xx/image/generic.mk
>> index 6f5a701..39be043 100644
>> --- a/target/linux/ar71xx/image/generic.mk
>> +++ b/target/linux/ar71xx/image/generic.mk
>> @@ -713,6 +713,23 @@ define Device/tellstick-znet-lite
>>  endef
>>  TARGET_DEVICES += tellstick-znet-lite
>>
>> +define Device/tl-wdr7500-v6
>> +  DEVICE_TITLE := TP-LINK WDR7500 v6
>> +  DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x
>> +  BOARDNAME := TL-WDR7500-V6
>> +  IMAGE_SIZE := 7872k
>> +  MTDPARTS := spi0.0:192k(u-boot)ro,64k(u-boot-env),7872k(firmware),64k(art)ro
>> +endef
>> +TARGET_DEVICES += tl-wdr7500-v6
>> +
>> +define Device/tl-wdr7500-v6-16M
>> +  $(Device/tl-wdr7500-v6)
>> +  DEVICE_TITLE := TP-LINK WDR7500 v6 16M
>> +  IMAGE_SIZE := 16064k
>> +  MTDPARTS := spi0.0:192k(u-boot)ro,64k(u-boot-env),16064k(firmware),64k(art)ro
>> +endef
>> +TARGET_DEVICES += tl-wdr7500-v6-16M
>> +
>>  define Device/oolite
>>    $(Device/tplink-16mlzma)
>>    DEVICE_TITLE := Gainstrong OOLITE
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>> b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>> new file mode 100644
>> index 0000000..8c1c989
>> --- /dev/null
>> +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>> @@ -0,0 +1,112 @@
>> +/*
>> + * Support for TP-Link TL-WDR7500 v6 board
>> + *
>> + * Copyright (C) 2017 Karol Bizewski <bizongod 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/phy.h>
>> +#include <linux/gpio.h>
>> +#include <linux/ar8216_platform.h>
>> +#include <linux/platform_device.h>
>> +
>> +#include <asm/mach-ath79/ath79.h>
>> +#include <asm/mach-ath79/ar71xx_regs.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-usb.h"
>> +#include "dev-wmac.h"
>> +#include "machtypes.h"
>> +
>> +#define WDR7500V6_GPIO_LED_SYSTEM       21
>> +#define WDR7500V6_GPIO_LED_TURBO        6
>> +
>> +#define WDR7500V6_GPIO_BTN_RESET        1
>> +#define WDR7500V6_GPIO_BTN_TURBO        5
>> +
>> +#define WDR7500V6_KEYS_POLL_INTERVAL    20
>> +#define WDR7500V6_KEYS_DEBOUNCE_INTERVAL        \
>> +                (3 * WDR7500V6_KEYS_POLL_INTERVAL)
>> +
>> +
>> +static struct gpio_led wdr7500v6_leds_gpio[] __initdata = {
>> +        {
>> +                .name           = "wdr7500v6:blue:system",
>> +                .gpio           = WDR7500V6_GPIO_LED_SYSTEM,
>> +                .active_low     = 1,
>> +        },
>> +        {
>> +                .name           = "wdr7500v6:green:turbo",
>> +                .gpio           = WDR7500V6_GPIO_LED_TURBO,
>> +                .active_low     = 1,
>> +        },
>> +};
>> +
>> +static struct gpio_keys_button wdr7500v6_gpio_keys[] __initdata = {
>> +        {
>> +                .desc           = "reset",
>> +                .type           = EV_KEY,
>> +                .code           = KEY_RESTART,
>> +                .debounce_interval = WDR7500V6_KEYS_DEBOUNCE_INTERVAL,
>> +                .gpio           = WDR7500V6_GPIO_BTN_RESET,
>> +                .active_low     = 1,
>> +        },
>> + {
>> + .desc = "turbo",
>> + .type = EV_KEY,
>> + .debounce_interval = WDR7500V6_KEYS_DEBOUNCE_INTERVAL,
>> + .gpio = WDR7500V6_GPIO_BTN_TURBO,
>> + .active_low = 1,
>> + },
>> +};
>> +
>> +static void __init tl_wdr7500_v6_setup(void)
>> +{
>> + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
>> +
>> + ath79_register_m25p80(NULL);
>> +
>> + ath79_register_mdio(0, 0x0);
>> +
>> + /* GMAC0 is connected to RTL8367S switch */
>> + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
>> + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
>> + ath79_eth0_data.speed = SPEED_1000;
>> + ath79_eth0_data.duplex = DUPLEX_FULL;
>> +
>> + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
>> + ath79_register_eth(0);
>> +
>> + ath79_register_wmac(mac + 0x1000, NULL);
>> +
>> + ap91_pci_init(mac + 0x2000, NULL);
>> +
>> + ath79_gpio_direction_select(WDR7500V6_GPIO_LED_SYSTEM, true);
>> + ath79_gpio_direction_select(WDR7500V6_GPIO_LED_TURBO , true);
>> +
>> + /* Turn off LEDs on boot */
>> + gpio_set_value(WDR7500V6_GPIO_LED_SYSTEM, 1);
>> + gpio_set_value(WDR7500V6_GPIO_LED_TURBO , 1);
>> +
>> + ath79_gpio_output_select(WDR7500V6_GPIO_LED_SYSTEM, 0);
>> + ath79_gpio_output_select(WDR7500V6_GPIO_LED_TURBO , 0);
>> +
>> + ath79_register_gpio_keys_polled(-1, WDR7500V6_KEYS_POLL_INTERVAL,
>> + ARRAY_SIZE(wdr7500v6_gpio_keys),
>> + wdr7500v6_gpio_keys);
>> +
>> +        ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr7500v6_leds_gpio),
>> +                                 wdr7500v6_leds_gpio);
>> +
>> +
>> +}
>> +
>> +MIPS_MACHINE(ATH79_MACH_TL_WDR7500_V6, "TL-WDR7500-V6", "TP-LINK
>> TL-WDR7500 v6", tl_wdr7500_v6_setup);
>>
>> _______________________________________________
>> Lede-dev mailing list
>> Lede-dev at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/lede-dev



More information about the Lede-dev mailing list