ar71xx: add AVM FRITZ!WLAN Repeater 300E support
authorMathias Kresin <dev@kresin.me>
Fri, 30 Dec 2016 10:53:21 +0000 (11:53 +0100)
committerMathias Kresin <dev@kresin.me>
Sat, 24 Jun 2017 20:36:38 +0000 (22:36 +0200)
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 <dev@kresin.me>
15 files changed:
include/image-commands.mk
target/linux/ar71xx/base-files/etc/board.d/01_leds
target/linux/ar71xx/base-files/etc/board.d/02_network
target/linux/ar71xx/base-files/etc/diag.sh
target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
target/linux/ar71xx/config-4.4
target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
target/linux/ar71xx/files/arch/mips/ath79/Makefile
target/linux/ar71xx/files/arch/mips/ath79/mach-fritz300e.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
target/linux/ar71xx/image/generic.mk
target/linux/ar71xx/mikrotik/config-default
target/linux/ar71xx/nand/config-default

index 093b93d0e96b0729babb7c117adb701c36966a6a..8607c85e9e156ae41ac2d11809c3f55632148c80 100644 (file)
@@ -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
index 87f99ea9d88993b318b38b9d4a89e5e99238ac21..d80efefc34e17b59da926fa282247751a9e6a595 100755 (executable)
@@ -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"
index 80355d616046f46665d7360cb13d96ec480b7426..9ff6dddd32119a2c3caf55c01c601153c32cb1d7 100755 (executable)
@@ -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)
                ;;
index dce5d8e3cff852f19b218288677c02811fbe3cf8..936a1148d00596cb97148e7e141f15c6a32e99ee 100644 (file)
@@ -54,6 +54,7 @@ get_status_led() {
        archer-c25-v1|\
        archer-c59-v1|\
        archer-c60-v1|\
+       fritz300e|\
        mr12|\
        mr16|\
        nbg6616|\
index 4db1b148a2d1223bb9a8ce750ef6094301b84540..b4d78175699745d06880b885c3fcb5db89f2b7d2 100644 (file)
@@ -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
 
index a1abfa047de3c01fc38b73f20929bf8ccf7787cd..ecc8dab36c4cfcbcb294ed18d1c50d0296df485f 100755 (executable)
@@ -640,6 +640,9 @@ ar71xx_board_detect() {
        *"ESR900")
                name="esr900"
                ;;
+       *"FRITZ!WLAN Repeater 300E")
+               name="fritz300e"
+               ;;
        *"GL AR150")
                name="gl-ar150"
                ;;
index 4ee467180d883fee1ca19c780e5d8e59a018a3ce..60e41c862e2dfdf4e9779564843ccd9b90669be7 100755 (executable)
@@ -647,6 +647,7 @@ platform_check_image() {
                return 0;
                ;;
        # these boards use metadata images
+       fritz300e|\
        rb-750-r2|\
        rb-750up-r2|\
        rb-941-2nd|\
index 6ac3a9ede3012883a7bb4f8fcc2933af48c08249..8a6335980c0c1e347762f08b44692669a9a4ae69 100644 (file)
@@ -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
index 6182a6f47f3b4f4cfc47cf699d1a61fc6cdf5864..0df5a88dc340dd467eb79ed6e05ef4ea84a46b01 100644 (file)
@@ -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
index 5c22fafe511b2c817a43cb295ec4df6a6a378e65..5a848d03994876d54b1e6694fc419b0f2b84e796 100644 (file)
@@ -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 (file)
index 0000000..43af71a
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ *  AVM FRITZ!WLAN Repeater 300E board support
+ *
+ *  Copyright (C) 2017 Mathias Kresin <dev@kresin.me>
+ *
+ *  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 <linux/gpio.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#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);
index 19d06c983416341a4831322c0678daef31724aaf..8d0dfd662b9e2ac9b9611dc9a71b9e15cd1f4400 100644 (file)
@@ -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 */
index c293555d7b873b21584bd21c2dad2bfc6230065a..56dcf5c9975f0c57e83250901a2cbe0ad2116eaf 100644 (file)
@@ -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
index f00933bd87cea68ed4148ddbcdd97231b933db8d..d0c8e49189c982f593905f8bbcc5003d76ae6fd0 100644 (file)
@@ -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
index 41eacbf160938859ad9e33e35124106f14715113..8420e15fb40459d3ed7a2b3b1f7185a69c431d86 100644 (file)
@@ -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