ar71xx: add support for COMFAST CF-E385AC
authorPiotr Dymacz <pepe2k@gmail.com>
Tue, 23 Jan 2018 20:37:16 +0000 (21:37 +0100)
committerPiotr Dymacz <pepe2k@gmail.com>
Thu, 22 Feb 2018 17:53:22 +0000 (18:53 +0100)
COMFAST CF-E385AC is an AC2200 ceiling mount AP with PoE support, based
on Qualcomm/Atheros QCA9558 + QCA9984 + QCA8337N.

Specification:

- 720/600/200 MHz (CPU/DDR/AHB)
- 256 MB of RAM (DDR2)
- 16 MB of FLASH (SPI NOR)
- 2x 10/100/1000 Mbps Ethernet, with PoE support
- 3T3R 2.4 GHz (QCA9558), with external LNA and PA (SE2576L)
- 4T4R 5 GHz (QCA9984), with external FEM (SKY85728-11)
- 7x internal antennas
- 1x RGB LED (driven by GPIO)
- 1x button (reset)
- UART, LEDs/GPIO and USB 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>
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/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 85f104a5fdf28f9e58560a85e9d6fbb563f11794..1b308d7f77c0689fbcd05050ebab0a6fe2bc64ac 100755 (executable)
@@ -218,10 +218,19 @@ cf-e375ac)
 cf-e355ac-v1|\
 cf-e355ac-v2|\
 cf-e380ac-v1|\
-cf-e380ac-v2)
-       ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth0"
+cf-e380ac-v2|\
+cf-e385ac)
        ucidef_set_led_wlan "wlan2g" "WLAN2G" "$board:blue:wlan2g" "phy1tpt"
        ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:red:wlan5g" "phy0tpt"
+
+       case "$board" in
+       cf-e385ac)
+               ucidef_set_led_switch "lan" "LAN" "$board:green:lan" "switch0" "0x04"
+               ;;
+       *)
+               ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth0"
+               ;;
+       esac
        ;;
 cf-e520n|\
 cf-e530n)
index 0fe71e07606a92684415f8a2630eb3bcfea9e5ea..434056a3447e4bbd41064c375cb001e981f5585a 100755 (executable)
@@ -266,6 +266,11 @@ ar71xx_setup_interfaces()
        rme-eg200)
                ucidef_set_interface_lan "eth0" "dhcp"
                ;;
+       cf-e385ac)
+               ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
+               ucidef_add_switch "switch0" \
+                       "0@eth0" "2:lan" "1:wan" "6@eth1"
+               ;;
        cpe210|\
        cpe510|\
        wbs210|\
index facc77ee60ff4e3633c36130caa0935bda161373..232e43b8dc3a01662a3bc8eaf8b7cfdbf850fc2c 100644 (file)
@@ -149,7 +149,8 @@ get_status_led() {
                status_led="$board:blue:wlan"
                ;;
        cf-e380ac-v1|\
-       cf-e380ac-v2)
+       cf-e380ac-v2|\
+       cf-e385ac)
                status_led="$board:blue:wlan2g"
                ;;
        cpe510)
index 3aa5e3c90f3717952e8355d96af481a872c6e81e..a3d4867b0b7f964320aa793c040e9eac6102bdb1 100644 (file)
@@ -161,6 +161,9 @@ case "$FIRMWARE" in
                ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
                        /lib/firmware/ath10k/QCA9888/hw2.0/board.bin
                ;;
+       cf-e385ac)
+               ath10kcal_extract "art" 20480 12064
+               ;;
        esac
        ;;
 *)
index 842f1c508115370c74e2f940f8bbd7d34f90b9d7..fc578cec65ff9bf3a0f978bf5099e78622ca7b23 100755 (executable)
@@ -531,6 +531,9 @@ ar71xx_board_detect() {
        *"CF-E380AC v2")
                name="cf-e380ac-v2"
                ;;
+       *"CF-E385AC")
+               name="cf-e385ac"
+               ;;
        *"CF-E520N")
                name="cf-e520n"
                ;;
index c408c7dfcec354b2f654341180e9ff70530a9669..b0809553597311f49f69ca973e25a10fd85b1bcb 100755 (executable)
@@ -213,6 +213,7 @@ platform_check_image() {
        cf-e375ac|\
        cf-e380ac-v1|\
        cf-e380ac-v2|\
+       cf-e385ac|\
        cf-e520n|\
        cf-e530n|\
        cpe505n|\
index 1ac6c8eddd3757d25403bd07c71a65e06d97cf00..a5baeac2edd5e0d7522cd67d6ad7131f8657ac54 100644 (file)
@@ -6,6 +6,7 @@
  *  - CF-E355AC v2 (QCA9531 + QCA9886)
  *  - CF-E375AC (QCA9563 + QCA9886 + QCA8337)
  *  - CF-E380AC v1/v2 (QCA9558)
+ *  - CF-E385AC (QCA9558 + QCA9984 + QCA8337)
  *  - CF-E520N/CF-E530N (QCA9531)
  *
  *  Copyright (C) 2016 Piotr Dymacz <pepe2k@gmail.com>
@@ -35,6 +36,7 @@
 #include "dev-wmac.h"
 #include "dev-usb.h"
 #include "machtypes.h"
+#include "pci.h"
 
 #define CF_EXXXN_KEYS_POLL_INTERVAL    20
 #define CF_EXXXN_KEYS_DEBOUNCE_INTERVAL        (3 * CF_EXXXN_KEYS_POLL_INTERVAL)
@@ -245,27 +247,27 @@ static struct mdio_board_info cf_e375ac_mdio0_info[] = {
        },
 };
 
-/* 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
+/* CF-E380AC v1/v2, CF-E385AC */
+#define CF_E38XAC_GPIO_LED_LAN         0
+#define CF_E38XAC_GPIO_LED_WLAN2G      2
+#define CF_E38XAC_GPIO_LED_WLAN5G      3
 
-#define CF_E380AC_V1V2_GPIO_EXT_WDT    17
+#define CF_E38XAC_GPIO_EXT_WDT         17
 
-#define CF_E380AC_V1V2_GPIO_BTN_RESET  19
+#define CF_E38XAC_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,
+               .gpio           = CF_E38XAC_GPIO_LED_LAN,
                .active_low     = 0,
        }, {
                .name           = "cf-e380ac-v1:blue:wlan2g",
-               .gpio           = CF_E380AC_V1V2_GPIO_LED_WLAN2G,
+               .gpio           = CF_E38XAC_GPIO_LED_WLAN2G,
                .active_low     = 0,
        }, {
                .name           = "cf-e380ac-v1:red:wlan5g",
-               .gpio           = CF_E380AC_V1V2_GPIO_LED_WLAN5G,
+               .gpio           = CF_E38XAC_GPIO_LED_WLAN5G,
                .active_low     = 0,
        },
 };
@@ -273,26 +275,42 @@ static struct gpio_led cf_e380ac_v1_leds_gpio[] __initdata = {
 static struct gpio_led cf_e380ac_v2_leds_gpio[] __initdata = {
        {
                .name           = "cf-e380ac-v2:green:lan",
-               .gpio           = CF_E380AC_V1V2_GPIO_LED_LAN,
+               .gpio           = CF_E38XAC_GPIO_LED_LAN,
                .active_low     = 0,
        }, {
                .name           = "cf-e380ac-v2:blue:wlan2g",
-               .gpio           = CF_E380AC_V1V2_GPIO_LED_WLAN2G,
+               .gpio           = CF_E38XAC_GPIO_LED_WLAN2G,
                .active_low     = 0,
        }, {
                .name           = "cf-e380ac-v2:red:wlan5g",
-               .gpio           = CF_E380AC_V1V2_GPIO_LED_WLAN5G,
+               .gpio           = CF_E38XAC_GPIO_LED_WLAN5G,
                .active_low     = 0,
        },
 };
 
-static struct gpio_keys_button cf_e380ac_v1v2_gpio_keys[] __initdata = {
+static struct gpio_led cf_e385ac_leds_gpio[] __initdata = {
+       {
+               .name           = "cf-e385ac:green:lan",
+               .gpio           = CF_E38XAC_GPIO_LED_LAN,
+               .active_low     = 0,
+       }, {
+               .name           = "cf-e385ac:blue:wlan2g",
+               .gpio           = CF_E38XAC_GPIO_LED_WLAN2G,
+               .active_low     = 0,
+       }, {
+               .name           = "cf-e385ac:red:wlan5g",
+               .gpio           = CF_E38XAC_GPIO_LED_WLAN5G,
+               .active_low     = 0,
+       },
+};
+
+static struct gpio_keys_button cf_e38xac_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,
+               .gpio           = CF_E38XAC_GPIO_BTN_RESET,
                .active_low     = 1,
        },
 };
@@ -557,11 +575,36 @@ static void __init cf_e375ac_setup(void)
 }
 MIPS_MACHINE(ATH79_MACH_CF_E375AC, "CF-E375AC", "COMFAST CF-E375AC", cf_e375ac_setup);
 
+static void __init cf_e38xac_common_setup(unsigned long art_ofs)
+{
+       cf_exxxn_common_setup(art_ofs, CF_E38XAC_GPIO_EXT_WDT);
+
+       ath79_register_pci();
+
+       /* Disable JTAG (enables GPIO0-3) */
+       ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
+
+       ath79_gpio_direction_select(CF_E38XAC_GPIO_LED_LAN, true);
+       ath79_gpio_direction_select(CF_E38XAC_GPIO_LED_WLAN2G, true);
+       ath79_gpio_direction_select(CF_E38XAC_GPIO_LED_WLAN5G, true);
+
+       ath79_gpio_output_select(CF_E38XAC_GPIO_LED_LAN, 0);
+       ath79_gpio_output_select(CF_E38XAC_GPIO_LED_WLAN2G, 0);
+       ath79_gpio_output_select(CF_E38XAC_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_e38xac_gpio_keys),
+                                       cf_e38xac_gpio_keys);
+}
+
 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);
+       cf_e38xac_common_setup(art_ofs);
 
        ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
 
@@ -578,26 +621,6 @@ static void __init cf_e380ac_v1v2_common_setup(unsigned long art_ofs)
        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)
@@ -622,6 +645,86 @@ static void __init cf_e380ac_v2_setup(void)
 MIPS_MACHINE(ATH79_MACH_CF_E380AC_V2, "CF-E380AC-V2", "COMFAST CF-E380AC v2",
             cf_e380ac_v2_setup);
 
+/* QCA8337 GMAC0 is connected with QCA9558 over RGMII */
+static struct ar8327_pad_cfg cf_e385ac_qca8337_pad0_cfg = {
+       .mode = AR8327_PAD_MAC_RGMII,
+       .txclk_delay_en = true,
+       .rxclk_delay_en = true,
+       .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
+       .rxclk_delay_sel = AR8327_CLK_DELAY_SEL1,
+};
+
+/* QCA8337 GMAC6 is connected with QCA9558 over SGMII */
+static struct ar8327_pad_cfg cf_e385ac_qca8337_pad6_cfg = {
+       .mode = AR8327_PAD_MAC_SGMII,
+       .sgmii_delay_en = true,
+       .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
+};
+
+static struct ar8327_platform_data cf_e385ac_qca8337_data = {
+       .pad0_cfg = &cf_e385ac_qca8337_pad0_cfg,
+       .pad6_cfg = &cf_e385ac_qca8337_pad6_cfg,
+       .port0_cfg = {
+               .force_link = 1,
+               .speed = AR8327_PORT_SPEED_1000,
+               .duplex = 1,
+               .txpause = 1,
+               .rxpause = 1,
+       },
+       .port6_cfg = {
+               .force_link = 1,
+               .speed = AR8327_PORT_SPEED_1000,
+               .duplex = 1,
+               .txpause = 1,
+               .rxpause = 1,
+       },
+};
+
+static struct mdio_board_info cf_e385ac_mdio0_info[] = {
+       {
+               .bus_id = "ag71xx-mdio.0",
+               .phy_addr = 0,
+               .platform_data = &cf_e385ac_qca8337_data,
+       },
+};
+
+static void __init cf_e385ac_setup(void)
+{
+       u8 *mac = (u8 *) KSEG1ADDR(0x1f040000);
+
+       cf_e38xac_common_setup(0x40000);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e385ac_leds_gpio),
+                                cf_e385ac_leds_gpio);
+
+       mdiobus_register_board_info(cf_e385ac_mdio0_info,
+                                   ARRAY_SIZE(cf_e385ac_mdio0_info));
+       ath79_register_mdio(0, 0x0);
+
+       ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
+
+       /* QCA9558 GMAC0 is connected to RMGII interface */
+       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+       ath79_eth0_data.phy_mask = BIT(0);
+       ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
+       ath79_eth0_pll_data.pll_1000 = 0x96000000;
+
+       ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+       ath79_register_eth(0);
+
+       /* QCA9558 GMAC1 is connected to SGMII interface */
+       ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
+       ath79_eth1_data.speed = SPEED_1000;
+       ath79_eth1_data.duplex = DUPLEX_FULL;
+       ath79_eth1_pll_data.pll_1000 = 0x03000101;
+
+       ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
+       ath79_register_eth(1);
+}
+
+MIPS_MACHINE(ATH79_MACH_CF_E385AC, "CF-E385AC", "COMFAST CF-E385AC",
+            cf_e385ac_setup);
+
 static void __init cf_e5x0n_gpio_setup(void)
 {
        ath79_gpio_direction_select(CF_E5X0N_GPIO_LED_WAN, true);
index 2d26b86c4d5fda4197d448e8c28b7740a9415778..c7e16ec07f5955f3a4b7b205ed9bcd3efc090a7c 100644 (file)
@@ -68,6 +68,7 @@ enum ath79_mach_type {
        ATH79_MACH_CF_E375AC,                   /* COMFAST CF-E375AC */
        ATH79_MACH_CF_E380AC_V1,                /* COMFAST CF-E380AC v1 */
        ATH79_MACH_CF_E380AC_V2,                /* COMFAST CF-E380AC v2 */
+       ATH79_MACH_CF_E385AC,                   /* COMFAST CF-E385AC */
        ATH79_MACH_CF_E520N,                    /* COMFAST CF-E520N */
        ATH79_MACH_CF_E530N,                    /* COMFAST CF-E530N */
        ATH79_MACH_CPE210,                      /* TP-LINK CPE210 */
index 2053028c62e37cea73105d2ca53763fc4fe74919..80e20ac0e1aba53b18d20467b20dd43265774336 100644 (file)
@@ -242,6 +242,16 @@ define Device/cf-e380ac-v2
 endef
 TARGET_DEVICES += cf-e380ac-v2
 
+define Device/cf-e385ac
+  DEVICE_TITLE := COMFAST CF-E385AC
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-ath10k ath10k-firmware-qca9984 \
+       -uboot-envtools
+  BOARDNAME := CF-E385AC
+  IMAGE_SIZE := 16000k
+  MTDPARTS := spi0.0:256k(u-boot)ro,64k(art)ro,16000k(firmware),64k(art-backup)ro
+endef
+TARGET_DEVICES += cf-e385ac
+
 define Device/cf-e520n
   DEVICE_TITLE := COMFAST CF-E520N
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2 -swconfig -uboot-envtools