summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2025-11-29 15:39:36 -0600
committerTom Rini <[email protected]>2025-11-29 15:39:36 -0600
commit65a131531077d75eaa01f8376d8f7f04c146a457 (patch)
tree137e6bf4444fa092c45c4e37197eea16573aaf16 /drivers
parent7af532a8ef1c6685eac58d587c9502ab31855aae (diff)
parentc8daa0abdb3c48aba9dd86228ed50a34c5482a73 (diff)
Merge tag 'u-boot-imx-next-20251129' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx into next
CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/28551 - Stop disabling device tree relocation on i.MX boards. - Add support for imx6ulz_smm_m2d. - Add support for Kontron i.MX93 OSM-S SoM and BL carrier board - Fix probe of i.MX FEC MDIO bus for DM_MDIO. - Cleanup for tqma6 boards. - Initialize the ELE RNG context on imx95_evk - Disable EFI partition, MP, sysboot, bind commands on tbs2910.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/fec_mxc.c56
-rw-r--r--drivers/net/fec_mxc.h4
2 files changed, 48 insertions, 12 deletions
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 9ac72d25ef6..fee9973c4dc 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -9,6 +9,7 @@
#include <cpu_func.h>
#include <dm.h>
+#include <dm/device-internal.h>
#include <env.h>
#include <log.h>
#include <malloc.h>
@@ -580,7 +581,7 @@ static int fecmxc_init(struct udevice *dev)
fec_reg_setup(fec);
- if (fec->xcv_type != SEVENWIRE)
+ if (fec->xcv_type != SEVENWIRE && !IS_ENABLED(CONFIG_DM_MDIO))
fec_mii_setspeed(dev, fec->bus->priv);
/* Set Opcode/Pause Duration Register */
@@ -1051,6 +1052,7 @@ static int dm_fec_mdio_probe(struct udevice *dev)
struct dm_fec_mdio_priv *priv = dev_get_priv(dev);
priv->regs = (struct ethernet_regs *)ofnode_get_addr(dev_ofnode(dev->parent));
+ fec_mii_setspeed(dev->parent, priv->regs);
return 0;
}
@@ -1065,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;
@@ -1079,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, NULL);
if (ret) {
printf("%s bind %s failed: %d\n", __func__, name, ret);
break;
@@ -1088,8 +1092,12 @@ static int dm_fec_bind_mdio(struct udevice *dev)
/* need to probe it as there is no compatible to do so */
ret = uclass_get_device_by_ofnode(UCLASS_MDIO, mdio, &mdiodev);
- if (!ret)
+ if (!ret) {
+ struct fec_priv *priv = dev_get_priv(dev);
+
+ priv->mdio_bus = mdiodev;
return 0;
+ }
printf("%s probe %s failed: %d\n", __func__, name, ret);
}
@@ -1189,9 +1197,11 @@ static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
priv->phydev = phydev;
priv->phydev->node = priv->phy_of_node;
- phy_config(phydev);
+ ret = phy_config(phydev);
+ if (ret)
+ pr_err("phy_config failed: %d", ret);
- return 0;
+ return ret;
}
#if CONFIG_IS_ENABLED(DM_GPIO)
@@ -1355,24 +1365,39 @@ static int fecmxc_probe(struct udevice *dev)
priv->dev_id = dev_seq(dev);
#ifdef CONFIG_DM_MDIO
+ /* If our instance manages the mdio bus, dm_fec_bind_mdio will bind, probe
+ * and register the MDIO bus driver. To get access to the mii_dev structure
+ * query it from the global mii_devs list.
+ */
ret = dm_fec_bind_mdio(dev);
- if (ret && ret != -ENODEV)
+ if (!ret)
+ bus = miiphy_get_dev_by_name(priv->mdio_name);
+ else if (ret != -ENODEV)
return ret;
#endif
#ifdef CONFIG_DM_ETH_PHY
- bus = eth_phy_get_mdio_bus(dev);
+ /* if our PHY is not on our mdio bus, this call queries the bus in case
+ * we using the DM abstraction for shared MDIO busses.
+ */
+ if (!bus)
+ bus = eth_phy_get_mdio_bus(dev);
#endif
+#ifndef CONFIG_DM_MDIO
if (!bus) {
+ ulong regs = (ulong)priv->eth;
+
dm_mii_bus = false;
-#ifdef CONFIG_FEC_MXC_MDIO_BASE
- bus = fec_get_miibus(dev, (ulong)CONFIG_FEC_MXC_MDIO_BASE,
- dev_seq(dev));
-#else
- bus = fec_get_miibus(dev, (ulong)priv->eth, dev_seq(dev));
+
+#if defined(CONFIG_FEC_MXC_MDIO_BASE)
+ regs = CONFIG_FEC_MXC_MDIO_BASE;
#endif
+
+ bus = fec_get_miibus(dev, regs, dev_seq(dev));
}
+#endif /* !CONFIG_DM_MDIO */
+
if (!bus) {
ret = -ENOMEM;
goto err_mii;
@@ -1427,8 +1452,15 @@ static int fecmxc_remove(struct udevice *dev)
free(priv->phydev);
fec_free_descs(priv);
+#ifdef CONFIG_DM_MDIO
+ if (priv->mdio_bus) {
+ device_remove(priv->mdio_bus, DM_REMOVE_NORMAL);
+ device_unbind(priv->mdio_bus);
+ }
+#else
mdio_unregister(priv->bus);
mdio_free(priv->bus);
+#endif
#ifdef CONFIG_DM_REGULATOR
if (priv->phy_supply)
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 77bfc1cbf45..8e95b539cd6 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -255,6 +255,10 @@ struct fec_priv {
int phy_id;
int (*mii_postcall)(int);
#endif
+#ifdef CONFIG_DM_MDIO
+ char mdio_name[MDIO_NAME_LEN];
+ struct udevice *mdio_bus;
+#endif
#ifdef CONFIG_DM_REGULATOR
struct udevice *phy_supply;
#endif