Commit ef8a2e27 authored by Antoine Tenart's avatar Antoine Tenart Committed by David S. Miller

net: macb: fix probing of PHY not described in the dt

This patch fixes the case where the PHY isn't described in the device
tree. This is due to the way the MDIO bus is registered in the driver:
whether the PHY is described in the device tree or not, the bus is
registered through of_mdiobus_register. The function masks all the PHYs
and only allow probing the ones described in the device tree. Prior to
the Phylink conversion this was also done but later on in the driver
the MDIO bus was manually scanned to circumvent the fact that the PHY
wasn't described.

This patch fixes it in a proper way, by registering the MDIO bus based
on if the PHY attached to a given interface is described in the device
tree or not.

Fixes: 7897b071 ("net: macb: convert to phylink")
Signed-off-by: default avatarAntoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0aa4d016
...@@ -664,9 +664,30 @@ static int macb_mii_probe(struct net_device *dev) ...@@ -664,9 +664,30 @@ static int macb_mii_probe(struct net_device *dev)
return 0; return 0;
} }
static int macb_mdiobus_register(struct macb *bp)
{
struct device_node *child, *np = bp->pdev->dev.of_node;
/* Only create the PHY from the device tree if at least one PHY is
* described. Otherwise scan the entire MDIO bus. We do this to support
* old device tree that did not follow the best practices and did not
* describe their network PHYs.
*/
for_each_available_child_of_node(np, child)
if (of_mdiobus_child_is_phy(child)) {
/* The loop increments the child refcount,
* decrement it before returning.
*/
of_node_put(child);
return of_mdiobus_register(bp->mii_bus, np);
}
return mdiobus_register(bp->mii_bus);
}
static int macb_mii_init(struct macb *bp) static int macb_mii_init(struct macb *bp)
{ {
struct device_node *np;
int err = -ENXIO; int err = -ENXIO;
/* Enable management port */ /* Enable management port */
...@@ -688,9 +709,7 @@ static int macb_mii_init(struct macb *bp) ...@@ -688,9 +709,7 @@ static int macb_mii_init(struct macb *bp)
dev_set_drvdata(&bp->dev->dev, bp->mii_bus); dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
np = bp->pdev->dev.of_node; err = macb_mdiobus_register(bp);
err = of_mdiobus_register(bp->mii_bus, np);
if (err) if (err)
goto err_out_free_mdiobus; goto err_out_free_mdiobus;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment