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: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
24a72b77f3
commit
dacdbb4dfc
@ -425,6 +425,13 @@ static int macb_mii_probe(struct net_device *dev)
|
|||||||
int phy_irq;
|
int phy_irq;
|
||||||
int ret;
|
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);
|
phydev = phy_find_first(bp->mii_bus);
|
||||||
if (!phydev) {
|
if (!phydev) {
|
||||||
netdev_err(dev, "no PHY found\n");
|
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");
|
netdev_err(dev, "Could not attach to PHY\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* mask with MAC supported features */
|
/* mask with MAC supported features */
|
||||||
if (macb_is_gem(bp) && bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE)
|
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;
|
np = bp->pdev->dev.of_node;
|
||||||
if (np) {
|
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 */
|
/* try dt phy registration */
|
||||||
err = of_mdiobus_register(bp->mii_bus, np);
|
err = of_mdiobus_register(bp->mii_bus, np);
|
||||||
|
|
||||||
@ -520,6 +538,7 @@ static int macb_mii_init(struct macb *bp)
|
|||||||
if (err)
|
if (err)
|
||||||
goto err_out_unregister_bus;
|
goto err_out_unregister_bus;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < PHY_MAX_ADDR; i++)
|
for (i = 0; i < PHY_MAX_ADDR; i++)
|
||||||
bp->mii_bus->irq[i] = PHY_POLL;
|
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->hclk);
|
||||||
clk_disable_unprepare(bp->pclk);
|
clk_disable_unprepare(bp->pclk);
|
||||||
clk_disable_unprepare(bp->rx_clk);
|
clk_disable_unprepare(bp->rx_clk);
|
||||||
|
of_node_put(bp->phy_node);
|
||||||
free_netdev(dev);
|
free_netdev(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,6 +930,7 @@ struct macb {
|
|||||||
struct macb_or_gem_ops macbgem_ops;
|
struct macb_or_gem_ops macbgem_ops;
|
||||||
|
|
||||||
struct mii_bus *mii_bus;
|
struct mii_bus *mii_bus;
|
||||||
|
struct device_node *phy_node;
|
||||||
int link;
|
int link;
|
||||||
int speed;
|
int speed;
|
||||||
int duplex;
|
int duplex;
|
||||||
|
Loading…
Reference in New Issue
Block a user