[OpenWrt-Devel] [PATCH 9/9] ar71xx: add support for Comfast E214N V2 Outdoor CPE

Zoltan HERPAI wigyori at uid0.hu
Sun Oct 22 16:21:27 EDT 2017


Based on Robert Budde's patch, with additional reworks.
https://github.com/openwrt/openwrt/pull/390

Signed-off-by: Zoltan HERPAI <wigyori at uid0.hu>
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |  10 ++
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh      |   1 +
 target/linux/ar71xx/config-4.4                     |   1 +
 target/linux/ar71xx/config-4.9                     |   1 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |   8 ++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../files/arch/mips/ath79/mach-cf-e214n-v2.c       | 124 +++++++++++++++++++++
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/generic.mk               |   8 ++
 10 files changed, 158 insertions(+)
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e214n-v2.c

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 27e6c8a..5707624 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -182,6 +182,16 @@ carambola2)
 	ucidef_set_led_netdev "wan" "WAN" "$board:orange:eth1" "eth1"
 	ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt"
 	;;
+cf-e214n-v2)
+	ucidef_set_led_netdev "lan" "LAN" "$board:lan" "eth0"
+	ucidef_set_led_netdev "wan" "WAN" "$board:wan" "eth1"
+	ucidef_set_led_wlan "wlan" "WLAN" "$board:wlan" "phy0tpt"
+	ucidef_set_rssimon "wlan" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "$board:link1" "wlan" "1" "100" "0" "13"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "$board:link2" "wlan" "26" "100" "-25" "13"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "$board:link3" "wlan" "51" "100" "-50" "13"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "$board:link4" "wlan" "76" "100" "-75" "13"
+	;;
 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/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index bdba81b..1c1317d 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -504,6 +504,9 @@ ar71xx_board_detect() {
 	*"Carambola2"*)
 		name="carambola2"
 		;;
+	*"CF-E214N v2")
+		name="cf-e214n-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 a60e44c..e768386 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -215,6 +215,7 @@ platform_check_image() {
 	bullet-m|\
 	c-55|\
 	carambola2|\
+	cf-e214n-v2|\
 	cf-e316n-v2|\
 	cf-e320n-v2|\
 	cf-e355ac|\
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index 4793bf4..d8f94e3 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -67,6 +67,7 @@ CONFIG_ATH79_MACH_C55=y
 CONFIG_ATH79_MACH_CAP324=y
 CONFIG_ATH79_MACH_CAP4200AG=y
 CONFIG_ATH79_MACH_CARAMBOLA2=y
+CONFIG_ATH79_MACH_CF_E214N_V2=y
 CONFIG_ATH79_MACH_CF_E316N_V2=y
 CONFIG_ATH79_MACH_CF_E320N_V2=y
 CONFIG_ATH79_MACH_CF_E355AC=y
diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9
index 285c638..df90b20 100644
--- a/target/linux/ar71xx/config-4.9
+++ b/target/linux/ar71xx/config-4.9
@@ -66,6 +66,7 @@ CONFIG_ATH79_MACH_C55=y
 CONFIG_ATH79_MACH_CAP324=y
 CONFIG_ATH79_MACH_CAP4200AG=y
 CONFIG_ATH79_MACH_CARAMBOLA2=y
+CONFIG_ATH79_MACH_CF_E214N_V2=y
 CONFIG_ATH79_MACH_CF_E316N_V2=y
 CONFIG_ATH79_MACH_CF_E320N_V2=y
 CONFIG_ATH79_MACH_CF_E355AC=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index ac77aed..a382f90 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -2032,6 +2032,14 @@ config ATH79_MACH_RAMBUTAN
 	select ATH79_DEV_USB
 	select ATH79_DEV_WMAC
 
+config ATH79_MACH_CF_E214N_V2
+	bool "COMFAST CF-E214N v2 board"
+	select SOC_QCA953X
+	select ATH79_DEV_ETH
+	select ATH79_DEV_LEDS_GPIO
+	select ATH79_DEV_M25P80
+	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 e6f0cae..985734f 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -75,6 +75,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_E214N_V2)		+= mach-cf-e214n-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_E355AC)		+= mach-cf-e316n-v2.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e214n-v2.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e214n-v2.c
new file mode 100644
index 0000000..f2f51be
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e214n-v2.c
@@ -0,0 +1,124 @@
+/*
+ *  COMFAST CF-E214N v2
+ *  by Shenzhen Four Seas Global Link Network Technology Co., Ltd
+ *
+ *  aka CF-E214V2, CF-E214N-V2 and CF-E214Nv2.0 (no FCC ID)
+ *
+ *  Copyright (C) 2017 Robert Budde <rl.budde at gmail.com>
+ *
+ *  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/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/timer.h>
+
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+#include "common.h"
+#include "dev-eth.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+
+static struct gpio_led cf_e214n_v2_leds_gpio[] __initdata = {
+	{
+		.name		= "cf-e214n-v2:wlan",
+		.gpio		= 0,
+		.active_low	= 1,
+	}, {
+		.name		= "cf-e214n-v2:lan",
+		.gpio		= 2,
+		.active_low	= 1,
+	}, {
+		.name		= "cf-e214n-v2:wan",
+		.gpio		= 3,
+		.active_low	= 1,
+	}, {
+		.name		= "cf-e214n-v2:link1",
+		.gpio		= 11,
+		.active_low	= 1,
+	}, {
+		.name		= "cf-e214n-v2:link2",
+		.gpio		= 12,
+		.active_low	= 1,
+	}, {
+		.name		= "cf-e214n-v2:link3",
+		.gpio		= 14,
+		.active_low	= 1,
+	}, {
+		.name		= "cf-e214n-v2:link4",
+		.gpio		= 16,
+		.active_low	= 1,
+	},
+};
+
+/* There's a Pericon Technology PT7A7514 connected to GPIO 13 */
+#define EXT_WATCHDOG_GPIO	13
+static struct timer_list gpio_wdt_timer;
+
+static void gpio_wdt_toggle(unsigned long period)
+{
+	static int state;
+	state = !state;
+	gpio_set_value(EXT_WATCHDOG_GPIO, state);
+	mod_timer(&gpio_wdt_timer, jiffies + period);
+}
+
+static void __init cf_e214n_v2_setup(void)
+{
+	u8 *maclan = (u8 *) KSEG1ADDR(0x1f010000);
+	u8 *macwlan = (u8 *) KSEG1ADDR(0x1f011002);
+	u8 *ee = (u8 *) KSEG1ADDR(0x1f011000);
+	u8 tmpmac[ETH_ALEN];
+
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(cf_e214n_v2_leds_gpio); i++)
+		ath79_gpio_output_select(cf_e214n_v2_leds_gpio[i].gpio,
+					 AR934X_GPIO_OUT_GPIO);
+
+	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));
+
+	ath79_register_m25p80(NULL);
+
+	ath79_register_mdio(0, 0x0);
+	ath79_register_mdio(1, 0x0);
+
+	ath79_init_mac(ath79_eth0_data.mac_addr, maclan, 0);
+	ath79_init_mac(ath79_eth1_data.mac_addr, maclan, 1);
+
+	/* "LAN" - GMAC0 is connected to the PHY4 of the internal switch */
+	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+	ath79_eth0_data.speed = SPEED_100;
+	ath79_eth0_data.duplex = DUPLEX_FULL;
+	ath79_eth0_data.phy_mask = BIT(4);
+	ath79_register_eth(0);
+
+	/* "WAN" - GMAC1 is connected to the internal switch */
+	ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+	ath79_eth1_data.speed = SPEED_1000;
+	ath79_eth1_data.duplex = DUPLEX_FULL;
+	ath79_switch_data.phy_poll_mask |= BIT(4);
+	ath79_switch_data.phy4_mii_en = 1;
+	ath79_register_eth(1);
+
+	ath79_init_mac(tmpmac, macwlan, 0);
+	ath79_register_wmac(ee, tmpmac);
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e214n_v2_leds_gpio),
+				 cf_e214n_v2_leds_gpio);
+
+	ath79_register_usb();
+}
+
+MIPS_MACHINE(ATH79_MACH_CF_E214N_V2, "CF-E214N-V2", "COMFAST CF-E214N v2",
+	     cf_e214n_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 bdf0167..46c9766 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -61,6 +61,7 @@ enum ath79_mach_type {
 	ATH79_MACH_CAP324,			/* PowerCloud CAP324 */
 	ATH79_MACH_CAP4200AG,			/* Senao CAP4200AG */
 	ATH79_MACH_CARAMBOLA2,			/* 8devices Carambola2 */
+	ATH79_MACH_CF_E214N_V2,			/* COMFAST CF-E214N v2 */
 	ATH79_MACH_CF_E316N_V2,			/* COMFAST CF-E316N v2 */
 	ATH79_MACH_CF_E320N_V2,			/* COMFAST CF-E320N v2 */
 	ATH79_MACH_CF_E355AC,			/* COMFAST CF-E355AC */
diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk
index 6f5a701..d91c8f8 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -135,6 +135,14 @@ define Device/carambola2
 endef
 TARGET_DEVICES += carambola2
 
+define Device/cf-e214n-v2
+  DEVICE_TITLE := COMFAST CF-E214N v2
+  BOARDNAME := CF-E214N-V2
+  IMAGE_SIZE := 16192k
+  MTDPARTS = spi0.0:64k(u-boot)ro,64k(art)ro,16192k(firmware),64k(nvram)ro
+endef
+TARGET_DEVICES += cf-e214n-v2
+
 define Device/cf-e316n-v2
   DEVICE_TITLE := COMFAST CF-E316N v2
   BOARDNAME := CF-E316N-V2
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list