From: Ivan Mikhaylov <i.mikhaylov@yadro.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Po-Yu Chuang <ratbert@faraday-tech.com>
Cc: Ivan Mikhaylov <i.mikhaylov@yadro.com>,
Joel Stanley <joel@jms.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<openbmc@lists.ozlabs.org>
Subject: [PATCH v3 2/3] net: ftgmac100: add handling of mdio/phy nodes for ast2400/2500
Date: Fri, 30 Oct 2020 16:37:06 +0300 [thread overview]
Message-ID: <20201030133707.12099-3-i.mikhaylov@yadro.com> (raw)
In-Reply-To: <20201030133707.12099-1-i.mikhaylov@yadro.com>
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@yadro.com>
---
drivers/net/ethernet/faraday/ftgmac100.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index ffad79050713..62bafd4b22e1 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1631,6 +1631,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;
@@ -1662,12 +1663,16 @@ 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");
+
+ err = of_mdiobus_register(priv->mii_bus, mdio_np);
if (err) {
dev_err(priv->dev, "Cannot register MDIO bus!\n");
goto err_register_mdiobus;
}
+ of_node_put(mdio_np);
+
return 0;
err_register_mdiobus:
@@ -1830,11 +1835,22 @@ 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");
- goto err_setup_mdio;
+ goto err_phy_connect;
}
/* Indicate that we support PAUSE frames (see comment in
--
2.21.1
next prev parent reply other threads:[~2020-10-30 13:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 13:37 [PATCH v3 0/3] add ast2400/2500 phy-handle support Ivan Mikhaylov
2020-10-30 13:37 ` [PATCH v3 1/3] net: ftgmac100: move phy connect out from ftgmac100_setup_mdio Ivan Mikhaylov
2020-10-30 13:37 ` Ivan Mikhaylov [this message]
2020-10-30 20:26 ` [PATCH v3 2/3] net: ftgmac100: add handling of mdio/phy nodes for ast2400/2500 Andrew Lunn
2020-10-30 13:37 ` [PATCH v3 3/3] dt-bindings: net: ftgmac100: describe phy-handle and MDIO Ivan Mikhaylov
2020-10-30 20:21 ` Andrew Lunn
2020-11-02 23:14 ` [PATCH v3 0/3] add ast2400/2500 phy-handle support Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201030133707.12099-3-i.mikhaylov@yadro.com \
--to=i.mikhaylov@yadro.com \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=joel@jms.id.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
--cc=ratbert@faraday-tech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).