net: arc: rockchip: fix emac mdio node support

[ Upstream commit 0a1c7a7b0adbf595ce7f218609db53749e966573 ]

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: 1dabb74971 ("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>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Johan Jonker 2024-11-04 21:01:39 +08:00 committed by Greg Kroah-Hartman
parent 8ed7a4a39c
commit 0012be71c5

View file

@ -133,6 +133,7 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
struct arc_emac_mdio_bus_data *data = &priv->bus_data; struct arc_emac_mdio_bus_data *data = &priv->bus_data;
struct device_node *np = priv->dev->of_node; struct device_node *np = priv->dev->of_node;
const char *name = "Synopsys MII Bus"; const char *name = "Synopsys MII Bus";
struct device_node *mdio_node;
struct mii_bus *bus; struct mii_bus *bus;
int error; 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); 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) { if (error) {
mdiobus_free(bus); mdiobus_free(bus);
return dev_err_probe(priv->dev, error, return dev_err_probe(priv->dev, error,