[source] ar71xx: add support for COMFAST CF-E320N v2 and CF-E520N/CF-E530N

LEDE Commits lede-commits at lists.infradead.org
Mon Nov 21 01:58:00 PST 2016


blogic pushed a commit to source.git, branch master:
https://git.lede-project.org/31952dbd1c40a2cd015ef435bd64fa9b2bb87eec

commit 31952dbd1c40a2cd015ef435bd64fa9b2bb87eec
Author: Piotr Dymacz <pepe2k at gmail.com>
AuthorDate: Wed Oct 5 02:24:58 2016 +0200

    ar71xx: add support for COMFAST CF-E320N v2 and CF-E520N/CF-E530N
    
    As we already have support for CF-E316N v2 and many devices from
    this vendor look similar, the support was included in existing
    mach-*.c file, with few cleanups and fixes.
    
    All 3 devices are based on Qualcomm/Atheros QCA9531 v2.
    
    COMFAST CF-E320N v2 is a ceiling mount AP with PoE support.
    Short specification:
    
    - 650/393/216 MHz (CPU/DDR/AHB)
    - 2x 10/100 Mbps Ethernet, both with PoE support
    - 64 MB of RAM (DDR2)
    - 16 MB of FLASH
    - 2T2R 2.4 GHz, up to 22 dBm
    - 2x internal antennas
    - 1x RGB LED, 1x button
    - UART (J1), GPIO (J9) and USB (J2) headers on PCB
    - external watchdog (Pericon Technology PT7A7514)
    
    COMFAST CF-E520N/CF-E530N are in-wall APs with USB and PoE support.
    They seem to have different only the front panel.
    Short specification:
    
    - 650/393/216 MHz (CPU/DDR/AHB)
    - 2x 10/100 Mbps Ethernet, WAN with PoE support
    - 1x USB 2.0 (in CF-E520N covered by panel, available on PCB)
    - 32 MB of RAM (DDR2)
    - 8 MB of FLASH
    - 2T2R 2.4 GHz, up to 22 dBm
    - 2x internal antennas
    - 1x LED, 1x button
    - UART (J1) headers on PCB
    
    Flash instruction:
    
    Original firmware is based on OpenWrt.
    Use sysupgrade image directly in vendor GUI.
    
    Signed-off-by: Piotr Dymacz <pepe2k at gmail.com>
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   9 +
 target/linux/ar71xx/base-files/etc/diag.sh         |   7 +-
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |  11 +-
 .../ar71xx/base-files/lib/upgrade/platform.sh      |   3 +
 target/linux/ar71xx/config-4.4                     |   3 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  32 ++-
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   3 +
 .../files/arch/mips/ath79/mach-cf-e316n-v2.c       | 273 ++++++++++++++++++---
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   3 +
 target/linux/ar71xx/image/generic.mk               |  27 +-
 10 files changed, 329 insertions(+), 42 deletions(-)

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 2a1138c..4490c09 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -115,6 +115,15 @@ cf-e316n-v2)
 	ucidef_set_led_netdev "wan" "WAN" "$board:blue:wan" "eth1"
 	ucidef_set_led_wlan "wlan" "WLAN" "$board:blue:wlan" "phy0tpt"
 	;;
+cf-e320n-v2)
+	ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth0"
+	ucidef_set_led_netdev "wan" "WAN" "$board:red:wan" "eth1"
+	ucidef_set_led_wlan "wlan" "WLAN" "$board:blue:wlan" "phy0tpt"
+	;;
+cf-e520n|\
+cf-e530n)
+	ucidef_set_led_netdev "wan" "WAN" "$board:blue:wan" "eth1"
+	;;
 cpe210|\
 cpe510)
 	ucidef_set_led_switch "lan0" "LAN0" "tp-link:green:lan0" "switch0" "0x20"
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index bfd619a..e1e76a4 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -86,9 +86,14 @@ get_status_led() {
 	cap4200ag)
 		status_led="senao:green:pwr"
 		;;
-	cf-e316n-v2)
+	cf-e316n-v2|\
+	cf-e520n|\
+	cf-e530n)
 		status_led="$board:blue:wan"
 		;;
+	cf-e320n-v2)
+		status_led="$board:blue:wlan"
+		;;
 	cpe510)
 		status_led="tp-link:green:link4"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 9495bf4..0b82d83 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -497,9 +497,18 @@ ar71xx_board_detect() {
 	*CAP4200AG)
 		name="cap4200ag"
 		;;
-	*"COMFAST CF-E316N v2")
+	*"CF-E316N v2")
 		name="cf-e316n-v2"
 		;;
+	*"CF-E320N v2")
+		name="cf-e320n-v2"
+		;;
+	*CF-E520N)
+		name="cf-e520n"
+		;;
+	*CF-E530N)
+		name="cf-e530n"
+		;;
 	*"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 2358c58..fa12870 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -182,6 +182,9 @@ platform_check_image() {
 	c-55|\
 	carambola2|\
 	cf-e316n-v2|\
+	cf-e320n-v2|\
+	cf-e520n|\
+	cf-e530n|\
 	dgl-5500-a1|\
 	dhp-1565-a1|\
 	dir-505-a1|\
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index aa20f9b..cc93515 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -62,6 +62,9 @@ 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_E320N_V2=y
+CONFIG_ATH79_MACH_CF_E520N=y
+CONFIG_ATH79_MACH_CF_E530N=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 ac8255b..73f8d21 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1677,7 +1677,7 @@ config ATH79_MACH_CARAMBOLA2
 	select ATH79_DEV_WMAC
 
 config ATH79_MACH_CF_E316N_V2
-	bool "COMFAST CF-E316N v2 board"
+	bool "COMFAST CF-E316N v2 support"
 	select SOC_AR934X
 	select ATH79_DEV_ETH
 	select ATH79_DEV_GPIO_BUTTONS
@@ -1686,6 +1686,36 @@ config ATH79_MACH_CF_E316N_V2
 	select ATH79_DEV_USB
 	select ATH79_DEV_WMAC
 
+config ATH79_MACH_CF_E320N_V2
+	bool "COMFAST CF-E320N v2 support"
+	select SOC_QCA953X
+	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
+	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_E530N
+	bool "COMFAST CF-E530N support"
+	select SOC_QCA953X
+	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 78e242a..24b3ea0 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -68,6 +68,9 @@ 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_E320N_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
 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-e316n-v2.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e316n-v2.c
index cf3d33a..d958bad 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
@@ -1,9 +1,10 @@
 /*
- *  COMFAST CF-E316N v2
- *  by Shenzhen Four Seas Global Link Network Technology Co., Ltd
- *
- *  aka CF-E316V2, CF-E316N-V2 and CF-E316Nv2.0 (no FCC ID)
+ *  Support for COMFAST boards:
+ *  - CF-E316N v2 (AR9341)
+ *  - CF-E320N v2 (QCA9531)
+ *  - CF-E520N/CF-E530N (QCA9531)
  *
+ *  Copyright (C) 2016 Piotr Dymacz <pepe2k at gmail.com>
  *  Copyright (C) 2015 Paul Fertser <fercerpav at gmail.com>
  *
  *  This program is free software; you can redistribute it and/or modify it
@@ -27,72 +28,171 @@
 #include "dev-usb.h"
 #include "machtypes.h"
 
+#define CF_EXXXN_KEYS_POLL_INTERVAL	20
+#define CF_EXXXN_KEYS_DEBOUNCE_INTERVAL	(3 * CF_EXXXN_KEYS_POLL_INTERVAL)
+
+/* CF-E316N v2 */
+#define CF_E316N_V2_GPIO_LED_DIAG_B	0
+#define CF_E316N_V2_GPIO_LED_DIAG_R	2
+#define CF_E316N_V2_GPIO_LED_DIAG_G	3
+#define CF_E316N_V2_GPIO_LED_WLAN	12
+#define CF_E316N_V2_GPIO_LED_WAN	17
+#define CF_E316N_V2_GPIO_LED_LAN	19
+
+#define CF_E316N_V2_GPIO_EXT_WDT	16
+
+#define CF_E316N_V2_GPIO_EXTERNAL_PA0	13
+#define CF_E316N_V2_GPIO_EXTERNAL_PA1	14
+
+#define CF_E316N_V2_GPIO_BTN_RESET	20
+
 static struct gpio_led cf_e316n_v2_leds_gpio[] __initdata = {
 	{
 		.name		= "cf-e316n-v2:blue:diag",
-		.gpio		= 0,
+		.gpio		= CF_E316N_V2_GPIO_LED_DIAG_B,
 		.active_low	= 0,
 	}, {
 		.name		= "cf-e316n-v2:red:diag",
-		.gpio		= 2,
+		.gpio		= CF_E316N_V2_GPIO_LED_DIAG_R,
 		.active_low	= 0,
 	}, {
 		.name		= "cf-e316n-v2:green:diag",
-		.gpio		= 3,
+		.gpio		= CF_E316N_V2_GPIO_LED_DIAG_G,
 		.active_low	= 0,
 	}, {
 		.name		= "cf-e316n-v2:blue:wlan",
-		.gpio		= 12,
+		.gpio		= CF_E316N_V2_GPIO_LED_WLAN,
 		.active_low	= 1,
 	}, {
 		.name		= "cf-e316n-v2:blue:wan",
-		.gpio		= 17,
+		.gpio		= CF_E316N_V2_GPIO_LED_WAN,
 		.active_low	= 1,
 	}, {
 		.name		= "cf-e316n-v2:blue:lan",
-		.gpio		= 19,
+		.gpio		= CF_E316N_V2_GPIO_LED_LAN,
 		.active_low	= 1,
 	},
 };
 
 static struct gpio_keys_button cf_e316n_v2_gpio_keys[] __initdata = {
 	{
+		.desc		= "reset",
+		.type		= EV_KEY,
+		.code		= KEY_RESTART,
+		.debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= CF_E316N_V2_GPIO_BTN_RESET,
+		.active_low	= 1,
+	},
+};
+
+/* CF-E320N v2 */
+#define CF_E320N_V2_GPIO_LED_WLAN	0
+#define CF_E320N_V2_GPIO_LED_WAN	2
+#define CF_E320N_V2_GPIO_LED_LAN	3
+
+#define CF_E320N_V2_GPIO_HEADER_J9_1	14
+#define CF_E320N_V2_GPIO_HEADER_J9_2	12
+#define CF_E320N_V2_GPIO_HEADER_J9_3	11
+#define CF_E320N_V2_GPIO_HEADER_J9_4	16
+
+#define CF_E320N_V2_GPIO_EXT_WDT	13
+
+#define CF_E320N_V2_GPIO_BTN_RESET	17
+
+static struct gpio_led cf_e320n_v2_leds_gpio[] __initdata = {
+	{
+		.name		= "cf-e320n-v2:green:lan",
+		.gpio		= CF_E320N_V2_GPIO_LED_LAN,
+		.active_low	= 0,
+	}, {
+		.name		= "cf-e320n-v2:red:wan",
+		.gpio		= CF_E320N_V2_GPIO_LED_WAN,
+		.active_low	= 0,
+	}, {
+		.name		= "cf-e320n-v2:blue:wlan",
+		.gpio		= CF_E320N_V2_GPIO_LED_WLAN,
+		.active_low	= 0,
+	},
+};
+
+static struct gpio_keys_button cf_e320n_v2_gpio_keys[] __initdata = {
+	{
 		.desc		= "Reset button",
 		.type		= EV_KEY,
 		.code		= KEY_RESTART,
-		.debounce_interval = 60,
-		.gpio		= 20,
+		.debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= CF_E320N_V2_GPIO_BTN_RESET,
 		.active_low	= 1,
 	},
 };
 
-/* There's a Pericon Technology PT7A7514 connected to GPIO 16 */
-#define EXT_WATCHDOG_GPIO	16
+/* CF-E520N/CF-E530N */
+#define CF_E5X0N_GPIO_LED_WAN		11
+#define CF_E5X0N_GPIO_BTN_RESET		17
+
+static struct gpio_led cf_e520n_leds_gpio[] __initdata = {
+	{
+		.name		= "cf-e520n:blue:wan",
+		.gpio		= CF_E5X0N_GPIO_LED_WAN,
+		.active_low	= 1,
+	}
+};
+
+static struct gpio_led cf_e530n_leds_gpio[] __initdata = {
+	{
+		.name		= "cf-e530n:blue:wan",
+		.gpio		= CF_E5X0N_GPIO_LED_WAN,
+		.active_low	= 1,
+	}
+};
+
+/*
+ * Some COMFAST devices include external hardware watchdog chip,
+ * Pericon Technology PT7A7514, connected to a selected GPIO
+ * and WiSoC RESET_L input. Watchdog time-out is ~1.6 s.
+ */
+#define CF_EXXXN_EXT_WDT_TIMEOUT_MS	500
+
 static struct timer_list gpio_wdt_timer;
 
-static void gpio_wdt_toggle(unsigned long period)
+static void gpio_wdt_toggle(unsigned long gpio)
 {
 	static int state;
+
 	state = !state;
-	gpio_set_value(EXT_WATCHDOG_GPIO, state);
-	mod_timer(&gpio_wdt_timer, jiffies + period);
+	gpio_set_value(gpio, state);
+
+	mod_timer(&gpio_wdt_timer,
+		  jiffies + msecs_to_jiffies(CF_EXXXN_EXT_WDT_TIMEOUT_MS));
 }
 
-static void __init cf_e316n_v2_setup(void)
+static void __init cf_exxxn_common_setup(int gpio_wdt)
 {
-	u8 *maclan = (u8 *) KSEG1ADDR(0x1f010000);
-	u8 *macwlan = (u8 *) KSEG1ADDR(0x1f011002);
-	u8 *ee = (u8 *) KSEG1ADDR(0x1f011000);
-	u8 tmpmac[ETH_ALEN];
+	u8 *art = (u8 *) KSEG1ADDR(0x1f011000);
+
+	if (gpio_wdt > -1) {
+		gpio_request_one(gpio_wdt, GPIOF_OUT_INIT_HIGH,
+				 "PT7A7514 watchdog");
 
-	gpio_request(EXT_WATCHDOG_GPIO, "PT7A7514 watchdog");
-	gpio_direction_output(EXT_WATCHDOG_GPIO, 0);
-	setup_timer(&gpio_wdt_timer, gpio_wdt_toggle, msecs_to_jiffies(500));
-	gpio_wdt_toggle(msecs_to_jiffies(1));
+		setup_timer(&gpio_wdt_timer, gpio_wdt_toggle, gpio_wdt);
+		gpio_wdt_toggle(gpio_wdt);
+	}
 
 	ath79_register_m25p80(NULL);
 
+	ath79_register_wmac(art, NULL);
+
+	ath79_register_usb();
+}
+
+static void __init cf_e316n_v2_setup(void)
+{
+	u8 *mac = (u8 *) KSEG1ADDR(0x1f010000);
+
+	cf_exxxn_common_setup(CF_E316N_V2_GPIO_EXT_WDT);
+
 	ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
+
 	ath79_register_mdio(1, 0x0);
 
 	/* GMAC0 is connected to the PHY0 of the internal switch */
@@ -101,32 +201,129 @@ static void __init cf_e316n_v2_setup(void)
 	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
 	ath79_eth0_data.phy_mask = BIT(0);
 	ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
-	ath79_init_mac(ath79_eth0_data.mac_addr, maclan, 0);
+	ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
 	ath79_register_eth(0);
 
 	/* GMAC1 is connected to the internal switch */
 	ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
-	ath79_init_mac(ath79_eth1_data.mac_addr, maclan, 2);
+	ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
 	ath79_register_eth(1);
 
 	/* Enable 2x Skyworks SE2576L WLAN power amplifiers */
-	gpio_request(13, "RF Amp 1");
-	gpio_direction_output(13, 1);
-	gpio_request(14, "RF Amp 2");
-	gpio_direction_output(14, 1);
-	ath79_init_mac(tmpmac, macwlan, 0);
-	ath79_register_wmac(ee, tmpmac);
+	gpio_request_one(CF_E316N_V2_GPIO_EXTERNAL_PA0, GPIOF_OUT_INIT_HIGH,
+			 "WLAN PA0");
+	gpio_request_one(CF_E316N_V2_GPIO_EXTERNAL_PA1, GPIOF_OUT_INIT_HIGH,
+			 "WLAN PA1");
 
 	ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e316n_v2_leds_gpio),
 				 cf_e316n_v2_leds_gpio);
 
-	ath79_register_gpio_keys_polled(1, 20,
+	ath79_register_gpio_keys_polled(1, CF_EXXXN_KEYS_POLL_INTERVAL,
 					ARRAY_SIZE(cf_e316n_v2_gpio_keys),
 					cf_e316n_v2_gpio_keys);
-
-	/* J1 is a High-Speed USB port, pin 1 is Vcc */
-	ath79_register_usb();
 }
 
 MIPS_MACHINE(ATH79_MACH_CF_E316N_V2, "CF-E316N-V2", "COMFAST CF-E316N v2",
 	     cf_e316n_v2_setup);
+
+static void __init cf_exxxn_qca953x_eth_setup(void)
+{
+	u8 *mac = (u8 *) KSEG1ADDR(0x1f010000);
+
+	ath79_setup_ar933x_phy4_switch(false, false);
+
+	ath79_register_mdio(0, 0x0);
+
+	ath79_switch_data.phy4_mii_en = 1;
+	ath79_switch_data.phy_poll_mask |= BIT(4);
+
+	/* LAN */
+	ath79_eth1_data.duplex = DUPLEX_FULL;
+	ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+	ath79_eth1_data.speed = SPEED_1000;
+	ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
+	ath79_register_eth(1);
+
+	/* WAN */
+	ath79_eth0_data.duplex = DUPLEX_FULL;
+	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+	ath79_eth0_data.speed = SPEED_100;
+	ath79_eth0_data.phy_mask = BIT(4);
+	ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+	ath79_register_eth(0);
+}
+
+static void __init cf_e320n_v2_setup(void)
+{
+	cf_exxxn_common_setup(CF_E320N_V2_GPIO_EXT_WDT);
+
+	cf_exxxn_qca953x_eth_setup();
+
+	/* Disable JTAG (enables GPIO0-3) */
+	ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
+
+	ath79_gpio_direction_select(CF_E320N_V2_GPIO_LED_LAN, true);
+	ath79_gpio_direction_select(CF_E320N_V2_GPIO_LED_WAN, true);
+	ath79_gpio_direction_select(CF_E320N_V2_GPIO_LED_WLAN, true);
+
+	ath79_gpio_output_select(CF_E320N_V2_GPIO_LED_LAN, 0);
+	ath79_gpio_output_select(CF_E320N_V2_GPIO_LED_WAN, 0);
+	ath79_gpio_output_select(CF_E320N_V2_GPIO_LED_WLAN, 0);
+
+	/* Enable GPIO function for GPIOs in J9 header */
+	ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_1, 0);
+	ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_2, 0);
+	ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_3, 0);
+	ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_4, 0);
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e320n_v2_leds_gpio),
+				 cf_e320n_v2_leds_gpio);
+
+	ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(cf_e320n_v2_gpio_keys),
+					cf_e320n_v2_gpio_keys);
+}
+
+MIPS_MACHINE(ATH79_MACH_CF_E320N_V2, "CF-E320N-V2", "COMFAST CF-E320N v2",
+	     cf_e320n_v2_setup);
+
+static void __init cf_e5x0n_gpio_setup(void)
+{
+	ath79_gpio_direction_select(CF_E5X0N_GPIO_LED_WAN, true);
+
+	ath79_gpio_output_select(CF_E5X0N_GPIO_LED_WAN, 0);
+
+	ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(cf_e320n_v2_gpio_keys),
+					cf_e320n_v2_gpio_keys);
+}
+
+static void __init cf_e520n_setup(void)
+{
+	cf_exxxn_common_setup(-1);
+
+	cf_exxxn_qca953x_eth_setup();
+
+	cf_e5x0n_gpio_setup();
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e520n_leds_gpio),
+				 cf_e520n_leds_gpio);
+}
+
+MIPS_MACHINE(ATH79_MACH_CF_E520N, "CF-E520N", "COMFAST CF-E520N",
+	     cf_e520n_setup);
+
+static void __init cf_e530n_setup(void)
+{
+	cf_exxxn_common_setup(-1);
+
+	cf_exxxn_qca953x_eth_setup();
+
+	cf_e5x0n_gpio_setup();
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e530n_leds_gpio),
+				 cf_e530n_leds_gpio);
+}
+
+MIPS_MACHINE(ATH79_MACH_CF_E530N, "CF-E530N", "COMFAST CF-E530N",
+	     cf_e530n_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index dec3d60..741ebb2 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -53,6 +53,9 @@ 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_E320N_V2,			/* COMFAST CF-E320N v2 */
+	ATH79_MACH_CF_E520N,			/* COMFAST CF-E520N */
+	ATH79_MACH_CF_E530N,			/* COMFAST CF-E530N */
 	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 d6142c1..e80c853 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -23,10 +23,35 @@ define Device/cf-e316n-v2
   BOARDNAME = CF-E316N-V2
   IMAGE_SIZE = 16192k
   CONSOLE = ttyS0,115200
-  MTDPARTS = spi0.0:64k(u-boot)ro,64k(art)ro,16192k(firmware),64k(nvram)ro
+  MTDPARTS = spi0.0:64k(u-boot)ro,64k(art)ro,16192k(firmware),64k(art-backup)ro
 endef
 TARGET_DEVICES += cf-e316n-v2
 
+define Device/cf-e320n-v2
+  $(Device/cf-e316n-v2)
+  DEVICE_TITLE := COMFAST CF-E320N v2
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2
+  BOARDNAME = CF-E320N-V2
+endef
+TARGET_DEVICES += cf-e320n-v2
+
+define Device/cf-e520n
+  DEVICE_TITLE := COMFAST CF-E520N
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2
+  BOARDNAME = CF-E520N
+  IMAGE_SIZE = 8000k
+  CONSOLE = ttyS0,115200
+  MTDPARTS = spi0.0:64k(u-boot)ro,64k(art)ro,8000k(firmware),64k(art-backup)ro
+endef
+TARGET_DEVICES += cf-e520n
+
+define Device/cf-e530n
+  $(Device/cf-e520n)
+  DEVICE_TITLE := COMFAST CF-E530N
+  BOARDNAME = CF-E530N
+endef
+TARGET_DEVICES += cf-e530n
+
 define Device/domywifi-dw33d
   DEVICE_TITLE := DomyWifi DW33D
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-storage kmod-ledtrig-usbdev kmod-ath10k



More information about the lede-commits mailing list