From 29934e5f0373a7f06c02c3bd6b23fd47cbd48ca2 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Sat, 26 May 2018 18:19:53 +0200 Subject: [PATCH] ar71xx: add support for Fritz!WLAN Repeater 450E This commit adds support for the AVM Fritz!WLAN Repeater 450E SOC: Qualcomm QCA9556 (Scorpion) 560MHz MIPS74Kc RAM: 64MB Zentel A3R12E40CBF DDR2 FLASH: 16MiB Winbond W25Q128 SPI NOR WLAN1: QCA9556 2.4 GHz 802.11b/g/n 3x3 INPUT: WPS button LED: Power, WiFi, LAN, RSSI indicator Serial: Header Next to Black metal shield Pinout is 3.3V - RX - TX - GND (Square Pad is 3.3V) The Serial setting is 115200-8-N-1. Tested and working: - Ethernet - 2.4GHz WiFi (correct MAC) - Installation via EVA bootloader - OpenWRT sysupgrade - Buttons - Most LEDs Not working: - 2 RSSI LEDs AVM used for RSSI{0,1} two of the Ethernet PHYs LEDs which they control over MDIO. Our driver doesn't expose these LEDs as GPIOs. While it is possible to implement this feature, it would require an additional kernel patch for a minor functionality. Installation via EVA: In the first seconds after Power is connected, the bootloader will listen for FTP connections on 192.168.178.1. Firmware can be uploaded like following: ftp> quote USER adam2 ftp> quote PASS adam2 ftp> binary ftp> debug ftp> passive ftp> quote MEDIA FLSH ftp> put openwrt-sysupgrade.bin mtd1 Note that this procedure might take up to two minutes. You need to powercycle the Device afterwards to boot OpenWRT. Signed-off-by: David Bauer (cherry picked from commit b4bf43c66767648f98494dd5f44e1301024b577c) --- .../ar71xx/base-files/etc/board.d/01_leds | 4 + .../ar71xx/base-files/etc/board.d/02_network | 1 + target/linux/ar71xx/base-files/etc/diag.sh | 1 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 3 +- target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 + .../ar71xx/base-files/lib/upgrade/platform.sh | 1 + target/linux/ar71xx/config-4.9 | 1 + .../files/arch/mips/ath79/Kconfig.openwrt | 9 + .../ar71xx/files/arch/mips/ath79/Makefile | 1 + .../files/arch/mips/ath79/mach-fritz450e.c | 177 ++++++++++++++++++ .../ar71xx/files/arch/mips/ath79/machtypes.h | 1 + target/linux/ar71xx/generic/config-default | 1 + target/linux/ar71xx/image/generic.mk | 10 + 13 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-fritz450e.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 aec7741489..2de8472e27 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -377,6 +377,10 @@ fritz4020) ucidef_set_led_netdev "wan" "WAN" "$board:green:wan" "eth0" ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt" ;; +fritz450e) + ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth0" + ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt" + ;; gl-ar300m) ucidef_set_led_wlan "wlan" "WLAN" "$board:red:wlan" "phy0tpt" ;; 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 0c6a055d93..006f27288f 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -80,6 +80,7 @@ ar71xx_setup_interfaces() eap7660d|\ el-mini|\ fritz300e|\ + fritz450e|\ gl-usb150|\ hiveap-121|\ koala|\ diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index f1f4980532..29fd244ab5 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -68,6 +68,7 @@ get_status_led() { archer-c7-v4|\ fritz300e|\ fritz4020|\ + fritz450e|\ gl-usb150|\ mr12|\ mr16|\ 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 6eb946468d..94bce7d335 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 @@ -75,7 +75,8 @@ case "$FIRMWARE" in ath9k_eeprom_extract "art" 4096 2048 ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +1) ;; - fritz4020) + fritz4020|\ + fritz450e) ath9k_eeprom_extract_reverse "urlader" 5441 1088 ;; mr18) diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index de058c90be..06660d1037 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -715,6 +715,9 @@ ar71xx_board_detect() { *"FRITZ!WLAN Repeater 300E") name="fritz300e" ;; + *"FRITZ!WLAN Repeater 450E") + name="fritz450e" + ;; *"GL-AR150") name="gl-ar150" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 4b038b726c..1b6580cdab 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -688,6 +688,7 @@ platform_check_image() { # these boards use metadata images fritz300e|\ fritz4020|\ + fritz450e|\ koala|\ rb-750-r2|\ rb-750p-pbr2|\ diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9 index 9f9d4dedc7..ca976677f0 100644 --- a/target/linux/ar71xx/config-4.9 +++ b/target/linux/ar71xx/config-4.9 @@ -116,6 +116,7 @@ CONFIG_ATH79=y # CONFIG_ATH79_MACH_F9K1115V2 is not set # CONFIG_ATH79_MACH_FRITZ300E is not set # CONFIG_ATH79_MACH_FRITZ4020 is not set +# CONFIG_ATH79_MACH_FRITZ450E is not set # CONFIG_ATH79_MACH_GL_AR150 is not set # CONFIG_ATH79_MACH_GL_AR300 is not set # CONFIG_ATH79_MACH_GL_AR300M 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 5ea7a6f532..bf9d87b3b9 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt @@ -2376,3 +2376,12 @@ config ATH79_MACH_FRITZ4020 select ATH79_DEV_LEDS_GPIO select ATH79_DEV_USB select ATH79_DEV_M25P80 + +config ATH79_MACH_FRITZ450E + bool "AVM FRITZ!WLAN Repeater 450E support" + select SOC_QCA955X + select ATH79_DEV_ETH + select ATH79_DEV_GPIO_BUTTONS + select ATH79_DEV_LEDS_GPIO + select ATH79_DEV_M25P80 + select ATH79_DEV_WMAC diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile index 17529499ac..a8e2aa82f5 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile @@ -126,6 +126,7 @@ obj-$(CONFIG_ATH79_MACH_EW_DORIN) += mach-ew-dorin.o obj-$(CONFIG_ATH79_MACH_F9K1115V2) += mach-f9k1115v2.o obj-$(CONFIG_ATH79_MACH_FRITZ300E) += mach-fritz300e.o obj-$(CONFIG_ATH79_MACH_FRITZ4020) += mach-fritz4020.o +obj-$(CONFIG_ATH79_MACH_FRITZ450E) += mach-fritz450e.o obj-$(CONFIG_ATH79_MACH_GL_AR150) += mach-gl-ar150.o obj-$(CONFIG_ATH79_MACH_GL_AR300) += mach-gl-ar300.o obj-$(CONFIG_ATH79_MACH_GL_AR300M) += mach-gl-ar300m.o diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-fritz450e.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-fritz450e.c new file mode 100644 index 0000000000..ee0a185304 --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-fritz450e.c @@ -0,0 +1,177 @@ +/* + * AVM FRITZ!WLAN Repeater 450E board support + * + * Copyright (C) 2018 David Bauer + * + * 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 +#include +#include +#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-spi.h" +#include "dev-wmac.h" +#include "machtypes.h" + +#define FRITZ450E_GPIO_LED_POWER 14 +#define FRITZ450E_GPIO_LED_LAN 13 +#define FRITZ450E_GPIO_LED_WLAN 15 +#define FRITZ450E_GPIO_LED_RSSI2 16 +#define FRITZ450E_GPIO_LED_RSSI3 17 +#define FRITZ450E_GPIO_LED_RSSI4 18 + +#define FRITZ450E_GPIO_BTN_WPS 4 +#define FRITZ450E_KEYS_POLL_INTERVAL 20 /* msecs */ +#define FRITZ450E_KEYS_DEBOUNCE_INTERVAL (3 * FRITZ450E_KEYS_POLL_INTERVAL) + +#define FRITZ450E_PHY_ADDRESS 0 +#define FRITZ450E_GPIO_PHY_RESET 11 +#define FRITZ450E_GPIO_MDIO_CLK 12 +#define FRITZ450E_GPIO_MDIO_DATA 19 + +#define FRITZ450E_OFFSET_URLADER_WIFI_MAC_REVERSE 0x1979 + + +static struct mtd_partition fritz450E_flash_partitions[] = { + { + .name = "urlader", + .offset = 0, + .size = 0x0020000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "firmware", + .offset = 0x0020000, + .size = 0x0EE0000, + }, { + .name = "tffs (1)", + .offset = 0x0f00000, + .size = 0x0080000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "tffs (2)", + .offset = 0x0f80000, + .size = 0x0080000, + .mask_flags = MTD_WRITEABLE, + } +}; + +static struct flash_platform_data fritz450E_flash_data = { + .parts = fritz450E_flash_partitions, + .nr_parts = ARRAY_SIZE(fritz450E_flash_partitions), +}; + +static struct gpio_led fritz450E_leds_gpio[] __initdata = { + { + .name = "fritz450e:green:lan", + .gpio = FRITZ450E_GPIO_LED_LAN, + .active_low = 1, + }, { + .name = "fritz450e:green:rssi2", + .gpio = FRITZ450E_GPIO_LED_RSSI2, + .active_low = 1, + }, { + .name = "fritz450e:green:rssi3", + .gpio = FRITZ450E_GPIO_LED_RSSI3, + .active_low = 1, + }, { + .name = "fritz450e:green:rssi4", + .gpio = FRITZ450E_GPIO_LED_RSSI4, + .active_low = 1, + }, { + .name = "fritz450e:green:wlan", + .gpio = FRITZ450E_GPIO_LED_WLAN, + .active_low = 1, + }, { + .name = "fritz450e:green:power", + .gpio = FRITZ450E_GPIO_LED_POWER, + .active_low = 0, + }, +}; + +static struct gpio_keys_button fritz450E_gpio_keys[] __initdata = { + { + .desc = "WPS Button", + .type = EV_KEY, + .code = KEY_WPS_BUTTON, + .debounce_interval = FRITZ450E_KEYS_DEBOUNCE_INTERVAL, + .gpio = FRITZ450E_GPIO_BTN_WPS, + .active_low = 1, + } +}; + +static struct at803x_platform_data fritz450E_at803x_data = { + .disable_smarteee = 1, + .has_reset_gpio = 1, + .reset_gpio = FRITZ450E_GPIO_PHY_RESET, +}; + +static struct mdio_board_info fritz450E_mdio_info[] = { + { + .bus_id = "ag71xx-mdio.1", + .phy_addr = FRITZ450E_PHY_ADDRESS, + .platform_data = &fritz450E_at803x_data, + }, +}; + +static void __init fritz450E_setup(void) { + u8 *urlader = (u8 *) KSEG1ADDR(0x1f000000); + u8 wifi_mac[ETH_ALEN]; + + ath79_register_m25p80(&fritz450E_flash_data); + + gpio_request_one(FRITZ450E_GPIO_MDIO_CLK, GPIOF_OUT_INIT_HIGH, "MDC Pull-UP"); + gpio_request_one(FRITZ450E_GPIO_MDIO_DATA, GPIOF_OUT_INIT_HIGH, "MDIO Pull-UP"); + gpio_request_one(FRITZ450E_GPIO_PHY_RESET, GPIOF_OUT_INIT_HIGH, "PHY reset"); + + /* Register PHY device */ + mdiobus_register_board_info(fritz450E_mdio_info, + ARRAY_SIZE(fritz450E_mdio_info)); + + /* Initialize Ethernet */ + ath79_extract_mac_reverse(urlader + FRITZ450E_OFFSET_URLADER_WIFI_MAC_REVERSE, wifi_mac); + ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, -2); + + ath79_register_mdio(1, ~BIT(FRITZ450E_PHY_ADDRESS)); + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev; + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII; + ath79_eth0_data.phy_mask = BIT(FRITZ450E_PHY_ADDRESS); + ath79_eth0_pll_data.pll_1000 = 0x03000000; + ath79_eth0_pll_data.pll_100 = 0x00000101; + ath79_eth0_pll_data.pll_10 = 0x00001313; + ath79_register_eth(0); + + /* Initialize 2.4GHz WiFi */ + ath79_register_wmac_simple(); + + /* Register GPIO buttons */ + ath79_register_gpio_keys_polled(-1, FRITZ450E_KEYS_POLL_INTERVAL, + ARRAY_SIZE(fritz450E_gpio_keys), + fritz450E_gpio_keys); + + /* Register LEDs */ + ath79_register_leds_gpio(-1, ARRAY_SIZE(fritz450E_leds_gpio), + fritz450E_leds_gpio); +} + +MIPS_MACHINE(ATH79_MACH_FRITZ450E, "FRITZ450E", + "AVM FRITZ!WLAN Repeater 450E", fritz450E_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h index 5f2244d209..3908e0dadc 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h @@ -121,6 +121,7 @@ enum ath79_mach_type { ATH79_MACH_F9K1115V2, /* Belkin AC1750DB */ ATH79_MACH_FRITZ300E, /* AVM FRITZ!WLAN Repeater 300E */ ATH79_MACH_FRITZ4020, /* AVM FRITZ!Box 4020 */ + ATH79_MACH_FRITZ450E, /* AVM FRITZ!WLAN Repeater 450E */ ATH79_MACH_GL_AR150, /* GL-AR150 support */ ATH79_MACH_GL_AR300, /* GL-AR300 */ ATH79_MACH_GL_AR300M, /* GL-AR300M */ diff --git a/target/linux/ar71xx/generic/config-default b/target/linux/ar71xx/generic/config-default index 0051048e30..a857844f33 100644 --- a/target/linux/ar71xx/generic/config-default +++ b/target/linux/ar71xx/generic/config-default @@ -89,6 +89,7 @@ CONFIG_ATH79_MACH_EW_DORIN=y CONFIG_ATH79_MACH_F9K1115V2=y CONFIG_ATH79_MACH_FRITZ300E=y CONFIG_ATH79_MACH_FRITZ4020=y +CONFIG_ATH79_MACH_FRITZ450E=y CONFIG_ATH79_MACH_GL_AR150=y CONFIG_ATH79_MACH_GL_AR300=y CONFIG_ATH79_MACH_GL_AR300M=y diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk index a49b0d655d..c74ca130b6 100644 --- a/target/linux/ar71xx/image/generic.mk +++ b/target/linux/ar71xx/image/generic.mk @@ -1321,3 +1321,13 @@ define Device/fritz4020 IMAGE_SIZE := 15232k endef TARGET_DEVICES += fritz4020 + +define Device/fritz450e + $(call Device/AVM) + DEVICE_TITLE := AVM FRITZ!WLAN Repeater 450E + DEVICE_PACKAGES += -swconfig + BOARDNAME := FRITZ450E + SUPPORTED_DEVICES := fritz450e + IMAGE_SIZE := 15232k +endef +TARGET_DEVICES += fritz450e -- 2.25.1