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: 3b8f99a3e7 ("net: fec: add support for DM_MDIO")

Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Alexander Feilke <alexander.feilke@ew.tq-group.com>
This commit is contained in:
Markus Niebel
2025-11-21 18:34:47 +01:00
committed by Fabio Estevam
parent f4434ae02d
commit c5d3f7ac8e
2 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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