From 16dda3ab84944253f800e508a289491738ec4a53 Mon Sep 17 00:00:00 2001 From: MR Date: Thu, 30 Jan 2020 14:39:35 +0800 Subject: [PATCH] ar71xx: add support for csac router --- .../ar71xx/base-files/etc/board.d/01_leds | 5 + .../ar71xx/base-files/etc/board.d/02_network | 4 + target/linux/ar71xx/base-files/etc/diag.sh | 3 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 7 +- target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 + .../ar71xx/base-files/lib/upgrade/platform.sh | 1 + target/linux/ar71xx/config-4.14 | 1 + target/linux/ar71xx/config-4.9 | 1 + .../files/arch/mips/ath79/Kconfig.openwrt | 10 ++ .../ar71xx/files/arch/mips/ath79/Makefile | 1 + .../ar71xx/files/arch/mips/ath79/mach-csac.c | 137 ++++++++++++++++++ .../ar71xx/files/arch/mips/ath79/machtypes.h | 1 + target/linux/ar71xx/generic/config-default | 1 + .../ar71xx/image/generic-legacy-devices.mk | 6 + target/linux/ar71xx/image/legacy.mk | 2 + 15 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-csac.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 9a517d4f6f..cec9393743 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -270,6 +270,11 @@ cr5000) ucidef_set_led_wlan "wlan" "WLAN" "pcs:blue:wlan" "phy0tpt" ucidef_set_led_usbdev "usb" "USB" "pcs:white:wps" "1-1" ;; +csac) + ucidef_set_led_switch "status" "STATUS" "csac:green:status" "switch0" "0x10" + ucidef_set_led_wlan "wlan2g" "WLAN2G" "csac:green:wlan2g" "phy1tpt" + ucidef_set_led_wlan "wlan5g" "WLAN5G" "csac:green:wlan5g" "phy0tpt" + ;; db120) ucidef_set_led_usbdev "usb" "USB" "$board:green:usb" "1-1" ;; 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 b83f793332..60befc4cde 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -279,6 +279,10 @@ ar71xx_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "3:wan" "4:lan" ;; + csac) + ucidef_add_switch "switch0" \ + "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" + ;; rme-eg200) ucidef_set_interface_lan "eth0" "dhcp" ;; diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index fc11aad0fb..5c175f1904 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -170,6 +170,9 @@ get_status_led() { cr5000) status_led="pcs:amber:power" ;; + csac) + status_led="csac:green:status" + ;; dap-1330-a1|\ dgl-5500-a1|\ dhp-1565-a1|\ 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 af6c976d36..1873d6db36 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 @@ -223,13 +223,18 @@ case "$FIRMWARE" in cf-e385ac) ath10kcal_extract "art" 20480 12064 ;; + csac) + ath10kcal_extract "art" 20480 12064 + ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ + /lib/firmware/ath10k/QCA9888/hw2.0/board.bin + ;; k2t) ath10kcal_extract "art" 20480 12064 ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) +2) ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ;; - tl-wdr6500-v6) + tl-wdr6500-v6) ath10kcal_extract "art" 8192 12064 ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 773575fe9f..8cd34b4266 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -609,6 +609,9 @@ ar71xx_board_detect() { *"CR5000") name="cr5000" ;; + *"CSAC III") + name="csac" + ;; *"DAP-1330 Rev. A1") name="dap-1330-a1" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 91ae4e29c0..55f0234ede 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -348,6 +348,7 @@ platform_check_image() { arduino-yun|\ bhr-4grv2|\ bxu2000n-2-a1|\ + csac|\ db120|\ dr344|\ dw33d|\ diff --git a/target/linux/ar71xx/config-4.14 b/target/linux/ar71xx/config-4.14 index 5be477c371..1577e74bc9 100644 --- a/target/linux/ar71xx/config-4.14 +++ b/target/linux/ar71xx/config-4.14 @@ -80,6 +80,7 @@ CONFIG_ATH79=y # CONFIG_ATH79_MACH_CPE870 is not set # CONFIG_ATH79_MACH_CR3000 is not set # CONFIG_ATH79_MACH_CR5000 is not set +# CONFIG_ATH79_MACH_CSAC is not set # CONFIG_ATH79_MACH_DAP_1330_A1 is not set # CONFIG_ATH79_MACH_DAP_2695_A1 is not set # CONFIG_ATH79_MACH_DB120 is not set diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9 index c7c6cadef5..9a73849ea5 100644 --- a/target/linux/ar71xx/config-4.9 +++ b/target/linux/ar71xx/config-4.9 @@ -81,6 +81,7 @@ CONFIG_ATH79=y # CONFIG_ATH79_MACH_CPE870 is not set # CONFIG_ATH79_MACH_CR3000 is not set # CONFIG_ATH79_MACH_CR5000 is not set +# CONFIG_ATH79_MACH_CSAC is not set # CONFIG_ATH79_MACH_DAP_1330_A1 is not set # CONFIG_ATH79_MACH_DAP_2695_A1 is not set # CONFIG_ATH79_MACH_DB120 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 7e3aef940d..35e049a951 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt @@ -215,6 +215,16 @@ config ATH79_MACH_AP152 select ATH79_DEV_WMAC select ATH79_DEV_AP9X_PCI if PCI +config ATH79_MACH_CSAC + bool "CSAC III support" + select SOC_QCA956X + select ATH79_DEV_GPIO_BUTTONS + select ATH79_DEV_LEDS_GPIO + select ATH79_DEV_M25P80 + select ATH79_DEV_USB + select ATH79_DEV_WMAC + select ATH79_DEV_AP9X_PCI if PCI + config ATH79_MACH_AP531B0 bool "Rockeetech AP531B0 support" select SOC_QCA953X diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile index 52d0a912f4..fe5fad82b1 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile @@ -91,6 +91,7 @@ obj-$(CONFIG_ATH79_MACH_CPE830) += mach-ap90q.o obj-$(CONFIG_ATH79_MACH_CPE870) += mach-cpe870.o obj-$(CONFIG_ATH79_MACH_CR3000) += mach-cr3000.o obj-$(CONFIG_ATH79_MACH_CR5000) += mach-cr5000.o +obj-$(CONFIG_ATH79_MACH_CSAC) += mach-csac.o obj-$(CONFIG_ATH79_MACH_DAP_1330_A1) += mach-dap-1330-a1.o obj-$(CONFIG_ATH79_MACH_DAP_2695_A1) += mach-dap-2695-a1.o obj-$(CONFIG_ATH79_MACH_DB120) += mach-db120.o diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-csac.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-csac.c new file mode 100644 index 0000000000..cf3fffc9a6 --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-csac.c @@ -0,0 +1,137 @@ + +/* + * Qualcomm Atheros csac reference board support + * + * Copyright (c) 2015 Qualcomm Atheros + * Copyright (c) 2012 Gabor Juhos + * + * 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 "common.h" +#include "dev-m25p80.h" +#include "machtypes.h" +#include "pci.h" +#include "dev-eth.h" +#include "dev-gpio-buttons.h" +#include "dev-leds-gpio.h" +#include "dev-spi.h" +#include "dev-usb.h" +#include "dev-wmac.h" + +#define CSAC_GPIO_LED_STATUS 7 +#define CSAC_GPIO_LED_WLAN2G 8 +#define CSAC_GPIO_LED_WLAN5G 9 + +#define CSAC_GPIO_BTN_RESET 2 +#define CSAC_KEYS_POLL_INTERVAL 20 /* msecs */ +#define CSAC_KEYS_DEBOUNCE_INTERVAL (3 * CSAC_KEYS_POLL_INTERVAL) + +#define CSAC_MAC0_OFFSET 0 +#define CSAC_WMAC_CALDATA_OFFSET 0x1000 + +static struct gpio_led csac_leds_gpio[] __initdata = { + { + .name = "csac:green:status", + .gpio = CSAC_GPIO_LED_STATUS, + .active_low = 1, + }, + { + .name = "csac:green:wlan2g", + .gpio = CSAC_GPIO_LED_WLAN2G, + .active_low = 1, + }, + { + .name = "csac:green:wlan5g", + .gpio = CSAC_GPIO_LED_WLAN5G, + .active_low = 1, + }, +}; + +static struct gpio_keys_button csac_gpio_keys[] __initdata = { + { + .desc = "Reset button", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = CSAC_KEYS_DEBOUNCE_INTERVAL, + .gpio = CSAC_GPIO_BTN_RESET, + .active_low = 1, + }, +}; + +static struct ar8327_pad_cfg csac_ar8337_pad0_cfg = { + .mode = AR8327_PAD_MAC_SGMII, + .sgmii_delay_en = true, +}; + +static struct ar8327_platform_data csac_ar8337_data = { + .pad0_cfg = &csac_ar8337_pad0_cfg, + .port0_cfg = { + .force_link = 1, + .speed = AR8327_PORT_SPEED_1000, + .duplex = 1, + .txpause = 1, + .rxpause = 1, + }, +}; + +static struct mdio_board_info csac_mdio0_info[] = { + { + .bus_id = "ag71xx-mdio.0", + .mdio_addr = 0, + .platform_data = &csac_ar8337_data, + }, +}; + +static void __init csac_setup(void) +{ + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); + + ath79_register_m25p80(NULL); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(csac_leds_gpio), + csac_leds_gpio); + ath79_register_gpio_keys_polled(-1, CSAC_KEYS_POLL_INTERVAL, + ARRAY_SIZE(csac_gpio_keys), + csac_gpio_keys); + + ath79_register_usb(); + + platform_device_register(&ath79_mdio0_device); + + mdiobus_register_board_info(csac_mdio0_info, + ARRAY_SIZE(csac_mdio0_info)); + + ath79_register_wmac(art + CSAC_WMAC_CALDATA_OFFSET, NULL); + ath79_register_pci(); + + ath79_init_mac(ath79_eth0_data.mac_addr, art + CSAC_MAC0_OFFSET, 0); + + /* GMAC0 is connected to an AR8337 switch */ + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII; + ath79_eth0_data.speed = SPEED_1000; + ath79_eth0_data.duplex = DUPLEX_FULL; + ath79_eth0_data.phy_mask = BIT(0); + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; + + ath79_register_eth(0); +} + +MIPS_MACHINE(ATH79_MACH_CSAC, "CSAC", "CSAC III", + csac_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h index 52e8a9a407..f40d7f0b51 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h @@ -82,6 +82,7 @@ enum ath79_mach_type { ATH79_MACH_CPE870, /* YunCore CPE870 */ ATH79_MACH_CR3000, /* PowerCloud Systems CR3000 */ ATH79_MACH_CR5000, /* PowerCloud Systems CR5000 */ + ATH79_MACH_CSAC, /* CSAC III */ ATH79_MACH_DAP_1330_A1, /* D-Link DAP-1330 rev. A1 */ ATH79_MACH_DAP_2695_A1, /* D-Link DAP-2695 rev. A1 */ ATH79_MACH_DB120, /* Atheros DB120 reference board */ diff --git a/target/linux/ar71xx/generic/config-default b/target/linux/ar71xx/generic/config-default index e9b7488844..5bdf0ff629 100644 --- a/target/linux/ar71xx/generic/config-default +++ b/target/linux/ar71xx/generic/config-default @@ -55,6 +55,7 @@ CONFIG_ATH79_MACH_CPE830=y CONFIG_ATH79_MACH_CPE870=y CONFIG_ATH79_MACH_CR3000=y CONFIG_ATH79_MACH_CR5000=y +CONFIG_ATH79_MACH_CSAC=y CONFIG_ATH79_MACH_DAP_1330_A1=y CONFIG_ATH79_MACH_DAP_2695_A1=y CONFIG_ATH79_MACH_DB120=y diff --git a/target/linux/ar71xx/image/generic-legacy-devices.mk b/target/linux/ar71xx/image/generic-legacy-devices.mk index 7deb963537..1ec8f1e58c 100644 --- a/target/linux/ar71xx/image/generic-legacy-devices.mk +++ b/target/linux/ar71xx/image/generic-legacy-devices.mk @@ -132,6 +132,12 @@ define LegacyDevice/CAP4200AG endef LEGACY_DEVICES += CAP4200AG +define LegacyDevice/CSAC + DEVICE_TITLE := CSAC III + DEVICE_PACKAGES := kmod-ath10k-ct ath10k-firmware-qca9888-ct kmod-usb-core kmod-usb2 kmod-usb-storage +endef +LEGACY_DEVICES += CSAC + define LegacyDevice/DB120 DEVICE_TITLE := Atheros DB120 reference board DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-storage diff --git a/target/linux/ar71xx/image/legacy.mk b/target/linux/ar71xx/image/legacy.mk index ab85757bd2..53824fdb01 100644 --- a/target/linux/ar71xx/image/legacy.mk +++ b/target/linux/ar71xx/image/legacy.mk @@ -247,6 +247,7 @@ cameo_ap123_mtdlayout_4M=mtdparts=spi0.0:64k(u-boot)ro,64k(nvram)ro,3712k(firmwa cameo_db120_mtdlayout=mtdparts=spi0.0:64k(uboot)ro,64k(nvram)ro,15936k(firmware),192k(lang)ro,64k(mac)ro,64k(art)ro cameo_db120_mtdlayout_8M=mtdparts=spi0.0:64k(uboot)ro,64k(nvram)ro,7872k(firmware),128k(lang)ro,64k(art)ro cap4200ag_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),320k(custom)ro,1536k(kernel),12096k(rootfs),2048k(failsafe),64k(art)ro,13632k@0xa0000(firmware) +csac_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k@0x50000(firmware) eap300v2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),320k(custom),13632k(firmware),2048k(failsafe),64k(art)ro db120_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware) dgl_5500_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,15296k(firmware),192k(lang)ro,512k(my-dlink)ro,64k(mac)ro,64k(art)ro @@ -892,6 +893,7 @@ $(eval $(call SingleProfile,AthLzma,64k,AP143_8M,ap143-8M,AP143,ttyS0,115200,$$( $(eval $(call SingleProfile,AthLzma,64k,AP143_16M,ap143-16M,AP143,ttyS0,115200,$$(ap143_mtdlayout_16M),RKuImage)) $(eval $(call SingleProfile,AthLzma,64k,AP147_010,ap147-010,AP147-010,ttyS0,115200,$$(ap147_mtdlayout),RKuImage)) $(eval $(call SingleProfile,AthLzma,64k,AP152_16M,ap152-16M,AP152,ttyS0,115200,$$(ap152_mtdlayout_16M),RKuImage)) +$(eval $(call SingleProfile,AthLzma,64k,CSAC,csac,CSAC,ttyS0,115200,$$(csac_mtdlayout),RKuImage)) $(eval $(call SingleProfile,AthLzma,64k,BXU2000N2,bxu2000n-2-a1,BXU2000n-2-A1,ttyS0,115200,$$(bxu2000n2_mtdlayout),RKuImage)) $(eval $(call SingleProfile,AthLzma,64k,CAP4200AG,cap4200ag,CAP4200AG,ttyS0,115200,$$(cap4200ag_mtdlayout),KRuImage)) $(eval $(call SingleProfile,AthLzma,64k,DB120,db120,DB120,ttyS0,115200,$$(db120_mtdlayout),RKuImage))