From 0eb7df25036bd1d0d05fbbc430e9b595abda0c3c Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Sun, 13 Jan 2019 22:21:41 +0800 Subject: [PATCH] ar71xx: add ARRIS SBR-AC1750 router support --- .../ar71xx/base-files/etc/board.d/01_leds | 6 + .../ar71xx/base-files/etc/board.d/02_network | 2 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 4 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 4 + target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 + .../lib/preinit/05_set_iface_mac_ar71xx | 4 + .../ar71xx/base-files/lib/upgrade/platform.sh | 5 + target/linux/ar71xx/config-4.14 | 1 + .../files/arch/mips/ath79/Kconfig.openwrt | 10 + .../ar71xx/files/arch/mips/ath79/Makefile | 1 + .../arch/mips/ath79/mach-arris-sbr-ac1750.c | 209 ++++++++++++++++++ .../ar71xx/files/arch/mips/ath79/machtypes.h | 1 + target/linux/ar71xx/image/nand.mk | 17 ++ target/linux/ar71xx/nand/config-default | 1 + 14 files changed, 268 insertions(+) create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-arris-sbr-ac1750.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 79e6ff40f..925560a1e 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -159,6 +159,12 @@ arduino-yun) ucidef_set_led_wlan "wlan" "WLAN" "arduino:blue:wlan" "phy0tpt" ucidef_set_led_usbdev "usb" "USB" "arduino:white:usb" "1-1.1" ;; +arris-sbr-ac1750) + ucidef_set_led_usbdev "usb" "USB" "arris:green:usb" "1-1" + ucidef_set_led_default "wps" "WPS" "arris:green:wps" "0" + ucidef_set_led_wlan "wlan2g" "WLAN" "wlan_2g" "phy1tpt" + ucidef_set_led_wlan "wlan5g" "WLAN5G" "wlan_5g" "phy0tpt" + ;; bhr-4grv2) ucidef_set_led_default "power" "POWER" "buffalo:green:power" "1" ucidef_set_led_default "diag" "DIAG" "buffalo:red:diag" "0" diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network index 5d7921c63..0b9ba40c1 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -302,6 +302,7 @@ ar71xx_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2" ;; + arris-sbr-ac1750|\ cr5000|\ dgl-5500-a1|\ dhp-1565-a1|\ @@ -624,6 +625,7 @@ ar71xx_setup_macs() mynet-n750) wan_mac=$(mtd_get_mac_ascii devdata "wanmac") ;; + arris-sbr-ac1750|\ k2t) lan_mac=$(cat /sys/class/net/eth0/address) wan_mac=$(macaddr_add "$lan_mac" 1) diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 4be6c0cb3..1eeabeb8e 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -70,6 +70,10 @@ board=$(board_name) case "$FIRMWARE" in "soc_wmac.eeprom") case $board in + arris-sbr-ac1750) + ath9k_eeprom_extract "caldata" 4096 2048 + ath9k_patch_firmware_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +3) + ;; c-55|\ c-60) ath9k_eeprom_extract "art" 4096 2048 diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index bee3eeaff..13af42604 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -109,6 +109,10 @@ case "$FIRMWARE" in ath10kcal_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; + arris-sbr-ac1750) + ath10kcal_extract "caldata" 20480 2116 + ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) +2) + ;; cf-e355ac-v1|\ cf-e380ac-v1|\ cf-e380ac-v2|\ diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 254fe423c..d79dcc0dc 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -475,6 +475,9 @@ ar71xx_board_detect() { *"AP91-5G") name="ap91-5g" ;; + *"ARRIS SBR-AC1750/TR3300 Router") + name="arris-sbr-ac1750" + ;; *"Archer C25 v1") name="archer-c25-v1" ;; diff --git a/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx index dc69970c8..3f99cc4b4 100644 --- a/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx +++ b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx @@ -22,6 +22,10 @@ preinit_set_mac_address() { . /lib/functions.sh case $(board_name) in + arris-sbr-ac1750) + mac_lan=$(mtd_get_mac_binary ft 0) + [ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan" + ;; c-55|\ c-60) mac_lan=$(mtd_get_mac_binary art 0) diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index cfac33c7c..84d8828b2 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -575,6 +575,7 @@ platform_check_image() { nand_do_platform_check routerboard $1 return $? ;; + arris-sbr-ac1750|\ c-60|\ hiveap-121|\ nbg6716|\ @@ -908,6 +909,10 @@ platform_do_upgrade() { z1) merakinand_do_upgrade "$1" ;; + arris-sbr-ac1750) + CI_KERNPART_EXT="kernel2" + nand_do_upgrade "$1" + ;; uap-pro|\ unifi-outdoor-plus) MTD_CONFIG_ARGS="-s 0x180000" diff --git a/target/linux/ar71xx/config-4.14 b/target/linux/ar71xx/config-4.14 index 001e7b334..c4b7a22d0 100644 --- a/target/linux/ar71xx/config-4.14 +++ b/target/linux/ar71xx/config-4.14 @@ -57,6 +57,7 @@ CONFIG_ATH79=y # CONFIG_ATH79_MACH_ARCHER_C60_V2 is not set # CONFIG_ATH79_MACH_ARCHER_C7 is not set # CONFIG_ATH79_MACH_ARDUINO_YUN is not set +# CONFIG_ATH79_MACH_ARRIS_SBR_AC1750 is not set # CONFIG_ATH79_MACH_AW_NR580 is not set # CONFIG_ATH79_MACH_BHR_4GRV2 is not set # CONFIG_ATH79_MACH_BHU_BXU2000N2_A is not set diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt index 3398d4a84..d44707d88 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt @@ -164,6 +164,16 @@ config ATH79_MACH_ARDUINO_YUN select ATH79_DEV_USB select ATH79_DEV_WMAC +config ATH79_MACH_ARRIS_SBR_AC1750 + bool "ARRIS SBR-AC1750/TR3300 Router" + select SOC_QCA955X + select ATH79_DEV_ETH + select ATH79_DEV_GPIO_BUTTONS + select ATH79_DEV_LEDS_GPIO + select ATH79_DEV_NFC + select ATH79_DEV_USB + select ATH79_DEV_WMAC + config ATH79_MACH_AP132 bool "Atheros AP132 reference board" select SOC_QCA955X diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile index 29a97b780..6b832cbbd 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile @@ -68,6 +68,7 @@ obj-$(CONFIG_ATH79_MACH_ARCHER_C7) += mach-archer-c7.o obj-$(CONFIG_ATH79_MACH_ARCHER_C7) += mach-archer-c7-v4.o obj-$(CONFIG_ATH79_MACH_ARCHER_C7) += mach-archer-c7-v5.o obj-$(CONFIG_ATH79_MACH_ARDUINO_YUN) += mach-arduino-yun.o +obj-$(CONFIG_ATH79_MACH_ARRIS_SBR_AC1750) += mach-arris-sbr-ac1750.o obj-$(CONFIG_ATH79_MACH_AW_NR580) += mach-aw-nr580.o obj-$(CONFIG_ATH79_MACH_BHR_4GRV2) += mach-bhr-4grv2.o obj-$(CONFIG_ATH79_MACH_BHU_BXU2000N2_A) += mach-bhu-bxu2000n2-a.o diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-arris-sbr-ac1750.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-arris-sbr-ac1750.c new file mode 100644 index 000000000..6e56f7de6 --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-arris-sbr-ac1750.c @@ -0,0 +1,209 @@ +/* + * ARRIS SBR-AC1750/TR3300 Router support + * + * Copyright (c) 2018 Chen Minqiang + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#include +#include +#include +#include + +#include + +#include "common.h" +#include "pci.h" +#include "dev-ap9x-pci.h" +#include "dev-gpio-buttons.h" +#include "dev-eth.h" +#include "dev-leds-gpio.h" +#include "dev-m25p80.h" +#include "dev-nfc.h" +#include "dev-usb.h" +#include "dev-wmac.h" +#include "machtypes.h" + +#define ARRIS_GPIO_EXT_WDT 18 +#define ARRIS_GPIO_LED_USB 22 +#define ARRIS_GPIO_LED_WLAN_5G 21 +#define ARRIS_GPIO_LED_WLAN_2G 2 +#define ARRIS_GPIO_LED_WPS_GREEN 23 + +#define ARRIS_GPIO_BTN_WPS 19 +#define ARRIS_GPIO_BTN_RESET 17 + +#define ARRIS_KEYS_POLL_INTERVAL 20 /* msecs */ +#define ARRIS_KEYS_DEBOUNCE_INTERVAL (3 * ARRIS_KEYS_POLL_INTERVAL) + +#define ARRIS_MAC0_OFFSET 0 +#define ARRIS_MAC1_OFFSET 6 +#define ARRIS_WMAC_CALDATA_OFFSET 0x1000 +#define ARRIS_PCIE_CALDATA_OFFSET 0x5000 + +static struct gpio_led arris_leds_gpio[] __initdata = { + { + .name = "arris:green:wps", + .gpio = ARRIS_GPIO_LED_WPS_GREEN, + .active_low = 1, + }, + { + .name = "wlan_2g", + .gpio = ARRIS_GPIO_LED_WLAN_2G, + .active_low = 1, + }, + { + .name = "wlan_5g", + .gpio = ARRIS_GPIO_LED_WLAN_5G, + .active_low = 1, + }, + { + .name = "arris:green:usb", + .gpio = ARRIS_GPIO_LED_USB, + .active_low = 1, + } +}; + +static struct gpio_keys_button arris_gpio_keys[] __initdata = { + { + .desc = "WPS button", + .type = EV_KEY, + .code = KEY_WPS_BUTTON, + .debounce_interval = ARRIS_KEYS_DEBOUNCE_INTERVAL, + .gpio = ARRIS_GPIO_BTN_WPS, + .active_low = 1, + }, + { + .desc = "RESET button", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = ARRIS_KEYS_DEBOUNCE_INTERVAL, + .gpio = ARRIS_GPIO_BTN_RESET, + .active_low = 1, + }, +}; + +static struct ar8327_pad_cfg arris_ar8327_pad0_cfg; +static struct ar8327_pad_cfg arris_ar8327_pad6_cfg; + +static struct ar8327_platform_data arris_ar8327_data = { + .pad0_cfg = &arris_ar8327_pad0_cfg, + .pad6_cfg = &arris_ar8327_pad6_cfg, + .port0_cfg = { + .force_link = 1, + .speed = AR8327_PORT_SPEED_1000, + .duplex = 1, + .txpause = 1, + .rxpause = 1, + }, + .port6_cfg = { + .force_link = 1, + .speed = AR8327_PORT_SPEED_1000, + .duplex = 1, + .txpause = 1, + .rxpause = 1, + }, +}; + +static struct mdio_board_info arris_mdio0_info[] = { + { + .bus_id = "ag71xx-mdio.0", + .mdio_addr = 0, + .platform_data = &arris_ar8327_data, + }, +}; + +#define EXT_WDT_TIMEOUT_MS 300 + +static struct timer_list gpio_wdt_timer; + +static void gpio_wdt_toggle(unsigned long gpio) +{ + static int state; + + state = !state; + gpio_set_value(gpio, state); + + mod_timer(&gpio_wdt_timer, + jiffies + msecs_to_jiffies(EXT_WDT_TIMEOUT_MS)); +} + +static void __init feed_external_wdt(int gpio_wdt) +{ + if (gpio_wdt > -1) { + gpio_request_one(gpio_wdt, GPIOF_OUT_INIT_HIGH, + "PT7A7514 watchdog"); + + setup_timer(&gpio_wdt_timer, gpio_wdt_toggle, gpio_wdt); + gpio_wdt_toggle(gpio_wdt); + } +} + +static void __init arris_setup(void) +{ + feed_external_wdt(ARRIS_GPIO_EXT_WDT); + + /* GMAC0 of the AR8327 switch is connected to GMAC1 via SGMII */ + arris_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_SGMII; + arris_ar8327_pad0_cfg.sgmii_delay_en = true; + + /* GMAC6 of the AR8327 switch is connected to GMAC0 via RGMII */ + arris_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_RGMII; + arris_ar8327_pad6_cfg.txclk_delay_en = true; + arris_ar8327_pad6_cfg.rxclk_delay_en = true; + arris_ar8327_pad6_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1; + arris_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2; + + ath79_eth0_pll_data.pll_1000 = 0x56000000; + ath79_eth1_pll_data.pll_1000 = 0x03000101; + + ath79_register_leds_gpio(-1, ARRAY_SIZE(arris_leds_gpio), + arris_leds_gpio); + ath79_register_gpio_keys_polled(-1, ARRIS_KEYS_POLL_INTERVAL, + ARRAY_SIZE(arris_gpio_keys), + arris_gpio_keys); + + ath79_register_usb(); + + ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW); + ath79_register_nfc(); + + ath79_register_wmac_simple(); + + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN); + + ath79_register_mdio(0, 0x0); + + mdiobus_register_board_info(arris_mdio0_info, + ARRAY_SIZE(arris_mdio0_info)); +#if 0 + /* GMAC0 is connected to the RMGII interface */ + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; + ath79_eth0_data.phy_mask = BIT(0); + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; + + ath79_register_eth(0); +#endif + /* GMAC1 is connected to the SGMII interface */ + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII; + ath79_eth1_data.speed = SPEED_1000; + ath79_eth1_data.duplex = DUPLEX_FULL; + + ath79_register_eth(1); + + ath79_register_pci(); +} + +MIPS_MACHINE(ATH79_MACH_ARRIS_SBR_AC1750, "ARRIS-SBR-AC1750", "ARRIS SBR-AC1750/TR3300 Router", arris_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h index d268e5814..044b10634 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h @@ -236,6 +236,7 @@ enum ath79_mach_type { ATH79_MACH_RME_EG200, /* eTactica EG200 */ ATH79_MACH_RUT9XX, /* Teltonika RUT900 series */ ATH79_MACH_RW2458N, /* Redwave RW2458N */ + ATH79_MACH_ARRIS_SBR_AC1750, /* ARRIS SBR-AC1750/TR3300 Router */ ATH79_MACH_SC1750, /* Abicom SC1750 */ ATH79_MACH_SC300M, /* Abicom SC300M */ ATH79_MACH_SC450, /* Abicom SC450 */ diff --git a/target/linux/ar71xx/image/nand.mk b/target/linux/ar71xx/image/nand.mk index ba9e1ba62..ff5eda201 100644 --- a/target/linux/ar71xx/image/nand.mk +++ b/target/linux/ar71xx/image/nand.mk @@ -14,6 +14,23 @@ define Build/MerakiNAND-old @mv $@.new $@ endef +define Device/arris-sbr-ac1750 + DEVICE_TITLE := ARRIS SBR-AC1750/TR3300 Router + DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport + BOARDNAME := ARRIS-SBR-AC1750 + BLOCKSIZE := 128KiB + PAGESIZE := 2048 + IMAGE_SIZE := 72m + KERNEL_SIZE := 4096k + UBINIZE_OPTS := -E 5 + MTDPARTS := ar934x-nfc:1m(u-boot)ro,1m(boot-flag),4m(kernel),32m(ubi),4m(kernel2),32m(ubi_rsvd),27m(config),1m(scfgmgr),4m(openwrt),1m(ft),2m(PKI),1m(caldata)ro + IMAGES := sysupgrade.tar kernel1.bin rootfs1.bin + KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma + IMAGE/kernel1.bin := append-kernel | check-size $$$$(KERNEL_SIZE) + IMAGE/rootfs1.bin := append-ubi | check-size $$$$(IMAGE_SIZE) + IMAGE/sysupgrade.tar := sysupgrade-tar | append-metadata +endef +TARGET_DEVICES += arris-sbr-ac1750 define Device/c-60 DEVICE_TITLE := AirTight C-60 diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default index 39b1ca499..d11401751 100644 --- a/target/linux/ar71xx/nand/config-default +++ b/target/linux/ar71xx/nand/config-default @@ -7,6 +7,7 @@ CONFIG_ATH79_DEV_NFC=y CONFIG_ATH79_DEV_SPI=y CONFIG_ATH79_DEV_USB=y CONFIG_ATH79_DEV_WMAC=y +CONFIG_ATH79_MACH_ARRIS_SBR_AC1750=y CONFIG_ATH79_MACH_C60=y CONFIG_ATH79_MACH_DOMYWIFI_DW33D=y CONFIG_ATH79_MACH_HIVEAP_121=y