On PCI based setups that are connected to C45 PHY we won't have DT
bindings specifying what's the correct PHY type.

Fallback to C45 if everything else fails when trying to acquire PHY.

Signed-off-by: Jose Abreu <[email protected]>
Cc: Joao Pinto <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index bc949665c529..e790ab79e819 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1014,6 +1014,20 @@ static int stmmac_init_phy(struct net_device *dev)
 
                phydev = mdiobus_get_phy(priv->mii, addr);
                if (!phydev) {
+                       /* Try C45 */
+                       phydev = get_phy_device(priv->mii, addr, true);
+                       if (phydev && !IS_ERR(phydev)) {
+                               ret = phy_device_register(phydev);
+                               if (ret) {
+                                       phy_device_free(phydev);
+                                       phydev = NULL;
+                               }
+                       } else {
+                               phydev = NULL;
+                       }
+               }
+
+               if (!phydev) {
                        netdev_err(priv->dev, "no phy at addr %d\n", addr);
                        return -ENODEV;
                }
-- 
2.7.4

Reply via email to