ar71xx: add support for ALFA Network AP91-5G
authorPiotr Dymacz <pepe2k@gmail.com>
Mon, 18 Dec 2017 13:51:28 +0000 (14:51 +0100)
committerPiotr Dymacz <pepe2k@gmail.com>
Sun, 14 Jan 2018 19:33:18 +0000 (20:33 +0100)
ALFA Network AP91-5G is a 5 GHz outdoor AP/CPE board, based on Atheros
AR7240 + AR9280.

Specification:

- 400/400/200 MHz (CPU/DDR/AHB)
- 32 MB of RAM (DDR1)
- 8 MB of FLASH (SPI NOR)
- 1x 10/100 Mbps Ethernet, with passive PoE support (24 V)
- 1T1R 5 GHz (AR9280), with ext. PA (SE5004L) and LNA, up to 27 dBm
- 6x LED (5 are driven by GPIO)
- 1x button (reset)
- external h/w watchdog (EM6324QYSP5B, disabled and not used)
- header for optional 802.3at/af PoE module
- DC jack for main power input (optional, not installed by default)
- UART and LEDs headers on PCB

Flash instruction:

Use "factory" image in vendor GUI (in case of problems, make sure your
board has up to date firmware). Alternatively, TFTP in U-Boot can be
used: select option "2. Load system code then write to Flash via TFTP"
during early boot and use "sysupgrade" image.

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
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/config-4.9
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-ap91-5g.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
target/linux/ar71xx/generic/config-default
target/linux/ar71xx/image/generic.mk

index e5baa90db896025961080723610a539d65ab6ba5..97bf33052cfcd86344c54ffd1f2300df4cdbb078 100755 (executable)
@@ -129,6 +129,14 @@ dr531)
                ;;
        esac
        ;;
+ap91-5g)
+       ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth0"
+       ucidef_set_rssimon "wlan0" "200000" "1"
+       ucidef_set_led_rssi "signal1" "SIGNAL1" "$board:red:signal1" "wlan0" "1" "100"
+       ucidef_set_led_rssi "signal2" "SIGNAL2" "$board:orange:signal2" "wlan0" "25" "100"
+       ucidef_set_led_rssi "signal3" "SIGNAL3" "$board:green:signal3" "wlan0" "50" "100"
+       ucidef_set_led_rssi "signal4" "SIGNAL4" "$board:green:signal4" "wlan0" "75" "100"
+       ;;
 bhr-4grv2)
        ucidef_set_led_default "power" "POWER" "buffalo:green:power" "1"
        ucidef_set_led_default "diag" "DIAG" "buffalo:red:diag" "0"
index fb61792bf41ab0c3f9c2046d30de39a8254f551b..461b72f4d7d8305c082f7f76771174bca4de1d39 100755 (executable)
@@ -64,6 +64,7 @@ ar71xx_setup_interfaces()
        antminer-s3|\
        antrouter-r1|\
        ap121f|\
+       ap91-5g|\
        aw-nr580|\
        bullet-m|\
        c-55|\
index 6cbb3576d8f4675041ba4de70f9e5c787a6b93d6..2f2d2c310349a458a519a8e0147cb7edc8ec759f 100644 (file)
@@ -80,6 +80,9 @@ get_status_led() {
        gl-mifi)
                status_led="$board:green:lan"
                ;;
+       ap91-5g)
+               status_led="$board:green:signal4"
+               ;;
        ap96)
                status_led="$board:green:led2"
                ;;
index b5440230a503c96771fc24276fa21c71f6fe7322..e90d89e20e61beff4b302b841d09c66101abaff5 100755 (executable)
@@ -446,6 +446,9 @@ ar71xx_board_detect() {
        *"AP90Q")
                name="ap90q"
                ;;
+       *"AP91-5G")
+               name="ap91-5g"
+               ;;
        *"Archer C25 v1")
                name="archer-c25-v1"
                ;;
index ecf6820a2b7cc53978990b50fa04d1ddb3eb146c..37c637b6f581341a206db747e78622192c6b46ae 100755 (executable)
@@ -310,6 +310,7 @@ platform_check_image() {
        ap136-020|\
        ap147-010|\
        ap152|\
+       ap91-5g|\
        ap96|\
        arduino-yun|\
        bhr-4grv2|\
index 8478368062621a4b747566ec8fb24eea4b30da62..44af80d0f32ee3b1ba0e8a7ad865206f283c0f86 100644 (file)
@@ -49,6 +49,7 @@ CONFIG_ATH79=y
 # CONFIG_ATH79_MACH_AP531B0 is not set
 # CONFIG_ATH79_MACH_AP81 is not set
 # CONFIG_ATH79_MACH_AP90Q is not set
+# CONFIG_ATH79_MACH_AP91_5G is not set
 # CONFIG_ATH79_MACH_AP96 is not set
 # CONFIG_ATH79_MACH_ARCHER_C25_V1 is not set
 # CONFIG_ATH79_MACH_ARCHER_C58_V1 is not set
index 854c14a0f02e4f91be83ee2872a9ddde1a4aecc0..401c41e4933c1a774d5f4e870832859be80abb9f 100644 (file)
@@ -47,6 +47,7 @@ CONFIG_ATH79=y
 # CONFIG_ATH79_MACH_AP531B0 is not set
 # CONFIG_ATH79_MACH_AP81 is not set
 # CONFIG_ATH79_MACH_AP90Q is not set
+# CONFIG_ATH79_MACH_AP91_5G is not set
 # CONFIG_ATH79_MACH_AP96 is not set
 # CONFIG_ATH79_MACH_ARCHER_C25_V1 is not set
 # CONFIG_ATH79_MACH_ARCHER_C58_V1 is not set
index 1198fcb74bd15b630f01b5573bc3c50e81fa60e5..f2717e86e997b588074a94a8d9ae5890048978ca 100644 (file)
@@ -225,6 +225,15 @@ config ATH79_MACH_AP90Q
        select ATH79_DEV_M25P80
        select ATH79_DEV_WMAC
 
+config ATH79_MACH_AP91_5G
+       bool "ALFA Network AP91-5G support"
+       select SOC_AR724X
+       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
+
 config ATH79_MACH_AP96
        bool "Atheros AP96 board support"
        select SOC_AR71XX
index 455af762e334f8fee59ed286b8fb9e8159c919a7..0e581005d7d66172dc9bddabe2943dbefb373720 100644 (file)
@@ -57,6 +57,7 @@ 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_AP91_5G)               += mach-ap91-5g.o
 obj-$(CONFIG_ATH79_MACH_AP96)                  += mach-ap96.o
 obj-$(CONFIG_ATH79_MACH_ARCHER_C25_V1)         += mach-archer-c25-v1.o
 obj-$(CONFIG_ATH79_MACH_ARCHER_C58_V1)         += mach-archer-c59-v1.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-ap91-5g.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-ap91-5g.c
new file mode 100644 (file)
index 0000000..64b9430
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * ALFA Network AP91-5G board support
+ *
+ * Copyright (C) 2018 Piotr Dymacz <pepe2k@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 <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 "machtypes.h"
+
+#define AP91_5G_GPIO_LED_LAN           17
+#define AP91_5G_GPIO_LED_SIGNAL1       12
+#define AP91_5G_GPIO_LED_SIGNAL2       8
+#define AP91_5G_GPIO_LED_SIGNAL3       6
+#define AP91_5G_GPIO_LED_SIGNAL4       7
+
+#define AP91_5G_GPIO_WDT_EN            1
+#define AP91_5G_GPIO_WDT_IN            0
+
+#define AP91_5G_GPIO_BTN_RESET         11
+
+#define AP91_5G_KEYS_POLL_INTERVAL     20
+#define AP91_5G_KEYS_DEBOUNCE_INTERVAL (3 * AP91_5G_KEYS_POLL_INTERVAL)
+
+#define AP91_5G_WMAC_CALDATA_OFFSET    0x1000
+
+static struct gpio_led ap91_5g_leds_gpio[] __initdata = {
+       {
+               .name           = "ap91-5g:green:lan",
+               .gpio           = AP91_5G_GPIO_LED_LAN,
+               .active_low     = 1,
+       }, {
+               .name           = "ap91-5g:red:signal1",
+               .gpio           = AP91_5G_GPIO_LED_SIGNAL1,
+               .active_low     = 1,
+       }, {
+               .name           = "ap91-5g:orange:signal2",
+               .gpio           = AP91_5G_GPIO_LED_SIGNAL2,
+               .active_low     = 1,
+       }, {
+               .name           = "ap91-5g:green:signal3",
+               .gpio           = AP91_5G_GPIO_LED_SIGNAL3,
+               .active_low     = 1,
+       }, {
+               .name           = "ap91-5g:green:signal4",
+               .gpio           = AP91_5G_GPIO_LED_SIGNAL4,
+               .active_low     = 1,
+       },
+};
+
+static struct gpio_keys_button ap91_5g_gpio_keys[] __initdata = {
+       {
+               .desc                   = "reset",
+               .type                   = EV_KEY,
+               .code                   = KEY_RESTART,
+               .debounce_interval      = AP91_5G_KEYS_DEBOUNCE_INTERVAL,
+               .gpio                   = AP91_5G_GPIO_BTN_RESET,
+               .active_low             = 1,
+       },
+};
+
+static void __init ap91_5g_setup(void)
+{
+       u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
+
+       ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
+                                 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
+
+       gpio_set_value(AP91_5G_GPIO_LED_LAN, 1);
+       gpio_set_value(AP91_5G_GPIO_LED_SIGNAL3, 1);
+       gpio_set_value(AP91_5G_GPIO_LED_SIGNAL4, 1);
+
+       ath79_register_m25p80(NULL);
+
+       ath79_register_mdio(0, 0x0);
+
+       /* LAN */
+       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, 0);
+       ath79_register_eth(0);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(ap91_5g_leds_gpio),
+                                ap91_5g_leds_gpio);
+
+       ath79_register_gpio_keys_polled(-1, AP91_5G_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(ap91_5g_gpio_keys),
+                                       ap91_5g_gpio_keys);
+
+       gpio_request_one(AP91_5G_GPIO_WDT_IN,
+                        GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
+                        "WDT input");
+
+       gpio_request_one(AP91_5G_GPIO_WDT_EN,
+                        GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
+                        "WDT enable");
+
+       ap91_pci_init(art + AP91_5G_WMAC_CALDATA_OFFSET, NULL);
+}
+
+MIPS_MACHINE(ATH79_MACH_AP91_5G, "AP91-5G", "ALFA Network AP91-5G",
+            ap91_5g_setup);
index 0f536f0ec5848e38e30891c0b9757991c910ebb0..c2cb8b612604db780dfe7b204b767f84e55d68fd 100644 (file)
@@ -41,6 +41,7 @@ enum ath79_mach_type {
        ATH79_MACH_AP152,                       /* Atheros AP152 reference board */
        ATH79_MACH_AP531B0,                     /* Rockeetech AP531B0 */
        ATH79_MACH_AP90Q,                       /* YunCore AP90Q */
+       ATH79_MACH_AP91_5G,                     /* ALFA Network AP91-5G */
        ATH79_MACH_AP96,                        /* Atheros AP96 */
        ATH79_MACH_ARCHER_C25_V1,               /* TP-LINK Archer C25 V1 board */
        ATH79_MACH_ARCHER_C5,                   /* TP-LINK Archer C5 board */
index d5b59b59453a71c2664930d2772040cde57a8ad0..e9bf6f3267a10ae90a3b9f9b03ea2e56f4841820 100644 (file)
@@ -25,6 +25,7 @@ CONFIG_ATH79_MACH_AP147=y
 CONFIG_ATH79_MACH_AP152=y
 CONFIG_ATH79_MACH_AP531B0=y
 CONFIG_ATH79_MACH_AP90Q=y
+CONFIG_ATH79_MACH_AP91_5G=y
 CONFIG_ATH79_MACH_AP96=y
 CONFIG_ATH79_MACH_ARCHER_C25_V1=y
 CONFIG_ATH79_MACH_ARCHER_C58_V1=y
index 89ab1f02917cf103fdf20eacb6fc5ae85381b204..d6515ac529c16f76a817645200c3b27084dea0a2 100644 (file)
@@ -1,5 +1,12 @@
 DEVICE_VARS += DAP_SIGNATURE NETGEAR_BOARD_ID NETGEAR_HW_ID NETGEAR_KERNEL_MAGIC ROOTFS_SIZE SEAMA_SIGNATURE
 
+define Build/alfa-network-rootfs-header
+       mkimage \
+               -A mips -O linux -T filesystem -C lzma -a 0 -e 0 \
+               -n 'RootfsImage' -d $@ $@.new
+       @mv $@.new $@
+endef
+
 define Build/mkbuffaloimg
        $(STAGING_DIR_HOST)/bin/mkbuffaloimg -B $(BOARDNAME) \
                -R $$(($(subst k, * 1024,$(ROOTFS_SIZE)))) \
@@ -105,6 +112,22 @@ define Device/ap90q
 endef
 TARGET_DEVICES += ap90q
 
+define Device/ap91-5g
+  DEVICE_TITLE := ALFA Network AP91-5G
+  DEVICE_PACKAGES := rssileds -swconfig
+  BOARDNAME := AP91-5G
+  IMAGE_SIZE := 7744k
+  KERNEL_SIZE := 1600k
+  ROOTFS_SIZE := 6144k
+  MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env),6144k(rootfs),1600k(kernel),64k(config)ro,64k(art)ro,7744k@0x50000(firmware)
+  IMAGES := sysupgrade.bin factory.bin
+  IMAGE/factory.bin := append-rootfs | pad-rootfs |\
+       alfa-network-rootfs-header | append-kernel | check-size $$$$(IMAGE_SIZE)
+  IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs |\
+       pad-to $$$$(ROOTFS_SIZE) | append-kernel | check-size $$$$(IMAGE_SIZE)
+endef
+TARGET_DEVICES += ap91-5g
+
 define Device/arduino-yun
   DEVICE_TITLE := Arduino Yun
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2