[PATCH v2 1/3] net: stmmac: allow drivers to explicitly select PHY device
James Hilliard
james.hilliard1 at gmail.com
Tue May 27 10:55:54 PDT 2025
Some devices like the Allwinner H616 need the ability to select a phy
in cases where multiple PHY's may be present in a device tree due to
needing the ability to support multiple SoC variants with runtime
PHY selection.
Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 22 +++++++++++++------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 59d07d0d3369..949c4a8a1456 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1210,17 +1210,25 @@ static int stmmac_init_phy(struct net_device *dev)
*/
if (!phy_fwnode || IS_ERR(phy_fwnode)) {
int addr = priv->plat->phy_addr;
- struct phy_device *phydev;
+ struct phy_device *phydev = NULL;
- if (addr < 0) {
- netdev_err(priv->dev, "no phy found\n");
- return -ENODEV;
+ if (priv->plat->phy_node) {
+ phy_fwnode = of_fwnode_handle(priv->plat->phy_node);
+ phydev = fwnode_phy_find_device(phy_fwnode);
+ fwnode_handle_put(phy_fwnode);
}
- phydev = mdiobus_get_phy(priv->mii, addr);
if (!phydev) {
- netdev_err(priv->dev, "no phy at addr %d\n", addr);
- return -ENODEV;
+ if (addr < 0) {
+ netdev_err(priv->dev, "no phy found\n");
+ return -ENODEV;
+ }
+
+ phydev = mdiobus_get_phy(priv->mii, addr);
+ if (!phydev) {
+ netdev_err(priv->dev, "no phy at addr %d\n", addr);
+ return -ENODEV;
+ }
}
ret = phylink_connect_phy(priv->phylink, phydev);
--
2.34.1
More information about the linux-arm-kernel
mailing list