Commit ab5f1105 authored by Ahmad Fatoum's avatar Ahmad Fatoum Committed by David S. Miller

net: macb: Fix regression breaking non-MDIO fixed-link PHYs

commit 739de9a1 ("net: macb: Reorganize macb_mii bringup") broke
initializing macb on the EVB-KSZ9477 eval board.
There, of_mdiobus_register was called even for the fixed-link representing
the RGMII-link to the switch with the result that the driver attempts to
enumerate PHYs on a non-existent MDIO bus:

	libphy: MACB_mii_bus: probed
	mdio_bus f0028000.ethernet-ffffffff: fixed-link has invalid PHY address
	mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 0
        [snip]
	mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 31

The "MDIO" bus registration succeeds regardless, having claimed the reset GPIO,
and calling of_phy_register_fixed_link later on fails because it tries
to claim the same GPIO:

	macb f0028000.ethernet: broken fixed-link specification

Fix this by registering the fixed-link before calling mdiobus_register.

Fixes: 739de9a1 ("net: macb: Reorganize macb_mii bringup")
Signed-off-by: default avatarAhmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 602b74ed
...@@ -482,11 +482,6 @@ static int macb_mii_probe(struct net_device *dev) ...@@ -482,11 +482,6 @@ static int macb_mii_probe(struct net_device *dev)
if (np) { if (np) {
if (of_phy_is_fixed_link(np)) { if (of_phy_is_fixed_link(np)) {
if (of_phy_register_fixed_link(np) < 0) {
dev_err(&bp->pdev->dev,
"broken fixed-link specification\n");
return -ENODEV;
}
bp->phy_node = of_node_get(np); bp->phy_node = of_node_get(np);
} else { } else {
bp->phy_node = of_parse_phandle(np, "phy-handle", 0); bp->phy_node = of_parse_phandle(np, "phy-handle", 0);
...@@ -569,7 +564,7 @@ static int macb_mii_init(struct macb *bp) ...@@ -569,7 +564,7 @@ static int macb_mii_init(struct macb *bp)
{ {
struct macb_platform_data *pdata; struct macb_platform_data *pdata;
struct device_node *np; struct device_node *np;
int err; int err = -ENXIO;
/* Enable management port */ /* Enable management port */
macb_writel(bp, NCR, MACB_BIT(MPE)); macb_writel(bp, NCR, MACB_BIT(MPE));
...@@ -592,12 +587,23 @@ static int macb_mii_init(struct macb *bp) ...@@ -592,12 +587,23 @@ 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; np = bp->pdev->dev.of_node;
if (np && of_phy_is_fixed_link(np)) {
if (of_phy_register_fixed_link(np) < 0) {
dev_err(&bp->pdev->dev,
"broken fixed-link specification %pOF\n", np);
goto err_out_free_mdiobus;
}
err = mdiobus_register(bp->mii_bus);
} else {
if (pdata) if (pdata)
bp->mii_bus->phy_mask = pdata->phy_mask; bp->mii_bus->phy_mask = pdata->phy_mask;
err = of_mdiobus_register(bp->mii_bus, np); err = of_mdiobus_register(bp->mii_bus, np);
}
if (err) if (err)
goto err_out_free_mdiobus; goto err_out_free_fixed_link;
err = macb_mii_probe(bp->dev); err = macb_mii_probe(bp->dev);
if (err) if (err)
...@@ -607,6 +613,7 @@ static int macb_mii_init(struct macb *bp) ...@@ -607,6 +613,7 @@ static int macb_mii_init(struct macb *bp)
err_out_unregister_bus: err_out_unregister_bus:
mdiobus_unregister(bp->mii_bus); mdiobus_unregister(bp->mii_bus);
err_out_free_fixed_link:
if (np && of_phy_is_fixed_link(np)) if (np && of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np); of_phy_deregister_fixed_link(np);
err_out_free_mdiobus: 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