[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250526182939.2593553-1-james.hilliard1@gmail.com>
Date: Mon, 26 May 2025 12:29:34 -0600
From: James Hilliard <james.hilliard1@...il.com>
To: netdev@...r.kernel.org
Cc: linux-sunxi@...ts.linux.dev,
James Hilliard <james.hilliard1@...il.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Russell King <linux@...linux.org.uk>,
"Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
Furong Xu <0x1207@...il.com>,
Kunihiko Hayashi <hayashi.kunihiko@...ionext.com>,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v1 1/3] net: stmmac: allow drivers to explicitly select PHY device
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@...il.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
Powered by blists - more mailing lists