mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Yan <andyshrk@163.com>
To: andrew+netdev@lunn.ch
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	david.wu@rock-chips.com, Johan Jonker <jbx6244@gmail.com>,
	Andy Yan <andyshrk@163.com>, Andy Yan <andy.yan@rock-chips.com>
Subject: [PATCH v2 2/2] net: arc: rockchip: fix emac mdio node support
Date: Mon,  4 Nov 2024 21:01:39 +0800	[thread overview]
Message-ID: <20241104130147.440125-3-andyshrk@163.com> (raw)
In-Reply-To: <20241104130147.440125-1-andyshrk@163.com>

From: Johan Jonker <jbx6244@gmail.com>

The binding emac_rockchip.txt is converted to YAML.
Changed against the original binding is an added MDIO subnode.
This make the driver failed to find the PHY, and given the 'mdio
has invalid PHY address' it is probably looking in the wrong node.
Fix emac_mdio.c so that it can handle both old and new
device trees.

Fixes: 1dabb74971b3 ("ARM: dts: rockchip: restyle emac nodes")
Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Tested-by: Andy Yan <andyshrk@163.com>
Link: https://lore.kernel.org/r/20220603163539.537-3-jbx6244@gmail.com
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>

---

Changes in v2:
- Add fix tag.
- Add more detail explaination.

 drivers/net/ethernet/arc/emac_mdio.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/arc/emac_mdio.c b/drivers/net/ethernet/arc/emac_mdio.c
index 87f40c2ba9040..078b1a72c1613 100644
--- a/drivers/net/ethernet/arc/emac_mdio.c
+++ b/drivers/net/ethernet/arc/emac_mdio.c
@@ -133,6 +133,7 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
 	struct arc_emac_mdio_bus_data *data = &priv->bus_data;
 	struct device_node *np = priv->dev->of_node;
 	const char *name = "Synopsys MII Bus";
+	struct device_node *mdio_node;
 	struct mii_bus *bus;
 	int error;
 
@@ -164,7 +165,13 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
 
 	snprintf(bus->id, MII_BUS_ID_SIZE, "%s", bus->name);
 
-	error = of_mdiobus_register(bus, priv->dev->of_node);
+	/* Backwards compatibility for EMAC nodes without MDIO subnode. */
+	mdio_node = of_get_child_by_name(np, "mdio");
+	if (!mdio_node)
+		mdio_node = of_node_get(np);
+
+	error = of_mdiobus_register(bus, mdio_node);
+	of_node_put(mdio_node);
 	if (error) {
 		mdiobus_free(bus);
 		return dev_err_probe(priv->dev, error,
-- 
2.34.1


  parent reply	other threads:[~2024-11-04 13:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-04 13:01 [PATCH v2 0/2] Fix the arc emac driver Andy Yan
2024-11-04 13:01 ` [PATCH v2 1/2] net: arc: fix the device for dma_map_single/dma_unmap_single Andy Yan
2024-11-04 13:01 ` Andy Yan [this message]
2024-11-07  1:50   ` [PATCH v2 2/2] net: arc: rockchip: fix emac mdio node support Jakub Kicinski
2024-11-07  3:05     ` Andrew Lunn
2024-11-07 13:00 ` [PATCH v2 0/2] Fix the arc emac driver patchwork-bot+netdevbpf

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=20241104130147.440125-3-andyshrk@163.com \
    --to=andyshrk@163.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andy.yan@rock-chips.com \
    --cc=david.wu@rock-chips.com \
    --cc=jbx6244@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®