/* Configure the MDIO bus and connect the external PHY */ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
{ struct device_node *np = pdev->dev.of_node; struct mii_bus *mii_bus; int ret;
/* Create the mii_bus object for talking to the MDIO bus */
adpt->mii_bus = mii_bus = devm_mdiobus_alloc(&pdev->dev); if (!mii_bus) return -ENOMEM;
if (has_acpi_companion(&pdev->dev)) {
u32 phy_addr;
ret = mdiobus_register(mii_bus); if (ret) {
dev_err(&pdev->dev, "could not register mdio bus\n"); return ret;
}
ret = device_property_read_u32(&pdev->dev, "phy-channel",
&phy_addr); if (ret) /* If we can't read a valid phy address, then assume * that there is only one phy on this mdio bus.
*/
adpt->phydev = phy_find_first(mii_bus); else
adpt->phydev = mdiobus_get_phy(mii_bus, phy_addr);
/* of_phy_find_device() claims a reference to the phydev, * so we do that here manually as well. When the driver * later unloads, it can unilaterally drop the reference * without worrying about ACPI vs DT.
*/ if (adpt->phydev)
get_device(&adpt->phydev->mdio.dev);
} else { struct device_node *phy_np;
ret = of_mdiobus_register(mii_bus, np); if (ret) {
dev_err(&pdev->dev, "could not register mdio bus\n"); return ret;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.