ar71xx: add support for Aerohive AP-121
authorChris Blake <chrisrblake93@gmail.com>
Thu, 27 Apr 2017 03:09:27 +0000 (22:09 -0500)
committerPiotr Dymacz <pepe2k@gmail.com>
Mon, 15 May 2017 20:58:59 +0000 (22:58 +0200)
This adds support for Aerohive AP-121 access point.

Specification:
- SoC: Atheros AR9344-BC2A at 560MHz
- WiFi 1: 2.4GHz Atheros AR9340? - SoC
- WiFi 2: 5.0GHz Atheros AR9382-AL1A
- Memory: 128MB from 2x Nanya NT5TU32M16DG-AC
- SPI: 1MB Macronix MX25L8006E
- NAND: 128MB Hynix H27U1G8F2BTR-BC
- Ethernet: Atheros AR8035-A
- USB: 1x 2.0
- TPM: Atmel SC3204

Flashing:
1. Hook into UART (9600 baud) and enter U-Boot. You may need to enter
a password of administrator or AhNf?d@ta06 if prompted.
2. Once in U-Boot, download and flash LEDE factory image over tftp:

dhcp;
setenv serverip tftp-server-ip;
tftpboot 0x81000000 lede-ar71xx-nand-hiveap-121-squashfs-factory.bin;
nand erase 0x800000 0x800000;
nand write 0x81000000 0x800000 0x800000;
reset;

Signed-off-by: Chris Blake <chrisrblake93@gmail.com>
[minor text changes in commit subject and description, fixed
alphabetical order in etc/diag.sh, use only model name in lib/ar71xx.sh,
fixed code style issues in mach-hiveap-121.c, ubinized factory image]
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
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-hiveap-121.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
target/linux/ar71xx/image/nand.mk
target/linux/ar71xx/nand/config-default

index 2a6dfa55bf7ba94ecb715327ad5a518fa0cad792..2737129eb64a56f64b8c57b24f11ef4f79fe41b4 100755 (executable)
@@ -74,6 +74,7 @@ ar71xx_setup_interfaces()
        eap300v2|\
        eap7660d|\
        el-mini|\
+       hiveap-121|\
        loco-m-xw|\
        mr12|\
        mr16|\
index cea95b7f4e6c3004e615f712f1120534d01ef79e..9cad8995dbb6db2a4d1318f8e143bd271677e5f6 100644 (file)
@@ -196,6 +196,10 @@ get_status_led() {
        esr900)
                status_led="engenius:amber:power"
                ;;
+       hiveap-121|\
+       nbg6716)
+               status_led="$board:white:power"
+               ;;
        hiwifi-hc6361)
                status_led="hiwifi:blue:system"
                ;;
@@ -248,9 +252,6 @@ get_status_led() {
        nbg460n_550n_550nh)
                status_led="nbg460n:green:power"
                ;;
-       nbg6716)
-               status_led="$board:white:power"
-               ;;
        om2p|\
        om2pv2|\
        om2pv4|\
index 5c3b1a7e1b601bb3bd7b42040a918be8e0de6391..a751c64a3ad4f7ff092db6ec7fbf2762519fab1a 100755 (executable)
@@ -651,6 +651,9 @@ ar71xx_board_detect() {
        *"GL-MIFI")
                name="gl-mifi"
                ;;
+       *"HiveAP-121")
+               name="hiveap-121"
+               ;;
        *"HiWiFi HC6361")
                name="hiwifi-hc6361"
                ;;
index 8ebdea3018918e578af6b27d9465d0324fc17530..e246f35addc252cc6ad075c52e518b4d50e57065 100755 (executable)
@@ -519,6 +519,7 @@ platform_check_image() {
                return $?
                ;;
        c-60|\
+       hiveap-121|\
        nbg6716|\
        r6100|\
        rambutan|\
@@ -662,6 +663,7 @@ platform_pre_upgrade() {
 
        case "$board" in
        c-60|\
+       hiveap-121|\
        nbg6716|\
        r6100|\
        rambutan|\
index 380254de41f7bc745ee99c9d53e71ad2f0e2283a..0a375862ba8836504e67e34d5638795b406d4376 100644 (file)
@@ -113,6 +113,7 @@ CONFIG_ATH79_MACH_GL_INET=y
 CONFIG_ATH79_MACH_GL_MIFI=y
 CONFIG_ATH79_MACH_GS_MINIBOX_V1=y
 CONFIG_ATH79_MACH_GS_OOLITE=y
+# CONFIG_ATH79_MACH_HIVEAP_121 is not set
 CONFIG_ATH79_MACH_HIWIFI_HC6361=y
 CONFIG_ATH79_MACH_HORNET_UB=y
 CONFIG_ATH79_MACH_JA76PF=y
index eb8219e363ea135a104bab99e4538f833b71b05f..9030954c277788ab1945882f363b34e14bbef24b 100644 (file)
@@ -796,6 +796,18 @@ config ATH79_MACH_GS_OOLITE
        select ATH79_DEV_USB
        select ATH79_DEV_WMAC
 
+config ATH79_MACH_HIVEAP_121
+       bool "Aerohive HiveAP-121 support"
+       select SOC_AR934X
+       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_NFC
+       select ATH79_DEV_USB
+       select ATH79_DEV_WMAC
+
 config ATH79_MACH_HIWIFI_HC6361
        bool "HiWiFi HC6361 board support"
        select SOC_AR933X
index f5030022883764a3a4aacb3aa96b48b55946b313..2868adcaef56fea7cb4296083f410f65123bc351 100644 (file)
@@ -117,6 +117,7 @@ obj-$(CONFIG_ATH79_MACH_GL_INET)            += mach-gl-inet.o
 obj-$(CONFIG_ATH79_MACH_GL_MIFI)               += mach-gl-mifi.o
 obj-$(CONFIG_ATH79_MACH_GS_MINIBOX_V1)         += mach-gs-minibox-v1.o
 obj-$(CONFIG_ATH79_MACH_GS_OOLITE)             += mach-gs-oolite.o
+obj-$(CONFIG_ATH79_MACH_HIVEAP_121)            += mach-hiveap-121.o
 obj-$(CONFIG_ATH79_MACH_HIWIFI_HC6361)         += mach-hiwifi-hc6361.o
 obj-$(CONFIG_ATH79_MACH_HORNET_UB)             += mach-hornet-ub.o
 obj-$(CONFIG_ATH79_MACH_JA76PF)                        += mach-ja76pf.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-hiveap-121.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-hiveap-121.c
new file mode 100644 (file)
index 0000000..363d73d
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ *  Aerohive HiveAP 121 board support
+ *
+ *  Copyright (C) 2017 Chris Blake <chrisrblake93@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/i2c.h>
+#include <linux/i2c-gpio.h>
+#include <linux/platform_device.h>
+#include <linux/ath9k_platform.h>
+#include <linux/platform/ar934x_nfc.h>
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+#include "common.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-nfc.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "dev-ap9x-pci.h"
+#include "dev-m25p80.h"
+#include "machtypes.h"
+
+#define HIVEAP_121_GPIO_LED_ORANGE     14
+#define HIVEAP_121_GPIO_LED_WHITE      21
+#define HIVEAP_121_GPIO_I2C_SCL                12
+#define HIVEAP_121_GPIO_I2C_SDA                13
+#define HIVEAP_121_GPIO_XLNA0          20
+#define HIVEAP_121_GPIO_XLNA1          19
+#define HIVEAP_121_GPIO_USB_POWER      15
+
+#define HIVEAP_121_GPIO_BTN_RESET              4
+#define HIVEAP_121_KEYS_POLL_INTERVAL          20 /* msecs */
+#define HIVEAP_121_KEYS_DEBOUNCE_INTERVAL      \
+                                       (3 * HIVEAP_121_KEYS_POLL_INTERVAL)
+
+#define HIVEAP_121_MAC_OFFSET  0x90000
+
+#define HIVEAP_121_LAN_PHYADDR 0
+
+static struct gpio_led hiveap_121_leds_gpio[] __initdata = {
+       {
+               .name           = "hiveap-121:orange:power",
+               .gpio           = HIVEAP_121_GPIO_LED_ORANGE,
+               .active_low     = 1,
+       }, {
+               .name           = "hiveap-121:white:power",
+               .gpio           = HIVEAP_121_GPIO_LED_WHITE,
+               .active_low     = 1,
+       }
+};
+
+static struct gpio_keys_button hiveap_121_gpio_keys[] __initdata = {
+       {
+               .desc = "reset",
+               .type = EV_KEY,
+               .code = KEY_RESTART,
+               .debounce_interval = HIVEAP_121_KEYS_DEBOUNCE_INTERVAL,
+               .gpio = HIVEAP_121_GPIO_BTN_RESET,
+               .active_low  = 1,
+       },
+};
+
+static struct i2c_gpio_platform_data hiveap_121_i2c_gpio_data = {
+       .sda_pin = HIVEAP_121_GPIO_I2C_SDA,
+       .scl_pin = HIVEAP_121_GPIO_I2C_SCL,
+};
+
+static struct platform_device hiveap_121_i2c_gpio_device = {
+       .name   = "i2c-gpio",
+       .id     = 0,
+       .dev    = {
+               .platform_data = &hiveap_121_i2c_gpio_data,
+       }
+};
+
+static struct i2c_board_info tpm_i2c_info[] __initdata = {
+       {
+               I2C_BOARD_INFO("tpm_i2c_atmel", 0x29),
+       }
+};
+
+static void __init hiveap_121_setup(void)
+{
+       u8 *base = (u8 *) KSEG1ADDR(0x1f000000);
+       u8 wlan0_mac[ETH_ALEN];
+       u8 wlan1_mac[ETH_ALEN];
+
+       /* NAND */
+       ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
+       ath79_register_nfc();
+
+       /* SPI */
+       ath79_register_m25p80(NULL);
+
+       /* MDIO Interface */
+       ath79_register_mdio(0, 0x0);
+       ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
+                                  AR934X_ETH_CFG_RXD_DELAY |
+                                  AR934X_ETH_CFG_RDV_DELAY);
+
+       /* GMAC0 is connected to the RGMII interface to an Atheros AR8035-A */
+       ath79_init_mac(ath79_eth0_data.mac_addr,
+                      base + HIVEAP_121_MAC_OFFSET, 0);
+       ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
+       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+       ath79_eth0_data.phy_mask = BIT(HIVEAP_121_LAN_PHYADDR);
+       ath79_eth0_pll_data.pll_1000 = 0x0e000000;
+       ath79_eth0_pll_data.pll_100 = 0x00000101;
+       ath79_eth0_pll_data.pll_10 = 0x00001313;
+       ath79_register_eth(0);
+
+       /* i2c */
+       ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
+       platform_device_register(&hiveap_121_i2c_gpio_device);
+
+       /* TPM */
+       i2c_register_board_info(0, tpm_i2c_info, ARRAY_SIZE(tpm_i2c_info));
+
+       /* LEDs and Buttons */
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(hiveap_121_leds_gpio),
+                                hiveap_121_leds_gpio);
+       ath79_register_gpio_keys_polled(-1, HIVEAP_121_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(hiveap_121_gpio_keys),
+                                       hiveap_121_gpio_keys);
+
+       /* USB */
+       gpio_request_one(HIVEAP_121_GPIO_USB_POWER,
+                        GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
+                        "USB power");
+       ath79_register_usb();
+
+       /* XLNA - SoC Wireless */
+       ath79_wmac_set_ext_lna_gpio(0, HIVEAP_121_GPIO_XLNA0);
+       ath79_wmac_set_ext_lna_gpio(1, HIVEAP_121_GPIO_XLNA1);
+
+       /* SoC Wireless */
+       ath79_init_mac(wlan0_mac, base + HIVEAP_121_MAC_OFFSET, 1);
+       ath79_register_wmac(NULL, wlan0_mac); /* Caldata in OTP */
+
+       /* PCIe Wireless */
+       ath79_init_mac(wlan1_mac, base + HIVEAP_121_MAC_OFFSET, 2);
+       ap91_pci_init(NULL, wlan1_mac); /* Caldata in OTP */
+}
+
+MIPS_MACHINE(ATH79_MACH_HIVEAP_121, "HiveAP-121", "Aerohive HiveAP-121",
+            hiveap_121_setup);
index 4f0ae32d45253f34d944fc39e6c68361b7070208..18033acd12e74a6c017030dd83140dabc175c2e5 100644 (file)
@@ -109,6 +109,7 @@ enum ath79_mach_type {
        ATH79_MACH_GL_MIFI,                     /* GL-MIFI support */
        ATH79_MACH_GS_MINIBOX_V1,               /* Gainstrong MiniBox V1.0 */
        ATH79_MACH_GS_OOLITE,                   /* GS OOLITE V1.0 */
+       ATH79_MACH_HIVEAP_121,                  /* Aerohive HiveAP-121*/
        ATH79_MACH_HIWIFI_HC6361,               /* HiWiFi HC6361 */
        ATH79_MACH_HORNET_UB,                   /* ALFA Networks Hornet-UB */
        ATH79_MACH_JA76PF,                      /* jjPlus JA76PF */
index dfe78c21682a457aadb28d34e8950538c381ca60..8f84b0cf7cc839a6538c0c4e00f2b60f2bfb73bc 100644 (file)
@@ -23,6 +23,24 @@ define Device/domywifi-dw33d
 endef
 TARGET_DEVICES += domywifi-dw33d
 
+define Device/hiveap-121
+  DEVICE_TITLE := Aerohive HiveAP-121
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-i2c-gpio-custom kmod-spi-gpio kmod-ath9k kmod-tpm-i2c-atmel
+  BOARDNAME = HiveAP-121
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  IMAGE_SIZE := 115m
+  KERNEL_SIZE := 5120k
+  UBINIZE_OPTS := -E 5
+  CONSOLE = ttyS0,9600
+  MTDPARTS = spi0.0:512k(u-boot)ro,64k(u-boot-env),64k(hw-info)ro,64k(boot-info)ro,64k(boot-sinfo)ro;ar934x-nfc:4096k(u-boot-1),4096k(u-boot-env-1),5m(kernel),111m(ubi),4096k(wifi-info)ro
+  IMAGES := sysupgrade.tar factory.bin
+  KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma
+  IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | check-size $$$$(IMAGE_SIZE)
+  IMAGE/sysupgrade.tar := sysupgrade-tar
+endef
+TARGET_DEVICES += hiveap-121
+
 define Build/MerakiNAND
        -$(STAGING_DIR_HOST)/bin/mkmerakifw \
                -B $(BOARDNAME) -s \
index 9b57f9047b0b2aca892d03d348774b175de08f36..f744da80c114bcb8ef3b9152cec1eea769e95d60 100644 (file)
@@ -76,6 +76,7 @@
 # CONFIG_ATH79_MACH_GL_MIFI is not set
 # CONFIG_ATH79_MACH_GS_MINIBOX_V1 is not set
 # CONFIG_ATH79_MACH_GS_OOLITE is not set
+CONFIG_ATH79_MACH_HIVEAP_121=y
 # CONFIG_ATH79_MACH_HIWIFI_HC6361 is not set
 # CONFIG_ATH79_MACH_HORNET_UB is not set
 # CONFIG_ATH79_MACH_JA76PF is not set