Lines Matching +full:read +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2006-2007 PA Semi, Inc
9 * Based on drivers/net/fs_enet/mii-bitbang.c.
25 #define DELAY 1 macro
34 #define MDC_PIN(bus) (((struct gpio_priv *)bus->priv)->mdc_pin)
35 #define MDIO_PIN(bus) (((struct gpio_priv *)bus->priv)->mdio_pin)
78 udelay(DELAY); in clock_out()
80 udelay(DELAY); in clock_out()
84 /* Utility to send the preamble, address, and register (common to read and write). */
85 static void bitbang_pre(struct mii_bus *bus, int read, u8 addr, u8 reg) in bitbang_pre() argument
95 /* send the start bit (01) and the read opcode (10) or write (10) */ in bitbang_pre()
99 clock_out(bus, read); in bitbang_pre()
100 clock_out(bus, !read); in bitbang_pre()
124 /* tri-state our MDIO I/O pin so we can read */ in gpio_mdio_read()
126 udelay(DELAY); in gpio_mdio_read()
128 udelay(DELAY); in gpio_mdio_read()
131 /* read 16 bits of register data, MSB first */ in gpio_mdio_read()
135 udelay(DELAY); in gpio_mdio_read()
137 udelay(DELAY); in gpio_mdio_read()
139 udelay(DELAY); in gpio_mdio_read()
145 udelay(DELAY); in gpio_mdio_read()
147 udelay(DELAY); in gpio_mdio_read()
167 udelay(DELAY); in gpio_mdio_write()
169 udelay(DELAY); in gpio_mdio_write()
172 udelay(DELAY); in gpio_mdio_write()
174 udelay(DELAY); in gpio_mdio_write()
183 udelay(DELAY); in gpio_mdio_write()
185 udelay(DELAY); in gpio_mdio_write()
190 * Tri-state the MDIO line. in gpio_mdio_write()
194 udelay(DELAY); in gpio_mdio_write()
196 udelay(DELAY); in gpio_mdio_write()
202 /*nothing here - dunno how to reset it*/ in gpio_mdio_reset()
209 struct device *dev = &ofdev->dev; in gpio_mdio_probe()
210 struct device_node *np = ofdev->dev.of_node; in gpio_mdio_probe()
216 err = -ENOMEM; in gpio_mdio_probe()
226 new_bus->name = "pasemi gpio mdio bus"; in gpio_mdio_probe()
227 new_bus->read = &gpio_mdio_read; in gpio_mdio_probe()
228 new_bus->write = &gpio_mdio_write; in gpio_mdio_probe()
229 new_bus->reset = &gpio_mdio_reset; in gpio_mdio_probe()
232 snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", *prop); in gpio_mdio_probe()
233 new_bus->priv = priv; in gpio_mdio_probe()
235 prop = of_get_property(np, "mdc-pin", NULL); in gpio_mdio_probe()
236 priv->mdc_pin = *prop; in gpio_mdio_probe()
238 prop = of_get_property(np, "mdio-pin", NULL); in gpio_mdio_probe()
239 priv->mdio_pin = *prop; in gpio_mdio_probe()
241 new_bus->parent = dev; in gpio_mdio_probe()
248 new_bus->name, err); in gpio_mdio_probe()
265 struct mii_bus *bus = dev_get_drvdata(&dev->dev); in gpio_mdio_remove()
269 dev_set_drvdata(&dev->dev, NULL); in gpio_mdio_remove()
271 kfree(bus->priv); in gpio_mdio_remove()
272 bus->priv = NULL; in gpio_mdio_remove()
281 .compatible = "gpio-mdio",
292 .name = "gpio-mdio-bitbang",
301 np = of_find_compatible_node(NULL, NULL, "1682m-gpio"); in gpio_mdio_init()
304 "pasemi,pwrficient-gpio"); in gpio_mdio_init()
306 return -ENODEV; in gpio_mdio_init()
311 return -ENODEV; in gpio_mdio_init()
327 MODULE_DESCRIPTION("Driver for MDIO over GPIO on PA Semi PWRficient-based boards");