mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-05 04:36:13 +02:00
net: fec_mxc: fix usage of DM_MDIO and DM_ETH_PHY
If DM_ETH_PHY is used and the FEC instance owns the shared MDIO bus,
eth_phy_get_mdio_bus returns NULL. If DM_MDIO bus is used, the
mdio_register API is called from dm_mdio_post_probe. Therefore the
bus should must be queried by name in this case.
For DM_MDIO case fec_mii_setspeed has already being called in
dm_fec_mdio_probe(), so skip setting this again.
Fixes: 3b8f99a3e762 ("net: fec: add support for DM_MDIO")
Fixes: e75d08821574 ("net: fec-mxc: prevent crash if no MAC address is set")
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:
parent
fc199c481c
commit
f4434ae02d
@ -581,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 */
|
||||
@ -1363,16 +1363,26 @@ 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("mdio");
|
||||
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 = fec_get_miibus(dev, (ulong)priv->eth, dev_seq(dev));
|
||||
#else
|
||||
bus = eth_phy_get_mdio_bus(dev);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DM_MDIO
|
||||
if (!bus) {
|
||||
ulong regs = (ulong)priv->eth;
|
||||
|
||||
@ -1384,8 +1394,8 @@ static int fecmxc_probe(struct udevice *dev)
|
||||
|
||||
bus = fec_get_miibus(dev, regs, dev_seq(dev));
|
||||
}
|
||||
#endif /* !CONFIG_DM_MDIO */
|
||||
|
||||
#endif /* CONFIG_DM_ETH_PHY */
|
||||
if (!bus) {
|
||||
ret = -ENOMEM;
|
||||
goto err_mii;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user