Merge "[qca-ssdk]: Add register access for Malibu"
diff --git a/include/init/ssdk_plat.h b/include/init/ssdk_plat.h
index 0ce16bd..75df79d 100755
--- a/include/init/ssdk_plat.h
+++ b/include/init/ssdk_plat.h
@@ -172,6 +172,11 @@
 
 };
 
+struct qca961x_mdio_data {
+        struct mii_bus          *mii_bus;
+        void __iomem            *membase;
+        int phy_irq[PHY_MAX_ADDR];
+};
 
 #define qca_phy_priv_get(_dev) \
 		container_of(_dev, struct qca_phy_priv, sw_dev)
diff --git a/src/init/ssdk_init.c b/src/init/ssdk_init.c
index 07b5d14..06ff400 100755
--- a/src/init/ssdk_init.c
+++ b/src/init/ssdk_init.c
@@ -1115,8 +1115,13 @@
 	const __be32 *prop = NULL;
 	struct device_node *mdio_node = NULL;
 	struct platform_device *mdio_plat = NULL;
+	struct qca961x_mdio_data *mdio_data = NULL;
 
-	mdio_node = of_find_compatible_node(NULL, NULL, "virtual,mdio-gpio");
+	if(ssdk_dt_global.switch_reg_access_mode == HSL_REG_LOCAL_BUS)
+		mdio_node = of_find_compatible_node(NULL, NULL, "qcom,qca961x-mdio");
+	else
+		mdio_node = of_find_compatible_node(NULL, NULL, "virtual,mdio-gpio");
+
 	if (!mdio_node) {
 		printk("getting virtual,mdio-gpio failed\n");
 		return 1;
@@ -1128,7 +1133,18 @@
 		return 1;
 	}
 
-	miibus = dev_get_drvdata(&mdio_plat->dev);
+	if(ssdk_dt_global.switch_reg_access_mode == HSL_REG_LOCAL_BUS)
+	{
+		mdio_data = dev_get_drvdata(&mdio_plat->dev);
+		if (!mdio_data) {
+                	printk("cannot get mdio_data reference from device data\n");
+                	return 1;
+        	}
+		miibus = mdio_data->mii_bus;
+	}
+	else
+		miibus = dev_get_drvdata(&mdio_plat->dev);
+
 	if (!miibus) {
 		printk("cannot get mii bus reference from device data\n");
 		return 1;
@@ -1188,6 +1204,9 @@
 	printk("ssdk_plat_init start\n");
 	mutex_init(&switch_mdio_lock);
 
+	if(miibus_get())
+		return -ENODEV;
+
 	if(ssdk_dt_global.switch_reg_access_mode == HSL_REG_LOCAL_BUS) {
 		if (!request_mem_region(ssdk_dt_global.switchreg_base_addr,
 				ssdk_dt_global.switchreg_size, "switch_mem")) {
@@ -1218,9 +1237,6 @@
 	}
 
 	if(ssdk_dt_global.switch_reg_access_mode == HSL_REG_MDIO) {
-		if(miibus_get())
-			return -ENODEV;
-
 		if(driver_find(qca_phy_driver.name, &mdio_bus_type)){
 			printk("QCA PHY driver had been Registered\n");
 			return 0;