From patchwork Sun Aug 12 23:48:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 956751 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=david-bauer.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Nru2Fs1G"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41pbDw5kDQz9s4c for ; Mon, 13 Aug 2018 09:49:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fqhAqyTtPSS3cU2DfjSvsDNthKkVYIufZH9W9/LWcS8=; b=Nru2Fs1Gz9PExqshHFOrWJyvWt yTg7Od8yQdOC2yhYKJCqbLLpexRDwZcXsWuJ54MvvyDWbprFwGNJQjWO5iKoUHa5B051qEkVqzKy2 AkMwiUNyPeq0BcPhe1LBNYKgWaYzJ61hzXqkUUTTNnDsDWO0IekN6AMhPhVrvcApRiQIBvfkNjy2o WLnUXQ+xe/RpZjQc+F5QSvA/9c9NEn7FYB6HfSz6/0b/hNpay/0Oji1z/z8couUUSXhUTSCwp5xcD g+caJNzbu9NXISSjge10o2oZSgP0YTsVbWtTRHVwyeX37JMZljRBgPb5H8RXj3suWb72WGOIFQkrK GA1s6X8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fp06w-0003d4-UY; Sun, 12 Aug 2018 23:49:26 +0000 Received: from mars.blocktrron.ovh ([51.254.112.43] helo=mail.blocktrron.ovh) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fp06b-00039D-WA for openwrt-devel@lists.openwrt.org; Sun, 12 Aug 2018 23:49:07 +0000 Received: from dbauer-t470.ffda.io (unknown [IPv6:2001:67c:2ed8:100e:a096:3f94:16c0:9b38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.blocktrron.ovh (Postfix) with ESMTPSA id ADB4122C81 for ; Mon, 13 Aug 2018 01:48:48 +0200 (CEST) From: David Bauer To: openwrt-devel@lists.openwrt.org Date: Mon, 13 Aug 2018 01:48:40 +0200 Message-Id: <20180812234840.18068-2-mail@david-bauer.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180812234840.18068-1-mail@david-bauer.net> References: <20180812234840.18068-1-mail@david-bauer.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180812_164906_339396_C66A3F9B X-CRM114-Status: GOOD ( 16.09 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH 2/2] ath79: add support for Fritz!Box 4020 X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This commit adds support for the AVM Fritz!Box 4020 WiFi-router. SoC: Qualcomm Atheros QCA9561 (Dragonfly) 750MHz RAM: Winbond W971GG6KB-25 FLASH: Macronix MX25L12835F WiFi: QCA9561 b/g/n 3x3 450Mbit/s USB: 1x USB 2.0 IN: WPS button, WiFi button OUT: Power LED green, Internet LED green, WLAN LED green, LAN LED green, INFO LED green, INFO LED red UART: 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 (LAN + WAN) - WiFi (correct MAC) - Installation via EVA bootloader - OpenWRT sysupgrade - Buttons - LEDs Not working: - USB port Installation via EVA: In the first seconds after Power is connected, the bootloader will listen for FTP connections on 169.254.157.1 (Might also be 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. After transfer is complete you need to powercycle the device to boot OpenWRT. Signed-off-by: David Bauer --- .../ath79/base-files/etc/board.d/01_leds | 4 + .../ath79/base-files/etc/board.d/02_network | 5 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 10 ++ .../linux/ath79/dts/qca9561_avm_fritz4020.dts | 169 ++++++++++++++++++ target/linux/ath79/image/generic.mk | 14 ++ .../005-gpio-74x164-add-initvals.patch | 12 ++ 6 files changed, 214 insertions(+) create mode 100644 target/linux/ath79/dts/qca9561_avm_fritz4020.dts create mode 100644 target/linux/ath79/patches-4.14/005-gpio-74x164-add-initvals.patch diff --git a/target/linux/ath79/base-files/etc/board.d/01_leds b/target/linux/ath79/base-files/etc/board.d/01_leds index c3dc1bbe56..f058bf599e 100755 --- a/target/linux/ath79/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/base-files/etc/board.d/01_leds @@ -17,6 +17,10 @@ avm,fritz300e) ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "$boardname:green:rssi3" "wlan0" "60" "100" ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "$boardname:green:rssi4" "wlan0" "80" "100" ;; +avm,fritz4020) + ucidef_set_led_netdev "wan" "WAN" "$boardname:green:wan" "eth0" + ucidef_set_led_switch "lan" "LAN" "$boardname:green:lan" "switch0" "0x1E" + ;; etactica,eg200) ucidef_set_led_netdev "lan" "LAN" "$boardname:red:eth0" "eth0" ucidef_set_led_oneshot "modbus" "Modbus" "$boardname:red:modbus" "100" "33" diff --git a/target/linux/ath79/base-files/etc/board.d/02_network b/target/linux/ath79/base-files/etc/board.d/02_network index fe2d5859d3..33bea4de4e 100755 --- a/target/linux/ath79/base-files/etc/board.d/02_network +++ b/target/linux/ath79/base-files/etc/board.d/02_network @@ -42,6 +42,7 @@ ath79_setup_interfaces() etactica,eg200) ucidef_set_interface_lan "eth0" "dhcp" ;; + avm,fritz4020|\ glinet,ar150|\ glinet,ar300m) ucidef_set_interfaces_lan_wan "eth1" "eth0" @@ -149,6 +150,10 @@ ath79_setup_macs() avm,fritz300e) lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)")) ;; + avm,fritz4020) + lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)")) + wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)")) + ;; dlink,dir-825-b1) lan_mac=$(mtd_get_mac_text "caldata" 65440) wan_mac=$(mtd_get_mac_text "caldata" 65460) diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 29c11bbd5f..34ef2f2137 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -162,4 +162,14 @@ case "$FIRMWARE" in ;; esac ;; +"ath9k-eeprom-ahb-18100000.wmac.bin") + case $board in + "avm,fritz4020") + ath9k_eeprom_extract_reverse "urlader" 5441 1088 + ;; + *) + ath9k_eeprom_die "board $board is not supported yet" + ;; + esac + ;; esac diff --git a/target/linux/ath79/dts/qca9561_avm_fritz4020.dts b/target/linux/ath79/dts/qca9561_avm_fritz4020.dts new file mode 100644 index 0000000000..7c82ca5f3b --- /dev/null +++ b/target/linux/ath79/dts/qca9561_avm_fritz4020.dts @@ -0,0 +1,169 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "qca956x.dtsi" + +/ { + compatible = "avm,fritz4020", "qca,qca9560"; + model = "AVM FRITZ!Box 4020"; + + aliases { + led-status = &power; + }; + + chosen { + bootargs = "console=ttyS0,115200n8"; + }; + + led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + gpio-sck = <&gpio 20 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio 19 GPIO_ACTIVE_HIGH>; + num-chipselects = <0>; + + led_gpio: led_gpio@0 { + compatible = "fairchild,74hc595"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + registers-number = <1>; + initvals = <0xff000000>; + spi-max-frequency = <10000000>; + }; + }; + + leds { + compatible = "gpio-leds"; + + power: power { + label = "fritz4020:green:power"; + gpios = <&led_gpio 2 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + wlan { + label = "fritz4020:green:wlan"; + gpios = <&led_gpio 3 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + default-state = "off"; + }; + + lan { + label = "fritz4020:green:lan"; + gpios = <&led_gpio 0 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + wan { + label = "fritz4020:green:wan"; + gpios = <&led_gpio 4 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + info { + label = "fritz4020:green:info"; + gpios = <&led_gpio 6 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + info_red { + label = "fritz4020:red:info"; + gpios = <&led_gpio 1 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + }; + + keys { + compatible = "gpio-keys-polled"; + poll-interval = <100>; + + wps_button { + label = "WPS button"; + linux,code = ; + gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; + }; + + wlan_button { + label = "WLAN button"; + linux,code = ; + gpios = <&gpio 21 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&uart { + status = "okay"; +}; + +&gpio { + status = "okay"; +}; + +&spi { + status = "okay"; + num-cs = <1>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "urlader"; + reg = <0x000000 0x020000>; + read-only; + }; + + partition@1 { + label = "firmware"; + reg = <0x020000 0xee0000>; + }; + + partition@2 { + label = "tffs (1)"; + reg = <0xf00000 0x080000>; + read-only; + }; + + partition@3 { + label = "tffs (2)"; + reg = <0xf80000 0x080000>; + read-only; + }; + }; + }; +}; + +ð0 { + status = "okay"; + + phy-mode = "mii"; + phy-handle = <&swphy0>; + + gmac-config { + device = <&gmac>; + + switch-phy-addr-swap = <1>; + switch-phy-swap = <1>; + }; +}; + +ð1 { + status = "okay"; +}; + +&wmac { + status = "okay"; + qca,no-eeprom; +}; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index a32136a40b..1df0114776 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -13,6 +13,20 @@ define Device/avm_fritz300e endef TARGET_DEVICES += avm_fritz300e +define Device/avm_fritz4020 + ATH_SOC := qca9561 + DEVICE_TITLE := AVM FRITZ!Box 4020 + IMAGE_SIZE := 15232k + KERNEL := kernel-bin | append-dtb | lzma | eva-image + KERNEL_INITRAMFS := $$(KERNEL) + 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) + DEVICE_PACKAGES := fritz-tffs + SUPPORTED_DEVICES += fritz4020 +endef +TARGET_DEVICES += avm_fritz4020 + define Device/buffalo_wzr-hp-g450h ATH_SOC := ar7242 DEVICE_TITLE := Buffalo WZR-HP-G450H diff --git a/target/linux/ath79/patches-4.14/005-gpio-74x164-add-initvals.patch b/target/linux/ath79/patches-4.14/005-gpio-74x164-add-initvals.patch new file mode 100644 index 0000000000..d437ada3e0 --- /dev/null +++ b/target/linux/ath79/patches-4.14/005-gpio-74x164-add-initvals.patch @@ -0,0 +1,12 @@ +--- a/drivers/gpio/gpio-74x164.c ++++ b/drivers/gpio/gpio-74x164.c +@@ -151,6 +151,9 @@ static int gen_74x164_probe(struct spi_d + chip->gpio_chip.parent = &spi->dev; + chip->gpio_chip.owner = THIS_MODULE; + ++ of_property_read_u8_array(spi->dev.of_node, "initvals", chip->buffer, ++ chip->registers); ++ + mutex_init(&chip->lock); + + ret = __gen_74x164_write_config(chip);