ar71xx: add support for COMFAST CF-E380AC v1 and v2
authorPiotr Dymacz <pepe2k@gmail.com>
Mon, 14 Nov 2016 16:38:23 +0000 (17:38 +0100)
committerJohn Crispin <john@phrozen.org>
Mon, 21 Nov 2016 09:05:40 +0000 (10:05 +0100)
COMFAST CF-E380AC v1/v2 is a ceiling mount AP with PoE
support, based on Qualcomm/Atheros QCA9558+QCA9880+AR8035.

There are two versions of this model, with different RAM
and U-Boot mtd partition sizes:
- v1: 128 MB of RAM, 128 KB U-Boot image size
- v2: 256 MB of RAM, 256 KB U-Boot image size

Version number is available only inside vendor GUI,
hardware and markings are the same.

Short specification:

- 720/600/200 MHz (CPU/DDR/AHB)
- 1x 10/100/1000 Mbps Ethernet, with PoE support
- 128 or 256 MB of RAM (DDR2)
- 16 MB of FLASH
- 3T3R 2.4 GHz, with external PA (SE2576L), up to 28 dBm
- 3T3R 5 GHz, with external PA (SE5003L1), up to 30 dBm
- 6x internal antennas
- 1x RGB LED, 1x button
- UART (T11), LEDs/GPIO (J7) and USB (T12) headers on PCB
- external watchdog (Pericon Technology PT7A7514)

Flash instruction:

Original firmware is based on OpenWrt.
Use sysupgrade image directly in vendor GUI.

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
12 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/etc/hotplug.d/firmware/11-ath10k-caldata
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-cf-e316n-v2.c
target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
target/linux/ar71xx/image/generic.mk

index 4490c09..29ee5d7 100755 (executable)
@@ -120,6 +120,12 @@ cf-e320n-v2)
        ucidef_set_led_netdev "wan" "WAN" "$board:red:wan" "eth1"
        ucidef_set_led_wlan "wlan" "WLAN" "$board:blue:wlan" "phy0tpt"
        ;;
+cf-e380ac-v1|\
+cf-e380ac-v2)
+       ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth0"
+       ucidef_set_led_wlan "wlan2g" "WLAN2G" "$board:blue:wlan2g" "phy1tpt"
+       ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:red:wlan5g" "phy0tpt"
+       ;;
 cf-e520n|\
 cf-e530n)
        ucidef_set_led_netdev "wan" "WAN" "$board:blue:wan" "eth1"
index df87c96..2b9a012 100755 (executable)
@@ -66,6 +66,8 @@ ar71xx_setup_interfaces()
        bullet-m|\
        c-55|\
        cap4200ag|\
+       cf-e380ac-v1|\
+       cf-e380ac-v2|\
        eap120|\
        eap300v2|\
        eap7660d|\
index e1e76a4..bb42843 100644 (file)
@@ -94,6 +94,10 @@ get_status_led() {
        cf-e320n-v2)
                status_led="$board:blue:wlan"
                ;;
+       cf-e380ac-v1|\
+       cf-e380ac-v2)
+               status_led="$board:blue:wlan2g"
+               ;;
        cpe510)
                status_led="tp-link:green:link4"
                ;;
index bbb28ed..7983dad 100644 (file)
@@ -47,13 +47,15 @@ board=$(ar71xx_board_name)
 case "$FIRMWARE" in
 "ath10k/cal-pci-0000:00:00.0.bin")
        case $board in
+       cf-e380ac-v1|\
+       cf-e380ac-v2|\
+       dlan-pro-1200-ac)
+               ath10kcal_extract "art" 20480 2116
+               ;;
        dap-2695-a1)
                ath10kcal_extract "radiocfg" 20480 2116
                ath10kcal_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
                ;;
-       dlan-pro-1200-ac)
-               ath10kcal_extract "art" 20480 2116
-               ;;
        dw33d)
                ath10kcal_extract "art" 20480 2116
                ath10kcal_patch_mac $(mtd_get_mac_binary art 18)
index 0b82d83..8f710e6 100755 (executable)
@@ -503,6 +503,12 @@ ar71xx_board_detect() {
        *"CF-E320N v2")
                name="cf-e320n-v2"
                ;;
+       *"CF-E380AC v1")
+               name="cf-e380ac-v1"
+               ;;
+       *"CF-E380AC v2")
+               name="cf-e380ac-v2"
+               ;;
        *CF-E520N)
                name="cf-e520n"
                ;;
index fa12870..87c9d8f 100755 (executable)
@@ -183,6 +183,8 @@ platform_check_image() {
        carambola2|\
        cf-e316n-v2|\
        cf-e320n-v2|\
+       cf-e380ac-v1|\
+       cf-e380ac-v2|\
        cf-e520n|\
        cf-e530n|\
        dgl-5500-a1|\
index cc93515..550b8bb 100644 (file)
@@ -63,6 +63,8 @@ CONFIG_ATH79_MACH_CAP4200AG=y
 CONFIG_ATH79_MACH_CARAMBOLA2=y
 CONFIG_ATH79_MACH_CF_E316N_V2=y
 CONFIG_ATH79_MACH_CF_E320N_V2=y
+CONFIG_ATH79_MACH_CF_E380AC_V1=y
+CONFIG_ATH79_MACH_CF_E380AC_V2=y
 CONFIG_ATH79_MACH_CF_E520N=y
 CONFIG_ATH79_MACH_CF_E530N=y
 CONFIG_ATH79_MACH_CPE510=y
index 73f8d21..3a3ed14 100644 (file)
@@ -1696,6 +1696,28 @@ config ATH79_MACH_CF_E320N_V2
        select ATH79_DEV_USB
        select ATH79_DEV_WMAC
 
+config ATH79_MACH_CF_E380AC_V1
+       bool "COMFAST CF-E380AC v1 support"
+       select SOC_QCA955X
+       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_USB
+       select ATH79_DEV_WMAC
+
+config ATH79_MACH_CF_E380AC_V2
+       bool "COMFAST CF-E380AC v2 support"
+       select SOC_QCA955X
+       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_USB
+       select ATH79_DEV_WMAC
+
 config ATH79_MACH_CF_E520N
        bool "COMFAST CF-E520N support"
        select SOC_QCA953X
index 24b3ea0..1924179 100644 (file)
@@ -69,6 +69,8 @@ obj-$(CONFIG_ATH79_MACH_CAP4200AG)            += mach-cap4200ag.o
 obj-$(CONFIG_ATH79_MACH_CARAMBOLA2)            += mach-carambola2.o
 obj-$(CONFIG_ATH79_MACH_CF_E316N_V2)           += mach-cf-e316n-v2.o
 obj-$(CONFIG_ATH79_MACH_CF_E320N_V2)           += mach-cf-e316n-v2.o
+obj-$(CONFIG_ATH79_MACH_CF_E380AC_V1)          += mach-cf-e316n-v2.o
+obj-$(CONFIG_ATH79_MACH_CF_E380AC_V2)          += mach-cf-e316n-v2.o
 obj-$(CONFIG_ATH79_MACH_CF_E520N)              += mach-cf-e316n-v2.o
 obj-$(CONFIG_ATH79_MACH_CF_E530N)              += mach-cf-e316n-v2.o
 obj-$(CONFIG_ATH79_MACH_CPE510)                        += mach-cpe510.o
index d958bad..2c202e3 100644 (file)
@@ -2,9 +2,11 @@
  *  Support for COMFAST boards:
  *  - CF-E316N v2 (AR9341)
  *  - CF-E320N v2 (QCA9531)
+ *  - CF-E380AC v1/v2 (QCA9558)
  *  - CF-E520N/CF-E530N (QCA9531)
  *
  *  Copyright (C) 2016 Piotr Dymacz <pepe2k@gmail.com>
+ *  Copyright (C) 2016 Gareth Parker <gareth41@orcon.net.nz>
  *  Copyright (C) 2015 Paul Fertser <fercerpav@gmail.com>
  *
  *  This program is free software; you can redistribute it and/or modify it
@@ -13,6 +15,7 @@
  */
 
 #include <linux/gpio.h>
+#include <linux/platform_data/phy-at803x.h>
 #include <linux/platform_device.h>
 #include <linux/timer.h>
 
@@ -20,6 +23,7 @@
 #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"
@@ -126,6 +130,70 @@ static struct gpio_keys_button cf_e320n_v2_gpio_keys[] __initdata = {
        },
 };
 
+/* CF-E380AC v1/v2 */
+#define CF_E380AC_V1V2_GPIO_LED_LAN    0
+#define CF_E380AC_V1V2_GPIO_LED_WLAN2G 2
+#define CF_E380AC_V1V2_GPIO_LED_WLAN5G 3
+
+#define CF_E380AC_V1V2_GPIO_EXT_WDT    17
+
+#define CF_E380AC_V1V2_GPIO_BTN_RESET  19
+
+static struct gpio_led cf_e380ac_v1_leds_gpio[] __initdata = {
+       {
+               .name           = "cf-e380ac-v1:green:lan",
+               .gpio           = CF_E380AC_V1V2_GPIO_LED_LAN,
+               .active_low     = 0,
+       }, {
+               .name           = "cf-e380ac-v1:blue:wlan2g",
+               .gpio           = CF_E380AC_V1V2_GPIO_LED_WLAN2G,
+               .active_low     = 0,
+       }, {
+               .name           = "cf-e380ac-v1:red:wlan5g",
+               .gpio           = CF_E380AC_V1V2_GPIO_LED_WLAN5G,
+               .active_low     = 0,
+       },
+};
+
+static struct gpio_led cf_e380ac_v2_leds_gpio[] __initdata = {
+       {
+               .name           = "cf-e380ac-v2:green:lan",
+               .gpio           = CF_E380AC_V1V2_GPIO_LED_LAN,
+               .active_low     = 0,
+       }, {
+               .name           = "cf-e380ac-v2:blue:wlan2g",
+               .gpio           = CF_E380AC_V1V2_GPIO_LED_WLAN2G,
+               .active_low     = 0,
+       }, {
+               .name           = "cf-e380ac-v2:red:wlan5g",
+               .gpio           = CF_E380AC_V1V2_GPIO_LED_WLAN5G,
+               .active_low     = 0,
+       },
+};
+
+static struct gpio_keys_button cf_e380ac_v1v2_gpio_keys[] __initdata = {
+       {
+               .desc           = "Reset button",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = CF_E380AC_V1V2_GPIO_BTN_RESET,
+               .active_low     = 1,
+       },
+};
+
+static struct at803x_platform_data cf_e380ac_v1v2_at803x_data = {
+       .disable_smarteee = 1,
+};
+
+static struct mdio_board_info cf_e380ac_v1v2_mdio0_info[] = {
+       {
+               .bus_id = "ag71xx-mdio.0",
+               .phy_addr = 0,
+               .platform_data = &cf_e380ac_v1v2_at803x_data,
+       },
+};
+
 /* CF-E520N/CF-E530N */
 #define CF_E5X0N_GPIO_LED_WAN          11
 #define CF_E5X0N_GPIO_BTN_RESET                17
@@ -166,9 +234,9 @@ static void gpio_wdt_toggle(unsigned long gpio)
                  jiffies + msecs_to_jiffies(CF_EXXXN_EXT_WDT_TIMEOUT_MS));
 }
 
-static void __init cf_exxxn_common_setup(int gpio_wdt)
+static void __init cf_exxxn_common_setup(unsigned long art_ofs, int gpio_wdt)
 {
-       u8 *art = (u8 *) KSEG1ADDR(0x1f011000);
+       u8 *art = (u8 *) KSEG1ADDR(0x1f001000 + art_ofs);
 
        if (gpio_wdt > -1) {
                gpio_request_one(gpio_wdt, GPIOF_OUT_INIT_HIGH,
@@ -189,7 +257,7 @@ static void __init cf_e316n_v2_setup(void)
 {
        u8 *mac = (u8 *) KSEG1ADDR(0x1f010000);
 
-       cf_exxxn_common_setup(CF_E316N_V2_GPIO_EXT_WDT);
+       cf_exxxn_common_setup(0x10000, CF_E316N_V2_GPIO_EXT_WDT);
 
        ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
 
@@ -255,7 +323,7 @@ static void __init cf_exxxn_qca953x_eth_setup(void)
 
 static void __init cf_e320n_v2_setup(void)
 {
-       cf_exxxn_common_setup(CF_E320N_V2_GPIO_EXT_WDT);
+       cf_exxxn_common_setup(0x10000, CF_E320N_V2_GPIO_EXT_WDT);
 
        cf_exxxn_qca953x_eth_setup();
 
@@ -287,6 +355,71 @@ static void __init cf_e320n_v2_setup(void)
 MIPS_MACHINE(ATH79_MACH_CF_E320N_V2, "CF-E320N-V2", "COMFAST CF-E320N v2",
             cf_e320n_v2_setup);
 
+static void __init cf_e380ac_v1v2_common_setup(unsigned long art_ofs)
+{
+       u8 *mac = (u8 *) KSEG1ADDR(0x1f000000 + art_ofs);
+
+       cf_exxxn_common_setup(art_ofs, CF_E380AC_V1V2_GPIO_EXT_WDT);
+
+       ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
+
+       ath79_register_mdio(0, 0x0);
+       mdiobus_register_board_info(cf_e380ac_v1v2_mdio0_info,
+                                   ARRAY_SIZE(cf_e380ac_v1v2_mdio0_info));
+
+       /* LAN */
+       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(0);
+       ath79_eth0_pll_data.pll_1000 = 0xbe000000;
+       ath79_eth0_pll_data.pll_100 = 0xb0000101;
+       ath79_eth0_pll_data.pll_10 = 0xb0001313;
+       ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+       ath79_register_eth(0);
+
+       ap91_pci_init(mac + 0x5000, NULL);
+
+       /* Disable JTAG (enables GPIO0-3) */
+       ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
+
+       ath79_gpio_direction_select(CF_E380AC_V1V2_GPIO_LED_LAN, true);
+       ath79_gpio_direction_select(CF_E380AC_V1V2_GPIO_LED_WLAN2G, true);
+       ath79_gpio_direction_select(CF_E380AC_V1V2_GPIO_LED_WLAN5G, true);
+
+       ath79_gpio_output_select(CF_E380AC_V1V2_GPIO_LED_LAN, 0);
+       ath79_gpio_output_select(CF_E380AC_V1V2_GPIO_LED_WLAN2G, 0);
+       ath79_gpio_output_select(CF_E380AC_V1V2_GPIO_LED_WLAN5G, 0);
+
+       /* For J7-4 */
+       ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN);
+
+       ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(cf_e380ac_v1v2_gpio_keys),
+                                       cf_e380ac_v1v2_gpio_keys);
+}
+
+static void __init cf_e380ac_v1_setup(void)
+{
+       cf_e380ac_v1v2_common_setup(0x20000);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_v1_leds_gpio),
+                                cf_e380ac_v1_leds_gpio);
+}
+
+MIPS_MACHINE(ATH79_MACH_CF_E380AC_V1, "CF-E380AC-V1", "COMFAST CF-E380AC v1",
+            cf_e380ac_v1_setup);
+
+static void __init cf_e380ac_v2_setup(void)
+{
+       cf_e380ac_v1v2_common_setup(0x40000);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_v2_leds_gpio),
+                                cf_e380ac_v2_leds_gpio);
+}
+
+MIPS_MACHINE(ATH79_MACH_CF_E380AC_V2, "CF-E380AC-V2", "COMFAST CF-E380AC v2",
+            cf_e380ac_v2_setup);
+
 static void __init cf_e5x0n_gpio_setup(void)
 {
        ath79_gpio_direction_select(CF_E5X0N_GPIO_LED_WAN, true);
@@ -300,7 +433,7 @@ static void __init cf_e5x0n_gpio_setup(void)
 
 static void __init cf_e520n_setup(void)
 {
-       cf_exxxn_common_setup(-1);
+       cf_exxxn_common_setup(0x10000, -1);
 
        cf_exxxn_qca953x_eth_setup();
 
@@ -315,7 +448,7 @@ MIPS_MACHINE(ATH79_MACH_CF_E520N, "CF-E520N", "COMFAST CF-E520N",
 
 static void __init cf_e530n_setup(void)
 {
-       cf_exxxn_common_setup(-1);
+       cf_exxxn_common_setup(0x10000, -1);
 
        cf_exxxn_qca953x_eth_setup();
 
index 741ebb2..5e504b1 100644 (file)
@@ -54,6 +54,8 @@ enum ath79_mach_type {
        ATH79_MACH_CARAMBOLA2,                  /* 8devices Carambola2 */
        ATH79_MACH_CF_E316N_V2,                 /* COMFAST CF-E316N v2 */
        ATH79_MACH_CF_E320N_V2,                 /* COMFAST CF-E320N v2 */
+       ATH79_MACH_CF_E380AC_V1,                /* COMFAST CF-E380AC v1 */
+       ATH79_MACH_CF_E380AC_V2,                /* COMFAST CF-E380AC v2 */
        ATH79_MACH_CF_E520N,                    /* COMFAST CF-E520N */
        ATH79_MACH_CF_E530N,                    /* COMFAST CF-E530N */
        ATH79_MACH_CPE210,                      /* TP-LINK CPE210 */
index e80c853..7381eec 100644 (file)
@@ -35,6 +35,25 @@ define Device/cf-e320n-v2
 endef
 TARGET_DEVICES += cf-e320n-v2
 
+define Device/cf-e380ac-v1
+  DEVICE_TITLE := COMFAST CF-E380AC v1
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-ath10k ath10k-firmware-qca988x
+  BOARDNAME = CF-E380AC-V1
+  IMAGE_SIZE = 16128k
+  CONSOLE = ttyS0,115200
+  MTDPARTS = spi0.0:128k(u-boot)ro,64k(art)ro,16128k(firmware),64k(art-backup)ro
+endef
+TARGET_DEVICES += cf-e380ac-v1
+
+define Device/cf-e380ac-v2
+  $(Device/cf-e380ac-v1)
+  DEVICE_TITLE := COMFAST CF-E380AC v2
+  BOARDNAME = CF-E380AC-V2
+  IMAGE_SIZE = 16000k
+  MTDPARTS = spi0.0:256k(u-boot)ro,64k(art)ro,16000k(firmware),64k(art-backup)ro
+endef
+TARGET_DEVICES += cf-e380ac-v2
+
 define Device/cf-e520n
   DEVICE_TITLE := COMFAST CF-E520N
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2