From e7cd6f5d66b827e31cfa7e7bc019ac1b86aac770 Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Fri, 30 Dec 2016 11:53:21 +0100 Subject: [PATCH] ar71xx: add AVM FRITZ!WLAN Repeater 300E support Specifications: * SoC: AR7242 (Virian 400MHz) * RAM: 64 MB DDR (W9751G6JB-25) * Flash: 16MB SPI flash (S25FL129PIF) * WiFi: AR9382 (2.4/5GHz) + 2x SE2595L * LAN: 1x1000M (PEF7071V) To install LEDE via EVA bootloader, a FTP connection need to be established to 192.168.178.1 within the first seconds after power on: ftp> quote USER adam2 ftp> quote PASS adam2 ftp> binary ftp> debug ftp> passive ftp> quote MEDIA FLSH ftp> put lede-ar71xx-generic-fritz300e-squashfs-sysupgrade.bin mtd1 Signed-off-by: Mathias Kresin --- include/image-commands.mk | 10 ++ .../ar71xx/base-files/etc/board.d/01_leds | 10 ++ .../ar71xx/base-files/etc/board.d/02_network | 4 + target/linux/ar71xx/base-files/etc/diag.sh | 1 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 21 +++ target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 + .../ar71xx/base-files/lib/upgrade/platform.sh | 1 + target/linux/ar71xx/config-4.4 | 3 + .../files/arch/mips/ath79/Kconfig.openwrt | 9 ++ .../ar71xx/files/arch/mips/ath79/Makefile | 1 + .../files/arch/mips/ath79/mach-fritz300e.c | 132 ++++++++++++++++++ .../ar71xx/files/arch/mips/ath79/machtypes.h | 1 + target/linux/ar71xx/image/generic.mk | 13 ++ target/linux/ar71xx/mikrotik/config-default | 3 + target/linux/ar71xx/nand/config-default | 3 + 15 files changed, 215 insertions(+) create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-fritz300e.c diff --git a/include/image-commands.mk b/include/image-commands.mk index 093b93d0e9..8607c85e9e 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -67,6 +67,16 @@ define Build/netgear-dni mv $@.new $@ endef +define Build/append-squashfs-fakeroot-be + rm -rf $@.fakefs $@.fakesquashfs + mkdir $@.fakefs + $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \ + $@.fakefs $@.fakesquashfs \ + -noappend -root-owned -be -nopad -b 65536 \ + $(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH)) + cat $@.fakesquashfs >> $@ +endef + # append a fake/empty rootfs uImage header, to fool the bootloaders # rootfs integrity check define Build/append-uImage-fakeroot-hdr 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 87f99ea9d8..d80efefc34 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -242,6 +242,16 @@ ens202ext) f9k1115v2) ucidef_set_led_usbdev "usb2" "USB2" "belkin:green:usb2" "1-1" ;; +fritz300e) + ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth0" + ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt" + ucidef_set_rssimon "wlan0" "200000" "1" + ucidef_set_led_rssi "rssilow" "RSSILOW" "$board:green:rssi0" "wlan0" "1" "100" + ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "$board:green:rssi1" "wlan0" "20" "100" + ucidef_set_led_rssi "rssimedium" "RSSIMEDIUM" "$board:green:rssi2" "wlan0" "40" "100" + ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "$board:green:rssi3" "wlan0" "60" "100" + ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "$board:green:rssi4" "wlan0" "80" "100" + ;; rb-750) ucidef_set_led_default "act" "act" "rb750:green:act" "1" ucidef_set_led_netdev "port1" "port1" "rb750:green:port1" "eth1" 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 80355d6160..9ff6dddd32 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -75,6 +75,7 @@ ar71xx_setup_interfaces() eap300v2|\ eap7660d|\ el-mini|\ + fritz300e|\ hiveap-121|\ loco-m-xw|\ mr12|\ @@ -518,6 +519,9 @@ ar71xx_setup_macs() lan_mac=$(mtd_get_mac_binary caldata 0) wan_mac=$(mtd_get_mac_binary caldata 6) ;; + fritz300e) + lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)")) + ;; tl-wr1043nd-v4) wan_mac=$(mtd_get_mac_binary config 0x1017c) ;; diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index dce5d8e3cf..936a1148d0 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -54,6 +54,7 @@ get_status_led() { archer-c25-v1|\ archer-c59-v1|\ archer-c60-v1|\ + fritz300e|\ mr12|\ mr16|\ nbg6616|\ 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 4db1b148a2..b4d7817569 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 @@ -40,6 +40,24 @@ ath9k_ubi_eeprom_extract() { ath9k_eeprom_die "failed to extract from $ubi" } +ath9k_eeprom_extract_reverse() { + local part=$1 + local offset=$2 + local count=$3 + local mtd + local reversed + local caldata + + mtd=$(find_mtd_chardev "$part") + reversed=$(hexdump -v -s $offset -n $count -e '/1 "%02x "' $mtd) + + for byte in $reversed; do + caldata="\x${byte}${caldata}" + done + + printf "%b" "$caldata" > /lib/firmware/$FIRMWARE +} + ath9k_patch_firmware_mac() { local mac=$1 @@ -99,6 +117,9 @@ case "$FIRMWARE" in ath9k_eeprom_extract "art" 20480 2048 ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +2) ;; + fritz300e) + ath9k_eeprom_extract_reverse "urloader" 5441 1088 + ;; mr18) . /lib/upgrade/nand.sh diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index a1abfa047d..ecc8dab36c 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -640,6 +640,9 @@ ar71xx_board_detect() { *"ESR900") name="esr900" ;; + *"FRITZ!WLAN Repeater 300E") + name="fritz300e" + ;; *"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 4ee467180d..60e41c862e 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -647,6 +647,7 @@ platform_check_image() { return 0; ;; # these boards use metadata images + fritz300e|\ rb-750-r2|\ rb-750up-r2|\ rb-941-2nd|\ diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4 index 6ac3a9ede3..8a6335980c 100644 --- a/target/linux/ar71xx/config-4.4 +++ b/target/linux/ar71xx/config-4.4 @@ -107,6 +107,7 @@ CONFIG_ATH79_MACH_ESR1750=y CONFIG_ATH79_MACH_ESR900=y CONFIG_ATH79_MACH_EW_DORIN=y CONFIG_ATH79_MACH_F9K1115V2=y +CONFIG_ATH79_MACH_FRITZ300E=y CONFIG_ATH79_MACH_GL_AR150=y CONFIG_ATH79_MACH_GL_AR300=y CONFIG_ATH79_MACH_GL_AR300M=y @@ -350,6 +351,7 @@ CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_FORCED_THREADING=y CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y +CONFIG_LANTIQ_PHY=y CONFIG_LEDS_GPIO=y CONFIG_LEDS_NU801=y # CONFIG_LEDS_WNDR3700_USB is not set @@ -386,6 +388,7 @@ CONFIG_MTD_PHYSMAP=y CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-2 CONFIG_MTD_REDBOOT_PARTS=y CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPLIT_EVA_FW=y CONFIG_MTD_SPLIT_FIRMWARE=y CONFIG_MTD_SPLIT_LZMA_FW=y CONFIG_MTD_SPLIT_SEAMA_FW=y diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt index 6182a6f47f..0df5a88dc3 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt @@ -2061,3 +2061,12 @@ config ATH79_MACH_TL_WPA8630 select ATH79_DEV_LEDS_GPIO select ATH79_DEV_M25P80 select ATH79_DEV_WMAC + +config ATH79_MACH_FRITZ300E + bool "AVM FRITZ!WLAN Repeater 300E support" + select SOC_AR724X + select ATH79_DEV_AP9X_PCI if PCI + select ATH79_DEV_ETH + select ATH79_DEV_GPIO_BUTTONS + select ATH79_DEV_LEDS_GPIO + select ATH79_DEV_M25P80 diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile index 5c22fafe51..5a848d0399 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile @@ -111,6 +111,7 @@ obj-$(CONFIG_ATH79_MACH_ESR1750) += mach-esr1750.o obj-$(CONFIG_ATH79_MACH_ESR900) += mach-esr900.o 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_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-fritz300e.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-fritz300e.c new file mode 100644 index 0000000000..43af71a0a8 --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-fritz300e.c @@ -0,0 +1,132 @@ +/* + * AVM FRITZ!WLAN Repeater 300E board support + * + * Copyright (C) 2017 Mathias Kresin + * + * 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 "dev-ap9x-pci.h" +#include "dev-eth.h" +#include "dev-gpio-buttons.h" +#include "dev-leds-gpio.h" +#include "dev-m25p80.h" +#include "machtypes.h" + +#define FRITZ300E_KEYS_POLL_INTERVAL 20 /* msecs */ +#define FRITZ300E_KEYS_DEBOUNCE_INTERVAL (3 * FRITZ300E_KEYS_POLL_INTERVAL) + +static struct mtd_partition fritz300e_flash_partitions[] = { + { + .name = "urloader", + .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 fritz300e_flash_data = { + .parts = fritz300e_flash_partitions, + .nr_parts = ARRAY_SIZE(fritz300e_flash_partitions), +}; + +static struct gpio_led fritz300e_leds_gpio[] __initdata = { + { + .name = "fritz300e:green:power", + .gpio = 13, + .active_low = 1, + }, { + .name = "fritz300e:green:lan", + .gpio = 15, + .active_low = 1, + }, { + .name = "fritz300e:green:wlan", + .gpio = 16, + .active_low = 1, + } +}; + +static struct gpio_led fritz300e_wmac_leds_gpio[] = { + { + .name = "fritz300e:green:rssi0", + .gpio = 10, + .active_low = 1, + }, { + .name = "fritz300e:green:rssi1", + .gpio = 4, + .active_low = 1, + }, { + .name = "fritz300e:green:rssi2", + .gpio = 6, + .active_low = 1, + }, { + .name = "fritz300e:green:rssi3", + .gpio = 7, + .active_low = 1, + }, { + .name = "fritz300e:green:rssi4", + .gpio = 5, + .active_low = 1, + } +}; + +static struct gpio_keys_button fritz300e_gpio_keys[] __initdata = { + { + .desc = "wps", + .type = EV_KEY, + .code = KEY_WPS_BUTTON, + .debounce_interval = FRITZ300E_KEYS_DEBOUNCE_INTERVAL, + .gpio = 12, + .active_low = 1, + }, +}; + +static void __init fritz300e_setup(void) +{ + /* get the Lantiq PEF7071V phy out of reset */ + gpio_request_one(11, GPIOF_OUT_INIT_HIGH, "phy reset"); + + ath79_register_m25p80(&fritz300e_flash_data); + + ath79_register_mdio(0, ~(BIT(0))); + + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; + ath79_eth0_data.speed = SPEED_1000; + ath79_eth0_data.duplex = DUPLEX_FULL; + ath79_eth0_data.phy_mask = BIT(0); + + ath79_register_eth(0); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(fritz300e_leds_gpio), + fritz300e_leds_gpio); + ath79_register_gpio_keys_polled(-1, FRITZ300E_KEYS_POLL_INTERVAL, + ARRAY_SIZE(fritz300e_gpio_keys), + fritz300e_gpio_keys); + + ap9x_pci_setup_wmac_leds(0, fritz300e_wmac_leds_gpio, + ARRAY_SIZE(fritz300e_wmac_leds_gpio)); + ap91_pci_init_simple(); +} + +MIPS_MACHINE(ATH79_MACH_FRITZ300E, "FRITZ300E", + "AVM FRITZ!WLAN Repeater 300E", fritz300e_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h index 19d06c9834..8d0dfd662b 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h @@ -103,6 +103,7 @@ enum ath79_mach_type { ATH79_MACH_EW_DORIN, /* embedded wireless Dorin Platform */ ATH79_MACH_EW_DORIN_ROUTER, /* embedded wireless Dorin Router Platform */ ATH79_MACH_F9K1115V2, /* Belkin AC1750DB */ + ATH79_MACH_FRITZ300E, /* AVM FRITZ!WLAN Repeater 300E */ 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/image/generic.mk b/target/linux/ar71xx/image/generic.mk index c293555d7b..56dcf5c997 100644 --- a/target/linux/ar71xx/image/generic.mk +++ b/target/linux/ar71xx/image/generic.mk @@ -878,3 +878,16 @@ define Device/zbt-we1526 IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | pad-to $$$$(ROOTFS_SIZE) | append-kernel | check-size $$$$(IMAGE_SIZE) endef TARGET_DEVICES += zbt-we1526 + +define Device/fritz300e + DEVICE_TITLE := AVM FRITZ!WLAN Repeater 300E + DEVICE_PACKAGES := fritz-tffs rssileds -swconfig -uboot-envtools + BOARDNAME := FRITZ300E + SUPPORTED_DEVICES := fritz300e + IMAGE_SIZE := 15232k + KERNEL := kernel-bin | patch-cmdline | lzma | eva-image + IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | \ + append-squashfs-fakeroot-be | pad-to 256 | \ + append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE) +endef +TARGET_DEVICES += fritz300e diff --git a/target/linux/ar71xx/mikrotik/config-default b/target/linux/ar71xx/mikrotik/config-default index f00933bd87..d0c8e49189 100644 --- a/target/linux/ar71xx/mikrotik/config-default +++ b/target/linux/ar71xx/mikrotik/config-default @@ -76,6 +76,7 @@ # CONFIG_ATH79_MACH_GL_AR300 is not set # CONFIG_ATH79_MACH_GL_AR300M is not set # CONFIG_ATH79_MACH_GL_DOMINO is not set +# CONFIG_ATH79_MACH_FRITZ300E is not set # CONFIG_ATH79_MACH_GL_INET is not set # CONFIG_ATH79_MACH_GL_MIFI is not set # CONFIG_ATH79_MACH_GS_MINIBOX_V1 is not set @@ -215,6 +216,7 @@ CONFIG_CRC16=y CONFIG_CRYPTO_DEFLATE=y CONFIG_GPIO_74X164=y CONFIG_GPIO_LATCH=y +# CONFIG_LANTIQ_PHY is not set CONFIG_LEDS_RB750=y CONFIG_LZO_DECOMPRESS=y # CONFIG_MTD_CFI is not set @@ -230,6 +232,7 @@ CONFIG_MTD_NAND_RB4XX=y CONFIG_MTD_NAND_RB750=y CONFIG_MTD_NAND_RB91X=y # CONFIG_MTD_REDBOOT_PARTS is not set +# CONFIG_MTD_SPLIT_EVA_FW is not set # CONFIG_MTD_TPLINK_PARTS is not set CONFIG_MTD_UBI=y CONFIG_MTD_UBI_BEB_LIMIT=20 diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default index 41eacbf160..8420e15fb4 100644 --- a/target/linux/ar71xx/nand/config-default +++ b/target/linux/ar71xx/nand/config-default @@ -70,6 +70,7 @@ # CONFIG_ATH79_MACH_ESR900 is not set # CONFIG_ATH79_MACH_EW_DORIN is not set # CONFIG_ATH79_MACH_F9K1115V2 is not set +# CONFIG_ATH79_MACH_FRITZ300E 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 @@ -197,6 +198,7 @@ CONFIG_ATH79_MACH_RAMBUTAN=y # CONFIG_ATH79_NVRAM is not set CONFIG_CMDLINE="rootfstype=squashfs noinitrd" # CONFIG_IP17XX_PHY is not set +# CONFIG_LANTIQ_PHY is not set # CONFIG_MARVELL_PHY is not set # CONFIG_MICREL_PHY is not set # CONFIG_MTD_CFI is not set @@ -212,6 +214,7 @@ CONFIG_MTD_NAND_ECC=y CONFIG_MTD_NAND_ECC_BCH=y # CONFIG_MTD_REDBOOT_PARTS is not set # CONFIG_MTD_SM_COMMON is not set +# CONFIG_MTD_SPLIT_EVA_FW is not set # CONFIG_MTD_SPLIT_SEAMA_FW is not set # CONFIG_MTD_TPLINK_PARTS is not set CONFIG_MTD_UBI=y -- 2.30.2