From c5d3f7ac8e78d199cd961bee2c3f63726a1c4c69 Mon Sep 17 00:00:00 2001 From: Markus Niebel Date: Fri, 21 Nov 2025 18:34:47 +0100 Subject: [PATCH] net: fec_mxc: add unique bus and device names for DM_MDIO 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 Signed-off-by: Alexander Stein Signed-off-by: Alexander Feilke --- 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 f62366dde6e..512f96e8df9 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