From f478fba663d3ea1bf919137277b9a81344006173 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Thu, 18 Aug 2016 00:05:03 +0200 Subject: [PATCH] ar71xx: add support for Zbtlink ZBT-WE1526 Zbtlink ZBT-WE1526 is based on Qualcomm Atheros QCA9531 v2. Short specification: - 650/400/200 MHz (CPU/DDR/AHB) - 5x 10/100 Mbps Ethernet - 1x USB 2.0 - 128 MB of RAM (DDR2) - 16 MB of FLASH - 2T2R 2.4 GHz, up to 22 dBm - two external, non-detachable antennas - 8x LED, 1x button - UART header (pinout: VCC, RX, TX, GND) Flash instruction: Use sysupgrade in vendor firmare which is based on OpenWrt. Signed-off-by: Piotr Dymacz --- .../ar71xx/base-files/etc/board.d/01_leds | 9 ++ .../ar71xx/base-files/etc/board.d/02_network | 3 +- target/linux/ar71xx/base-files/etc/diag.sh | 3 + target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 + .../ar71xx/base-files/lib/upgrade/platform.sh | 1 + target/linux/ar71xx/config-4.4 | 1 + .../files/arch/mips/ath79/Kconfig.openwrt | 10 ++ .../ar71xx/files/arch/mips/ath79/Makefile | 1 + .../files/arch/mips/ath79/mach-zbt-we1526.c | 153 ++++++++++++++++++ .../ar71xx/files/arch/mips/ath79/machtypes.h | 1 + target/linux/ar71xx/image/legacy-devices.mk | 6 + target/linux/ar71xx/image/legacy.mk | 1 + 12 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-zbt-we1526.c 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 d731130540..cf05859813 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -813,6 +813,15 @@ wzr-hp-g300nh) ucidef_set_led_usbdev "usb" "USB" "buffalo:blue:usb" "1-1" ;; +zbt-we1526) + ucidef_set_led_netdev "wan" "WAN" "zbt-we1526:green:wan" "eth1" + ucidef_set_led_switch "lan1" "LAN1" "zbt-we1526:green:lan1" "switch0" "0x10" + ucidef_set_led_switch "lan2" "LAN2" "zbt-we1526:green:lan2" "switch0" "0x08" + ucidef_set_led_switch "lan3" "LAN3" "zbt-we1526:green:lan3" "switch0" "0x04" + ucidef_set_led_switch "lan4" "LAN4" "zbt-we1526:green:lan4" "switch0" "0x02" + ucidef_set_led_wlan "wlan" "WLAN" "zbt-we1526:green:wlan" "phy0tpt" + ;; + zcn-1523h-2) ucidef_set_led_netdev "lan1" "lan1" "zcn-1523h:green:lan1" "eth0" ;; 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 11e78a687c..f185e059b2 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -479,7 +479,8 @@ tl-wr842n-v3 |\ whr-g301n |\ whr-hp-g300n |\ whr-hp-gn |\ -wzr-hp-ag300h) +wzr-hp-ag300h |\ +zbt-we1526) ucidef_set_interfaces_lan_wan "eth0" "eth1" ucidef_add_switch "switch0" \ "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 71ebf89cd9..69ef609332 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -426,6 +426,9 @@ get_status_led() { wrt160nl) status_led="wrt160nl:blue:wps" ;; + zbt-we1526) + status_led="zbt-we1526:green:status" + ;; zcn-1523h-2 | zcn-1523h-5) status_led="zcn-1523h:amber:init" ;; diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 1e7427d446..e57701ab53 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -1098,6 +1098,9 @@ ar71xx_board_detect() { *WHR-HP-G300N) name="whr-hp-g300n" ;; + *ZBT-WE1526) + name="zbt-we1526" + ;; *ZCN-1523H-2) name="zcn-1523h-2" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index c02e5e775e..716fa525a9 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -198,6 +198,7 @@ platform_check_image() { mr12 | \ mr16 | \ wpj558 | \ + zbt-we1526 | \ zcn-1523h-2 | \ zcn-1523h-5) [ "$magic_long" != "68737173" -a "$magic_long" != "19852003" ] && { diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4 index 5878b7a52b..a984b1e1cd 100644 --- a/target/linux/ar71xx/config-4.4 +++ b/target/linux/ar71xx/config-4.4 @@ -201,6 +201,7 @@ CONFIG_ATH79_MACH_WZR_HP_AG300H=y CONFIG_ATH79_MACH_WZR_HP_G300NH=y CONFIG_ATH79_MACH_WZR_HP_G300NH2=y CONFIG_ATH79_MACH_WZR_HP_G450H=y +CONFIG_ATH79_MACH_ZBT_WE1526=y CONFIG_ATH79_MACH_ZCN_1523H=y CONFIG_ATH79_NVRAM=y CONFIG_ATH79_PCI_ATH9K_FIXUP=y diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt index a0ceecbb14..a6f19daa0d 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt @@ -1552,6 +1552,16 @@ config ATH79_MACH_MYNET_REXT select ATH79_DEV_WMAC select ATH79_NVRAM +config ATH79_MACH_ZBT_WE1526 + bool "Zbtlink ZBT-WE1526 board 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_USB + select ATH79_DEV_WMAC + config ATH79_MACH_ZCN_1523H bool "Zcomax ZCN-1523H support" select SOC_AR724X diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile index ff4fe9f27b..3222a76660 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile @@ -205,6 +205,7 @@ obj-$(CONFIG_ATH79_MACH_WZR_HP_G300NH2) += mach-wzr-hp-g300nh2.o obj-$(CONFIG_ATH79_MACH_WZR_HP_AG300H) += mach-wzr-hp-ag300h.o obj-$(CONFIG_ATH79_MACH_WZR_HP_G450H) += mach-wzr-hp-g450h.o obj-$(CONFIG_ATH79_MACH_WZR_450HP2) += mach-wzr-450hp2.o +obj-$(CONFIG_ATH79_MACH_ZBT_WE1526) += mach-zbt-we1526.o obj-$(CONFIG_ATH79_MACH_ZCN_1523H) += mach-zcn-1523h.o obj-$(CONFIG_ATH79_MACH_CARAMBOLA2) += mach-carambola2.o obj-$(CONFIG_ATH79_MACH_NBG6716) += mach-nbg6716.o diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-zbt-we1526.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-zbt-we1526.c new file mode 100644 index 0000000000..42bad11905 --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-zbt-we1526.c @@ -0,0 +1,153 @@ +/* + * Zbtlink ZBT-WE1526 board support + * + * Copyright (C) 2016 Piotr Dymacz + * + * Based on mach-dr531.c and mach-tl-wr841n-v9.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 +#include + +#include +#include + +#include "common.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 ZBT_WE1526_GPIO_LED_STATUS 13 +#define ZBT_WE1526_GPIO_LED_LAN1 16 +#define ZBT_WE1526_GPIO_LED_LAN2 15 +#define ZBT_WE1526_GPIO_LED_LAN3 14 +#define ZBT_WE1526_GPIO_LED_LAN4 11 +#define ZBT_WE1526_GPIO_LED_WAN 4 +#define ZBT_WE1526_GPIO_LED_WLAN 12 + +#define ZBT_WE1526_GPIO_BTN_RESET 17 + +#define ZBT_WE1526_KEYS_POLL_INTERVAL 20 /* msecs */ +#define ZBT_WE1526_KEYS_DEBOUNCE_INTERVAL \ + (3 * ZBT_WE1526_KEYS_POLL_INTERVAL) + +#define ZBT_WE1526_MAC0_OFFSET 0x0 +#define ZBT_WE1526_MAC1_OFFSET 0x6 +#define ZBT_WE1526_WMAC_CALDATA_OFFSET 0x1000 + +static struct gpio_led zbt_we1526_leds_gpio[] __initdata = { + { + .name = "zbt-we1526:green:status", + .gpio = ZBT_WE1526_GPIO_LED_STATUS, + .active_low = 1, + }, + { + .name = "zbt-we1526:green:lan1", + .gpio = ZBT_WE1526_GPIO_LED_LAN1, + .active_low = 1, + }, + { + .name = "zbt-we1526:green:lan2", + .gpio = ZBT_WE1526_GPIO_LED_LAN2, + .active_low = 1, + }, + { + .name = "zbt-we1526:green:lan3", + .gpio = ZBT_WE1526_GPIO_LED_LAN3, + .active_low = 1, + }, + { + .name = "zbt-we1526:green:lan4", + .gpio = ZBT_WE1526_GPIO_LED_LAN4, + .active_low = 1, + }, + { + .name = "zbt-we1526:green:wan", + .gpio = ZBT_WE1526_GPIO_LED_WAN, + .active_low = 1, + }, + { + .name = "zbt-we1526:green:wlan", + .gpio = ZBT_WE1526_GPIO_LED_WLAN, + .active_low = 1, + }, +}; + +static struct gpio_keys_button zbt_we1526_gpio_keys[] __initdata = { + { + .desc = "reset", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = ZBT_WE1526_KEYS_DEBOUNCE_INTERVAL, + .gpio = ZBT_WE1526_GPIO_BTN_RESET, + .active_low = 1, + }, +}; + +static void __init zbt_we1526_gpio_setup(void) +{ + /* For LED on GPIO4 */ + ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN); + ath79_gpio_output_select(ZBT_WE1526_GPIO_LED_WAN, 0); + + ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_STATUS, true); + ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN1, true); + ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN2, true); + ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN3, true); + ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN4, true); + ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_WAN, true); + ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_WLAN, true); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(zbt_we1526_leds_gpio), + zbt_we1526_leds_gpio); + + ath79_register_gpio_keys_polled(-1, ZBT_WE1526_KEYS_POLL_INTERVAL, + ARRAY_SIZE(zbt_we1526_gpio_keys), + zbt_we1526_gpio_keys); +} + +static void __init zbt_we1526_setup(void) +{ + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); + + ath79_register_m25p80(NULL); + + zbt_we1526_gpio_setup(); + + ath79_setup_ar933x_phy4_switch(false, false); + + ath79_register_mdio(0, 0x0); + + /* LAN */ + ath79_eth1_data.duplex = DUPLEX_FULL; + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; + ath79_switch_data.phy_poll_mask |= BIT(4); + ath79_init_mac(ath79_eth1_data.mac_addr, + art + ZBT_WE1526_MAC0_OFFSET, 0); + ath79_register_eth(1); + + /* WAN */ + ath79_switch_data.phy4_mii_en = 1; + ath79_eth0_data.duplex = DUPLEX_FULL; + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; + ath79_eth0_data.phy_mask = BIT(4); + ath79_eth0_data.speed = SPEED_100; + ath79_init_mac(ath79_eth0_data.mac_addr, + art + ZBT_WE1526_MAC1_OFFSET, 0); + ath79_register_eth(0); + + ath79_register_wmac(art + ZBT_WE1526_WMAC_CALDATA_OFFSET, NULL); + + ath79_register_usb(); +} + +MIPS_MACHINE(ATH79_MACH_ZBT_WE1526, "ZBT-WE1526", "Zbtlink ZBT-WE1526", + zbt_we1526_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h index 3051a2572b..a3b8c8749d 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h @@ -266,6 +266,7 @@ enum ath79_mach_type { ATH79_MACH_WZR_HP_G300NH2, /* Buffalo WZR-HP-G300NH2 */ ATH79_MACH_WZR_HP_G450H, /* Buffalo WZR-HP-G450H */ ATH79_MACH_WZR_450HP2, /* Buffalo WZR-450HP2 */ + ATH79_MACH_ZBT_WE1526, /* Zbtlink ZBT-WE1526 */ ATH79_MACH_ZCN_1523H_2, /* Zcomax ZCN-1523H-2-xx */ ATH79_MACH_ZCN_1523H_5, /* Zcomax ZCN-1523H-5-xx */ }; diff --git a/target/linux/ar71xx/image/legacy-devices.mk b/target/linux/ar71xx/image/legacy-devices.mk index 1d295f1006..72114cdce9 100644 --- a/target/linux/ar71xx/image/legacy-devices.mk +++ b/target/linux/ar71xx/image/legacy-devices.mk @@ -705,6 +705,12 @@ define LegacyDevice/WZR450HP2 endef LEGACY_DEVICES += WZR450HP2 +define LegacyDevice/ZBTWE1526 + DEVICE_TITLE := Zbtlink ZBT-WE1526 + DEVICE_PACKAGES := kmod-usb-core kmod-usb2 +endef +LEGACY_DEVICES += ZBTWE1526 + define LegacyDevice/ZCN1523H28 DEVICE_TITLE := Zcomax ZCN-1523H-2-8 endef diff --git a/target/linux/ar71xx/image/legacy.mk b/target/linux/ar71xx/image/legacy.mk index c2daba9f60..03af6582c4 100644 --- a/target/linux/ar71xx/image/legacy.mk +++ b/target/linux/ar71xx/image/legacy.mk @@ -964,6 +964,7 @@ $(eval $(call SingleProfile,AthLzma,64k,WPJ558_16M,wpj558-16M,WPJ558,ttyS0,11520 $(eval $(call SingleProfile,AthLzma,64k,WRTNODE2Q,wrtnode2q,WRTNODE2Q,ttyS0,115200,$$(wrtnode2q_mtdlayout),KRuImage)) $(eval $(call SingleProfile,AthLzma,64k,YUN_8M,yun-8M,Yun,ttyATH0,250000,$$(yun_mtdlayout_8M),RKuImage)) $(eval $(call SingleProfile,AthLzma,64k,YUN_16M,yun-16M,Yun,ttyATH0,250000,$$(yun_mtdlayout_16M),RKuImage)) +$(eval $(call SingleProfile,AthLzma,64k,ZBTWE1526,zbt-we1526,ZBT-WE1526,ttyS0,115200,$$(ap147_mtdlayout),RKuImage)) $(eval $(call SingleProfile,Belkin,64k,F9K1115V2,f9k1115v2,F9K1115V2,ttyS0,115200,$$(f9k1115v2_mtdlayout),BR-6679BAC)) -- 2.30.2