linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] net: stmmac: allow drivers to explicitly select PHY device
@ 2025-05-27 17:55 James Hilliard
  2025-05-27 17:55 ` [PATCH v2 2/3] net: stmmac: dwmac-sun8i: Allow runtime AC200/AC300 phy selection James Hilliard
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: James Hilliard @ 2025-05-27 17:55 UTC (permalink / raw)
  To: netdev
  Cc: linux-sunxi, James Hilliard, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
	Alexandre Torgue, Russell King, Russell King (Oracle), Furong Xu,
	Kunihiko Hayashi, linux-stm32, linux-arm-kernel, linux-kernel

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@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



^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2025-05-31  0:51 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 17:55 [PATCH v2 1/3] net: stmmac: allow drivers to explicitly select PHY device James Hilliard
2025-05-27 17:55 ` [PATCH v2 2/3] net: stmmac: dwmac-sun8i: Allow runtime AC200/AC300 phy selection James Hilliard
2025-05-27 17:55 ` [PATCH v2 3/3] dt-bindings: net: sun8i-emac: Add AC300 EMAC1 nvmem " James Hilliard
2025-05-27 19:14 ` [PATCH v2 1/3] net: stmmac: allow drivers to explicitly select PHY device Andrew Lunn
2025-05-27 19:21   ` James Hilliard
2025-05-27 20:01     ` Andrew Lunn
2025-05-27 20:16       ` James Hilliard
2025-05-27 20:30         ` Andrew Lunn
2025-05-27 20:37           ` James Hilliard
2025-05-27 21:48             ` Andrew Lunn
2025-05-27 22:47               ` James Hilliard
2025-05-28  7:53             ` Russell King (Oracle)
2025-05-28 11:57               ` James Hilliard
2025-05-28 13:24                 ` Andrew Lunn
2025-05-28 14:11                   ` Chen-Yu Tsai
2025-05-28 17:25                     ` James Hilliard
2025-05-28 18:34                       ` Russell King (Oracle)
2025-05-28 19:10                         ` James Hilliard
2025-05-28 19:26                           ` Andrew Lunn
2025-05-28 19:45                             ` James Hilliard
2025-05-28 21:05                               ` Andrew Lunn
2025-05-28 21:14                                 ` James Hilliard
2025-05-28 21:29                                   ` Andrew Lunn
2025-05-28 21:45                                     ` James Hilliard
2025-05-28 23:47                                       ` Andrew Lunn
2025-05-29  0:31                                         ` James Hilliard
2025-05-30 23:46       ` James Hilliard
2025-05-30 23:56         ` Florian Fainelli
2025-05-31  0:02           ` James Hilliard
2025-05-31  0:24             ` Florian Fainelli
2025-05-31  0:49               ` James Hilliard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).