The Comfast E314N-V2 is a 2.4 GHz 2x2 radio with a built-in directional
antenna and a second Ethernet port - very similar to the Ubiquiti
NanoStation M2. The Ethernet port features a pass-through PoE
capability, enabled or disabled with a slide switch. The radio is built
using a Qualcomm/Atheros QCA9531 chipset.

The majority of the changes are in the
target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e316n-v2.c file.
One significant change is that the function cf_exxxn_qca953x_eth_setup
had to be moved before the CF-314N section in that file.

Firmware can be flashed on these units by the following method:
1.) Apply power to the unit
2.) Immediately AFTER applying power, hold down the reset button
3.) The WAN, LAN, and wireless lights will flash - wait three seconds
(three flashes) and then release the button.
4.) After a second, the lights will "flutter" quickly and the unit will
be visible at 192.168.1.1. A web page will be available to enable quick
and simple uploading and flashing of firmware.

During the boot process, these units also look for a tftp server at
192.168.1.10. If one is present, the firmware can be uploaded as a file
called "firmware-auto.bin"
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   5 +
 target/linux/ar71xx/base-files/etc/diag.sh         |   1 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh      |   1 +
 target/linux/ar71xx/config-4.4                     |   1 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  10 ++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../files/arch/mips/ath79/mach-cf-e316n-v2.c       | 148 +++++++++++++++++----
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/generic.mk               |   9 ++
 10 files changed, 153 insertions(+), 27 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 833522f..dae3481 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -143,6 +143,11 @@ carambola2)
        ucidef_set_led_netdev "wan" "WAN" "$board:orange:eth1" "eth1"
        ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt"
        ;;
+cf-e314n-v2)
+    ucidef_set_led_netdev "wan" "WAN" "$board:white:wan" "eth0"
+       ucidef_set_led_netdev "lan" "lAN" "$board:white:lan" "eth1"
+       ucidef_set_led_wlan "wlan" "WLAN" "$board:white:wlan" "phy0tpt"
+    ;;
 cf-e316n-v2)
        ucidef_set_led_netdev "lan" "LAN" "$board:blue:lan" "eth0"
        ucidef_set_led_netdev "wan" "WAN" "$board:blue:wan" "eth1"
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh 
b/target/linux/ar71xx/base-files/etc/diag.sh
index bc2fc2f..e2f26eb 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -101,6 +101,7 @@ get_status_led() {
        cap4200ag)
                status_led="senao:green:pwr"
                ;;
+    cf-e314n-v2|\
        cf-e316n-v2|\
        cf-e520n|\
        cf-e530n)
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh 
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index bf36598..b01f4af 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -487,6 +487,9 @@ ar71xx_board_detect() {
        *CAP4200AG)
                name="cap4200ag"
                ;;
+       *"CF-E314N v2")
+               name="cf-e314n-v2"
+               ;;
        *"CF-E316N v2")
                name="cf-e316n-v2"
                ;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh 
b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 21ad2a6..f7d03e5 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -209,6 +209,7 @@ platform_check_image() {
        bullet-m|\
        c-55|\
        carambola2|\
+    cf-e314n-v2|\
        cf-e316n-v2|\
        cf-e320n-v2|\
        cf-e380ac-v1|\
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index a862245..7ba7e2f 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -62,6 +62,7 @@ CONFIG_ATH79_MACH_C60=y
 CONFIG_ATH79_MACH_CAP324=y
 CONFIG_ATH79_MACH_CAP4200AG=y
 CONFIG_ATH79_MACH_CARAMBOLA2=y
+CONFIG_ATH79_MACH_CF_E314N_V2=y
 CONFIG_ATH79_MACH_CF_E316N_V2=y
 CONFIG_ATH79_MACH_CF_E320N_V2=y
 CONFIG_ATH79_MACH_CF_E380AC_V1=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt 
b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 58d7e43..d85ae2c 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1765,6 +1765,16 @@ config ATH79_MACH_CARAMBOLA2
        select ATH79_DEV_USB
        select ATH79_DEV_WMAC
 
+config ATH79_MACH_CF_E314N_V2
+       bool "COMFAST CF-E314N 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_E316N_V2
        bool "COMFAST CF-E316N v2 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 7aee760..942eb80 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_ATH79_MACH_C60)                  += mach-c60.o
 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_E314N_V2)           += mach-cf-e316n-v2.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
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 2c202e3..87c2127 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,5 +1,6 @@
 /*
  *  Support for COMFAST boards:
+ *  - CF-E314N v2 (QCA9531)
  *  - CF-E316N v2 (AR9341)
  *  - CF-E320N v2 (QCA9531)
  *  - CF-E380AC v1/v2 (QCA9558)
@@ -35,6 +36,63 @@
 #define CF_EXXXN_KEYS_POLL_INTERVAL    20
 #define CF_EXXXN_KEYS_DEBOUNCE_INTERVAL        (3 * 
CF_EXXXN_KEYS_POLL_INTERVAL)
 
+/* CF-E314N */
+#define CF_E314N_V2_GPIO_LED_WLAN      0
+#define CF_E314N_V2_GPIO_LED_WAN       2
+#define CF_E314N_V2_GPIO_LED_LAN       3
+
+#define CF_E314N_V2_GPIO_LED_SIGNAL1   11
+#define CF_E314N_V2_GPIO_LED_SIGNAL2   12
+#define CF_E314N_V2_GPIO_LED_SIGNAL3   14
+#define CF_E314N_V2_GPIO_LED_SIGNAL4   16
+
+#define CF_E314N_V2_GPIO_EXT_WDT       13
+
+#define CF_E314N_V2_GPIO_BTN_RESET     17
+
+static struct gpio_led cf_e314n_v2_leds_gpio[] __initdata = {
+       {
+               .name           = "cf-e314n-v2:white:lan",
+               .gpio           = CF_E314N_V2_GPIO_LED_LAN,
+               .active_low     = 1,
+       }, {
+               .name           = "cf-e314n-v2:white:wan",
+               .gpio           = CF_E314N_V2_GPIO_LED_WAN,
+               .active_low     = 1,
+       }, {
+               .name           = "cf-e314n-v2:white:wlan",
+               .gpio           = CF_E314N_V2_GPIO_LED_WLAN,
+               .active_low     = 1,
+       }, {
+               .name           = "cf-e314n-v2:white:signal1",
+               .gpio           = CF_E314N_V2_GPIO_LED_SIGNAL1,
+               .active_low     = 1,
+    }, {
+               .name           = "cf-e314n-v2:white:signal2",
+               .gpio           = CF_E314N_V2_GPIO_LED_SIGNAL2,
+               .active_low     = 1,
+    }, {
+               .name           = "cf-e314n-v2:white:signal3",
+               .gpio           = CF_E314N_V2_GPIO_LED_SIGNAL3,
+               .active_low     = 1,
+    }, {
+               .name           = "cf-e314n-v2:white:signal4",
+               .gpio           = CF_E314N_V2_GPIO_LED_SIGNAL4,
+               .active_low     = 1,
+       },
+};
+
+static struct gpio_keys_button cf_e314n_v2_gpio_keys[] __initdata = {
+       {
+               .desc           = "Reset button",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = CF_E314N_V2_GPIO_BTN_RESET,
+               .active_low     = 1,
+       },
+};
+
 /* CF-E316N v2 */
 #define CF_E316N_V2_GPIO_LED_DIAG_B    0
 #define CF_E316N_V2_GPIO_LED_DIAG_R    2
@@ -253,6 +311,69 @@ static void __init cf_exxxn_common_setup(unsigned long 
art_ofs, int gpio_wdt)
        ath79_register_usb();
 }
 
+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_e314n_v2_setup(void)
+{
+       cf_exxxn_common_setup(0x10000, CF_E314N_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_E314N_V2_GPIO_LED_LAN, true);
+       ath79_gpio_direction_select(CF_E314N_V2_GPIO_LED_WAN, true);
+       ath79_gpio_direction_select(CF_E314N_V2_GPIO_LED_WLAN, true);
+    ath79_gpio_direction_select(CF_E314N_V2_GPIO_LED_SIGNAL1, true);
+       ath79_gpio_direction_select(CF_E314N_V2_GPIO_LED_SIGNAL2, true);
+       ath79_gpio_direction_select(CF_E314N_V2_GPIO_LED_SIGNAL3, true);
+       ath79_gpio_direction_select(CF_E314N_V2_GPIO_LED_SIGNAL4, true);
+
+       ath79_gpio_output_select(CF_E314N_V2_GPIO_LED_LAN, 0);
+       ath79_gpio_output_select(CF_E314N_V2_GPIO_LED_WAN, 0);
+       ath79_gpio_output_select(CF_E314N_V2_GPIO_LED_WLAN, 0);
+       ath79_gpio_output_select(CF_E314N_V2_GPIO_LED_SIGNAL1, 0);
+       ath79_gpio_output_select(CF_E314N_V2_GPIO_LED_SIGNAL2, 0);
+       ath79_gpio_output_select(CF_E314N_V2_GPIO_LED_SIGNAL3, 0);
+       ath79_gpio_output_select(CF_E314N_V2_GPIO_LED_SIGNAL4, 0);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e314n_v2_leds_gpio),
+                                cf_e314n_v2_leds_gpio);
+
+       ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(cf_e314n_v2_gpio_keys),
+                                       cf_e314n_v2_gpio_keys);
+}
+
+MIPS_MACHINE(ATH79_MACH_CF_E314N_V2, "CF-E314N-V2", "COMFAST CF-E314N v2",
+            cf_e314n_v2_setup);
+
 static void __init cf_e316n_v2_setup(void)
 {
        u8 *mac = (u8 *) KSEG1ADDR(0x1f010000);
@@ -294,33 +415,6 @@ static void __init cf_e316n_v2_setup(void)
 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(0x10000, CF_E320N_V2_GPIO_EXT_WDT);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h 
b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index a12685c..78c2322 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -53,6 +53,7 @@ enum ath79_mach_type {
        ATH79_MACH_CAP324,                      /* PowerCloud CAP324 */
        ATH79_MACH_CAP4200AG,                   /* Senao CAP4200AG */
        ATH79_MACH_CARAMBOLA2,                  /* 8devices Carambola2 */
+       ATH79_MACH_CF_E314N_V2,                 /* COMFAST CF-E314N v2 */
        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 */
diff --git a/target/linux/ar71xx/image/generic.mk 
b/target/linux/ar71xx/image/generic.mk
index e11a899..9717841 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -40,6 +40,15 @@ define Device/carambola2
 endef
 TARGET_DEVICES += carambola2
 
+define Device/cf-e314n-v2
+  DEVICE_TITLE := COMFAST CF-E314N v2
+  BOARDNAME = CF-E314N-V2
+  IMAGE_SIZE = 16192k
+  CONSOLE = ttyS0,115200
+  MTDPARTS = spi0.0:64k(u-boot)ro,64k(art)ro,16192k(firmware),64k(art-backup)ro
+endef
+TARGET_DEVICES += cf-e314n-v2
+
 define Device/cf-e316n-v2
   DEVICE_TITLE := COMFAST CF-E316N v2
   BOARDNAME = CF-E316N-V2
-- 
2.7.4


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to