diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-21 16:03:22 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-03-13 12:00:28 +0100 |
commit | ac855ffe5730f7c95644e6b19ac340bf0f53cb16 (patch) | |
tree | 865fd5e0d51f7b635cf5a4f529f4bf7add14f6ba | |
parent | 3639b69111fffd8d612e8314c228b7cb82b52f61 (diff) | |
download | barebox-ac855ffe5730f7c95644e6b19ac340bf0f53cb16.tar.gz barebox-ac855ffe5730f7c95644e6b19ac340bf0f53cb16.tar.xz |
net: phy: fix miibus parent device of_node not matching phy node
The device node of a miibus parent device usually points to the ethernet
device node whereas the parent device node of a phy device usually
points to the mdio {} subnode between the ethernet node and the phy
node, so both can't match. Ethernet drivers usually provide a pointer
to the mdio {} subnode in miibus::dev.of_node, so use that to match
against the phy nodes parent.
This occured on a TQMa6UL where two FECs are registered, but both phys
are connected to the FEC2.
Link: https://lore.barebox.org/20240221150323.2715164-8-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/net/phy/mdio_bus.c | 10 | ||||
-rw-r--r-- | drivers/net/phy/phy.c | 2 |
2 files changed, 4 insertions, 8 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 94123ef614..eed7c779e7 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -316,19 +316,15 @@ int mdiobus_register(struct mii_bus *bus) pr_info("%s: probed\n", dev_name(&bus->dev)); + if (!bus->dev.of_node) + bus->dev.of_node = bus->parent->of_node; + if (bus->dev.of_node) { bus->dev.of_node->dev = &bus->dev; /* Register PHY's as child node to mdio node */ of_mdiobus_register(bus, bus->dev.of_node); } - else if (bus->parent->of_node) { - /* - * Register PHY's as child node to the ethernet node, - * if there was no mdio node - */ - of_mdiobus_register(bus, bus->parent->of_node); - } return 0; } diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index ad02732ff9..abd78b2c80 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -358,7 +358,7 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev) if (!of_property_read_u32(phy_node, "reg", &addr)) { of_device_ensure_probed(phy_node->parent); for_each_mii_bus(bus) { - if (bus->parent->of_node == phy_node->parent) { + if (bus->dev.of_node == phy_node->parent) { struct phy_device *phy = mdiobus_scan(bus, addr); if (!IS_ERR(phy)) return phy; |