Commit dacdbb4d authored by Michael Grzeschik's avatar Michael Grzeschik Committed by David S. Miller

net: macb: add fixed-link node support

In case the MACB is directly connected to a
non-mdio PHY/device, it should be possible to provide
a fixed link configuration in the DT.
Signed-off-by: default avatarMichael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 24a72b77
......@@ -425,6 +425,13 @@ static int macb_mii_probe(struct net_device *dev)
int phy_irq;
int ret;
if (bp->phy_node) {
phydev = of_phy_connect(dev, bp->phy_node,
&macb_handle_link_change, 0,
bp->phy_interface);
if (!phydev)
return -ENODEV;
} else {
phydev = phy_find_first(bp->mii_bus);
if (!phydev) {
netdev_err(dev, "no PHY found\n");
......@@ -452,6 +459,7 @@ static int macb_mii_probe(struct net_device *dev)
netdev_err(dev, "Could not attach to PHY\n");
return ret;
}
}
/* mask with MAC supported features */
if (macb_is_gem(bp) && bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE)
......@@ -499,6 +507,16 @@ static int macb_mii_init(struct macb *bp)
np = bp->pdev->dev.of_node;
if (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");
goto err_out_unregister_bus;
}
bp->phy_node = of_node_get(np);
err = mdiobus_register(bp->mii_bus);
} else {
/* try dt phy registration */
err = of_mdiobus_register(bp->mii_bus, np);
......@@ -520,6 +538,7 @@ static int macb_mii_init(struct macb *bp)
if (err)
goto err_out_unregister_bus;
}
}
} else {
for (i = 0; i < PHY_MAX_ADDR; i++)
bp->mii_bus->irq[i] = PHY_POLL;
......@@ -3438,6 +3457,7 @@ static int macb_remove(struct platform_device *pdev)
clk_disable_unprepare(bp->hclk);
clk_disable_unprepare(bp->pclk);
clk_disable_unprepare(bp->rx_clk);
of_node_put(bp->phy_node);
free_netdev(dev);
}
......
......@@ -930,6 +930,7 @@ struct macb {
struct macb_or_gem_ops macbgem_ops;
struct mii_bus *mii_bus;
struct device_node *phy_node;
int link;
int speed;
int duplex;
......
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