summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2018-01-23 15:43:25 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-01-25 08:19:48 +0100
commitdbd08c5ac14993842137494c16952c01214a039d (patch)
tree6c1f6a44627b3ee0d867c191cfcad82658720cb4 /drivers
parentdd95f5389989d69c46411d9325f7adfa043ee0a5 (diff)
downloadbarebox-dbd08c5ac14993842137494c16952c01214a039d.tar.gz
barebox-dbd08c5ac14993842137494c16952c01214a039d.tar.xz
net: phy: scan PHYs referenced by phandle
If we point to a PHY node by phandle, that PHY might well be on a MDIO bus that hasn't been scanned when we look for the PHY. Fortunately we know exactly where to look for the PHY, so make sure to scan the bus at the right address. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/phy/phy.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 35a9ce7ea8..2b8fa63c06 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -319,6 +319,8 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev)
{
struct device_d *dev;
struct device_node *phy_node;
+ struct mii_bus *bus;
+ int addr;
if (!IS_ENABLED(CONFIG_OFDEVICE))
return NULL;
@@ -340,6 +342,16 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev)
if (!phy_node)
return NULL;
+ if (!of_property_read_u32(phy_node, "reg", &addr)) {
+ for_each_mii_bus(bus) {
+ if (bus->parent->device_node == phy_node->parent) {
+ struct phy_device *phy = mdiobus_scan(bus, addr);
+ if (!IS_ERR(phy))
+ return phy;
+ }
+ }
+ }
+
bus_for_each_device(&mdio_bus_type, dev) {
if (dev->device_node == phy_node)
return container_of(dev, struct phy_device, dev);