From: Jonas Karlman Date: Thu, 18 Jan 2024 07:19:45 +0000 (+0000) Subject: net: designware: Reset eth phy before phy connect X-Git-Url: http://git.dujemihanovic.xyz/%22http:/www.sics.se/static/git-logo.png?a=commitdiff_plain;h=f1e2f412b0aa24a5f5256dc7894a4c70bb6a0076;p=u-boot.git net: designware: Reset eth phy before phy connect Some ethernet PHY require being reset before a phy-id can be read back on the MDIO bus. This can result in the following message being show on e.g. a Radxa ROCK Pi E v1.21 with a RTL8211F ethernet PHY. Could not get PHY for ethernet@ff540000: addr -1 Add support to designware ethernet driver to reset eth phy by calling the eth phy uclass function eth_phy_set_mdio_bus(). The call use NULL as bus parameter to not set a shared mdio bus reference that would be freed when probe fails. Also add a eth_phy_get_addr() call to try and get the phy addr from DT when DM_MDIO is disabled. This help fix ethernet on Radxa ROCK Pi E v1.21: => mdio list ethernet@ff540000: 1 - RealTek RTL8211F <--> ethernet@ff540000 Reported-by: Trevor Woerner Signed-off-by: Jonas Karlman Reviewed-by: Kever Yang --- diff --git a/drivers/net/designware.c b/drivers/net/designware.c index c8696358d6..c15fb36ae3 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -576,6 +577,9 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev) struct phy_device *phydev; int ret; + if (IS_ENABLED(CONFIG_DM_ETH_PHY)) + eth_phy_set_mdio_bus(dev, NULL); + #if IS_ENABLED(CONFIG_DM_MDIO) phydev = dm_eth_phy_connect(dev); if (!phydev) @@ -583,6 +587,9 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev) #else int phy_addr = -1; + if (IS_ENABLED(CONFIG_DM_ETH_PHY)) + phy_addr = eth_phy_get_addr(dev); + #ifdef CONFIG_PHY_ADDR phy_addr = CONFIG_PHY_ADDR; #endif