Skip to content

Commit ab5f110

Browse files
a3fdavem330
authored andcommitted
net: macb: Fix regression breaking non-MDIO fixed-link PHYs
commit 739de9a ("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: 739de9a ("net: macb: Reorganize macb_mii bringup") Signed-off-by: Ahmad Fatoum <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 602b74e commit ab5f110

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,6 @@ static int macb_mii_probe(struct net_device *dev)
482482

483483
if (np) {
484484
if (of_phy_is_fixed_link(np)) {
485-
if (of_phy_register_fixed_link(np) < 0) {
486-
dev_err(&bp->pdev->dev,
487-
"broken fixed-link specification\n");
488-
return -ENODEV;
489-
}
490485
bp->phy_node = of_node_get(np);
491486
} else {
492487
bp->phy_node = of_parse_phandle(np, "phy-handle", 0);
@@ -569,7 +564,7 @@ static int macb_mii_init(struct macb *bp)
569564
{
570565
struct macb_platform_data *pdata;
571566
struct device_node *np;
572-
int err;
567+
int err = -ENXIO;
573568

574569
/* Enable management port */
575570
macb_writel(bp, NCR, MACB_BIT(MPE));
@@ -592,12 +587,23 @@ static int macb_mii_init(struct macb *bp)
592587
dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
593588

594589
np = bp->pdev->dev.of_node;
595-
if (pdata)
596-
bp->mii_bus->phy_mask = pdata->phy_mask;
590+
if (np && of_phy_is_fixed_link(np)) {
591+
if (of_phy_register_fixed_link(np) < 0) {
592+
dev_err(&bp->pdev->dev,
593+
"broken fixed-link specification %pOF\n", np);
594+
goto err_out_free_mdiobus;
595+
}
596+
597+
err = mdiobus_register(bp->mii_bus);
598+
} else {
599+
if (pdata)
600+
bp->mii_bus->phy_mask = pdata->phy_mask;
601+
602+
err = of_mdiobus_register(bp->mii_bus, np);
603+
}
597604

598-
err = of_mdiobus_register(bp->mii_bus, np);
599605
if (err)
600-
goto err_out_free_mdiobus;
606+
goto err_out_free_fixed_link;
601607

602608
err = macb_mii_probe(bp->dev);
603609
if (err)
@@ -607,6 +613,7 @@ static int macb_mii_init(struct macb *bp)
607613

608614
err_out_unregister_bus:
609615
mdiobus_unregister(bp->mii_bus);
616+
err_out_free_fixed_link:
610617
if (np && of_phy_is_fixed_link(np))
611618
of_phy_deregister_fixed_link(np);
612619
err_out_free_mdiobus:

0 commit comments

Comments
 (0)