From patchwork Sat May 27 20:26:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Roederer X-Patchwork-Id: 767772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3wZvgg5WVLz9s5j for ; Sun, 28 May 2017 06:27:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jYYbltFb"; dkim-atps=neutral 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: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:In-Reply-To:References: List-Owner; bh=MwH4hO1WNIj1tcqOnr5iXpfIIcYu6V/4mTHjPOanBv8=; b=jYYbltFb6mEZLU oGCh/42Cw3zF0wTmcUEBWx8zkT1r6wU3oKSUPhH4J1MzAgdU9KVHQeNb1ZzEuj4ia2yTu1sV/oK4S oO2nnC0trKVxHFfovqJWdHIqrdpWAoTv46wZakb4gD8XWUSbZHLwgGle+suq2rApekicbq/EcfiwQ M6ojTi6U/YPMSXY1zmD01SmlES0hrkKJNGUTpQXLDp4Wl3zowjzGkXw0HnbJ7LXv036j8utGeF4/y +C4r38TRG2hB1o80DoKMX39prK+UmmnvP5VYkQtyO4pozRDbr4KQGr8Cbhi7ciYIwHSP1XAH1eoZ3 EAKFo2hDwn3b1ws4iySA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dEiIo-0002RZ-Bu; Sat, 27 May 2017 20:27:10 +0000 Received: from settle.geroedel.de ([2a02:180:1:1::5b8f:5085] helo=mail.geroedel.de) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dEiIN-0002OW-Oo for lede-dev@lists.infradead.org; Sat, 27 May 2017 20:26:46 +0000 Received: from backuphost ([192.168.15.2] helo=feeble.bln.roederer.dhs.org) by mail.geroedel.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1dEiHu-0004LV-Jo for lede-dev@lists.infradead.org; Sat, 27 May 2017 22:26:15 +0200 Received: from build.bln.roederer.dhs.org ([192.168.8.5] helo=build) by feeble.bln.roederer.dhs.org with smtp (Exim 4.84_2) (envelope-from ) id 1dEiHu-0000L8-0l for lede-dev@lists.infradead.org; Sat, 27 May 2017 22:26:14 +0200 Received: (nullmailer pid 14628 invoked by uid 10000); Sat, 27 May 2017 20:26:13 -0000 From: Sven Roederer To: lede-dev@lists.infradead.org Date: Sat, 27 May 2017 22:26:10 +0200 Message-Id: <1495916770-14584-1-git-send-email-devel-sven@geroedel.de> X-Mailer: git-send-email 2.1.4 X-SA-Exim-Connect-IP: 192.168.15.2 X-SA-Exim-Mail-From: devel-sven@geroedel.de X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on settle.geroedel.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable version=3.3.2 X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mail.geroedel.de) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170527_132643_969420_B348A62A X-CRM114-Status: GOOD ( 15.23 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH] ramips: add support for Ubiquiti EdgeRouter X-SFP X-BeenThere: lede-dev@lists.infradead.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: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch adds support for the Ubiquiti EdgeRouter X-SFP and improves support for the EdgeRouter X. Specification: - SoC: MediaTek MT7621AT - Flash: 256 MiB - RAM: 265 MiB - Ethernet: 5 x LAN (1000 Mbps) - UART: 1 x UART on PCB (3.3V, RX, TX, GND) - 57600 8N1 - EdgeRouter X: - 1 x PoE-Passtrough (Eth4) - powered by Wallwart or passive PoE - EdgeRouter X-SFP: - 5 x PoE-Out (24V, passive) - 1 x SFP (unknown status) - powered by Wallwart (24V) Doesn't work: * SoC has crypto engine but no open driver. * SoC has nat acceleration, but no open driver. * This router has 2MB spi flash soldered in but MT nand/spi drivers do not support pin sharing, so it is not accessable and disabled. Stock firmware could read it and it was empty. Installation via vendor firmware: - build an Initrd-image (> 3MiB) and upload the factory-image - initrd can have luci-mod-failsafe - flash final firmware via LuCI / sysupgrade on rebooted system via TFTP: - stop uboot into tftp-load into option "1" - upload factory.bin image Signed-off-by: Sven Roederer --- .../linux/ramips/base-files/etc/board.d/02_network | 1 + .../ramips/base-files/etc/board.d/03_gpio_switches | 25 +++++ target/linux/ramips/base-files/lib/ramips.sh | 3 + .../ramips/base-files/lib/upgrade/platform.sh | 9 +- target/linux/ramips/dts/UBNT-ERX-SFP.dts | 24 +++++ target/linux/ramips/dts/UBNT-ERX.dts | 102 +------------------- target/linux/ramips/dts/UBNT-ERX.dtsi | 106 +++++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 13 +++ 8 files changed, 179 insertions(+), 104 deletions(-) create mode 100755 target/linux/ramips/base-files/etc/board.d/03_gpio_switches create mode 100644 target/linux/ramips/dts/UBNT-ERX-SFP.dts create mode 100644 target/linux/ramips/dts/UBNT-ERX.dtsi diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network index 80a3bc2..490a41e 100755 --- a/target/linux/ramips/base-files/etc/board.d/02_network +++ b/target/linux/ramips/base-files/etc/board.d/02_network @@ -165,6 +165,7 @@ ramips_setup_interfaces() rb750gr3|\ rt-n14u|\ ubnt-erx|\ + ubnt-erx-sfp|\ ur-326n4g|\ wrtnode|\ wrtnode2p | \ diff --git a/target/linux/ramips/base-files/etc/board.d/03_gpio_switches b/target/linux/ramips/base-files/etc/board.d/03_gpio_switches new file mode 100755 index 0000000..859dfb3 --- /dev/null +++ b/target/linux/ramips/base-files/etc/board.d/03_gpio_switches @@ -0,0 +1,25 @@ +#!/bin/sh + +. /lib/functions/uci-defaults.sh +. /lib/ramips.sh + +board_config_update + +board=$(ramips_board_name) + +case "$board" in +ubnt-erx) + ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "0" + ;; +ubnt-erx-sfp) + ucidef_add_gpio_switch "poe_power_port0" "PoE Power Port0" "496" + ucidef_add_gpio_switch "poe_power_port1" "PoE Power Port1" "497" + ucidef_add_gpio_switch "poe_power_port2" "PoE Power Port2" "498" + ucidef_add_gpio_switch "poe_power_port3" "PoE Power Port3" "499" + ucidef_add_gpio_switch "poe_power_port4" "PoE Power Port4" "500" + ;; +esac + +board_config_flush + +exit 0 diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh index 87cb7ff..b5f0617 100755 --- a/target/linux/ramips/base-files/lib/ramips.sh +++ b/target/linux/ramips/base-files/lib/ramips.sh @@ -481,6 +481,9 @@ ramips_board_detect() { *"UBNT-ERX") name="ubnt-erx" ;; + *"UBNT-ERX-SFP") + name="ubnt-erx-sfp" + ;; *"UR-326N4G") name="ur-326n4g" ;; diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh index adad8da..d8a7c08 100755 --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh @@ -249,7 +249,8 @@ platform_check_image() { # these boards use metadata images return 0 ;; - ubnt-erx) + ubnt-erx|\ + ubnt-erx-sfp) nand_do_platform_check "$board" "$1" return $?; ;; @@ -271,7 +272,8 @@ platform_nand_pre_upgrade() { local board=$(ramips_board_name) case "$board" in - ubnt-erx) + ubnt-erx|\ + ubnt-erx-sfp) platform_upgrade_ubnt_erx "$ARGV" ;; esac @@ -283,7 +285,8 @@ platform_pre_upgrade() { case "$board" in hc5962|\ r6220|\ - ubnt-erx) + ubnt-erx|\ + ubnt-erx-sfp) nand_do_upgrade "$ARGV" ;; esac diff --git a/target/linux/ramips/dts/UBNT-ERX-SFP.dts b/target/linux/ramips/dts/UBNT-ERX-SFP.dts new file mode 100644 index 0000000..69599fe --- /dev/null +++ b/target/linux/ramips/dts/UBNT-ERX-SFP.dts @@ -0,0 +1,24 @@ +/dts-v1/; + +#include "UBNT-ERX.dtsi" + +#include + +/ { + model = "UBNT-ERX-SFP"; + compatible = "ubiquiti,edgerouterx-sfp"; + + i2c-gpio { + compatible = "i2c-gpio"; + gpios = <&gpio0 3 GPIO_ACTIVE_HIGH /* sda */ + &gpio0 4 GPIO_ACTIVE_HIGH /* scl */ + >; + #address-cells = <1>; + #size-cells = <0>; + + pca9555@25 { + compatible = "pca9555"; + reg = <0x25>; + }; + }; +}; diff --git a/target/linux/ramips/dts/UBNT-ERX.dts b/target/linux/ramips/dts/UBNT-ERX.dts index 0b2da95..7715162 100644 --- a/target/linux/ramips/dts/UBNT-ERX.dts +++ b/target/linux/ramips/dts/UBNT-ERX.dts @@ -1,107 +1,7 @@ -#include - /dts-v1/; -#include "mt7621.dtsi" +#include "UBNT-ERX.dtsi" / { model = "UBNT-ERX"; - - memory@0 { - device_type = "memory"; - reg = <0x0 0x10000000>; - }; - - chosen { - bootargs = "console=ttyS0,57600"; - }; - - gpio-keys-polled { - compatible = "gpio-keys-polled"; - #address-cells = <1>; - #size-cells = <0>; - poll-interval = <20>; - - reset { - label = "reset"; - gpios = <&gpio0 12 1>; - linux,code = ; - }; - }; -}; - -ðernet { - mtd-mac-address = <&factory 0x22>; -}; - -&nand { - status = "okay"; - - partition@0 { - label = "u-boot"; - reg = <0x0 0x80000>; - read-only; - }; - - partition@80000 { - label = "u-boot-env"; - reg = <0x80000 0x60000>; - read-only; - }; - - factory: partition@e0000 { - label = "factory"; - reg = <0xe0000 0x60000>; - }; - - partition@140000 { - label = "kernel1"; - reg = <0x140000 0x300000>; - }; - - partition@440000 { - label = "kernel2"; - reg = <0x440000 0x300000>; - }; - - partition@740000 { - label = "ubi"; - reg = <0x740000 0xf7c0000>; - }; -}; - -&pinctrl { - state_default: pinctrl0 { - gpio { - ralink,group = "uart2", "uart3", "i2c", "pcie", "rgmii2", "jtag"; - ralink,function = "gpio"; - }; - }; -}; - -&spi0 { - /* This board has 2Mb spi flash soldered in and visible - from manufacturer's firmware. - But this SoC shares spi and nand pins, - and current driver does't handle this sharing well */ - status = "disabled"; - - m25p80@0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "jedec,spi-nor"; - reg = <1>; - spi-max-frequency = <10000000>; - m25p,chunked-io = <32>; - - partition@0 { - label = "spi"; - reg = <0x0 0x200000>; - read-only; - }; - }; -}; - -&xhci { - status = "disabled"; }; diff --git a/target/linux/ramips/dts/UBNT-ERX.dtsi b/target/linux/ramips/dts/UBNT-ERX.dtsi new file mode 100644 index 0000000..b38c719 --- /dev/null +++ b/target/linux/ramips/dts/UBNT-ERX.dtsi @@ -0,0 +1,106 @@ +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "ubiquiti,edgerouterx"; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x10000000>; + }; + + chosen { + bootargs = "console=ttyS0,57600"; + }; + + gpio-keys-polled { + compatible = "gpio-keys-polled"; + #address-cells = <1>; + #size-cells = <0>; + poll-interval = <20>; + + reset { + label = "reset"; + gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +ðernet { + mtd-mac-address = <&factory 0x22>; +}; + +&nand { + status = "okay"; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "u-boot-env"; + reg = <0x80000 0x60000>; + read-only; + }; + + factory: partition@e0000 { + label = "factory"; + reg = <0xe0000 0x60000>; + }; + + partition@140000 { + label = "kernel1"; + reg = <0x140000 0x300000>; + }; + + partition@440000 { + label = "kernel2"; + reg = <0x440000 0x300000>; + }; + + partition@740000 { + label = "ubi"; + reg = <0x740000 0xf7c0000>; + }; +}; + +&pinctrl { + state_default: pinctrl0 { + gpio { + ralink,group = "uart2", "uart3", "i2c", "pcie", "rgmii2", "jtag"; + ralink,function = "gpio"; + }; + }; +}; + +&spi0 { + /* This board has 2Mb spi flash soldered in and visible + from manufacturer's firmware. + But this SoC shares spi and nand pins, + and current driver does't handle this sharing well */ + status = "disabled"; + + m25p80@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "jedec,spi-nor"; + reg = <1>; + spi-max-frequency = <10000000>; + m25p,chunked-io = <32>; + + partition@0 { + label = "spi"; + reg = <0x0 0x200000>; + read-only; + }; + }; +}; + +&xhci { + status = "disabled"; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index b57552a..f65449a 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -176,6 +176,19 @@ define Device/ubnt-erx endef TARGET_DEVICES += ubnt-erx +define Device/ubnt-erx-sfp + DTS := UBNT-ERX-SFP + FILESYSTEMS := squashfs + KERNEL_SIZE := 3145728 + KERNEL := $(KERNEL_DTB) | uImage lzma + IMAGES := sysupgrade.tar + KERNEL_INITRAMFS := $$(KERNEL) | ubnt-erx-factory-image $(KDIR)/tmp/$$(KERNEL_INITRAMFS_PREFIX)-factory.tar + IMAGE/sysupgrade.tar := sysupgrade-tar | append-metadata + DEVICE_TITLE := Ubiquiti EdgeRouter X-SFP + DEVICE_PACKAGES := -kmod-mt76 -kmod-rt2x00-lib -kmod-mac80211 -kmod-cfg80211 -wpad-mini -iwinfo kmod-i2c-algo-pca kmod-gpio-pca953x kmod-i2c-gpio-custom +endef +TARGET_DEVICES += ubnt-erx-sfp + define Device/vr500 DTS := VR500 IMAGE_SIZE := 66453504