From: Felix Fietkau Date: Fri, 11 Sep 2015 16:31:35 +0000 (+0000) Subject: target: ar71xx: add support for COMFAST CF-E316N v2 board X-Git-Tag: reboot~2082 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2ce833060a6ac412d0df362edb950b19da9af04c;p=oweals%2Fopenwrt.git target: ar71xx: add support for COMFAST CF-E316N v2 board This adds full support (sans sysupgrading from vendor firmware) for the COMFAST CF-E316N v2 (aka CF-E316V2, CF-E316N-V2 and CF-E316Nv2.0, no FCC ID) by Shenzhen Four Seas Global Link Network Technology Co., Ltd (this company is actively refusing to provide GPL'd sources for the OpenWrt version they ship with the device, damn them). Signed-off-by: Paul Fertser SVN-Revision: 46852 --- diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 36de775df5..1b1f6c7c66 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -56,6 +56,9 @@ get_status_led() { cap4200ag) status_led="senao:green:pwr" ;; + cf-e316n-v2) + status_led="$(ar71xx_board_name):blue:wan" + ;; cpe510) status_led="tp-link:green:link4" ;; diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds index e7f7a4cd62..6ecc0e2881 100644 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds @@ -96,6 +96,12 @@ carambola2) ucidef_set_led_wlan "wlan" "WLAN" "carambola2:green: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" + ucidef_set_led_wlan "wlan" "WLAN" "$board:blue:wlan" "phy0tpt" + ;; + cpe510) ucidef_set_led_switch "lan0" "LAN0" "tp-link:green:lan0" "switch0" "0x20" ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x10" diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index e1f345eb93..d4959408de 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -392,6 +392,9 @@ ar71xx_board_detect() { *CAP4200AG) name="cap4200ag" ;; + *"COMFAST CF-E316N v2") + name="cf-e316n-v2" + ;; *"CPE210/220/510/520") name="cpe510" 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 c1962e4e9f..673ee4ecd0 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -199,6 +199,7 @@ platform_check_image() { ap81 | \ ap83 | \ ap132 | \ + cf-e316n-v2 | \ dgl-5500-a1 |\ dhp-1565-a1 |\ dir-505-a1 | \ diff --git a/target/linux/ar71xx/config-4.1 b/target/linux/ar71xx/config-4.1 index 21c460178d..97cbc137a4 100644 --- a/target/linux/ar71xx/config-4.1 +++ b/target/linux/ar71xx/config-4.1 @@ -50,6 +50,7 @@ CONFIG_ATH79_MACH_BHU_BXU2000N2_A=y CONFIG_ATH79_MACH_BSB=y CONFIG_ATH79_MACH_CAP4200AG=y CONFIG_ATH79_MACH_CARAMBOLA2=y +CONFIG_ATH79_MACH_CF_E316N_V2=y CONFIG_ATH79_MACH_CPE510=y CONFIG_ATH79_MACH_DB120=y CONFIG_ATH79_MACH_DGL_5500_A1=y 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 new file mode 100644 index 0000000000..cf3d33a552 --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e316n-v2.c @@ -0,0 +1,132 @@ +/* + * 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) + * + * Copyright (C) 2015 Paul Fertser + * + * 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 +#include +#include + +#include +#include + +#include "common.h" +#include "dev-eth.h" +#include "dev-gpio-buttons.h" +#include "dev-leds-gpio.h" +#include "dev-m25p80.h" +#include "dev-wmac.h" +#include "dev-usb.h" +#include "machtypes.h" + +static struct gpio_led cf_e316n_v2_leds_gpio[] __initdata = { + { + .name = "cf-e316n-v2:blue:diag", + .gpio = 0, + .active_low = 0, + }, { + .name = "cf-e316n-v2:red:diag", + .gpio = 2, + .active_low = 0, + }, { + .name = "cf-e316n-v2:green:diag", + .gpio = 3, + .active_low = 0, + }, { + .name = "cf-e316n-v2:blue:wlan", + .gpio = 12, + .active_low = 1, + }, { + .name = "cf-e316n-v2:blue:wan", + .gpio = 17, + .active_low = 1, + }, { + .name = "cf-e316n-v2:blue:lan", + .gpio = 19, + .active_low = 1, + }, +}; + +static struct gpio_keys_button cf_e316n_v2_gpio_keys[] __initdata = { + { + .desc = "Reset button", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = 60, + .gpio = 20, + .active_low = 1, + }, +}; + +/* There's a Pericon Technology PT7A7514 connected to GPIO 16 */ +#define EXT_WATCHDOG_GPIO 16 +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_e316n_v2_setup(void) +{ + u8 *maclan = (u8 *) KSEG1ADDR(0x1f010000); + u8 *macwlan = (u8 *) KSEG1ADDR(0x1f011002); + u8 *ee = (u8 *) KSEG1ADDR(0x1f011000); + u8 tmpmac[ETH_ALEN]; + + 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_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 */ + ath79_switch_data.phy4_mii_en = 1; + ath79_switch_data.phy_poll_mask = BIT(0); + 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_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_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); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e316n_v2_leds_gpio), + cf_e316n_v2_leds_gpio); + + ath79_register_gpio_keys_polled(1, 20, + 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); diff --git a/target/linux/ar71xx/generic/profiles/comfast.mk b/target/linux/ar71xx/generic/profiles/comfast.mk new file mode 100644 index 0000000000..5d447e5cec --- /dev/null +++ b/target/linux/ar71xx/generic/profiles/comfast.mk @@ -0,0 +1,19 @@ +# +# Copyright (C) 2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +define Profile/CF-E316N-V2 + NAME:=COMFAST CF-E316N v2 + PACKAGES:= +endef + +define Profile/CF-E316N-V2/Description + Package set optimised for the 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) +endef + +$(eval $(call Profile,CF-E316N-V2)) diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index e6fe36ad09..71f7ef368d 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -179,6 +179,14 @@ define Device/carambola2 endef TARGET_DEVICES += carambola2 +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 +endef +TARGET_DEVICES += cf-e316n-v2 + define Device/wndr3700 BOARDNAME = WNDR3700 NETGEAR_KERNEL_MAGIC = 0x33373030 diff --git a/target/linux/ar71xx/patches-4.1/509-MIPS-ath79-process-board-kernel-option.patch b/target/linux/ar71xx/patches-4.1/509-MIPS-ath79-process-board-kernel-option.patch index 13ff1664d7..2366c40cd0 100644 --- a/target/linux/ar71xx/patches-4.1/509-MIPS-ath79-process-board-kernel-option.patch +++ b/target/linux/ar71xx/patches-4.1/509-MIPS-ath79-process-board-kernel-option.patch @@ -1,6 +1,6 @@ --- a/arch/mips/ath79/setup.c +++ b/arch/mips/ath79/setup.c -@@ -237,6 +237,8 @@ void __init plat_time_init(void) +@@ -236,6 +236,8 @@ void __init plat_time_init(void) mips_hpt_frequency = cpu_clk_rate / 2; } diff --git a/target/linux/ar71xx/patches-4.1/700-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-4.1/700-MIPS-ath79-openwrt-machines.patch index 02ebd1b4c9..93f51951ae 100644 --- a/target/linux/ar71xx/patches-4.1/700-MIPS-ath79-openwrt-machines.patch +++ b/target/linux/ar71xx/patches-4.1/700-MIPS-ath79-openwrt-machines.patch @@ -1,6 +1,6 @@ --- a/arch/mips/ath79/machtypes.h +++ b/arch/mips/ath79/machtypes.h -@@ -16,24 +16,207 @@ +@@ -16,24 +16,208 @@ enum ath79_mach_type { ATH79_MACH_GENERIC = 0, @@ -28,6 +28,7 @@ + ATH79_MACH_BHU_BXU2000N2_A1, /* BHU BXU2000n-2 A1 */ + ATH79_MACH_CAP4200AG, /* Senao CAP4200AG */ + ATH79_MACH_CARAMBOLA2, /* 8devices Carambola2 */ ++ ATH79_MACH_CF_E316N_V2, /* COMFAST CF-E316N v2 */ + ATH79_MACH_CPE510, /* TP-LINK CPE510 */ ATH79_MACH_DB120, /* Atheros DB120 reference board */ ATH79_MACH_PB44, /* Atheros PB44 reference board */ @@ -1437,7 +1438,7 @@ config ATH79_MACH_UBNT_XM bool "Ubiquiti Networks XM/UniFi boards" -@@ -83,6 +1212,97 @@ config ATH79_MACH_UBNT_XM +@@ -83,6 +1212,107 @@ config ATH79_MACH_UBNT_XM Say 'Y' here if you want your kernel to support the Ubiquiti Networks XM (rev 1.0) board. @@ -1511,6 +1512,16 @@ + select ATH79_DEV_USB + select ATH79_DEV_WMAC + ++config ATH79_MACH_CF_E316N_V2 ++ bool "COMFAST CF-E316N v2 board" ++ select SOC_AR934X ++ 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 @@ -1535,7 +1546,7 @@ endmenu config SOC_AR71XX -@@ -134,7 +1354,10 @@ config ATH79_DEV_DSA +@@ -134,7 +1364,10 @@ config ATH79_DEV_DSA config ATH79_DEV_ETH def_bool n @@ -1547,7 +1558,7 @@ def_bool n config ATH79_DEV_GPIO_BUTTONS -@@ -164,6 +1387,11 @@ config ATH79_PCI_ATH9K_FIXUP +@@ -164,6 +1397,11 @@ config ATH79_PCI_ATH9K_FIXUP def_bool n config ATH79_ROUTERBOOT @@ -1561,7 +1572,7 @@ endif --- a/arch/mips/ath79/Makefile +++ b/arch/mips/ath79/Makefile -@@ -38,9 +38,133 @@ obj-$(CONFIG_ATH79_ROUTERBOOT) += route +@@ -38,9 +38,134 @@ obj-$(CONFIG_ATH79_ROUTERBOOT) += route # # Machines # @@ -1583,6 +1594,7 @@ +obj-$(CONFIG_ATH79_MACH_AW_NR580) += mach-aw-nr580.o +obj-$(CONFIG_ATH79_MACH_BHU_BXU2000N2_A)+= mach-bhu-bxu2000n2-a.o +obj-$(CONFIG_ATH79_MACH_CAP4200AG) += mach-cap4200ag.o ++obj-$(CONFIG_ATH79_MACH_CF_E316N_V2) += mach-cf-e316n-v2.o +obj-$(CONFIG_ATH79_MACH_CPE510) += mach-cpe510.o obj-$(CONFIG_ATH79_MACH_DB120) += mach-db120.o +obj-$(CONFIG_ATH79_MACH_DLAN_PRO_500_WP) += mach-dlan-pro-500-wp.o diff --git a/target/linux/ar71xx/patches-4.1/814-MIPS-ath79-add-blackswift.patch b/target/linux/ar71xx/patches-4.1/814-MIPS-ath79-add-blackswift.patch index 787db80279..cc01cd6bd2 100644 --- a/target/linux/ar71xx/patches-4.1/814-MIPS-ath79-add-blackswift.patch +++ b/target/linux/ar71xx/patches-4.1/814-MIPS-ath79-add-blackswift.patch @@ -25,8 +25,8 @@ obj-$(CONFIG_ATH79_MACH_BHU_BXU2000N2_A)+= mach-bhu-bxu2000n2-a.o +obj-$(CONFIG_ATH79_MACH_BSB) += mach-bsb.o obj-$(CONFIG_ATH79_MACH_CAP4200AG) += mach-cap4200ag.o + obj-$(CONFIG_ATH79_MACH_CF_E316N_V2) += mach-cf-e316n-v2.o obj-$(CONFIG_ATH79_MACH_CPE510) += mach-cpe510.o - obj-$(CONFIG_ATH79_MACH_DB120) += mach-db120.o --- a/arch/mips/ath79/machtypes.h +++ b/arch/mips/ath79/machtypes.h @@ -39,6 +39,7 @@ enum ath79_mach_type { @@ -36,4 +36,4 @@ + ATH79_MACH_BSB, /* Smart Electronics Black Swift board */ ATH79_MACH_CAP4200AG, /* Senao CAP4200AG */ ATH79_MACH_CARAMBOLA2, /* 8devices Carambola2 */ - ATH79_MACH_CPE510, /* TP-LINK CPE510 */ + ATH79_MACH_CF_E316N_V2, /* COMFAST CF-E316N v2 */ diff --git a/target/linux/ar71xx/patches-4.1/814-MIPS-ath79-add-tplink-tl-wdr6500-v2-support.patch b/target/linux/ar71xx/patches-4.1/814-MIPS-ath79-add-tplink-tl-wdr6500-v2-support.patch index 036087a80d..1955bfaa7b 100644 --- a/target/linux/ar71xx/patches-4.1/814-MIPS-ath79-add-tplink-tl-wdr6500-v2-support.patch +++ b/target/linux/ar71xx/patches-4.1/814-MIPS-ath79-add-tplink-tl-wdr6500-v2-support.patch @@ -20,7 +20,7 @@ select SOC_AR933X --- a/arch/mips/ath79/machtypes.h +++ b/arch/mips/ath79/machtypes.h -@@ -154,6 +154,7 @@ enum ath79_mach_type { +@@ -155,6 +155,7 @@ enum ath79_mach_type { ATH79_MACH_TL_WA901ND_V3, /* TP-LINK TL-WA901ND v3 */ ATH79_MACH_TL_WDR3500, /* TP-LINK TL-WDR3500 */ ATH79_MACH_TL_WDR4300, /* TP-LINK TL-WDR4300 */ @@ -30,7 +30,7 @@ ATH79_MACH_TL_WR1043ND, /* TP-LINK TL-WR1043ND */ --- a/arch/mips/ath79/Makefile +++ b/arch/mips/ath79/Makefile -@@ -130,6 +130,7 @@ obj-$(CONFIG_ATH79_MACH_TL_WA901ND) += m +@@ -131,6 +131,7 @@ obj-$(CONFIG_ATH79_MACH_TL_WA901ND) += m obj-$(CONFIG_ATH79_MACH_TL_WA901ND_V2) += mach-tl-wa901nd-v2.o obj-$(CONFIG_ATH79_MACH_TL_WDR3500) += mach-tl-wdr3500.o obj-$(CONFIG_ATH79_MACH_TL_WDR4300) += mach-tl-wdr4300.o