[PATCH net-next 10/10] net: stmmac: Try to get C45 PHY if everything else fails
From: Jose Abreu
Date: Wed Jun 26 2019 - 09:48:34 EST
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 <joabreu@xxxxxxxxxxxx>
Cc: Joao Pinto <jpinto@xxxxxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>
Cc: Giuseppe Cavallaro <peppe.cavallaro@xxxxxx>
Cc: Alexandre Torgue <alexandre.torgue@xxxxxx>
---
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