/* Number of seconds we wait for "MDIO complete" flag to appear */ #define ARC_MDIO_COMPLETE_POLL_COUNT 1
/** * arc_mdio_complete_wait - Waits until MDIO transaction is completed. * @priv: Pointer to ARC EMAC private data structure. * * returns: 0 on success, -ETIMEDOUT on a timeout.
*/ staticint arc_mdio_complete_wait(struct arc_emac_priv *priv)
{ unsignedint i;
for (i = 0; i < ARC_MDIO_COMPLETE_POLL_COUNT * 40; i++) { unsignedint status = arc_reg_get(priv, R_STATUS);
status &= MDIO_MASK;
if (status) { /* Reset "MDIO complete" flag */
arc_reg_set(priv, R_STATUS, status); return 0;
}
msleep(25);
}
return -ETIMEDOUT;
}
/** * arc_mdio_read - MDIO interface read function. * @bus: Pointer to MII bus structure. * @phy_addr: Address of the PHY device. * @reg_num: PHY register to read. * * returns: The register contents on success, -ETIMEDOUT on a timeout. * * Reads the contents of the requested register from the requested PHY * address.
*/ staticint arc_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num)
{ struct arc_emac_priv *priv = bus->priv; unsignedint value; int error;
/** * arc_mdio_write - MDIO interface write function. * @bus: Pointer to MII bus structure. * @phy_addr: Address of the PHY device. * @reg_num: PHY register to write to. * @value: Value to be written into the register. * * returns: 0 on success, -ETIMEDOUT on a timeout. * * Writes the value to the requested register.
*/ staticint arc_mdio_write(struct mii_bus *bus, int phy_addr, int reg_num, u16 value)
{ struct arc_emac_priv *priv = bus->priv;
of_property_read_u32(np, "phy-reset-duration", &data->msec); /* A sane reset duration should not be longer than 1s */ if (data->msec > 1000)
data->msec = 1;
/* Backwards compatibility for EMAC nodes without MDIO subnode. */
mdio_node = of_get_child_by_name(np, "mdio"); if (!mdio_node)
mdio_node = of_node_get(np);
error = of_mdiobus_register(bus, mdio_node);
of_node_put(mdio_node); if (error) {
mdiobus_free(bus); return dev_err_probe(priv->dev, error, "cannot register MDIO bus %s\n", name);
}
return 0;
}
/** * arc_mdio_remove - MDIO remove function. * @priv: Pointer to ARC EMAC private data structure. * * Unregisters the MDIO and frees any associate memory for MII bus.
*/ int arc_mdio_remove(struct arc_emac_priv *priv)
{
mdiobus_unregister(priv->bus);
mdiobus_free(priv->bus);
priv->bus = NULL;
return 0;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.20 Sekunden
(vorverarbeitet)
¤
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.