// SPDX-License-Identifier: GPL-2.0-only /* * fwnode helpers for the MDIO (Ethernet PHY) API * * This file provides helper functions for extracting PHY device information * out of the fwnode and using it to populate an mii_bus.
*/
int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, struct fwnode_handle *child, u32 addr)
{ int rc;
rc = fwnode_irq_get(child, 0); /* Don't wait forever if the IRQ provider doesn't become available, * just fall back to poll mode
*/ if (rc == -EPROBE_DEFER)
rc = driver_deferred_probe_check_state(&phy->mdio.dev); if (rc == -EPROBE_DEFER) return rc;
/* Associate the fwnode with the device structure so it * can be looked up later
*/
fwnode_handle_get(child);
device_set_node(&phy->mdio.dev, child);
/* All data is now stored in the phy struct; * register it
*/
rc = phy_device_register(phy); if (rc) {
device_set_node(&phy->mdio.dev, NULL);
fwnode_handle_put(child); return rc;
}
if (is_acpi_node(child)) {
phy->irq = bus->irq[addr];
/* Associate the fwnode with the device structure so it * can be looked up later.
*/
phy->mdio.dev.fwnode = fwnode_handle_get(child);
/* All data is now stored in the phy struct, so register it */
rc = phy_device_register(phy); if (rc) {
phy->mdio.dev.fwnode = NULL;
fwnode_handle_put(child); goto clean_phy;
}
} elseif (is_of_node(child)) {
rc = fwnode_mdiobus_phy_device_register(bus, phy, child, addr); if (rc) goto clean_phy;
}
/* phy->mii_ts may already be defined by the PHY driver. A * mii_timestamper probed via the device tree will still have * precedence.
*/ if (mii_ts)
phy->mii_ts = mii_ts;
return 0;
unregister_phy: if (is_acpi_node(child) || is_of_node(child))
phy_device_remove(phy);
clean_phy:
phy_device_free(phy);
clean_mii_ts:
unregister_mii_timestamper(mii_ts);
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.