net: ftgmac100: Add DM_MDIO support

Add support for DM_MDIO to connect to PHY.  For the systems that have a
stand-alone MDIO hardware block, enable CONFIG_DM_MDIO to use driver
model for MDIO devices.

Signed-off-by: Dylan Hung <dylan_hung@aspeedtech.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
This commit is contained in:
Dylan Hung 2021-12-09 10:12:24 +08:00 committed by Tom Rini
parent 94a43f7dc6
commit 9c27ce781d

View File

@ -220,7 +220,11 @@ static int ftgmac100_phy_init(struct udevice *dev)
struct phy_device *phydev; struct phy_device *phydev;
int ret; int ret;
if (IS_ENABLED(CONFIG_DM_MDIO))
phydev = dm_eth_phy_connect(dev);
else
phydev = phy_connect(priv->bus, priv->phy_addr, dev, priv->phy_mode); phydev = phy_connect(priv->bus, priv->phy_addr, dev, priv->phy_mode);
if (!phydev) if (!phydev)
return -ENODEV; return -ENODEV;
@ -589,11 +593,17 @@ static int ftgmac100_probe(struct udevice *dev)
if (ret) if (ret)
goto out; goto out;
/*
* If DM MDIO is enabled, the MDIO bus will be initialized later in
* dm_eth_phy_connect
*/
if (!IS_ENABLED(CONFIG_DM_MDIO)) {
ret = ftgmac100_mdio_init(dev); ret = ftgmac100_mdio_init(dev);
if (ret) { if (ret) {
dev_err(dev, "Failed to initialize mdiobus: %d\n", ret); dev_err(dev, "Failed to initialize mdiobus: %d\n", ret);
goto out; goto out;
} }
}
ret = ftgmac100_phy_init(dev); ret = ftgmac100_phy_init(dev);
if (ret) { if (ret) {