[qca-ssdk]: adjust miibus node get for MIPs DTS support
Change-Id: Ifc4a033d2d13c923122d83467d992911fd3d8cf0
Signed-off-by: xiaofeis <xiaofeis@codeaurora.org>
diff --git a/src/init/ssdk_init.c b/src/init/ssdk_init.c
index fec99cd..fa17a42 100755
--- a/src/init/ssdk_init.c
+++ b/src/init/ssdk_init.c
@@ -1861,41 +1861,30 @@
}
#else
struct ag71xx_mdio *am;
+ struct device_node *mdio_node = NULL;
+ struct platform_device *mdio_plat = NULL;
- struct device *miidev;
- char busid[MII_BUS_ID_SIZE];
- snprintf(busid, MII_BUS_ID_SIZE, "%s.%d",
- IPQ806X_MDIO_BUS_NAME, IPQ806X_MDIO_BUS_NUM);
-
- miidev = bus_find_device_by_name(&platform_bus_type, NULL, busid);
- if (!miidev) {
- printk("cannot get mii bus\n");
+ mdio_node = of_find_compatible_node(NULL, NULL, "qca,ag71xx-mdio");
+ if (!mdio_node) {
+ printk("No MDIO node found in DTS!\n");
return 1;
}
-
- am = dev_get_drvdata(miidev);
+ mdio_plat = of_find_device_by_node(mdio_node);
+ if (!mdio_plat) {
+ printk("cannot find platform device from mdio node\n");
+ return 1;
+ }
+ am = dev_get_drvdata(&mdio_plat->dev);
+ if (!am) {
+ printk("cannot get mdio_data reference from device data\n");
+ return 1;
+ }
miibus = am->mii_bus;
-
- if(switch_chip_id_adjuest()) {
-
- snprintf(busid, MII_BUS_ID_SIZE, "%s.%d",
- IPQ806X_MDIO_BUS_NAME, MDIO_BUS_1);
-
- miidev = bus_find_device_by_name(&platform_bus_type, NULL, busid);
- if (!miidev) {
- printk("cannot get mii bus\n");
- return 1;
- }
-
- am = dev_get_drvdata(miidev);
- miibus = am->mii_bus;
- printk("chip_version:0x%x\n", (qca_ar8216_mii_read(0)&0xff00)>>8);
- }
-
- if(!miidev){
- printk("mdio bus '%s' get FAIL\n", busid);
+ if (!miibus) {
+ printk("cannot get mii bus reference from device data\n");
return 1;
}
+ switch_chip_id_adjuest();
#endif
#else
#ifdef BOARD_AR71XX