From patchwork Fri Sep 4 12:45:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Fertser X-Patchwork-Id: 514423 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 682221402A9 for ; Fri, 4 Sep 2015 22:45:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=RTGmGImn; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 5CBD428C151; Fri, 4 Sep 2015 14:44:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 38A5F28BE9E for ; Fri, 4 Sep 2015 14:44:20 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .gmail. - helo: .mail-la0-f52.google. - helo-domain: .google.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -8.5 Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 4 Sep 2015 14:44:19 +0200 (CEST) Received: by laeb10 with SMTP id b10so12828300lae.1 for ; Fri, 04 Sep 2015 05:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iXG+zSPnxJcFh9MDk7T+SHXesS/m++SeEVTG798Dwg0=; b=RTGmGImnaeGusrbnU/9WfDimxztYhc+qu5vvhmP+z6AFx3iH4q+gSghzNTtXpc/0R3 OzsVi5sWWl9zy6/F3ewZGavrpDgMqIB9g/MTL6jvy/Vzf8itqiTnijKc3Lwiz9BIU1dM sIn3QIUfR7Z7UMPNUhRfgH4BJPK+UojUltGAWzdXTHgxI56lHEwRqxAwO7oeCc/P0lNP CmA0opsZiA7vguYvJfY5ds77tdwMAag7LOvU8Zg4kIoMP09QlrQQjFXa0eLb0k/ZzI4W a7o52dB2EmF6klkXFU+7mlaH7CivrSliWMVZcMIrNRDMtD7IMwSjWx7grZiWjlvIHpWe j1SQ== X-Received: by 10.152.21.196 with SMTP id x4mr3462163lae.117.1441370719843; Fri, 04 Sep 2015 05:45:19 -0700 (PDT) Received: from home.paul.comp (paulfertser.info. [2001:470:26:54b:250:70ff:fee7:41ec]) by smtp.gmail.com with ESMTPSA id jc10sm557647lac.12.2015.09.04.05.45.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2015 05:45:19 -0700 (PDT) Received: from home.paul.comp (localhost [127.0.0.1]) by home.paul.comp (8.14.4/8.14.4/Debian-8) with ESMTP id t84CjHr2000626; Fri, 4 Sep 2015 15:45:17 +0300 Received: (from paul@localhost) by home.paul.comp (8.14.4/8.14.4/Submit) id t84CjHux000625; Fri, 4 Sep 2015 15:45:17 +0300 From: Paul Fertser To: openwrt-devel@lists.openwrt.org Date: Fri, 4 Sep 2015 15:45:02 +0300 Message-Id: <1441370702-589-1-git-send-email-fercerpav@gmail.com> X-Mailer: git-send-email 2.1.4 In-reply-to: <1440756578-25758-1-git-send-email-fercerpav@gmail.com> References: <1440756578-25758-1-git-send-email-fercerpav@gmail.com> Cc: Paul Fertser Subject: [OpenWrt-Devel] [PATCH v2] target: ar71xx: add support for COMFAST CF-E316N v2 board X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" 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 --- v2: register USB platform devices as there exists an unpopulated HS USB header easily accessible on board target/linux/ar71xx/base-files/etc/diag.sh | 3 + .../ar71xx/base-files/etc/uci-defaults/01_leds | 6 + target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 + .../ar71xx/base-files/lib/upgrade/platform.sh | 1 + target/linux/ar71xx/config-4.1 | 1 + .../files/arch/mips/ath79/mach-cf-e316n-v2.c | 132 +++++++++++++++++++++ target/linux/ar71xx/generic/profiles/comfast.mk | 19 +++ target/linux/ar71xx/image/Makefile | 8 ++ .../700-MIPS-ath79-openwrt-machines.patch | 51 +++++--- 9 files changed, 208 insertions(+), 16 deletions(-) create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e316n-v2.c create mode 100644 target/linux/ar71xx/generic/profiles/comfast.mk diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 36de775..1b1f6c7 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 e7f7a4c..6ecc0e2 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 e1f345e..d495940 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 c1962e4..673ee4e 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 21c4601..97cbc13 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 0000000..cf3d33a --- /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 0000000..5d447e5 --- /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 8f609de..e72f524 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -188,6 +188,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/700-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-4.1/700-MIPS-ath79-openwrt-machines.patch index 02ebd1b..ade0c2c 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,8 @@ ---- a/arch/mips/ath79/machtypes.h -+++ b/arch/mips/ath79/machtypes.h -@@ -16,24 +16,207 @@ +Index: linux-4.1.5/arch/mips/ath79/machtypes.h +=================================================================== +--- linux-4.1.5.orig/arch/mips/ath79/machtypes.h 2015-08-16 16:57:42.480656824 +0100 ++++ linux-4.1.5/arch/mips/ath79/machtypes.h 2015-08-16 16:59:33.868656175 +0100 +@@ -16,24 +16,208 @@ enum ath79_mach_type { ATH79_MACH_GENERIC = 0, @@ -28,6 +30,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 */ @@ -208,9 +211,11 @@ }; #endif /* _ATH79_MACHTYPE_H */ ---- a/arch/mips/ath79/Kconfig -+++ b/arch/mips/ath79/Kconfig -@@ -2,6 +2,90 @@ if ATH79 +Index: linux-4.1.5/arch/mips/ath79/Kconfig +=================================================================== +--- linux-4.1.5.orig/arch/mips/ath79/Kconfig 2015-08-16 16:57:42.480656824 +0100 ++++ linux-4.1.5/arch/mips/ath79/Kconfig 2015-08-16 17:03:19.472654861 +0100 +@@ -2,6 +2,90 @@ menu "Atheros AR71XX/AR724X/AR913X machine selection" @@ -301,7 +306,7 @@ config ATH79_MACH_AP121 bool "Atheros AP121 reference board" select SOC_AR933X -@@ -11,62 +95,1107 @@ config ATH79_MACH_AP121 +@@ -11,62 +95,1107 @@ select ATH79_DEV_M25P80 select ATH79_DEV_USB select ATH79_DEV_WMAC @@ -1437,7 +1442,7 @@ config ATH79_MACH_UBNT_XM bool "Ubiquiti Networks XM/UniFi boards" -@@ -83,6 +1212,97 @@ config ATH79_MACH_UBNT_XM +@@ -83,6 +1212,106 @@ Say 'Y' here if you want your kernel to support the Ubiquiti Networks XM (rev 1.0) board. @@ -1511,6 +1516,15 @@ + 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_WMAC ++ +config ATH79_MACH_BHU_BXU2000N2_A + bool "BHU BXU2000n-2 rev. A support" + select SOC_AR934X @@ -1535,7 +1549,7 @@ endmenu config SOC_AR71XX -@@ -134,7 +1354,10 @@ config ATH79_DEV_DSA +@@ -134,7 +1364,10 @@ config ATH79_DEV_ETH def_bool n @@ -1547,7 +1561,7 @@ def_bool n config ATH79_DEV_GPIO_BUTTONS -@@ -164,6 +1387,11 @@ config ATH79_PCI_ATH9K_FIXUP +@@ -164,6 +1397,11 @@ def_bool n config ATH79_ROUTERBOOT @@ -1559,9 +1573,11 @@ def_bool n endif ---- a/arch/mips/ath79/Makefile -+++ b/arch/mips/ath79/Makefile -@@ -38,9 +38,133 @@ obj-$(CONFIG_ATH79_ROUTERBOOT) += route +Index: linux-4.1.5/arch/mips/ath79/Makefile +=================================================================== +--- linux-4.1.5.orig/arch/mips/ath79/Makefile 2015-08-16 16:57:42.480656824 +0100 ++++ linux-4.1.5/arch/mips/ath79/Makefile 2015-08-16 17:05:19.072654165 +0100 +@@ -38,9 +38,134 @@ # # Machines # @@ -1583,6 +1599,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 @@ -1695,9 +1712,11 @@ +obj-$(CONFIG_ATH79_MACH_ZCN_1523H) += mach-zcn-1523h.o +obj-$(CONFIG_ATH79_MACH_CARAMBOLA2) += mach-carambola2.o +obj-$(CONFIG_ATH79_MACH_NBG6716) += mach-nbg6716.o ---- a/arch/mips/ath79/prom.c -+++ b/arch/mips/ath79/prom.c -@@ -130,6 +130,13 @@ void __init prom_init(void) +Index: linux-4.1.5/arch/mips/ath79/prom.c +=================================================================== +--- linux-4.1.5.orig/arch/mips/ath79/prom.c 2015-08-16 16:57:42.480656824 +0100 ++++ linux-4.1.5/arch/mips/ath79/prom.c 2015-08-16 16:57:42.476656824 +0100 +@@ -130,6 +130,13 @@ initrd_end = initrd_start + fw_getenvl("initrd_size"); } #endif