summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Tilak <[email protected]>2026-06-10 16:09:57 +0530
committerJerome Forissier <[email protected]>2026-07-23 17:05:20 +0200
commit2671bd1d77abdbf0b52a52e1419e01543476143b (patch)
tree28600226ca4d852f730effb9276d109ba0bb4e67
parent614ebea14bfc4f015a739e0d7b047fe98b831d37 (diff)
net: phy: fix duplicate eth_phy binding
When both CONFIG_PHY_ETHERNET_ID and CONFIG_DM_ETH_PHY are enabled, eth_phy_binds_nodes() called from eth_post_bind() already binds the ethernet PHY node to eth_phy_generic_drv. However, phy_connect_phy_id() called via phy_connect() also binds the same PHY node, resulting in duplicate entries in the DM tree. Fix this by introducing phy_connect_dm_bound() which checks if the PHY is already bound via uclass_find_device_by_phandle(). If so, it gets the phy_device via phy_find_by_mask() since the udevice does not store a phy_device pointer and the phy_device can only be obtained by scanning the MDIO bus. The phydev->node is then set from the already-bound DM device. This skips the generic binding methods in phy_connect() when the PHY is already DM-bound. Fixes: 68a4d1506109 ("net: phy: Bind ETH_PHY uclass driver to each new PHY") Signed-off-by: Pranav Tilak <[email protected]>
-rw-r--r--drivers/net/phy/phy.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index d7e0c4fe02d..f2e9b2a9820 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -20,6 +20,7 @@
#include <asm-generic/gpio.h>
#include <dm/device_compat.h>
#include <dm/of_extra.h>
+#include <dm/uclass-internal.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/err.h>
@@ -921,6 +922,27 @@ static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
}
#endif
+#ifdef CONFIG_DM_ETH_PHY
+static struct phy_device *phy_connect_dm_bound(struct mii_dev *bus,
+ struct udevice *dev,
+ uint mask)
+{
+ struct udevice *dm_phy_dev;
+ struct phy_device *phydev;
+
+ if (!uclass_find_device_by_phandle(UCLASS_ETH_PHY, dev,
+ "phy-handle", &dm_phy_dev)) {
+ phydev = phy_find_by_mask(bus, mask);
+ if (phydev)
+ phydev->node = dev_ofnode(dm_phy_dev);
+
+ return phydev;
+ }
+
+ return NULL;
+}
+#endif
+
struct phy_device *phy_connect(struct mii_dev *bus, int addr,
struct udevice *dev,
phy_interface_t interface)
@@ -928,8 +950,13 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
struct phy_device *phydev = NULL;
uint mask = (addr >= 0) ? (1 << addr) : 0xffffffff;
+#ifdef CONFIG_DM_ETH_PHY
+ phydev = phy_connect_dm_bound(bus, dev, mask);
+#endif
+
#ifdef CONFIG_PHY_FIXED
- phydev = phy_connect_fixed(bus, dev);
+ if (!phydev)
+ phydev = phy_connect_fixed(bus, dev);
#endif
#ifdef CONFIG_PHY_NCSI