Update prowl device tree, preparation for qca8k.

(266650eec4d14bb554a471aab5d50d6394743e24 updated for moved files,
slight code tweaks.

Change-Id: I17d88d8a892f9485236cbb3c0ce7f67364149ed1
diff --git a/arch/arc/boot/dts/prowl.dts b/arch/arc/boot/dts/prowl.dts
index 57b88d9..55bc4ac 100644
--- a/arch/arc/boot/dts/prowl.dts
+++ b/arch/arc/boot/dts/prowl.dts
@@ -65,4 +65,120 @@
 		interrupt-map-mask = <0x0 0 0 1>;
 		interrupt-map = <0x0 0 0 1 &core_intc 28>;
 	};
+	/*
+	 * mdio device is instantiated by the emac_lib driver, which does
+	 * not depend upon the device tree for discovery. The driver is
+	 * updated to search for the entry named 'mdio' and associate this
+	 * device tree node.
+	 */
+	mdio0: mdio {
+		compatible = "virtual,mdio_bus";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		phy_port1: phy@0 {
+			reg = <0>;
+		};
+
+		phy_port2: phy@1 {
+			reg = <1>;
+		};
+
+		phy_port3: phy@2 {
+			reg = <2>;
+		};
+
+		phy_port4: phy@3 {
+			reg = <3>;
+		};
+
+		phy_port5: phy@4 {
+			reg = <4>;
+		};
+	};
+	/*
+	 * wan0 device is instantiated by the switch_emac driver, which does
+	 * not depend upon the device tree for discovery. The driver is
+	 * updated to search for the entry named 'wan0' and associate this
+	 * device tree node.
+	 */
+	wan0: wan0 {
+		status = "ok";
+		phy-mode = "rgmii";
+		qcom,id = <1>;
+
+		fixed-link {
+			speed = <1000>;
+			full-duplex;
+		};
+	};
+	/*
+	 * lan0 device is instantiated by the switch_emac driver, which does
+	 * not depend upon the device tree for discovery. The driver is
+	 * updated to search for the entry named 'lan0' and associate this
+	 * device tree node.
+	 */
+	lan0: lan0 {
+		status = "ok";
+		phy-mode = "rgmii";
+		qcom,id = <2>;
+
+		fixed-link {
+			speed = <1000>;
+			full-duplex;
+		};
+	};
+	/*
+	 * qca8k offload uses DSA (distributed switch architecture).
+	 * DSA requires access to the mdio bus and ethernet net_device.
+	 */
+	dsa@0 {
+		compatible = "qca,ar8xxx";
+		#address-cells = <2>;
+		#size-cells = <0>;
+
+		dsa,ethernet = <&wan0>;
+		dsa,mii-bus = <&mdio0>;
+
+		switch@0 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0 0>;	/* MDIO address 0, switch 0 in tree */
+
+			port@0 {
+				reg = <0>;
+				label = "cpu";
+			};
+
+			port@1 {
+				reg = <1>;
+				label = "lan1";
+				phy-handle = <&phy_port1>;
+			};
+
+			port@2 {
+				reg = <2>;
+				label = "lan2";
+				phy-handle = <&phy_port2>;
+			};
+
+			port@3 {
+				reg = <3>;
+				label = "lan3";
+				phy-handle = <&phy_port3>;
+			};
+
+			port@4 {
+				reg = <4>;
+				label = "lan4";
+				phy-handle = <&phy_port4>;
+			};
+
+			wan_port: port@5 {
+				reg = <5>;
+				label = "wan";
+				phy-handle = <&phy_port5>;
+			};
+		};
+	};
 };
diff --git a/drivers/qtn/ruby/emac_lib.c b/drivers/qtn/ruby/emac_lib.c
index b482e41..a3ce8c63 100644
--- a/drivers/qtn/ruby/emac_lib.c
+++ b/drivers/qtn/ruby/emac_lib.c
@@ -652,6 +652,7 @@
 	int i;
 	struct emac_common *privc = netdev_priv(dev);
 	struct mii_bus *mii = NULL;
+	struct device_node *device_node;
 
 	/* Alloc bus structure */
 	mii = mdiobus_alloc();
@@ -691,6 +692,14 @@
 		mii->irq[i] = PHY_POLL;
 	}
 
+	/* Associate the mdio bus with a device tree entry */
+	device_node = of_find_node_by_name(NULL, "mdio");
+	if (device_node != NULL) {
+		printk(KERN_INFO "%s: associated mdio with of_node 0x%08x\n",
+			__FUNCTION__, device_node);
+		mii->dev.of_node = device_node;
+	}
+
 	/* Register bus if we are using PHY */
 	if ((privc->emac_cfg & EMAC_PHY_NOT_IN_USE) == 0) {
 		if (mdiobus_register(mii)) {
diff --git a/drivers/qtn/topaz/switch_emac.c b/drivers/qtn/topaz/switch_emac.c
index bc5eb12..b0561af 100644
--- a/drivers/qtn/topaz/switch_emac.c
+++ b/drivers/qtn/topaz/switch_emac.c
@@ -1143,6 +1143,7 @@
 	struct topaz_emac_priv *priv = NULL;
 	struct emac_common *privc = NULL;
 	struct net_device *dev = NULL;
+	struct device_node *of_node = NULL;
 	int rc;
 	int emac_cfg;
 	int emac_phy;
@@ -1188,6 +1189,14 @@
 #endif
 	topaz_emac_set_eth_addr(dev, port_num);
 
+	/* find the device tree node associated with this device */
+	of_node = of_find_node_by_name(NULL, devname);
+	if (of_node != NULL) {
+		printk(KERN_INFO "%s: associated %s with of_node 0x%08x\n",
+			__FUNCTION__, devname, of_node);
+		dev->dev.of_node = of_node;
+	}
+
 	/* Initialize private data */
 	priv = netdev_priv(dev);
 	memset(priv, 0, sizeof(*priv));