From: Piotr Dymacz Date: Tue, 23 Jan 2018 20:37:16 +0000 (+0100) Subject: ar71xx: add support for COMFAST CF-E385AC X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=650a5e993b3b252da511e90706f3759d5ea68ce1;p=openwrt%2Fstaging%2Fadrian.git ar71xx: add support for COMFAST CF-E385AC 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 --- 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 85f104a5fd..1b308d7f77 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -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) diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network index 0fe71e0760..434056a344 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -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|\ diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index facc77ee60..232e43b8dc 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -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) diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 3aa5e3c90f..a3d4867b0b 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -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 ;; *) diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 842f1c5081..fc578cec65 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -531,6 +531,9 @@ ar71xx_board_detect() { *"CF-E380AC v2") name="cf-e380ac-v2" ;; + *"CF-E385AC") + name="cf-e385ac" + ;; *"CF-E520N") name="cf-e520n" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index c408c7dfce..b080955359 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -213,6 +213,7 @@ platform_check_image() { cf-e375ac|\ cf-e380ac-v1|\ cf-e380ac-v2|\ + cf-e385ac|\ cf-e520n|\ cf-e530n|\ cpe505n|\ diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e316n-v2.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e316n-v2.c index 1ac6c8eddd..a5baeac2ed 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e316n-v2.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e316n-v2.c @@ -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 @@ -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); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h index 2d26b86c4d..c7e16ec07f 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h @@ -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 */ diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk index 2053028c62..80e20ac0e1 100644 --- a/target/linux/ar71xx/image/generic.mk +++ b/target/linux/ar71xx/image/generic.mk @@ -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