// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2004-2013 Synopsys, Inc. (www.synopsys.com) * * MDIO implementation for ARC EMAC */ #include <linux/delay.h> #include <linux/of_mdio.h> #include <linux/platform_device.h> #include <linux/gpio/consumer.h> #include "emac.h" /* Number of seconds we wait for "MDIO complete" flag to appear */ #define ARC_MDIO_COMPLETE_POLL_COUNT … /** * 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. */ static int arc_mdio_complete_wait(struct arc_emac_priv *priv) { … } /** * 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. */ static int arc_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num) { … } /** * 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. */ static int arc_mdio_write(struct mii_bus *bus, int phy_addr, int reg_num, u16 value) { … } /** * arc_mdio_reset * @bus: points to the mii_bus structure * Description: reset the MII bus */ static int arc_mdio_reset(struct mii_bus *bus) { … } /** * arc_mdio_probe - MDIO probe function. * @priv: Pointer to ARC EMAC private data structure. * * returns: 0 on success, -ENOMEM when mdiobus_alloc * (to allocate memory for MII bus structure) fails. * * Sets up and registers the MDIO interface. */ int arc_mdio_probe(struct arc_emac_priv *priv) { … } /** * 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) { … }