From 8b82aea440583198be21bbbe4e3f6d7bd814aad8 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Thu, 17 Jun 2021 16:13:40 +0200
Subject: [PATCH 14/43] ipq806x: simplify ecw5410 dts

Signed-off-by: John Crispin <john@phrozen.org>
---
 .../etc/hotplug.d/firmware/11-ath10k-caldata  |  6 +-
 .../arm/boot/dts/qcom-ipq8068-ecw5410.dts     | 83 +++++++++++--------
 target/linux/ipq806x/image/Makefile           |  2 +-
 .../linux/ipq806x/patches-5.4/999-at803.patch | 12 +++
 4 files changed, 64 insertions(+), 39 deletions(-)
 create mode 100644 target/linux/ipq806x/patches-5.4/999-at803.patch

diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 3befc40630..e5715a79aa 100644
--- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -16,9 +16,6 @@ case "$FIRMWARE" in
 		caldata_extract "ART" 0x1000 0x2f20
 		ath10k_patch_mac $(mtd_get_mac_binary ART 0x1e)
 		;;
-	edgecore,ecw5410)
-		caldata_extract "0:ART" 0x1000 0x2f20
-		;;
 	linksys,ea7500-v1 |\
 	linksys,ea8500)
 		caldata_extract "art" 0x1000 0x2f20
@@ -59,6 +56,9 @@ case "$FIRMWARE" in
 		caldata_extract "ART" 0x5000 0x2f20
 		ath10k_patch_mac $(mtd_get_mac_binary ART 0x18)
 		;;
+	edgecore,ecw5410)
+		caldata_extract "0:ART" 0x1000 0x2f20
+		;;
 	linksys,ea7500-v1 |\
 	linksys,ea8500)
 		caldata_extract "art" 0x5000 0x2f20
diff --git a/target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8068-ecw5410.dts b/target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8068-ecw5410.dts
index 712910c261..e87ef16b9a 100644
--- a/target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8068-ecw5410.dts
+++ b/target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8068-ecw5410.dts
@@ -95,6 +95,16 @@
 			gpios = <&qcom_pinmux 59 GPIO_ACTIVE_LOW>;
 		};
 	};
+
+	i2c-gpio {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		compatible = "i2c-gpio";
+		gpios = <&qcom_pinmux 8 GPIO_ACTIVE_HIGH>, /* sda */
+			<&qcom_pinmux 9 GPIO_ACTIVE_HIGH>; /* scl */
+		i2c-gpio,delay-us = <5>;
+	};
 };
 
 
@@ -124,7 +134,7 @@
 
 	led_pins: led_pins {
 		mux {
-			pins = "gpio16", "gpio23", "gpio24", "gpio26",
+			pins = "gpio6", "gpio7", "gpio16", "gpio23", "gpio24", "gpio26",
 				   "gpio28", "gpio59";
 			function = "gpio";
 			drive-strength = <2>;
@@ -259,39 +269,6 @@
 };
 
 &soc {
-	nand@1ac00000 {
-		status = "okay";
-
-		pinctrl-0 = <&nand_pins>;
-		pinctrl-names = "default";
-
-		nand@0 {
-			compatible = "qcom,nandcs";
-
-			reg = <0>;
-
-			nand-ecc-strength = <4>;
-			nand-bus-width = <8>;
-			nand-ecc-step-size = <512>;
-
-			partitions {
-				compatible = "fixed-partitions";
-				#address-cells = <1>;
-				#size-cells = <1>;
-
-				rootfs1@0 {
-					label = "rootfs1";
-					reg = <0x0000000 0x4000000>;
-				};
-
-				rootfs2@4000000 {
-					label = "rootfs2";
-					reg = <0x4000000 0x4000000>;
-				};
-			};
-		};
-	};
-
 	mdio1: mdio {
 		compatible = "virtual,mdio-gpio";
 		#address-cells = <1>;
@@ -306,14 +283,50 @@
 
 		phy0: ethernet-phy@0 {
 			reg = <0>;
+			reset-gpios = <&qcom_pinmux 7 GPIO_ACTIVE_HIGH>;
 		};
 
 		phy1: ethernet-phy@1 {
 			reg = <1>;
+			reset-gpios = <&qcom_pinmux 6 GPIO_ACTIVE_HIGH>;
 		};
 	};
 };
 
+&nand_controller {
+	status = "okay";
+
+	pinctrl-0 = <&nand_pins>;
+	pinctrl-names = "default";
+
+	nand@0 {
+		compatible = "qcom,nandcs";
+
+		reg = <0>;
+
+		nand-ecc-strength = <4>;
+		nand-bus-width = <8>;
+		nand-ecc-step-size = <512>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			rootfs1@0 {
+				label = "rootfs1";
+				reg = <0x0000000 0x4000000>;
+			};
+
+			rootfs2@4000000 {
+				label = "rootfs2";
+				reg = <0x4000000 0x4000000>;
+			};
+		};
+	};
+};
+
+
 &gmac2 {
 	status = "okay";
 
@@ -328,7 +341,7 @@
 	status = "okay";
 
 	qcom,id = <3>;
-	mdiobus = <&mdio1>;
+	mdiobus = <&mdio0>;
 
 	phy-mode = "sgmii";
 	phy-handle = <&phy0>;
diff --git a/target/linux/ipq806x/image/Makefile b/target/linux/ipq806x/image/Makefile
index 3bc60fa931..d620f0eb70 100644
--- a/target/linux/ipq806x/image/Makefile
+++ b/target/linux/ipq806x/image/Makefile
@@ -142,7 +142,7 @@ define Device/edgecore_ecw5410
 	BLOCKSIZE := 128k
 	PAGESIZE := 2048
 	DEVICE_DTS_CONFIG := config@v2.0-ap160
-	DEVICE_PACKAGES := ath10k-firmware-qca9984-ct ipq-wifi-edgecore_ecw5410
+	DEVICE_PACKAGES := ath10k-firmware-qca9984-ct ipq-wifi-edgecore_ecw5410 kmod-i2c-gpio
 endef
 TARGET_DEVICES += edgecore_ecw5410
 
diff --git a/target/linux/ipq806x/patches-5.4/999-at803.patch b/target/linux/ipq806x/patches-5.4/999-at803.patch
new file mode 100644
index 0000000000..0dda8bdd59
--- /dev/null
+++ b/target/linux/ipq806x/patches-5.4/999-at803.patch
@@ -0,0 +1,12 @@
+Index: linux-5.4.111/drivers/net/phy/at803x.c
+===================================================================
+--- linux-5.4.111.orig/drivers/net/phy/at803x.c
++++ linux-5.4.111/drivers/net/phy/at803x.c
+@@ -486,6 +486,7 @@ static struct phy_driver at803x_driver[]
+ 	.phy_id_mask		= AT803X_PHY_ID_MASK,
+ 	.probe			= at803x_probe,
+ 	.config_init		= at803x_config_init,
++	.link_change_notify	= at803x_link_change_notify,
+ 	.set_wol		= at803x_set_wol,
+ 	.get_wol		= at803x_get_wol,
+ 	.suspend		= at803x_suspend,
-- 
2.25.1

