From 1e27bcc8f5fa7997578d297c44e8923802eeb200 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= <cynerd@email.cz>
Date: Sun, 10 Mar 2019 13:48:12 +0100
Subject: [PATCH] patches: openwrt: change sfp support patch for Omnia

Previous patch was causing null pointer dereference kernel panic with
phy variant. This one hopefully should fix it.
---
 .../0005-Turris-Omnia-Improved-suppport.patch | 1001 +++--------------
 1 file changed, 140 insertions(+), 861 deletions(-)

diff --git a/patches/openwrt/wip/0005-Turris-Omnia-Improved-suppport.patch b/patches/openwrt/wip/0005-Turris-Omnia-Improved-suppport.patch
index 7b89b8bf0..bcea7e9d6 100644
--- a/patches/openwrt/wip/0005-Turris-Omnia-Improved-suppport.patch
+++ b/patches/openwrt/wip/0005-Turris-Omnia-Improved-suppport.patch
@@ -1,28 +1,26 @@
-From 126e3c79d573bfd7d5fe2ef1a5eca40b97e5377a Mon Sep 17 00:00:00 2001
+From 12d90ca504123ddbe1b951c0e4fb69d126789d17 Mon Sep 17 00:00:00 2001
 From: Michal Hrusecky <Michal@Hrusecky.net>
 Date: Fri, 22 Feb 2019 08:30:39 +0100
 Subject: [PATCH] Turris Omnia: Improved suppport
 
 ---
- ...88-turris-omnia-separate-dtb-for-sfp.patch | 906 ++++++++++++++++++
- ...turris-omnia-disable-unused-ethernet.patch |  38 +
- .../8890-turris-omnia-led-driver.patch        | 323 +++++++
- ...91-turris-omnia-custom-led-functions.patch | 269 ++++++
- ...8892-turris-omnia-enable-leds-in-dts.patch | 102 ++
- 5 files changed, 1638 insertions(+)
- create mode 100644 target/linux/mvebu/patches-4.14/8888-turris-omnia-separate-dtb-for-sfp.patch
- create mode 100644 target/linux/mvebu/patches-4.14/8889-turris-omnia-disable-unused-ethernet.patch
+ ...nia-Add-separate-DTS-for-SFP-support.patch | 231 +++++++++++++
+ .../8890-turris-omnia-led-driver.patch        | 323 ++++++++++++++++++
+ ...91-turris-omnia-custom-led-functions.patch | 269 +++++++++++++++
+ ...8892-turris-omnia-enable-leds-in-dts.patch | 102 ++++++
+ 4 files changed, 925 insertions(+)
+ create mode 100644 target/linux/mvebu/patches-4.14/8888-Turris-Omnia-Add-separate-DTS-for-SFP-support.patch
  create mode 100644 target/linux/mvebu/patches-4.14/8890-turris-omnia-led-driver.patch
  create mode 100644 target/linux/mvebu/patches-4.14/8891-turris-omnia-custom-led-functions.patch
  create mode 100644 target/linux/mvebu/patches-4.14/8892-turris-omnia-enable-leds-in-dts.patch
 
-diff --git a/target/linux/mvebu/patches-4.14/8888-turris-omnia-separate-dtb-for-sfp.patch b/target/linux/mvebu/patches-4.14/8888-turris-omnia-separate-dtb-for-sfp.patch
+diff --git a/target/linux/mvebu/patches-4.14/8888-Turris-Omnia-Add-separate-DTS-for-SFP-support.patch b/target/linux/mvebu/patches-4.14/8888-Turris-Omnia-Add-separate-DTS-for-SFP-support.patch
 new file mode 100644
-index 0000000000..f543c886b4
+index 0000000000..5b1fbda0ad
 --- /dev/null
-+++ b/target/linux/mvebu/patches-4.14/8888-turris-omnia-separate-dtb-for-sfp.patch
-@@ -0,0 +1,906 @@
-+From d1a1a4888169dbeb2e947bc91198e9439da8b280 Mon Sep 17 00:00:00 2001
++++ b/target/linux/mvebu/patches-4.14/8888-Turris-Omnia-Add-separate-DTS-for-SFP-support.patch
+@@ -0,0 +1,231 @@
++From fbdfa10edabdeb83ac3604a783b433913621541b Mon Sep 17 00:00:00 2001
 +From: Tomas Hlavacek <tmshlvck@gmail.com>
 +Date: Sat, 11 Aug 2018 21:21:50 +0200
 +Subject: [PATCH] Turris Omnia: Add separate DTS for SFP support
@@ -42,23 +40,27 @@ index 0000000000..f543c886b4
 +PHY disabled
 +  armada-385-turris-omnia-phy.dts - DT with the PHY configuration and
 +SFP disabled
++
++Current DSA driver does not allow multiple CPU ports and Turris Omnia
++has two RGMII iterfaces wired between CPU and DSA switch.
++Disable the second CPU port until there is a suitable driver to use it.
 +---
 + arch/arm/boot/dts/Makefile                    |  3 +-
-+ .../boot/dts/armada-385-turris-omnia-phy.dts  | 36 +++++++++++++++++
-+ .../boot/dts/armada-385-turris-omnia-sfp.dts  | 39 +++++++++++++++++++
-+ ...omnia.dts => armada-385-turris-omnia.dtsi} | 27 +++----------
-+ 4 files changed, 82 insertions(+), 23 deletions(-)
++ .../boot/dts/armada-385-turris-omnia-phy.dts  | 26 ++++++++++++++
++ .../boot/dts/armada-385-turris-omnia-sfp.dts  | 27 ++++++++++++++
++ ...omnia.dts => armada-385-turris-omnia.dtsi} | 36 +++++++++++--------
++ 4 files changed, 77 insertions(+), 15 deletions(-)
 + create mode 100644 arch/arm/boot/dts/armada-385-turris-omnia-phy.dts
 + create mode 100644 arch/arm/boot/dts/armada-385-turris-omnia-sfp.dts
-+ rename arch/arm/boot/dts/{armada-385-turris-omnia.dts => armada-385-turris-omnia.dtsi} (93%)
++ rename arch/arm/boot/dts/{armada-385-turris-omnia.dts => armada-385-turris-omnia.dtsi} (89%)
 +
-+Index: linux-4.14.101/arch/arm/boot/dts/Makefile
-+===================================================================
-+--- linux-4.14.101.orig/arch/arm/boot/dts/Makefile
-++++ linux-4.14.101/arch/arm/boot/dts/Makefile
-+@@ -1029,7 +1029,8 @@ dtb-$(CONFIG_MACH_ARMADA_38X) += \
++diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
++index f4f5aeaf3298..b0016846cdf7 100644
++--- a/arch/arm/boot/dts/Makefile
+++++ b/arch/arm/boot/dts/Makefile
++@@ -1206,7 +1206,8 @@ dtb-$(CONFIG_MACH_ARMADA_38X) += \
++ 	armada-385-linksys-rango.dtb \
 + 	armada-385-linksys-shelby.dtb \
-+ 	armada-385-linksys-venom.dtb \
 + 	armada-385-synology-ds116.dtb \
 +-	armada-385-turris-omnia.dtb \
 ++	armada-385-turris-omnia-phy.dtb \
@@ -66,11 +68,12 @@ index 0000000000..f543c886b4
 + 	armada-388-clearfog.dtb \
 + 	armada-388-clearfog-base.dtb \
 + 	armada-388-clearfog-pro.dtb \
-+Index: linux-4.14.101/arch/arm/boot/dts/armada-385-turris-omnia-phy.dts
-+===================================================================
++diff --git a/arch/arm/boot/dts/armada-385-turris-omnia-phy.dts b/arch/arm/boot/dts/armada-385-turris-omnia-phy.dts
++new file mode 100644
++index 000000000000..eb3c573c8038
 +--- /dev/null
-++++ linux-4.14.101/arch/arm/boot/dts/armada-385-turris-omnia-phy.dts
-+@@ -0,0 +1,36 @@
+++++ b/arch/arm/boot/dts/armada-385-turris-omnia-phy.dts
++@@ -0,0 +1,26 @@
 ++// SPDX-License-Identifier: (GPL-2.0 OR MIT)
 ++/*
 ++ * Device Tree file for the Turris Omnia
@@ -89,29 +92,20 @@ index 0000000000..f543c886b4
 ++
 ++#include "armada-385-turris-omnia.dtsi"
 ++
+++&phy1 {
+++	status = "okay";
+++};
 ++
-++/* WAN port */
 ++&eth2 {
-++        status = "okay";
 ++        phy-mode = "sgmii";
 ++        phy = <&phy1>;
 ++};
-++
-++&mdio {
-++	phy1: phy@1 {
-++		status = "okay";
-++		compatible = "ethernet-phy-id0141.0DD1", "ethernet-phy-ieee802.3-c22";
-++		reg = <1>;
-++
-++		/* irq is connected to &pcawan pin 7 */
-++	};
-++};
-++
-+Index: linux-4.14.101/arch/arm/boot/dts/armada-385-turris-omnia-sfp.dts
-+===================================================================
++diff --git a/arch/arm/boot/dts/armada-385-turris-omnia-sfp.dts b/arch/arm/boot/dts/armada-385-turris-omnia-sfp.dts
++new file mode 100644
++index 000000000000..bb75b1082b31
 +--- /dev/null
-++++ linux-4.14.101/arch/arm/boot/dts/armada-385-turris-omnia-sfp.dts
-+@@ -0,0 +1,39 @@
+++++ b/arch/arm/boot/dts/armada-385-turris-omnia-sfp.dts
++@@ -0,0 +1,27 @@
 ++// SPDX-License-Identifier: (GPL-2.0 OR MIT)
 ++/*
 ++ * Device Tree file for the Turris Omnia
@@ -130,829 +124,38 @@ index 0000000000..f543c886b4
 ++
 ++#include "armada-385-turris-omnia.dtsi"
 ++
-++/ {
-++	sfp: sfp {
-++		compatible = "sff,sfp";
-++		i2c-bus = <&i2csfp>;
-++		tx-fault-gpios = <&sfpgpio 0 GPIO_ACTIVE_HIGH>;
-++		tx-disable-gpios = <&sfpgpio 1 GPIO_ACTIVE_HIGH>;
-++		rate-select0-gpios = <&sfpgpio 2 GPIO_ACTIVE_HIGH>;
-++		los-gpios = <&sfpgpio 3 GPIO_ACTIVE_HIGH>;
-++		mod-def0-gpios = <&sfpgpio 4 GPIO_ACTIVE_LOW>;
-++	};
+++&sfp {
+++	status = "okay";
 ++};
 ++
-++
-++/* WAN port */
 ++&eth2 {
-++	status = "okay";
 ++	phy-mode = "sgmii";
 ++	managed = "in-band-status";
 ++	sfp = <&sfp>;
 ++};
-++
-+Index: linux-4.14.101/arch/arm/boot/dts/armada-385-turris-omnia.dts
-+===================================================================
-+--- linux-4.14.101.orig/arch/arm/boot/dts/armada-385-turris-omnia.dts
-++++ /dev/null
-+@@ -1,392 +0,0 @@
-+-/*
-+- * Device Tree file for the Turris Omnia
-+- *
-+- * Copyright (C) 2016 Uwe Kleine-König <uwe@kleine-koenig.org>
++diff --git a/arch/arm/boot/dts/armada-385-turris-omnia.dts b/arch/arm/boot/dts/armada-385-turris-omnia.dtsi
++similarity index 89%
++rename from arch/arm/boot/dts/armada-385-turris-omnia.dts
++rename to arch/arm/boot/dts/armada-385-turris-omnia.dtsi
++index 768b6c5d2129..e5343d68e4d7 100644
++--- a/arch/arm/boot/dts/armada-385-turris-omnia.dts
+++++ b/arch/arm/boot/dts/armada-385-turris-omnia.dtsi
++@@ -3,13 +3,11 @@
++  * Device Tree file for the Turris Omnia
++  *
++  * Copyright (C) 2016 Uwe Kleine-König <uwe@kleine-koenig.org>
 +- * Copyright (C) 2016 Tomas Hlavacek <tmshlvkc@gmail.com>
-+- *
-+- * This file is dual-licensed: you can use it either under the terms
-+- * of the GPL or the X11 license, at your option. Note that this dual
-+- * licensing only applies to this file, and not this project as a
-+- * whole.
-+- *
-+- *  a) This file is licensed under the terms of the GNU General Public
-+- *     License version 2.  This program is licensed "as is" without
-+- *     any warranty of any kind, whether express or implied.
-+- *
-+- * Or, alternatively,
-+- *
-+- *  b) Permission is hereby granted, free of charge, to any person
-+- *     obtaining a copy of this software and associated documentation
-+- *     files (the "Software"), to deal in the Software without
-+- *     restriction, including without limitation the rights to use,
-+- *     copy, modify, merge, publish, distribute, sublicense, and/or
-+- *     sell copies of the Software, and to permit persons to whom the
-+- *     Software is furnished to do so, subject to the following
-+- *     conditions:
-+- *
-+- *     The above copyright notice and this permission notice shall be
-+- *     included in all copies or substantial portions of the Software.
-+- *
-+- *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-+- *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-+- *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-+- *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-+- *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-+- *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-+- *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-+- *     OTHER DEALINGS IN THE SOFTWARE.
-+- */
-+-
-+-/*
-+- * Schematic available at https://www.turris.cz/doc/_media/rtrom01-schema.pdf
-+- */
-+-
+++ * Copyright (C) 2016-2019 Tomas Hlavacek <tmshlvkc@gmail.com>
++  *
++  * Schematic available at https://www.turris.cz/doc/_media/rtrom01-schema.pdf
++  */
++ 
 +-/dts-v1/;
 +-
-+-#include <dt-bindings/gpio/gpio.h>
-+-#include <dt-bindings/input/input.h>
-+-#include "armada-385.dtsi"
-+-
-+-/ {
-+-	model = "Turris Omnia";
-+-	compatible = "cznic,turris-omnia", "marvell,armada385", "marvell,armada380";
-+-
-+-	chosen {
-+-		stdout-path = &uart0;
-+-	};
-+-
-+-	memory {
-+-		device_type = "memory";
-+-		reg = <0x00000000 0x40000000>; /* 1024 MB */
-+-	};
-+-
-+-	soc {
-+-		ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
-+-			  MBUS_ID(0x01, 0x1d) 0 0xfff00000 0x100000
-+-			  MBUS_ID(0x09, 0x19) 0 0xf1100000 0x10000
-+-			  MBUS_ID(0x09, 0x15) 0 0xf1110000 0x10000>;
-+-
-+-		internal-regs {
-+-
-+-			/* USB part of the PCIe2/USB 2.0 port */
-+-			usb@58000 {
-+-				status = "okay";
-+-			};
-+-
-+-			sata@a8000 {
-+-				status = "okay";
-+-			};
-+-
-+-			sdhci@d8000 {
-+-				pinctrl-names = "default";
-+-				pinctrl-0 = <&sdhci_pins>;
-+-				status = "okay";
-+-
-+-				bus-width = <8>;
-+-				no-1-8-v;
-+-				non-removable;
-+-			};
-+-
-+-			usb3@f0000 {
-+-				status = "okay";
-+-			};
-+-
-+-			usb3@f8000 {
-+-				status = "okay";
-+-			};
-+-		};
-+-
-+-		pcie {
-+-			status = "okay";
-+-
-+-			pcie@1,0 {
-+-				/* Port 0, Lane 0 */
-+-				status = "okay";
-+-			};
-+-
-+-			pcie@2,0 {
-+-				/* Port 1, Lane 0 */
-+-				status = "okay";
-+-			};
-+-
-+-			pcie@3,0 {
-+-				/* Port 2, Lane 0 */
-+-				status = "okay";
-+-			};
-+-		};
-+-	};
-+-};
-+-
-+-/* Connected to 88E6176 switch, port 6 */
-+-&eth0 {
-+-	pinctrl-names = "default";
-+-	pinctrl-0 = <&ge0_rgmii_pins>;
-+-	status = "okay";
-+-	phy-mode = "rgmii";
-+-
-+-	fixed-link {
-+-		speed = <1000>;
-+-		full-duplex;
-+-	};
-+-};
-+-
-+-/* Connected to 88E6176 switch, port 5 */
-+-&eth1 {
-+-	pinctrl-names = "default";
-+-	pinctrl-0 = <&ge1_rgmii_pins>;
-+-	status = "okay";
-+-	phy-mode = "rgmii";
-+-
-+-	fixed-link {
-+-		speed = <1000>;
-+-		full-duplex;
-+-	};
-+-};
-+-
-+-/* WAN port */
-+-&eth2 {
-+-	status = "okay";
-+-	phy-mode = "sgmii";
-+-	phy = <&phy1>;
-+-};
-+-
-+-&i2c0 {
-+-	pinctrl-names = "default";
-+-	pinctrl-0 = <&i2c0_pins>;
-+-	status = "okay";
-+-
-+-	i2cmux@70 {
-+-		compatible = "nxp,pca9547";
-+-		#address-cells = <1>;
-+-		#size-cells = <0>;
-+-		reg = <0x70>;
-+-		status = "okay";
-+-
-+-		i2c@0 {
-+-			#address-cells = <1>;
-+-			#size-cells = <0>;
-+-			reg = <0>;
-+-
-+-			/* STM32F0 command interface at address 0x2a */
-+-			/* leds device (in STM32F0) at address 0x2b */
-+-
-+-			eeprom@54 {
-+-				compatible = "atmel,24c64";
-+-				reg = <0x54>;
-+-
-+-				/* The EEPROM contains data for bootloader.
-+-				 * Contents:
-+-				 * 	struct omnia_eeprom {
-+-				 * 		u32 magic; (=0x0341a034 in LE)
-+-				 *		u32 ramsize; (in GiB)
-+-				 * 		char regdomain[4];
-+-				 * 		u32 crc32;
-+-				 * 	};
-+-				 */
-+-			};
-+-		};
-+-
-+-		i2c@1 {
-+-			#address-cells = <1>;
-+-			#size-cells = <0>;
-+-			reg = <1>;
-+-
-+-			/* routed to PCIe0/mSATA connector (CN7A) */
-+-		};
-+-
-+-		i2c@2 {
-+-			#address-cells = <1>;
-+-			#size-cells = <0>;
-+-			reg = <2>;
-+-
-+-			/* routed to PCIe1/USB2 connector (CN61A) */
-+-		};
-+-
-+-		i2c@3 {
-+-			#address-cells = <1>;
-+-			#size-cells = <0>;
-+-			reg = <3>;
-+-
-+-			/* routed to PCIe2 connector (CN62A) */
-+-		};
-+-
-+-		i2c@4 {
-+-			#address-cells = <1>;
-+-			#size-cells = <0>;
-+-			reg = <4>;
-+-
-+-			/* routed to SFP+ */
-+-		};
-+-
-+-		i2c@5 {
-+-			#address-cells = <1>;
-+-			#size-cells = <0>;
-+-			reg = <5>;
-+-
-+-			/* ATSHA204A at address 0x64 */
-+-		};
-+-
-+-		i2c@6 {
-+-			#address-cells = <1>;
-+-			#size-cells = <0>;
-+-			reg = <6>;
-+-
-+-			/* exposed on pin header */
-+-		};
-+-
-+-		i2c@7 {
-+-			#address-cells = <1>;
-+-			#size-cells = <0>;
-+-			reg = <7>;
-+-
-+-			pcawan: gpio@71 {
-+-				/*
-+-				 * GPIO expander for SFP+ signals and
-+-				 * and phy irq
-+-				 */
-+-				compatible = "nxp,pca9538";
-+-				reg = <0x71>;
-+-
-+-				pinctrl-names = "default";
-+-				pinctrl-0 = <&pcawan_pins>;
-+-
-+-				interrupt-parent = <&gpio1>;
-+-				interrupts = <14 IRQ_TYPE_LEVEL_LOW>;
-+-
-+-				gpio-controller;
-+-				#gpio-cells = <2>;
-+-			};
-+-		};
-+-	};
-+-};
-+-
-+-&mdio {
-+-	pinctrl-names = "default";
-+-	pinctrl-0 = <&mdio_pins>;
-+-	status = "okay";
-+-
-+-	phy1: phy@1 {
-+-		status = "okay";
-+-		compatible = "ethernet-phy-id0141.0DD1", "ethernet-phy-ieee802.3-c22";
-+-		reg = <1>;
-+-
-+-		/* irq is connected to &pcawan pin 7 */
-+-	};
-+-
-+-	/* Switch MV88E6176 at address 0x10 */
-+-	switch@10 {
-+-		compatible = "marvell,mv88e6085";
-+-		#address-cells = <1>;
-+-		#size-cells = <0>;
-+-		dsa,member = <0 0>;
-+-
-+-		reg = <0x10>;
-+-
-+-		ports {
-+-			#address-cells = <1>;
-+-			#size-cells = <0>;
-+-
-+-			ports@0 {
-+-				reg = <0>;
-+-				label = "lan0";
-+-			};
-+-
-+-			ports@1 {
-+-				reg = <1>;
-+-				label = "lan1";
-+-			};
-+-
-+-			ports@2 {
-+-				reg = <2>;
-+-				label = "lan2";
-+-			};
-+-
-+-			ports@3 {
-+-				reg = <3>;
-+-				label = "lan3";
-+-			};
-+-
-+-			ports@4 {
-+-				reg = <4>;
-+-				label = "lan4";
-+-			};
-+-
-+-			ports@5 {
-+-				reg = <5>;
-+-				label = "cpu";
-+-				ethernet = <&eth1>;
-+-				phy-mode = "rgmii-id";
-+-
-+-				fixed-link {
-+-					speed = <1000>;
-+-					full-duplex;
-+-				};
-+-			};
-+-
-+-			/* port 6 is connected to eth0 */
-+-		};
-+-	};
-+-};
-+-
-+-&pinctrl {
-+-	pcawan_pins: pcawan-pins {
-+-		marvell,pins = "mpp46";
-+-		marvell,function = "gpio";
-+-	};
-+-
-+-	spi0cs0_pins: spi0cs0-pins {
-+-		marvell,pins = "mpp25";
-+-		marvell,function = "spi0";
-+-	};
-+-
-+-	spi0cs1_pins: spi0cs1-pins {
-+-		marvell,pins = "mpp26";
-+-		marvell,function = "spi0";
-+-	};
-+-};
-+-
-+-&spi0 {
-+-	pinctrl-names = "default";
-+-	pinctrl-0 = <&spi0_pins &spi0cs0_pins>;
-+-	status = "okay";
-+-
-+-	spi-nor@0 {
-+-		compatible = "spansion,s25fl164k", "jedec,spi-nor";
-+-		#address-cells = <1>;
-+-		#size-cells = <1>;
-+-		reg = <0>;
-+-		spi-max-frequency = <40000000>;
-+-
-+-		partitions {
-+-			compatible = "fixed-partitions";
-+-			#address-cells = <1>;
-+-			#size-cells = <1>;
-+-
-+-			partition@0 {
-+-				reg = <0x0 0x00100000>;
-+-				label = "U-Boot";
-+-			};
-+-
-+-			partition@100000 {
-+-				reg = <0x00100000 0x00700000>;
-+-				label = "Rescue system";
-+-			};
-+-		};
-+-	};
-+-
-+-	/* MISO, MOSI, SCLK and CS1 are routed to pin header CN11 */
-+-};
-+-
-+-&uart0 {
-+-	/* Pin header CN10 */
-+-	pinctrl-names = "default";
-+-	pinctrl-0 = <&uart0_pins>;
-+-	status = "okay";
-+-};
-+-
-+-&uart1 {
-+-	/* Pin header CN11 */
-+-	pinctrl-names = "default";
-+-	pinctrl-0 = <&uart1_pins>;
-+-	status = "okay";
-+-};
-+Index: linux-4.14.101/arch/arm/boot/dts/armada-385-turris-omnia.dtsi
-+===================================================================
-+--- /dev/null
-++++ linux-4.14.101/arch/arm/boot/dts/armada-385-turris-omnia.dtsi
-+@@ -0,0 +1,375 @@
-++/*
-++ * Device Tree file for the Turris Omnia
-++ *
-++ * Copyright (C) 2016 Uwe Kleine-König <uwe@kleine-koenig.org>
-++ * Copyright (C) 2016-2019 Tomas Hlavacek <tmshlvkc@gmail.com>
-++ *
-++ * This file is dual-licensed: you can use it either under the terms
-++ * of the GPL or the X11 license, at your option. Note that this dual
-++ * licensing only applies to this file, and not this project as a
-++ * whole.
-++ *
-++ *  a) This file is licensed under the terms of the GNU General Public
-++ *     License version 2.  This program is licensed "as is" without
-++ *     any warranty of any kind, whether express or implied.
-++ *
-++ * Or, alternatively,
-++ *
-++ *  b) Permission is hereby granted, free of charge, to any person
-++ *     obtaining a copy of this software and associated documentation
-++ *     files (the "Software"), to deal in the Software without
-++ *     restriction, including without limitation the rights to use,
-++ *     copy, modify, merge, publish, distribute, sublicense, and/or
-++ *     sell copies of the Software, and to permit persons to whom the
-++ *     Software is furnished to do so, subject to the following
-++ *     conditions:
-++ *
-++ *     The above copyright notice and this permission notice shall be
-++ *     included in all copies or substantial portions of the Software.
-++ *
-++ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-++ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-++ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-++ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-++ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-++ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-++ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-++ *     OTHER DEALINGS IN THE SOFTWARE.
-++ */
-++
-++/*
-++ * Schematic available at https://www.turris.cz/doc/_media/rtrom01-schema.pdf
-++ */
-++
-++#include <dt-bindings/gpio/gpio.h>
-++#include <dt-bindings/input/input.h>
-++#include "armada-385.dtsi"
-++
-++/ {
-++	model = "Turris Omnia";
-++	compatible = "cznic,turris-omnia", "marvell,armada385", "marvell,armada380";
-++
-++	chosen {
-++		stdout-path = &uart0;
-++	};
-++
-++	memory {
-++		device_type = "memory";
-++		reg = <0x00000000 0x40000000>; /* 1024 MB */
-++	};
-++
-++	soc {
-++		ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
-++			  MBUS_ID(0x01, 0x1d) 0 0xfff00000 0x100000
-++			  MBUS_ID(0x09, 0x19) 0 0xf1100000 0x10000
-++			  MBUS_ID(0x09, 0x15) 0 0xf1110000 0x10000>;
-++
-++		internal-regs {
-++
-++			/* USB part of the PCIe2/USB 2.0 port */
-++			usb@58000 {
-++				status = "okay";
-++			};
-++
-++			sata@a8000 {
-++				status = "okay";
-++			};
-++
-++			sdhci@d8000 {
-++				pinctrl-names = "default";
-++				pinctrl-0 = <&sdhci_pins>;
-++				status = "okay";
-++
-++				bus-width = <8>;
-++				no-1-8-v;
-++				non-removable;
-++			};
-++
-++			usb3@f0000 {
-++				status = "okay";
-++			};
-++
-++			usb3@f8000 {
-++				status = "okay";
-++			};
-++		};
-++
-++		pcie {
-++			status = "okay";
-++
-++			pcie@1,0 {
-++				/* Port 0, Lane 0 */
-++				status = "okay";
-++			};
-++
-++			pcie@2,0 {
-++				/* Port 1, Lane 0 */
-++				status = "okay";
-++			};
-++
-++			pcie@3,0 {
-++				/* Port 2, Lane 0 */
-++				status = "okay";
-++			};
-++		};
-++	};
-++};
-++
-++/* Connected to 88E6176 switch, port 6 */
-++&eth0 {
-++	pinctrl-names = "default";
-++	pinctrl-0 = <&ge0_rgmii_pins>;
-++	status = "okay";
-++	phy-mode = "rgmii";
-++
-++	fixed-link {
-++		speed = <1000>;
-++		full-duplex;
-++	};
-++};
-++
-++/* Connected to 88E6176 switch, port 5 */
-++&eth1 {
-++	pinctrl-names = "default";
-++	pinctrl-0 = <&ge1_rgmii_pins>;
-++	status = "okay";
-++	phy-mode = "rgmii";
-++
-++	fixed-link {
-++		speed = <1000>;
-++		full-duplex;
-++	};
-++};
-++
-++&i2c0 {
-++	pinctrl-names = "default";
-++	pinctrl-0 = <&i2c0_pins>;
-++	status = "okay";
-++
-++	i2cmux@70 {
-++		compatible = "nxp,pca9547";
-++		#address-cells = <1>;
-++		#size-cells = <0>;
-++		reg = <0x70>;
-++		status = "okay";
-++
-++		i2c@0 {
-++			#address-cells = <1>;
-++			#size-cells = <0>;
-++			reg = <0>;
-++
-++			/* STM32F0 command interface at address 0x2a */
-++			/* leds device (in STM32F0) at address 0x2b */
-++
-++			eeprom@54 {
-++				compatible = "atmel,24c64";
-++				reg = <0x54>;
-++
-++				/* The EEPROM contains data for bootloader.
-++				 * Contents:
-++				 * 	struct omnia_eeprom {
-++				 * 		u32 magic; (=0x0341a034 in LE)
-++				 *		u32 ramsize; (in GiB)
-++				 * 		char regdomain[4];
-++				 * 		u32 crc32;
-++				 * 	};
-++				 */
-++			};
-++		};
-++
-++		i2c@1 {
-++			#address-cells = <1>;
-++			#size-cells = <0>;
-++			reg = <1>;
-++
-++			/* routed to PCIe0/mSATA connector (CN7A) */
-++		};
-++
-++		i2c@2 {
-++			#address-cells = <1>;
-++			#size-cells = <0>;
-++			reg = <2>;
-++
-++			/* routed to PCIe1/USB2 connector (CN61A) */
-++		};
-++
-++		i2c@3 {
-++			#address-cells = <1>;
-++			#size-cells = <0>;
-++			reg = <3>;
-++
-++			/* routed to PCIe2 connector (CN62A) */
-++		};
-++
-++		i2csfp: i2c@4 {
-++			#address-cells = <1>;
-++			#size-cells = <0>;
-++			reg = <4>;
-++
-++			/* routed to SFP+ */
-++		};
-++
-++		i2c@5 {
-++			#address-cells = <1>;
-++			#size-cells = <0>;
-++			reg = <5>;
-++
-++			/* ATSHA204A at address 0x64 */
-++		};
-++
-++		i2c@6 {
-++			#address-cells = <1>;
-++			#size-cells = <0>;
-++			reg = <6>;
-++
-++			/* exposed on pin header */
-++		};
-++
-++		i2c@7 {
-++			#address-cells = <1>;
-++			#size-cells = <0>;
-++			reg = <7>;
-++
-++			sfpgpio: gpio@71 {
-++				/*
-++				 * GPIO expander for SFP+ signals and
-++				 * and phy irq
-++				 */
-++				compatible = "nxp,pca9538";
-++				reg = <0x71>;
-++
-++				pinctrl-names = "default";
-++				pinctrl-0 = <&wanint_pins>;
-++
-++				interrupt-parent = <&gpio1>;
-++				interrupts = <14 IRQ_TYPE_LEVEL_LOW>;
-++
-++				gpio-controller;
-++				#gpio-cells = <2>;
-++			};
-++		};
-++	};
-++};
-++
-++&mdio {
-++	pinctrl-names = "default";
-++	pinctrl-0 = <&mdio_pins>;
-++	status = "okay";
-++
-++	/* Switch MV88E6176 at address 0x10 */
-++	switch@10 {
-++		compatible = "marvell,mv88e6085";
-++		#address-cells = <1>;
-++		#size-cells = <0>;
-++		dsa,member = <0 0>;
-++
-++		reg = <0x10>;
-++
-++		ports {
-++			#address-cells = <1>;
-++			#size-cells = <0>;
-++
-++			ports@0 {
-++				reg = <0>;
-++				label = "lan0";
-++			};
-++
-++			ports@1 {
-++				reg = <1>;
-++				label = "lan1";
-++			};
-++
-++			ports@2 {
-++				reg = <2>;
-++				label = "lan2";
-++			};
-++
-++			ports@3 {
-++				reg = <3>;
-++				label = "lan3";
-++			};
-++
-++			ports@4 {
-++				reg = <4>;
-++				label = "lan4";
-++			};
-++
-++			ports@5 {
-++				reg = <5>;
-++				label = "cpu";
-++				ethernet = <&eth1>;
-++				phy-mode = "rgmii-id";
-++
-++				fixed-link {
-++					speed = <1000>;
-++					full-duplex;
-++				};
-++			};
-++
-++			/* port 6 is connected to eth0 */
-++		};
-++	};
-++};
-++
-++&pinctrl {
-++	wanint_pins: wanint-pins {
-++		marvell,pins = "mpp46";
-++		marvell,function = "gpio";
-++	};
-++
-++	spi0cs0_pins: spi0cs0-pins {
-++		marvell,pins = "mpp25";
-++		marvell,function = "spi0";
-++	};
-++
-++	spi0cs1_pins: spi0cs1-pins {
-++		marvell,pins = "mpp26";
-++		marvell,function = "spi0";
-++	};
-++};
-++
-++&spi0 {
-++	pinctrl-names = "default";
-++	pinctrl-0 = <&spi0_pins &spi0cs0_pins>;
-++	status = "okay";
-++
-++	spi-nor@0 {
-++		compatible = "spansion,s25fl164k", "jedec,spi-nor";
-++		#address-cells = <1>;
-++		#size-cells = <1>;
-++		reg = <0>;
-++		spi-max-frequency = <40000000>;
-++
-++		partitions {
-++			compatible = "fixed-partitions";
-++			#address-cells = <1>;
-++			#size-cells = <1>;
-++
-++			partition@0 {
-++				reg = <0x0 0x00100000>;
-++				label = "U-Boot";
-++			};
-++
-++			partition@100000 {
-++				reg = <0x00100000 0x00700000>;
-++				label = "Rescue system";
-++			};
-++		};
-++	};
-++
-++	/* MISO, MOSI, SCLK and CS1 are routed to pin header CN11 */
-++};
-++
-++&uart0 {
-++	/* Pin header CN10 */
-++	pinctrl-names = "default";
-++	pinctrl-0 = <&uart0_pins>;
-++	status = "okay";
-++};
-++
-++&uart1 {
-++	/* Pin header CN11 */
-++	pinctrl-names = "default";
-++	pinctrl-0 = <&uart1_pins>;
-++	status = "okay";
-++};
-diff --git a/target/linux/mvebu/patches-4.14/8889-turris-omnia-disable-unused-ethernet.patch b/target/linux/mvebu/patches-4.14/8889-turris-omnia-disable-unused-ethernet.patch
-new file mode 100644
-index 0000000000..05321731c2
---- /dev/null
-+++ b/target/linux/mvebu/patches-4.14/8889-turris-omnia-disable-unused-ethernet.patch
-@@ -0,0 +1,38 @@
-+From fc43f245702928316ded5913d706d0c1f927461d Mon Sep 17 00:00:00 2001
-+From: Tomas Hlavacek <tmshlvck@gmail.com>
-+Date: Wed, 20 Feb 2019 14:13:48 +0100
-+Subject: [PATCH] Turris Omnia: Disable unused eth0
-+
-+Current DSA driver does not allow multiple CPU ports and Turris Omnia
-+has two RGMII iterfaces wired between CPU and DSA switch.
-+
-+Disable (as a workaround) the second CPU port until there is a progress
-+on DSA multi-CPU ports.
-+---
-+ arch/arm/boot/dts/armada-385-turris-omnia.dtsi | 5 +++--
-+ 1 file changed, 3 insertions(+), 2 deletions(-)
-+
-+diff --git a/arch/arm/boot/dts/armada-385-turris-omnia.dtsi b/arch/arm/boot/dts/armada-385-turris-omnia.dtsi
-+index 082445fe993c..5045015ce823 100644
-+--- a/arch/arm/boot/dts/armada-385-turris-omnia.dtsi
-++++ b/arch/arm/boot/dts/armada-385-turris-omnia.dtsi
-+@@ -82,8 +82,9 @@
++ #include <dt-bindings/gpio/gpio.h>
++ #include <dt-bindings/input/input.h>
++ #include "armada-385.dtsi"
++@@ -84,8 +82,9 @@
 + 	};
 + };
 + 
@@ -963,7 +166,7 @@ index 0000000000..05321731c2
 + 	pinctrl-names = "default";
 + 	pinctrl-0 = <&ge0_rgmii_pins>;
 + 	status = "okay";
-+@@ -93,7 +94,7 @@
++@@ -95,7 +94,7 @@
 + 		speed = <1000>;
 + 		full-duplex;
 + 	};
@@ -972,6 +175,82 @@ index 0000000000..05321731c2
 + 
 + /* Connected to 88E6176 switch, port 5 */
 + &eth1 {
++@@ -110,11 +109,9 @@
++ 	};
++ };
++ 
++-/* WAN port */
+++/* WAN dual-personality port */
++ &eth2 {
++-	status = "okay";
++-	phy-mode = "sgmii";
++-	phy = <&phy1>;
+++        status = "okay";
++ };
++ 
++ &i2c0 {
++@@ -177,7 +174,7 @@
++ 			/* routed to PCIe2 connector (CN62A) */
++ 		};
++ 
++-		i2c@4 {
+++		i2csfp: i2c@4 {
++ 			#address-cells = <1>;
++ 			#size-cells = <0>;
++ 			reg = <4>;
++@@ -206,7 +203,7 @@
++ 			#size-cells = <0>;
++ 			reg = <7>;
++ 
++-			pcawan: gpio@71 {
+++			sfpgpio: gpio@71 {
++ 				/*
++ 				 * GPIO expander for SFP+ signals and
++ 				 * and phy irq
++@@ -215,7 +212,7 @@
++ 				reg = <0x71>;
++ 
++ 				pinctrl-names = "default";
++-				pinctrl-0 = <&pcawan_pins>;
+++				pinctrl-0 = <&wanint_pins>;
++ 
++ 				interrupt-parent = <&gpio1>;
++ 				interrupts = <14 IRQ_TYPE_LEVEL_LOW>;
++@@ -233,7 +230,7 @@
++ 	status = "okay";
++ 
++ 	phy1: phy@1 {
++-		status = "okay";
+++		status = "disabled";
++ 		compatible = "ethernet-phy-id0141.0DD1", "ethernet-phy-ieee802.3-c22";
++ 		reg = <1>;
++ 
++@@ -293,10 +290,21 @@
++ 			/* port 6 is connected to eth0 */
++ 		};
++ 	};
+++
+++	sfp: sfp {
+++		compatible = "sff,sfp";
+++		status = "disabled";
+++		i2c-bus = <&i2csfp>;
+++		tx-fault-gpios = <&sfpgpio 0 GPIO_ACTIVE_HIGH>;
+++		tx-disable-gpios = <&sfpgpio 1 GPIO_ACTIVE_HIGH>;
+++		rate-select0-gpios = <&sfpgpio 2 GPIO_ACTIVE_HIGH>;
+++		los-gpios = <&sfpgpio 3 GPIO_ACTIVE_HIGH>;
+++		mod-def0-gpios = <&sfpgpio 4 GPIO_ACTIVE_LOW>;
+++	};
++ };
++ 
++ &pinctrl {
++-	pcawan_pins: pcawan-pins {
+++	wanint_pins: wanint-pins {
++ 		marvell,pins = "mpp46";
++ 		marvell,function = "gpio";
++ 	};
++-- 
++2.21.0
++
 diff --git a/target/linux/mvebu/patches-4.14/8890-turris-omnia-led-driver.patch b/target/linux/mvebu/patches-4.14/8890-turris-omnia-led-driver.patch
 new file mode 100644
 index 0000000000..477370d4b1
@@ -1685,5 +964,5 @@ index 0000000000..c162f2270b
 + 
 + 		i2c@1 {
 -- 
-2.20.1
+2.21.0
 
-- 
GitLab