[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201015124917.8168-3-i.mikhaylov@yadro.com>
Date: Thu, 15 Oct 2020 15:49:17 +0300
From: Ivan Mikhaylov <i.mikhaylov@...ro.com>
To: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Po-Yu Chuang <ratbert@...aday-tech.com>
CC: Ivan Mikhaylov <i.mikhaylov@...ro.com>,
Joel Stanley <joel@....id.au>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <openbmc@...ts.ozlabs.org>
Subject: [PATCH v1 2/2] net: ftgmac100: add handling of mdio/phy nodes for ast2400/2500
phy-handle can't be handled well for ast2400/2500 which has an embedded
MDIO controller. Add ftgmac100_mdio_setup for ast2400/2500 and initialize
PHYs from mdio child node with of_mdiobus_register.
Signed-off-by: Ivan Mikhaylov <i.mikhaylov@...ro.com>
---
drivers/net/ethernet/faraday/ftgmac100.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 6997e121824b..e32066519ec1 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1638,6 +1638,7 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
struct ftgmac100 *priv = netdev_priv(netdev);
struct platform_device *pdev = to_platform_device(priv->dev);
struct device_node *np = pdev->dev.of_node;
+ struct device_node *mdio_np;
int i, err = 0;
u32 reg;
@@ -1669,12 +1670,20 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
for (i = 0; i < PHY_MAX_ADDR; i++)
priv->mii_bus->irq[i] = PHY_POLL;
- err = mdiobus_register(priv->mii_bus);
+ mdio_np = of_get_child_by_name(np, "mdio");
+ if (mdio_np)
+ err = of_mdiobus_register(priv->mii_bus, mdio_np);
+ else
+ err = mdiobus_register(priv->mii_bus);
+
if (err) {
dev_err(priv->dev, "Cannot register MDIO bus!\n");
goto err_register_mdiobus;
}
+ if (mdio_np)
+ of_node_put(mdio_np);
+
return 0;
err_register_mdiobus:
@@ -1830,10 +1839,23 @@ static int ftgmac100_probe(struct platform_device *pdev)
} else if (np && of_get_property(np, "phy-handle", NULL)) {
struct phy_device *phy;
+ /* Support "mdio"/"phy" child nodes for ast2400/2500 with
+ * an embedded MDIO controller. Automatically scan the DTS for
+ * available PHYs and register them.
+ */
+ if (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
+ of_device_is_compatible(np, "aspeed,ast2500-mac")) {
+ err = ftgmac100_setup_mdio(netdev);
+ if (err)
+ goto err_setup_mdio;
+ }
+
phy = of_phy_get_and_connect(priv->netdev, np,
&ftgmac100_adjust_link);
if (!phy) {
dev_err(&pdev->dev, "Failed to connect to phy\n");
+ if (priv->mii_bus)
+ mdiobus_unregister(priv->mii_bus);
goto err_setup_mdio;
}
--
2.21.1
Powered by blists - more mailing lists