diff mbox series

[v2,2/2] net: arc: rockchip: fix emac mdio node support

Message ID 20241104130147.440125-3-andyshrk@163.com (mailing list archive)
State Accepted
Commit 0a1c7a7b0adbf595ce7f218609db53749e966573
Delegated to: Netdev Maintainers
Headers show
Series Fix the arc emac driver | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 1 blamed authors not CCed: heiko@sntech.de; 4 maintainers not CCed: edumazet@google.com pabeni@redhat.com kuba@kernel.org heiko@sntech.de
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 21 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 4 this patch: 4
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-11-07--12-00 (tests: 787)

Commit Message

Andy Yan Nov. 4, 2024, 1:01 p.m. UTC
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(-)

Comments

Jakub Kicinski Nov. 7, 2024, 1:50 a.m. UTC | #1
On Mon,  4 Nov 2024 21:01:39 +0800 Andy Yan wrote:
> 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.

Andrew, looks good?
Andrew Lunn Nov. 7, 2024, 3:05 a.m. UTC | #2
On Wed, Nov 06, 2024 at 05:50:02PM -0800, Jakub Kicinski wrote:
> On Mon,  4 Nov 2024 21:01:39 +0800 Andy Yan wrote:
> > 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.
> 
> Andrew, looks good?

The MDIO patch looks correct. I cannot say anything about the DMA
mapping.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
diff mbox series

Patch

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,