[PATCH 7/8] net: fec_mxc: add unique bus and device names for DM_MDIO

Alexander Feilke Alexander.Feilke at ew.tq-group.com
Fri Nov 21 18:34:47 CET 2025


From: Markus Niebel <Markus.Niebel at ew.tq-group.com>

When using DM_MDIO on SOC with more than one FEC and not sharing the MDIO
bus the name of the driver and the bus needs to be unique. Since name
used in device_bind_driver_to_node needs to be a static string, add the
string to the fec_priv struct and reuse fec_set_dev_name to generate the
name with the device sequence number.

Fixes: 3b8f99a3e762 ("net: fec: add support for DM_MDIO")

Signed-off-by: Markus Niebel <Markus.Niebel at ew.tq-group.com>
Signed-off-by: Alexander Stein <alexander.stein at ew.tq-group.com>
Signed-off-by: Alexander Feilke <alexander.feilke at ew.tq-group.com>
---
 drivers/net/fec_mxc.c | 6 ++++--
 drivers/net/fec_mxc.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 6789bfe2500..f6ca87cee3a 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1067,6 +1067,7 @@ U_BOOT_DRIVER(fec_mdio) = {
 
 static int dm_fec_bind_mdio(struct udevice *dev)
 {
+	struct fec_priv *fec = dev_get_priv(dev);
 	struct udevice *mdiodev;
 	const char *name;
 	ofnode mdio;
@@ -1081,8 +1082,9 @@ static int dm_fec_bind_mdio(struct udevice *dev)
 		if (strcmp(name, "mdio"))
 			continue;
 
+		fec_set_dev_name(fec->mdio_name, dev_seq(dev));
 		ret = device_bind_driver_to_node(dev, "fec_mdio",
-						 name, mdio, &mdiodev);
+						 fec->mdio_name, mdio, &mdiodev);
 		if (ret) {
 			printf("%s bind %s failed: %d\n", __func__, name, ret);
 			break;
@@ -1369,7 +1371,7 @@ static int fecmxc_probe(struct udevice *dev)
 	 */
 	ret = dm_fec_bind_mdio(dev);
 	if (!ret)
-		bus = miiphy_get_dev_by_name("mdio");
+		bus = miiphy_get_dev_by_name(priv->mdio_name);
 	else if (ret != -ENODEV)
 		return ret;
 #endif
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 12cc00423fa..8e95b539cd6 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -256,6 +256,7 @@ struct fec_priv {
 	int (*mii_postcall)(int);
 #endif
 #ifdef CONFIG_DM_MDIO
+	char mdio_name[MDIO_NAME_LEN];
 	struct udevice *mdio_bus;
 #endif
 #ifdef CONFIG_DM_REGULATOR
-- 
2.34.1



More information about the U-Boot mailing list