Lines Matching +full:phy +full:- +full:reset +full:- +full:duration

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2004-2013 Synopsys, Inc. (www.synopsys.com)
19 * arc_mdio_complete_wait - Waits until MDIO transaction is completed.
22 * returns: 0 on success, -ETIMEDOUT on a timeout.
34 /* Reset "MDIO complete" flag */ in arc_mdio_complete_wait()
42 return -ETIMEDOUT; in arc_mdio_complete_wait()
46 * arc_mdio_read - MDIO interface read function.
48 * @phy_addr: Address of the PHY device.
49 * @reg_num: PHY register to read.
51 * returns: The register contents on success, -ETIMEDOUT on a timeout.
53 * Reads the contents of the requested register from the requested PHY
58 struct arc_emac_priv *priv = bus->priv; in arc_mdio_read()
71 dev_dbg(priv->dev, "arc_mdio_read(phy_addr=%i, reg_num=%x) = %x\n", in arc_mdio_read()
78 * arc_mdio_write - MDIO interface write function.
80 * @phy_addr: Address of the PHY device.
81 * @reg_num: PHY register to write to.
84 * returns: 0 on success, -ETIMEDOUT on a timeout.
91 struct arc_emac_priv *priv = bus->priv; in arc_mdio_write()
93 dev_dbg(priv->dev, in arc_mdio_write()
106 * Description: reset the MII bus
110 struct arc_emac_priv *priv = bus->priv; in arc_mdio_reset()
111 struct arc_emac_mdio_bus_data *data = &priv->bus_data; in arc_mdio_reset()
113 if (data->reset_gpio) { in arc_mdio_reset()
114 gpiod_set_value_cansleep(data->reset_gpio, 1); in arc_mdio_reset()
115 msleep(data->msec); in arc_mdio_reset()
116 gpiod_set_value_cansleep(data->reset_gpio, 0); in arc_mdio_reset()
123 * arc_mdio_probe - MDIO probe function.
126 * returns: 0 on success, -ENOMEM when mdiobus_alloc
133 struct arc_emac_mdio_bus_data *data = &priv->bus_data; in arc_mdio_probe()
134 struct device_node *np = priv->dev->of_node; in arc_mdio_probe()
142 return -ENOMEM; in arc_mdio_probe()
144 priv->bus = bus; in arc_mdio_probe()
145 bus->priv = priv; in arc_mdio_probe()
146 bus->parent = priv->dev; in arc_mdio_probe()
147 bus->name = name; in arc_mdio_probe()
148 bus->read = &arc_mdio_read; in arc_mdio_probe()
149 bus->write = &arc_mdio_write; in arc_mdio_probe()
150 bus->reset = &arc_mdio_reset; in arc_mdio_probe()
152 /* optional reset-related properties */ in arc_mdio_probe()
153 data->reset_gpio = devm_gpiod_get_optional(priv->dev, "phy-reset", in arc_mdio_probe()
155 if (IS_ERR(data->reset_gpio)) { in arc_mdio_probe()
157 return dev_err_probe(priv->dev, PTR_ERR(data->reset_gpio), in arc_mdio_probe()
161 of_property_read_u32(np, "phy-reset-duration", &data->msec); in arc_mdio_probe()
162 /* A sane reset duration should not be longer than 1s */ in arc_mdio_probe()
163 if (data->msec > 1000) in arc_mdio_probe()
164 data->msec = 1; in arc_mdio_probe()
166 snprintf(bus->id, MII_BUS_ID_SIZE, "%s", bus->name); in arc_mdio_probe()
177 return dev_err_probe(priv->dev, error, in arc_mdio_probe()
185 * arc_mdio_remove - MDIO remove function.
192 mdiobus_unregister(priv->bus); in arc_mdio_remove()
193 mdiobus_free(priv->bus); in arc_mdio_remove()
194 priv->bus = NULL; in arc_mdio_remove()