From f6c99241baec562c092704f2c80650da65d3e683 Mon Sep 17 00:00:00 2001
From: Chuanhong Guo <gch981213@gmail.com>
Date: Tue, 17 Jul 2018 17:09:14 +0800
Subject: [PATCH] ath79: ar934x: Update dts for current ag71xx driver

Enable mdio1 by default because mdio1 is needed when eth1 is enabled.

PS: If a ar9341 device has only one port and you only want to use gmac0,
change compatible of gmac1 to "syscon", "simple-mfd" in dts.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
---
 target/linux/ath79/dts/ar9341.dtsi |  8 ++++++++
 target/linux/ath79/dts/ar934x.dtsi | 30 ++++++++++++++++++++++++++++--
 target/linux/ath79/dts/ath79.dtsi  |  8 ++++++--
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/target/linux/ath79/dts/ar9341.dtsi b/target/linux/ath79/dts/ar9341.dtsi
index 751db2a1e8..a7c5ac6262 100644
--- a/target/linux/ath79/dts/ar9341.dtsi
+++ b/target/linux/ath79/dts/ar9341.dtsi
@@ -16,3 +16,11 @@
 	interrupt-parent = <&cpuintc>;
 	interrupts = <2>;
 };
+
+&eth0 {
+	phy-mode = "mii";
+};
+
+&eth1 {
+	status = "okay";
+};
diff --git a/target/linux/ath79/dts/ar934x.dtsi b/target/linux/ath79/dts/ar934x.dtsi
index 75865a718a..a93739ceed 100644
--- a/target/linux/ath79/dts/ar934x.dtsi
+++ b/target/linux/ath79/dts/ar934x.dtsi
@@ -191,12 +191,13 @@
 };
 
 &mdio0 {
+	compatible = "qca,ar9340-mdio";
 	resets = <&rst 22>;
 	reset-names = "mdio";
 };
 
 &eth0 {
-	compatible = "qca,ar9340-eth", "syscon";
+	compatible = "qca,ar9340-eth", "syscon", "simple-mfd";
 
 	pll-data = <0x16000000 0x00000101 0x00001616>;
 	pll-reg = <0x4 0x2c 17>;
@@ -207,13 +208,38 @@
 };
 
 &mdio1 {
+	status = "okay";
+
+	compatible = "qca,ar9340-mdio";
 	resets = <&rst 23>;
 	reset-names = "mdio";
 	builtin-switch;
+
+	builtin_switch: switch0@1f {
+		compatible = "qca,ar8229-builtin";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		reg = <0x1f>;
+		phy-mode = "gmii";
+		phy4-mii-enable;
+
+		mdio-bus {
+			swphy0: ethernet-phy@0 {
+				reg = <0>;
+				phy-mode = "mii";
+			};
+
+			swphy4: ethernet-phy@4 {
+				reg = <4>;
+				phy-mode = "mii";
+			};
+		};
+	};
 };
 
 &eth1 {
-	compatible = "qca,ar9340-eth", "syscon";
+	compatible = "qca,ar9340-eth", "syscon", "simple-mfd";
 
 	resets = <&rst 13>;
 	reset-names = "mac";
diff --git a/target/linux/ath79/dts/ath79.dtsi b/target/linux/ath79/dts/ath79.dtsi
index cec4d0b6b0..a57c58659f 100644
--- a/target/linux/ath79/dts/ath79.dtsi
+++ b/target/linux/ath79/dts/ath79.dtsi
@@ -43,7 +43,7 @@
 		eth0: eth@19000000 {
 			status = "disabled";
 
-			compatible = "qca,ath79-eth", "syscon";
+			compatible = "qca,ath79-eth", "syscon", "simple-mfd";
 			reg = <0x19000000 0x200>;
 
 			interrupts = <4>;
@@ -51,6 +51,8 @@
 
 			mdio0: mdio-bus {
 				status = "disabled";
+
+				compatible = "qca,ath79-mdio";
 				#address-cells = <1>;
 				#size-cells = <0>;
 
@@ -64,7 +66,7 @@
 		eth1: eth@1a000000 {
 			status = "disabled";
 
-			compatible = "qca,ath79-eth", "syscon";
+			compatible = "qca,ath79-eth", "syscon", "simple-mfd";
 			reg = <0x1a000000 0x200>;
 
 			interrupts = <5>;
@@ -72,6 +74,8 @@
 
 			mdio1: mdio-bus {
 				status = "disabled";
+
+				compatible = "qca,ath79-mdio";
 				#address-cells = <1>;
 				#size-cells = <0>;
 
-- 
2.30.2