[PATCH 3/3] net: ravb: Use PHY MDIO address from DT if available

Marek Vasut marek.vasut+renesas at mailbox.org
Sun Jan 21 18:29:35 CET 2024


In case the PHY is fully described in DT, use PHY MDIO address
from DT directly instead of always using auto-detection. This
also fixes the behavior of 'mdio list' in such DT setup, which
now prints the PHY connected to the MAC correctly.

Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Paul Barker <paul.barker.ct at bp.renesas.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
---
 drivers/net/sh_eth.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index 7b1f59dc498..5e2e3054ecf 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <env.h>
+#include <eth_phy.h>
 #include <log.h>
 #include <malloc.h>
 #include <net.h>
@@ -597,11 +598,16 @@ static int sh_eth_phy_config(struct udevice *dev)
 	struct sh_ether_priv *priv = dev_get_priv(dev);
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct sh_eth_dev *eth = &priv->shdev;
-	int ret = 0;
 	struct sh_eth_info *port_info = &eth->port_info[eth->port];
 	struct phy_device *phydev;
+	int phy_addr;
+	int ret = 0;
+
+	phy_addr = eth_phy_get_addr(dev);
+	if (phy_addr < 0)
+		phy_addr = -1;
 
-	phydev = phy_connect(priv->bus, -1, dev, pdata->phy_interface);
+	phydev = phy_connect(priv->bus, phy_addr, dev, pdata->phy_interface);
 	if (!phydev)
 		return -ENODEV;
 
-- 
2.43.0



More information about the U-Boot mailing list