[LEDE-DEV] [PATCH] Add support for Comfast E380AC v1 and v2

Gareth Parker gareth41 at orcon.net.nz
Mon Oct 17 03:14:44 PDT 2016


The Comfast E380AC is a single port PoE Dual Band AP.

There are two versions which are only identifiable through the web administration interface, v1 has 128mb ram and a uboot size of 128k, v2 has 256mb ram and a uboot size of 256k, the remaining hardware and PCB markings are the same.

The factory firmware is built on openwrt and will accept a sysupgrade file, this patch produces two sysupgrade files for both versions.

Signed-off-by: Gareth Parker <gareth41 at orcon.net.nz>
---
 target/linux/ar71xx/base-files/etc/diag.sh         |    4 +
 .../etc/hotplug.d/firmware/11-ath10k-caldata       |    5 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |    6 +
 .../ar71xx/base-files/lib/upgrade/platform.sh      |   12 ++
 target/linux/ar71xx/config-4.4                     |    1 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |   10 +
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |    1 +
 .../ar71xx/files/arch/mips/ath79/mach-cf-e380ac.c  |  197 ++++++++++++++++++++
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |    2 +
 target/linux/ar71xx/image/generic.mk               |   18 ++
 10 files changed, 256 insertions(+)
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e380ac.c

diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index d6e257d..c8e6b48 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -82,6 +82,10 @@ get_status_led() {
 	cf-e316n-v2)
 		status_led="$board:blue:wan"
 		;;
+	cf-e380ac-v1|\
+	cf-e380ac-v2)
+		status_led="cfe380ac:green"
+		;;
 	cpe510)
 		status_led="tp-link:green:link4"
 		;;
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 0e93feb..7598a83 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
@@ -47,6 +47,11 @@ board=$(ar71xx_board_name)
 case "$FIRMWARE" in
 "ath10k/cal-pci-0000:00:00.0.bin")
 	case $board in
+	cf-e380ac-v1 | \
+	cf-e380ac-v2)
+		ath10kcal_extract "art" 20480 2116
+		ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +3)
+		;;
 	dlan-pro-1200-ac)
 		ath10kcal_extract "art" 20480 2116
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index dae6fb2..fb017f5 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -488,6 +488,12 @@ ar71xx_board_detect() {
 	*"COMFAST CF-E316N v2")
 		name="cf-e316n-v2"
 		;;
+	*"COMFAST CF-E380AC-V1")
+		name="cf-e380ac-v1"
+		;;
+	*"COMFAST CF-E380AC-V2")
+		name="cf-e380ac-v2"
+		;;
 	*"CPE210/220")
 		name="cpe210"
 		tplink_pharos_board_detect
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 559f97d..2463587 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -495,6 +495,16 @@ platform_check_image() {
 		alfa_check_image "$1" && return 0
 		return 1
 		;;
+
+	cf-e380ac-v1|\
+	cf-e380ac-v2)
+		[ "$magic_long" != "27051956" ] && {
+			echo "Invalid image type."
+			return 1
+		}
+		return 0
+		;;
+
 	wndr3700|\
 	wnr1000-v2|\
 	wnr2000-v3|\
@@ -597,6 +607,8 @@ platform_do_upgrade() {
 	om5p)
 		platform_do_upgrade_openmesh "$ARGV"
 		;;
+	cf-e380ac-v1|\
+	cf-e380ac-v2|\
 	uap-pro|\
 	unifi-outdoor-plus)
 		MTD_CONFIG_ARGS="-s 0x180000"
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index 7aeac89..9232c4c 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -60,6 +60,7 @@ CONFIG_ATH79_MACH_CAP324=y
 CONFIG_ATH79_MACH_CAP4200AG=y
 CONFIG_ATH79_MACH_CARAMBOLA2=y
 CONFIG_ATH79_MACH_CF_E316N_V2=y
+CONFIG_ATH79_MACH_CF_E380AC=y
 CONFIG_ATH79_MACH_CPE510=y
 CONFIG_ATH79_MACH_CR3000=y
 CONFIG_ATH79_MACH_CR5000=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 4cefde1..340d6f3 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1623,6 +1623,16 @@ config ATH79_MACH_CF_E316N_V2
 	select ATH79_DEV_USB
 	select ATH79_DEV_WMAC
 
+config ATH79_MACH_CF_E380AC
+	bool "COMFAST CF-E380AC board support"
+	select SOC_QCA955X
+	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_BHU_BXU2000N2_A
 	bool "BHU BXU2000n-2 rev. A support"
 	select SOC_AR934X
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
index 5e7a811..e364dbe 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_ATH79_MACH_CAP324)			+= mach-cap324.o
 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_E380AC)		+= mach-cf-e380ac.o
 obj-$(CONFIG_ATH79_MACH_CPE510)			+= mach-cpe510.o
 obj-$(CONFIG_ATH79_MACH_CR3000)			+= mach-cr3000.o
 obj-$(CONFIG_ATH79_MACH_CR5000)			+= mach-cr5000.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e380ac.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e380ac.c
new file mode 100644
index 0000000..47a848c
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e380ac.c
@@ -0,0 +1,197 @@
+/*
+ *  COMFAST cf-e380ac board support
+ *
+ *  There are two versions for this board, the only difference being v1 has
+ *  a u-boot size of 128k and v2 has a u-boot size of 256k.  The hardware
+ *  is the same.  Version numbers are printed in the factory firmware web
+ *  administration.
+ *
+ *  Copyright (C) 2016 Gareth Parker <gareth41 at orcon.net.nz>
+ *
+ *  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/init.h>
+#include <linux/pci.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/ath9k_platform.h>
+#include <linux/etherdevice.h>
+#include <linux/ar8216_platform.h>
+#include <linux/platform_data/phy-at803x.h>
+
+#include <asm/mach-ath79/irq.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 "dev-usb.h"
+#include "dev-wmac.h"
+#include "dev-nfc.h"
+#include "machtypes.h"
+#include "pci.h"
+
+#define CF_E380AC_KEYS_POLL_INTERVAL	20	/* msecs */
+#define CF_E380AC_KEYS_DEBOUNCE_INTERVAL (3 * CF_E380AC_KEYS_POLL_INTERVAL)
+
+#define CF_E380AC_GPIO_WATCHDOG		17
+
+#define CF_E380AC_GPIO_BTN_RESET_WPS	19
+
+#define CF_E380AC_GPIO_LED_RED		3
+#define CF_E380AC_GPIO_LED_GREEN	0
+#define CF_E380AC_GPIO_LED_BLUE		2
+
+#define CF_E380AC_WMAC_CALDATA_OFFSET		0x1000
+#define CF_E380AC_PCIE_CALDATA_OFFSET		0x5000
+
+static struct gpio_led cf_e380ac_leds_gpio[] __initdata = {
+	{
+		.name		= "cfe380ac:red",
+		.gpio		= CF_E380AC_GPIO_LED_RED,
+		.active_low	= 0,
+	},
+	{
+		.name		= "cfe380ac:green",
+		.gpio		= CF_E380AC_GPIO_LED_GREEN,
+		.active_low	= 0,
+	},
+	{
+		.name		= "cfe380ac:blue",
+		.gpio		= CF_E380AC_GPIO_LED_BLUE,
+		.active_low	= 0,
+	},
+
+};
+
+static struct gpio_keys_button cf_e380ac_gpio_keys[] __initdata = {
+	{
+		.desc		= "Reset button/WPS button",
+		.type		= EV_KEY,
+		.code		= KEY_RESTART,
+		.debounce_interval = CF_E380AC_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= CF_E380AC_GPIO_BTN_RESET_WPS,
+		.active_low	= 1,
+	},
+};
+
+static struct at803x_platform_data cf_e380ac_at803x_data = {
+	.disable_smarteee = 1,
+};
+
+static struct mdio_board_info cf_e380ac_mdio0_info[] = {
+	{
+		.bus_id = "ag71xx-mdio.0",
+		.phy_addr = 0,
+		.platform_data = &cf_e380ac_at803x_data,
+	},
+};
+
+static struct timer_list gpio_watchdog;
+
+static void gpio_watchdog_init(unsigned long period)
+{
+        static int state;
+        state = !state;
+        gpio_set_value(CF_E380AC_GPIO_WATCHDOG, state);
+        mod_timer(&gpio_watchdog, jiffies + period);
+}
+
+static void __init cf_e380ac_v1_setup(void)
+{
+	u8 *art = (u8 *) KSEG1ADDR(0x1f020000);
+	u8 wlan0_mac[ETH_ALEN];
+	u8 wlan1_mac[ETH_ALEN];
+
+	gpio_request(CF_E380AC_GPIO_WATCHDOG, "watchdog init");
+	gpio_direction_output(CF_E380AC_GPIO_WATCHDOG, 0);
+	setup_timer(&gpio_watchdog, gpio_watchdog_init, msecs_to_jiffies(500));
+	gpio_watchdog_init(msecs_to_jiffies(1));
+
+	ath79_register_m25p80(NULL);
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_leds_gpio),
+					cf_e380ac_leds_gpio);
+	ath79_register_gpio_keys_polled(-1, CF_E380AC_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(cf_e380ac_gpio_keys),
+					cf_e380ac_gpio_keys);
+
+	ath79_register_usb();
+
+	ath79_init_mac(wlan0_mac, art, 1);
+	ath79_init_mac(wlan1_mac, art, 3);
+
+	ath79_register_wmac(art + CF_E380AC_WMAC_CALDATA_OFFSET, wlan0_mac);
+	ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
+
+	ath79_register_mdio(0, 0x0);
+	mdiobus_register_board_info(cf_e380ac_mdio0_info,
+				    ARRAY_SIZE(cf_e380ac_mdio0_info));
+
+	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_10 = 0xB0001313;
+	ath79_eth0_pll_data.pll_100 = 0xB0000101;
+	ath79_eth0_pll_data.pll_1000 = 0xBE000000;
+	ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
+	ath79_register_eth(0);
+
+	ap91_pci_init(art + CF_E380AC_PCIE_CALDATA_OFFSET, wlan1_mac);
+}
+
+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)
+{
+	u8 *art = (u8 *) KSEG1ADDR(0x1f040000);
+	u8 wlan0_mac[ETH_ALEN];
+	u8 wlan1_mac[ETH_ALEN];
+
+	gpio_request(CF_E380AC_GPIO_WATCHDOG, "watchdog init");
+	gpio_direction_output(CF_E380AC_GPIO_WATCHDOG, 0);
+	setup_timer(&gpio_watchdog, gpio_watchdog_init, msecs_to_jiffies(500));
+	gpio_watchdog_init(msecs_to_jiffies(1));
+
+	ath79_register_m25p80(NULL);
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_leds_gpio),
+					cf_e380ac_leds_gpio);
+	ath79_register_gpio_keys_polled(-1, CF_E380AC_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(cf_e380ac_gpio_keys),
+					cf_e380ac_gpio_keys);
+
+	ath79_register_usb();
+
+	ath79_init_mac(wlan0_mac, art, 1);
+	ath79_init_mac(wlan1_mac, art, 3);
+
+	ath79_register_wmac(art + CF_E380AC_WMAC_CALDATA_OFFSET, wlan0_mac);
+	ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
+
+	ath79_register_mdio(0, 0x0);
+	mdiobus_register_board_info(cf_e380ac_mdio0_info,
+				    ARRAY_SIZE(cf_e380ac_mdio0_info));
+
+	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_10 = 0xB0001313;
+	ath79_eth0_pll_data.pll_100 = 0xB0000101;
+	ath79_eth0_pll_data.pll_1000 = 0xBE000000;
+	ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
+	ath79_register_eth(0);
+
+	ap91_pci_init(art + CF_E380AC_PCIE_CALDATA_OFFSET, wlan1_mac);
+}
+
+MIPS_MACHINE(ATH79_MACH_CF_E380AC_V2, "CF-E380AC-V2", "COMFAST CF-E380AC-V2",
+	     cf_e380ac_v2_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index e3611dc..d5fc5fd 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -51,6 +51,8 @@ enum ath79_mach_type {
 	ATH79_MACH_CAP4200AG,			/* Senao CAP4200AG */
 	ATH79_MACH_CARAMBOLA2,			/* 8devices Carambola2 */
 	ATH79_MACH_CF_E316N_V2,			/* COMFAST CF-E316N v2 */
+	ATH79_MACH_CF_E380AC_V1,		/* COMFAST CF-E380AC-V1 */
+	ATH79_MACH_CF_E380AC_V2,		/* COMFAST CF-E380AC-V2 */
 	ATH79_MACH_CPE210,			/* TP-LINK CPE210 */
 	ATH79_MACH_CPE510,			/* TP-LINK CPE510 */
 	ATH79_MACH_CR3000,			/* PowerCloud CR3000 */
diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk
index 0307b26..43c2d62 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -27,6 +27,24 @@ define Device/cf-e316n-v2
 endef
 TARGET_DEVICES += cf-e316n-v2
 
+define Device/cf-e380ac-v1
+  DEVICE_TITLE := COMFAST CF-E380AC-V1
+  BOARDNAME = CF-E380AC-V1
+  IMAGE_SIZE = 16128k
+  CONSOLE = ttyS0,115200
+  MTDPARTS = spi0.0:128k(u-boot)ro,64k(art)ro,16128k(firmware),64k(nvram)ro
+endef
+TARGET_DEVICES += cf-e380ac-v1
+
+define Device/cf-e380ac-v2
+  DEVICE_TITLE := COMFAST CF-E380AC-V2
+  BOARDNAME = CF-E380AC-V2
+  IMAGE_SIZE = 16000k
+  CONSOLE = ttyS0,115200
+  MTDPARTS = spi0.0:256k(u-boot)ro,64k(art)ro,16000k(firmware),64k(nvram)ro
+endef
+TARGET_DEVICES += cf-e380ac-v2
+
 define Device/weio
   DEVICE_TITLE := WeIO
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2
-- 
1.7.9.5




More information about the Lede-dev mailing list