From 53ef20f65acdcd068b1166d2522dcbe7d7e298c4 Mon Sep 17 00:00:00 2001 From: Shuanglin Liu Date: Fri, 3 Mar 2017 01:23:50 +0800 Subject: [PATCH] ar71xx: add support for Rockeetech AP531B0 Specification: - SoC: Qualcomm Atheros QCA9531 (650/400/216 MHz (CPU/DDR/AHB)) - RAM: 64 MiB DDR2 - Storage: 16 MiB of flash (optional 16 MiB second flash) - Wireless: built into QCA9531 (Honey Bee), PHY modes b/g/n - Ethernet: 1x100M (port0) 1x100M (port 4) - PCI-E: x1 - SIMcard slot: x1 - USB 2.0 port: x1 (optional) - Ext GPIO pin: x8 - UART for serial console: x1 - External watchdog: x1 (optional) - Power supply: 9-48V (DC jack/passive PoE) Installation through tftp: - Copy into tftp directory - Connect board via ttl port and Ethernet port - Boot the AP531B0 - When "Autobooting in 1 seconds" appears press Enter - Set serverip and ipaddr appropriate (e.g. setenv serverip 192.168.88.10;setenv ipaddr 192.168.88.1) - Enter "tftp 0x8050000 " - Enter "erase 0x9f050000 +$filesize" - Enter "cp.b 0x80500000 0x9f050000 $filesize" - Enter "reset" Signed-off-by: Shuanglin Liu --- .../ar71xx/base-files/etc/board.d/01_leds | 9 +- target/linux/ar71xx/base-files/etc/diag.sh | 1 + 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 | 12 ++ .../ar71xx/files/arch/mips/ath79/Makefile | 1 + .../files/arch/mips/ath79/mach-ap531b0.c | 112 ++++++++++++++++++ .../ar71xx/files/arch/mips/ath79/machtypes.h | 1 + target/linux/ar71xx/image/generic.mk | 9 ++ target/linux/ar71xx/mikrotik/config-default | 1 + target/linux/ar71xx/nand/config-default | 1 + 12 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ap531b0.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 0ed533dddb..32d49318e6 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -49,6 +49,11 @@ antrouter-r1) ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt" ucidef_set_led_default "btc" "BTC" "$board:green:btc" "0" ;; +ap531b0|\ +sc1750|\ +sc450) + ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt" + ;; archer-c59-v1|\ archer-c60-v1) ucidef_set_led_switch "lan" "LAN" "$board:green:lan" "switch0" "0x1E" @@ -490,10 +495,6 @@ re450) ucidef_set_led_wlan "wlan2g" "WLAN 2.4 GHz" "$board:blue:wlan2g" "phy1tpt" ucidef_set_led_wlan "wlan5g" "WLAN 5 GHz" "$board:blue:wlan5g" "phy0tpt" ;; -sc1750|\ -sc450) - ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt" - ;; smart-300) ucidef_set_led_netdev "wan" "WAN" "nc-link:green:wan" "eth0" ucidef_set_led_switch "lan1" "LAN1" "nc-link:green:lan1" "switch0" "0x04" diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 7987e51a67..461d0daf4b 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -31,6 +31,7 @@ get_status_led() { status_led="$board:green:system" ;; ap132|\ + ap531b0|\ db120|\ dr344|\ tew-632brp|\ diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index ae0189d05b..4a0c85d631 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -458,6 +458,9 @@ ar71xx_board_detect() { *"AP152 reference board") name="ap152" ;; + *AP531B0) + name="ap531b0" + ;; *AP90Q) name="ap90q" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 576ff6c06c..f89ad2cda9 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -204,6 +204,7 @@ platform_check_image() { airgateway|\ airrouter|\ ap132|\ + ap531b0|\ ap90q|\ archer-c59-v1|\ archer-c60-v1|\ diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4 index 206ace62f7..68b408a65b 100644 --- a/target/linux/ar71xx/config-4.4 +++ b/target/linux/ar71xx/config-4.4 @@ -47,6 +47,7 @@ CONFIG_ATH79_MACH_AP136=y CONFIG_ATH79_MACH_AP143=y CONFIG_ATH79_MACH_AP147=y CONFIG_ATH79_MACH_AP152=y +CONFIG_ATH79_MACH_AP531B0=y # CONFIG_ATH79_MACH_AP81 is not set CONFIG_ATH79_MACH_AP90Q=y CONFIG_ATH79_MACH_AP96=y diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt index 514d05d6de..72f3591bbe 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt @@ -183,6 +183,18 @@ config ATH79_MACH_AP152 select ATH79_DEV_WMAC select ATH79_DEV_AP9X_PCI if PCI +config ATH79_MACH_AP531B0 + bool "Rockeetech AP531B0 support" + select SOC_QCA953X + 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_SPI + select ATH79_DEV_USB + select ATH79_DEV_WMAC + config ATH79_MACH_AP90Q bool "YunCore AP90Q support" select SOC_QCA953X diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile index 64752591d5..73832448cd 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile @@ -53,6 +53,7 @@ obj-$(CONFIG_ATH79_MACH_AP136) += mach-ap136.o obj-$(CONFIG_ATH79_MACH_AP143) += mach-ap143.o obj-$(CONFIG_ATH79_MACH_AP147) += mach-ap147.o obj-$(CONFIG_ATH79_MACH_AP152) += mach-ap152.o +obj-$(CONFIG_ATH79_MACH_AP531B0) += mach-ap531b0.o obj-$(CONFIG_ATH79_MACH_AP90Q) += mach-ap90q.o obj-$(CONFIG_ATH79_MACH_AP96) += mach-ap96.o obj-$(CONFIG_ATH79_MACH_ARCHER_C59_V1) += mach-archer-c59-v1.o diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-ap531b0.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-ap531b0.c new file mode 100644 index 0000000000..3cb2697955 --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-ap531b0.c @@ -0,0 +1,112 @@ +/* + * Rockeetech AP531B0 11ng wireless AP board support + * + * Copyright (C) 2013 Gabor Juhos + * Copyright (C) 2016 Shuanglin Liu + * + * 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-spi.h" +#include "dev-usb.h" +#include "dev-wmac.h" +#include "machtypes.h" +#include "pci.h" +#include "dev-ap9x-pci.h" + +#define AP531B0_GPIO_LED_WLAN 12 +#define AP531B0_GPIO_LED_STATUS 11 + +#define AP531B0_GPIO_RST_BTN 17 + +#define AP531B0_KEYS_POLL_INTERVAL 20 /* msecs */ +#define AP531B0_KEYS_DEBOUNCE_INTERVAL (3 * AP531B0_KEYS_POLL_INTERVAL) + +#define AP531B0_WMAC_CALDATA_OFFSET 0x1000 + + +static struct gpio_led ap531b0_leds_gpio[] __initdata = { + { + .name = "ap531b0:green:status", + .gpio = AP531B0_GPIO_LED_STATUS, + .active_low = 1, + }, + { + .name = "ap531b0:green:wlan", + .gpio = AP531B0_GPIO_LED_WLAN, + .active_low = 1, + } +}; + +static struct gpio_keys_button ap531b0_gpio_keys[] __initdata = { + { + .desc = "reset", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = AP531B0_KEYS_DEBOUNCE_INTERVAL, + .gpio = AP531B0_GPIO_RST_BTN, + .active_low = 1, + }, +}; + + +static void __init ap531b0_gpio_led_setup(void) +{ + + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap531b0_leds_gpio), + ap531b0_leds_gpio); + + ath79_register_gpio_keys_polled(-1, AP531B0_KEYS_POLL_INTERVAL, + ARRAY_SIZE(ap531b0_gpio_keys), + ap531b0_gpio_keys); +} + +static void __init ap531b0_setup(void) +{ + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); + u8 *pmac; + + ath79_register_m25p80(NULL); + ap531b0_gpio_led_setup(); + ath79_register_usb(); + ath79_register_pci(); + + ath79_register_mdio(0, 0x0); + + pmac = art + AP531B0_WMAC_CALDATA_OFFSET + 2; + ath79_init_mac(ath79_eth0_data.mac_addr, pmac, 1); + ath79_init_mac(ath79_eth1_data.mac_addr, pmac, 2); + + ath79_register_wmac(art + AP531B0_WMAC_CALDATA_OFFSET, pmac); + + /* WAN port */ + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; + ath79_eth0_data.speed = SPEED_100; + ath79_eth0_data.duplex = DUPLEX_FULL; + ath79_eth0_data.phy_mask = BIT(4); + ath79_register_eth(0); + + /* LAN ports */ + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; + ath79_eth1_data.speed = SPEED_1000; + ath79_eth1_data.duplex = DUPLEX_FULL; + ath79_switch_data.phy_poll_mask |= BIT(4); + ath79_switch_data.phy4_mii_en = 1; + ath79_register_eth(1); +} + +MIPS_MACHINE(ATH79_MACH_AP531B0, "AP531B0", "Rockeetech AP531B0", + ap531b0_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h index 4cad6287a8..f3277cd2a0 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h @@ -37,6 +37,7 @@ enum ath79_mach_type { ATH79_MACH_AP143, /* Atheros AP143 reference board */ ATH79_MACH_AP147_010, /* Atheros AP147-010 reference board */ ATH79_MACH_AP152, /* Atheros AP152 reference board */ + ATH79_MACH_AP531B0, /* Rockeetech AP531B0 */ ATH79_MACH_AP90Q, /* YunCore AP90Q */ ATH79_MACH_AP96, /* Atheros AP96 */ ATH79_MACH_ARCHER_C5, /* TP-LINK Archer C5 board */ diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk index 02f074796e..34bb7da84d 100644 --- a/target/linux/ar71xx/image/generic.mk +++ b/target/linux/ar71xx/image/generic.mk @@ -1,3 +1,12 @@ +define Device/ap531b0 + DEVICE_TITLE := Rockeetech AP531B0 + DEVICE_PACKAGES := kmod-usb-core kmod-usb2 + BOARDNAME = AP531B0 + IMAGE_SIZE := 16000k + MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,16000k(firmware),64k(art)ro +endef +TARGET_DEVICES += ap531b0 + define Device/ap90q DEVICE_TITLE := YunCore AP90Q BOARDNAME = AP90Q diff --git a/target/linux/ar71xx/mikrotik/config-default b/target/linux/ar71xx/mikrotik/config-default index 733914983e..cf6f754c84 100644 --- a/target/linux/ar71xx/mikrotik/config-default +++ b/target/linux/ar71xx/mikrotik/config-default @@ -13,6 +13,7 @@ # CONFIG_ATH79_MACH_AP143 is not set # CONFIG_ATH79_MACH_AP147 is not set # CONFIG_ATH79_MACH_AP152 is not set +# CONFIG_ATH79_MACH_AP531B0 is not set # CONFIG_ATH79_MACH_AP90Q is not set # CONFIG_ATH79_MACH_AP96 is not set # CONFIG_ATH79_MACH_ARCHER_C59_V1 is not set diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default index 14504a4b3c..24e712c18b 100644 --- a/target/linux/ar71xx/nand/config-default +++ b/target/linux/ar71xx/nand/config-default @@ -13,6 +13,7 @@ # CONFIG_ATH79_MACH_AP143 is not set # CONFIG_ATH79_MACH_AP147 is not set # CONFIG_ATH79_MACH_AP152 is not set +# CONFIG_ATH79_MACH_AP531B0 is not set # CONFIG_ATH79_MACH_AP90Q is not set # CONFIG_ATH79_MACH_AP96 is not set # CONFIG_ATH79_MACH_ARCHER_C59_V1 is not set