aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/ftgmac100.c
diff options
context:
space:
mode:
authorDylan Hung2021-12-09 10:12:24 +0800
committerTom Rini2022-01-18 12:48:17 -0500
commit9c27ce781dd3fa9b7a5c42a34bf44f702756b30f (patch)
treeb3e163d3595484882dd41046a0d9176dfcf5b867 /drivers/net/ftgmac100.c
parent94a43f7dc6811b590b8caf92a0486723ead47d0e (diff)
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>
Diffstat (limited to 'drivers/net/ftgmac100.c')
-rw-r--r--drivers/net/ftgmac100.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
index 0687230b4bb..b6e9526c3b9 100644
--- a/drivers/net/ftgmac100.c
+++ b/drivers/net/ftgmac100.c
@@ -220,7 +220,11 @@ static int ftgmac100_phy_init(struct udevice *dev)
struct phy_device *phydev;
int ret;
- phydev = phy_connect(priv->bus, priv->phy_addr, dev, priv->phy_mode);
+ 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);
+
if (!phydev)
return -ENODEV;
@@ -589,10 +593,16 @@ static int ftgmac100_probe(struct udevice *dev)
if (ret)
goto out;
- ret = ftgmac100_mdio_init(dev);
- if (ret) {
- dev_err(dev, "Failed to initialize mdiobus: %d\n", ret);
- 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);
+ if (ret) {
+ dev_err(dev, "Failed to initialize mdiobus: %d\n", ret);
+ goto out;
+ }
}
ret = ftgmac100_phy_init(dev);