Lines Matching refs:sc

120 	struct vf_gpio_softc *sc;
123 sc = device_get_softc(dev);
124 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
126 if (bus_alloc_resources(dev, vf_gpio_spec, sc->res)) {
128 mtx_destroy(&sc->sc_mtx);
133 sc->bst = rman_get_bustag(sc->res[0]);
134 sc->bsh = rman_get_bushandle(sc->res[0]);
136 gpio_sc = sc;
138 sc->gpio_npins = NGPIO;
140 for (i = 0; i < sc->gpio_npins; i++) {
141 sc->gpio_pins[i].gp_pin = i;
142 sc->gpio_pins[i].gp_caps = DEFAULT_CAPS;
143 sc->gpio_pins[i].gp_flags =
144 (READ4(sc, GPIO_PDOR(i)) & (1 << (i % 32))) ?
146 snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,
150 sc->sc_busdev = gpiobus_attach_bus(dev);
151 if (sc->sc_busdev == NULL) {
152 bus_release_resources(dev, vf_gpio_spec, sc->res);
153 mtx_destroy(&sc->sc_mtx);
163 struct vf_gpio_softc *sc;
165 sc = device_get_softc(dev);
167 return (sc->sc_busdev);
181 struct vf_gpio_softc *sc;
184 sc = device_get_softc(dev);
185 for (i = 0; i < sc->gpio_npins; i++) {
186 if (sc->gpio_pins[i].gp_pin == pin)
190 if (i >= sc->gpio_npins)
193 GPIO_LOCK(sc);
194 memcpy(name, sc->gpio_pins[i].gp_name, GPIOMAXNAME);
195 GPIO_UNLOCK(sc);
203 struct vf_gpio_softc *sc;
206 sc = device_get_softc(dev);
207 for (i = 0; i < sc->gpio_npins; i++) {
208 if (sc->gpio_pins[i].gp_pin == pin)
212 if (i >= sc->gpio_npins)
215 GPIO_LOCK(sc);
216 *caps = sc->gpio_pins[i].gp_caps;
217 GPIO_UNLOCK(sc);
225 struct vf_gpio_softc *sc;
228 sc = device_get_softc(dev);
229 for (i = 0; i < sc->gpio_npins; i++) {
230 if (sc->gpio_pins[i].gp_pin == pin)
234 if (i >= sc->gpio_npins)
237 GPIO_LOCK(sc);
238 *flags = sc->gpio_pins[i].gp_flags;
239 GPIO_UNLOCK(sc);
247 struct vf_gpio_softc *sc;
250 sc = device_get_softc(dev);
251 for (i = 0; i < sc->gpio_npins; i++) {
252 if (sc->gpio_pins[i].gp_pin == pin)
256 if (i >= sc->gpio_npins)
259 GPIO_LOCK(sc);
260 *val = (READ4(sc, GPIO_PDIR(i)) & (1 << (i % 32))) ? 1 : 0;
261 GPIO_UNLOCK(sc);
269 struct vf_gpio_softc *sc;
272 sc = device_get_softc(dev);
273 for (i = 0; i < sc->gpio_npins; i++) {
274 if (sc->gpio_pins[i].gp_pin == pin)
278 if (i >= sc->gpio_npins)
281 GPIO_LOCK(sc);
282 WRITE4(sc, GPIO_PTOR(i), (1 << (i % 32)));
283 GPIO_UNLOCK(sc);
289 vf_gpio_pin_configure(struct vf_gpio_softc *sc, struct gpio_pin *pin,
293 GPIO_LOCK(sc);
305 WRITE4(sc, GPIO_PCOR(pin->gp_pin),
310 GPIO_UNLOCK(sc);
316 struct vf_gpio_softc *sc;
319 sc = device_get_softc(dev);
320 for (i = 0; i < sc->gpio_npins; i++) {
321 if (sc->gpio_pins[i].gp_pin == pin)
325 if (i >= sc->gpio_npins)
328 vf_gpio_pin_configure(sc, &sc->gpio_pins[i], flags);
336 struct vf_gpio_softc *sc;
339 sc = device_get_softc(dev);
340 for (i = 0; i < sc->gpio_npins; i++) {
341 if (sc->gpio_pins[i].gp_pin == pin)
345 if (i >= sc->gpio_npins)
348 GPIO_LOCK(sc);
350 WRITE4(sc, GPIO_PSOR(i), (1 << (i % 32)));
352 WRITE4(sc, GPIO_PCOR(i), (1 << (i % 32)));
353 GPIO_UNLOCK(sc);