Lines Matching +full:pin +full:- +full:val
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
61 #define MDO sc->miibb_ops.mbo_bits[MII_BIT_MDO]
62 #define MDI sc->miibb_ops.mbo_bits[MII_BIT_MDI]
63 #define MDC sc->miibb_ops.mbo_bits[MII_BIT_MDC]
64 #define MDIRPHY sc->miibb_ops.mbo_bits[MII_BIT_DIR_HOST_PHY]
65 #define MDIRHOST sc->miibb_ops.mbo_bits[MII_BIT_DIR_PHY_HOST]
90 if (devi->npins < GPIOMDIO_MIN_PINS) { in gpiomdio_probe()
93 GPIOMDIO_MIN_PINS, devi->npins); in gpiomdio_probe()
96 device_set_desc(dev, "GPIO MDIO bit-banging Bus driver"); in gpiomdio_probe()
105 pcell_t pin; in gpiomdio_attach() local
110 sc->sc_dev = dev; in gpiomdio_attach()
111 sc->sc_busdev = device_get_parent(dev); in gpiomdio_attach()
113 if ((node = ofw_bus_get_node(dev)) == -1) in gpiomdio_attach()
115 if (OF_getencprop(node, "mdc", &pin, sizeof(pin)) > 0) in gpiomdio_attach()
116 sc->mdc_pin = (int)pin; in gpiomdio_attach()
117 if (OF_getencprop(node, "mdio", &pin, sizeof(pin)) > 0) in gpiomdio_attach()
118 sc->mdio_pin = (int)pin; in gpiomdio_attach()
120 if (sc->mdc_pin < 0 || sc->mdc_pin > 1) in gpiomdio_attach()
121 sc->mdc_pin = GPIOMDIO_MDC_DFLT; in gpiomdio_attach()
122 if (sc->mdio_pin < 0 || sc->mdio_pin > 1) in gpiomdio_attach()
123 sc->mdio_pin = GPIOMDIO_MDIO_DFLT; in gpiomdio_attach()
126 device_printf(dev, "MDC pin: %d, MDIO pin: %d\n", in gpiomdio_attach()
127 devi->pins[sc->mdc_pin], devi->pins[sc->mdio_pin]); in gpiomdio_attach()
135 sc->miibb_ops.mbo_read = gpiomdio_bb_read; in gpiomdio_attach()
136 sc->miibb_ops.mbo_write = gpiomdio_bb_write; in gpiomdio_attach()
148 unsigned int val; in gpiomdio_bb_read() local
151 GPIOBUS_PIN_GET(sc->sc_busdev, sc->sc_dev, sc->mdio_pin, &val); in gpiomdio_bb_read()
153 return (val != 0 ? MDI_BIT : 0); in gpiomdio_bb_read()
157 gpiomdio_bb_write(device_t dev, uint32_t val) in gpiomdio_bb_write() argument
163 /* Set the data pin state. */ in gpiomdio_bb_write()
164 if ((val & (MDIRPHY_BIT | MDO_BIT)) == (MDIRPHY_BIT | MDO_BIT)) in gpiomdio_bb_write()
165 GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->mdio_pin, 1); in gpiomdio_bb_write()
166 else if ((val & (MDIRPHY_BIT | MDO_BIT)) == MDIRPHY_BIT) in gpiomdio_bb_write()
167 GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->mdio_pin, 0); in gpiomdio_bb_write()
168 if (val & MDIRPHY_BIT) in gpiomdio_bb_write()
169 GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->mdio_pin, in gpiomdio_bb_write()
171 else if (val & MDIRHOST_BIT) in gpiomdio_bb_write()
172 GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->mdio_pin, in gpiomdio_bb_write()
176 if (val & MDC_BIT) in gpiomdio_bb_write()
177 GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->mdc_pin, 1); in gpiomdio_bb_write()
179 GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->mdc_pin, 0); in gpiomdio_bb_write()
180 GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->mdc_pin, in gpiomdio_bb_write()
191 return (mii_bitbang_readreg(dev, &sc->miibb_ops, phy, reg)); in gpiomdio_readreg()
195 gpiomdio_writereg(device_t dev, int phy, int reg, int val) in gpiomdio_writereg() argument
200 mii_bitbang_writereg(dev, &sc->miibb_ops, phy, reg, val); in gpiomdio_writereg()