gpiobus.c revision 243464
1213237Sgonzo/*- 2213237Sgonzo * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org> 3213237Sgonzo * All rights reserved. 4213237Sgonzo * 5213237Sgonzo * Redistribution and use in source and binary forms, with or without 6213237Sgonzo * modification, are permitted provided that the following conditions 7213237Sgonzo * are met: 8213237Sgonzo * 1. Redistributions of source code must retain the above copyright 9213237Sgonzo * notice, this list of conditions and the following disclaimer. 10213237Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 11213237Sgonzo * notice, this list of conditions and the following disclaimer in the 12213237Sgonzo * documentation and/or other materials provided with the distribution. 13213237Sgonzo * 14213277Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15213277Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16213277Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17213277Sgonzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18213277Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19213277Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20213277Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21213277Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22213277Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23213277Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24213277Sgonzo * SUCH DAMAGE. 25213237Sgonzo */ 26213237Sgonzo 27213237Sgonzo#include <sys/cdefs.h> 28213237Sgonzo__FBSDID("$FreeBSD: head/sys/dev/gpio/gpiobus.c 243464 2012-11-23 19:20:38Z gonzo $"); 29213237Sgonzo 30213237Sgonzo#include <sys/param.h> 31213237Sgonzo#include <sys/systm.h> 32213237Sgonzo#include <sys/malloc.h> 33213237Sgonzo#include <sys/module.h> 34213237Sgonzo#include <sys/kernel.h> 35213237Sgonzo#include <sys/queue.h> 36213237Sgonzo#include <sys/sysctl.h> 37213237Sgonzo#include <sys/types.h> 38213237Sgonzo 39213237Sgonzo#include <sys/bus.h> 40213237Sgonzo#include <machine/bus.h> 41213237Sgonzo#include <sys/rman.h> 42213237Sgonzo#include <machine/resource.h> 43213237Sgonzo 44213237Sgonzo#include <sys/gpio.h> 45213237Sgonzo#include <dev/gpio/gpiobusvar.h> 46213237Sgonzo#include "gpio_if.h" 47213237Sgonzo#include "gpiobus_if.h" 48213237Sgonzo 49213237Sgonzostatic void gpiobus_print_pins(struct gpiobus_ivar *); 50213237Sgonzostatic int gpiobus_parse_pins(struct gpiobus_softc *, device_t, int); 51213237Sgonzostatic int gpiobus_probe(device_t); 52213237Sgonzostatic int gpiobus_attach(device_t); 53213237Sgonzostatic int gpiobus_detach(device_t); 54213237Sgonzostatic int gpiobus_suspend(device_t); 55213237Sgonzostatic int gpiobus_resume(device_t); 56213237Sgonzostatic int gpiobus_print_child(device_t, device_t); 57213237Sgonzostatic int gpiobus_child_location_str(device_t, device_t, char *, size_t); 58213237Sgonzostatic int gpiobus_child_pnpinfo_str(device_t, device_t, char *, size_t); 59213237Sgonzostatic device_t gpiobus_add_child(device_t, u_int, const char *, int); 60213237Sgonzostatic void gpiobus_hinted_child(device_t, const char *, int); 61213237Sgonzo 62213237Sgonzo/* 63213237Sgonzo * GPIOBUS interface 64213237Sgonzo */ 65213237Sgonzostatic void gpiobus_lock_bus(device_t); 66213237Sgonzostatic void gpiobus_unlock_bus(device_t); 67213237Sgonzostatic void gpiobus_acquire_bus(device_t, device_t); 68213237Sgonzostatic void gpiobus_release_bus(device_t, device_t); 69213237Sgonzostatic int gpiobus_pin_setflags(device_t, device_t, uint32_t, uint32_t); 70213237Sgonzostatic int gpiobus_pin_getflags(device_t, device_t, uint32_t, uint32_t*); 71213237Sgonzostatic int gpiobus_pin_getcaps(device_t, device_t, uint32_t, uint32_t*); 72213237Sgonzostatic int gpiobus_pin_set(device_t, device_t, uint32_t, unsigned int); 73213237Sgonzostatic int gpiobus_pin_get(device_t, device_t, uint32_t, unsigned int*); 74213237Sgonzostatic int gpiobus_pin_toggle(device_t, device_t, uint32_t); 75213237Sgonzo 76213237Sgonzo#define GPIOBUS_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) 77213237Sgonzo#define GPIOBUS_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) 78213237Sgonzo#define GPIOBUS_LOCK_INIT(_sc) \ 79213237Sgonzo mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->sc_dev), \ 80213237Sgonzo "gpiobus", MTX_DEF) 81213237Sgonzo#define GPIOBUS_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx); 82213237Sgonzo#define GPIOBUS_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED); 83213237Sgonzo#define GPIOBUS_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED); 84213237Sgonzo 85213237Sgonzo 86213237Sgonzostatic void 87213237Sgonzogpiobus_print_pins(struct gpiobus_ivar *devi) 88213237Sgonzo{ 89213237Sgonzo int range_start, range_stop, need_coma; 90213237Sgonzo int i; 91213237Sgonzo 92213237Sgonzo if (devi->npins == 0) 93213237Sgonzo return; 94213237Sgonzo 95213237Sgonzo need_coma = 0; 96213237Sgonzo range_start = range_stop = devi->pins[0]; 97213237Sgonzo for (i = 1; i < devi->npins; i++) { 98213237Sgonzo if (devi->pins[i] != (range_stop + 1)) { 99213237Sgonzo if (need_coma) 100213237Sgonzo printf(","); 101213237Sgonzo if (range_start != range_stop) 102213237Sgonzo printf("%d-%d", range_start, range_stop); 103213237Sgonzo else 104213237Sgonzo printf("%d", range_start); 105213237Sgonzo 106213237Sgonzo range_start = range_stop = devi->pins[i]; 107213237Sgonzo need_coma = 1; 108213237Sgonzo } 109213237Sgonzo else 110213237Sgonzo range_stop++; 111213237Sgonzo } 112213237Sgonzo 113213237Sgonzo if (need_coma) 114213237Sgonzo printf(","); 115213237Sgonzo if (range_start != range_stop) 116213237Sgonzo printf("%d-%d", range_start, range_stop); 117213237Sgonzo else 118213237Sgonzo printf("%d", range_start); 119213237Sgonzo} 120213237Sgonzo 121213237Sgonzostatic int 122213237Sgonzogpiobus_parse_pins(struct gpiobus_softc *sc, device_t child, int mask) 123213237Sgonzo{ 124213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 125213237Sgonzo int i, npins; 126213237Sgonzo 127213237Sgonzo npins = 0; 128213237Sgonzo for (i = 0; i < 32; i++) { 129213237Sgonzo if (mask & (1 << i)) 130213237Sgonzo npins++; 131213237Sgonzo } 132213237Sgonzo 133213237Sgonzo if (npins == 0) { 134213237Sgonzo device_printf(child, "empty pin mask"); 135213237Sgonzo return (EINVAL); 136213237Sgonzo } 137213237Sgonzo 138213237Sgonzo devi->npins = npins; 139213237Sgonzo devi->pins = malloc(sizeof(uint32_t) * devi->npins, M_DEVBUF, 140213237Sgonzo M_NOWAIT | M_ZERO); 141213237Sgonzo 142213237Sgonzo if (!devi->pins) 143213237Sgonzo return (ENOMEM); 144213237Sgonzo 145213237Sgonzo npins = 0; 146213237Sgonzo for (i = 0; i < 32; i++) { 147213237Sgonzo 148213237Sgonzo if ((mask & (1 << i)) == 0) 149213237Sgonzo continue; 150213237Sgonzo 151213237Sgonzo if (i >= sc->sc_npins) { 152213237Sgonzo device_printf(child, 153213237Sgonzo "invalid pin %d, max: %d\n", i, sc->sc_npins - 1); 154213237Sgonzo return (EINVAL); 155213237Sgonzo } 156213237Sgonzo 157213237Sgonzo devi->pins[npins++] = i; 158213237Sgonzo /* 159213237Sgonzo * Mark pin as mapped and give warning if it's already mapped 160213237Sgonzo */ 161213237Sgonzo if (sc->sc_pins_mapped[i]) { 162213237Sgonzo device_printf(child, 163213237Sgonzo "warning: pin %d is already mapped\n", i); 164213237Sgonzo return (EINVAL); 165213237Sgonzo } 166213237Sgonzo sc->sc_pins_mapped[i] = 1; 167213237Sgonzo } 168213237Sgonzo 169213237Sgonzo return (0); 170213237Sgonzo} 171213237Sgonzo 172213237Sgonzostatic int 173213237Sgonzogpiobus_probe(device_t dev) 174213237Sgonzo{ 175213237Sgonzo device_set_desc(dev, "GPIO bus"); 176213237Sgonzo return (0); 177213237Sgonzo} 178213237Sgonzo 179213237Sgonzostatic int 180213237Sgonzogpiobus_attach(device_t dev) 181213237Sgonzo{ 182213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 183213237Sgonzo int res; 184213237Sgonzo 185213237Sgonzo sc->sc_busdev = dev; 186213237Sgonzo sc->sc_dev = device_get_parent(dev); 187213237Sgonzo res = GPIO_PIN_MAX(sc->sc_dev, &sc->sc_npins); 188213237Sgonzo if (res) 189213237Sgonzo return (ENXIO); 190213237Sgonzo 191213237Sgonzo /* 192213237Sgonzo * Increase to get number of pins 193213237Sgonzo */ 194213237Sgonzo sc->sc_npins++; 195213237Sgonzo 196213237Sgonzo KASSERT(sc->sc_npins != 0, ("GPIO device with no pins")); 197213237Sgonzo 198213237Sgonzo sc->sc_pins_mapped = malloc(sizeof(int) * sc->sc_npins, M_DEVBUF, 199213237Sgonzo M_NOWAIT | M_ZERO); 200213237Sgonzo 201213237Sgonzo if (!sc->sc_pins_mapped) 202213237Sgonzo return (ENOMEM); 203213237Sgonzo 204213237Sgonzo /* init bus lock */ 205213237Sgonzo GPIOBUS_LOCK_INIT(sc); 206213237Sgonzo 207213237Sgonzo /* 208213237Sgonzo * Get parent's pins and mark them as unmapped 209213237Sgonzo */ 210213237Sgonzo bus_enumerate_hinted_children(dev); 211213237Sgonzo return (bus_generic_attach(dev)); 212213237Sgonzo} 213213237Sgonzo 214213237Sgonzo/* 215213237Sgonzo * Since this is not a self-enumerating bus, and since we always add 216213237Sgonzo * children in attach, we have to always delete children here. 217213237Sgonzo */ 218213237Sgonzostatic int 219213237Sgonzogpiobus_detach(device_t dev) 220213237Sgonzo{ 221213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 222227701Shselasky int err; 223213237Sgonzo 224213237Sgonzo KASSERT(mtx_initialized(&sc->sc_mtx), 225213237Sgonzo ("gpiobus mutex not initialized")); 226213237Sgonzo GPIOBUS_LOCK_DESTROY(sc); 227213237Sgonzo 228213237Sgonzo if ((err = bus_generic_detach(dev)) != 0) 229213237Sgonzo return (err); 230213237Sgonzo 231227701Shselasky /* detach and delete all children */ 232227849Shselasky device_delete_children(dev); 233227701Shselasky 234213237Sgonzo if (sc->sc_pins_mapped) { 235213237Sgonzo free(sc->sc_pins_mapped, M_DEVBUF); 236213237Sgonzo sc->sc_pins_mapped = NULL; 237213237Sgonzo } 238213237Sgonzo 239213237Sgonzo return (0); 240213237Sgonzo} 241213237Sgonzo 242213237Sgonzostatic int 243213237Sgonzogpiobus_suspend(device_t dev) 244213237Sgonzo{ 245213237Sgonzo 246213237Sgonzo return (bus_generic_suspend(dev)); 247213237Sgonzo} 248213237Sgonzo 249213237Sgonzostatic int 250213237Sgonzogpiobus_resume(device_t dev) 251213237Sgonzo{ 252213237Sgonzo 253213237Sgonzo return (bus_generic_resume(dev)); 254213237Sgonzo} 255213237Sgonzo 256213237Sgonzostatic int 257213237Sgonzogpiobus_print_child(device_t dev, device_t child) 258213237Sgonzo{ 259213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 260213237Sgonzo int retval = 0; 261213237Sgonzo 262213237Sgonzo retval += bus_print_child_header(dev, child); 263213237Sgonzo retval += printf(" at pin(s) "); 264213237Sgonzo gpiobus_print_pins(devi); 265213237Sgonzo retval += bus_print_child_footer(dev, child); 266213237Sgonzo 267213237Sgonzo return (retval); 268213237Sgonzo} 269213237Sgonzo 270213237Sgonzostatic int 271213237Sgonzogpiobus_child_location_str(device_t bus, device_t child, char *buf, 272213237Sgonzo size_t buflen) 273213237Sgonzo{ 274213237Sgonzo 275213237Sgonzo snprintf(buf, buflen, "pins=?"); 276213237Sgonzo return (0); 277213237Sgonzo} 278213237Sgonzo 279213237Sgonzostatic int 280213237Sgonzogpiobus_child_pnpinfo_str(device_t bus, device_t child, char *buf, 281213237Sgonzo size_t buflen) 282213237Sgonzo{ 283213237Sgonzo 284213237Sgonzo *buf = '\0'; 285213237Sgonzo return (0); 286213237Sgonzo} 287213237Sgonzo 288213237Sgonzostatic device_t 289213237Sgonzogpiobus_add_child(device_t dev, u_int order, const char *name, int unit) 290213237Sgonzo{ 291213237Sgonzo device_t child; 292213237Sgonzo struct gpiobus_ivar *devi; 293213237Sgonzo 294213237Sgonzo child = device_add_child_ordered(dev, order, name, unit); 295213237Sgonzo if (child == NULL) 296213237Sgonzo return (child); 297213237Sgonzo devi = malloc(sizeof(struct gpiobus_ivar), M_DEVBUF, M_NOWAIT | M_ZERO); 298213237Sgonzo if (devi == NULL) { 299213237Sgonzo device_delete_child(dev, child); 300213237Sgonzo return (0); 301213237Sgonzo } 302213237Sgonzo device_set_ivars(child, devi); 303213237Sgonzo return (child); 304213237Sgonzo} 305213237Sgonzo 306213237Sgonzostatic void 307213237Sgonzogpiobus_hinted_child(device_t bus, const char *dname, int dunit) 308213237Sgonzo{ 309213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(bus); 310213237Sgonzo struct gpiobus_ivar *devi; 311213237Sgonzo device_t child; 312213237Sgonzo int pins; 313213237Sgonzo 314213237Sgonzo 315213237Sgonzo child = BUS_ADD_CHILD(bus, 0, dname, dunit); 316213237Sgonzo devi = GPIOBUS_IVAR(child); 317213237Sgonzo resource_int_value(dname, dunit, "pins", &pins); 318213237Sgonzo if (gpiobus_parse_pins(sc, child, pins)) 319213237Sgonzo device_delete_child(bus, child); 320213237Sgonzo} 321213237Sgonzo 322213237Sgonzostatic void 323213237Sgonzogpiobus_lock_bus(device_t busdev) 324213237Sgonzo{ 325213237Sgonzo struct gpiobus_softc *sc; 326213237Sgonzo 327213237Sgonzo sc = device_get_softc(busdev); 328213237Sgonzo GPIOBUS_ASSERT_UNLOCKED(sc); 329213237Sgonzo GPIOBUS_LOCK(sc); 330213237Sgonzo} 331213237Sgonzo 332213237Sgonzostatic void 333213237Sgonzogpiobus_unlock_bus(device_t busdev) 334213237Sgonzo{ 335213237Sgonzo struct gpiobus_softc *sc; 336213237Sgonzo 337213237Sgonzo sc = device_get_softc(busdev); 338213237Sgonzo GPIOBUS_ASSERT_LOCKED(sc); 339213237Sgonzo GPIOBUS_UNLOCK(sc); 340213237Sgonzo} 341213237Sgonzo 342213237Sgonzostatic void 343213237Sgonzogpiobus_acquire_bus(device_t busdev, device_t child) 344213237Sgonzo{ 345213237Sgonzo struct gpiobus_softc *sc; 346213237Sgonzo 347213237Sgonzo sc = device_get_softc(busdev); 348213237Sgonzo GPIOBUS_ASSERT_LOCKED(sc); 349213237Sgonzo 350213237Sgonzo if (sc->sc_owner) 351243464Sgonzo panic("gpiobus: cannot serialize the access to device."); 352213237Sgonzo sc->sc_owner = child; 353213237Sgonzo} 354213237Sgonzo 355213237Sgonzostatic void 356213237Sgonzogpiobus_release_bus(device_t busdev, device_t child) 357213237Sgonzo{ 358213237Sgonzo struct gpiobus_softc *sc; 359213237Sgonzo 360213237Sgonzo sc = device_get_softc(busdev); 361213237Sgonzo GPIOBUS_ASSERT_LOCKED(sc); 362213237Sgonzo 363213237Sgonzo if (!sc->sc_owner) 364243464Sgonzo panic("gpiobus: releasing unowned bus."); 365213237Sgonzo if (sc->sc_owner != child) 366243464Sgonzo panic("gpiobus: you don't own the bus. game over."); 367213237Sgonzo 368213237Sgonzo sc->sc_owner = NULL; 369213237Sgonzo} 370213237Sgonzo 371213237Sgonzostatic int 372213237Sgonzogpiobus_pin_setflags(device_t dev, device_t child, uint32_t pin, 373213237Sgonzo uint32_t flags) 374213237Sgonzo{ 375213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 376213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 377213237Sgonzo 378213237Sgonzo if (pin >= devi->npins) 379213237Sgonzo return (EINVAL); 380213237Sgonzo 381213237Sgonzo return GPIO_PIN_SETFLAGS(sc->sc_dev, devi->pins[pin], flags); 382213237Sgonzo} 383213237Sgonzo 384213237Sgonzostatic int 385213237Sgonzogpiobus_pin_getflags(device_t dev, device_t child, uint32_t pin, 386213237Sgonzo uint32_t *flags) 387213237Sgonzo{ 388213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 389213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 390213237Sgonzo 391213237Sgonzo if (pin >= devi->npins) 392213237Sgonzo return (EINVAL); 393213237Sgonzo 394213237Sgonzo return GPIO_PIN_GETFLAGS(sc->sc_dev, devi->pins[pin], flags); 395213237Sgonzo} 396213237Sgonzo 397213237Sgonzostatic int 398213237Sgonzogpiobus_pin_getcaps(device_t dev, device_t child, uint32_t pin, 399213237Sgonzo uint32_t *caps) 400213237Sgonzo{ 401213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 402213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 403213237Sgonzo 404213237Sgonzo if (pin >= devi->npins) 405213237Sgonzo return (EINVAL); 406213237Sgonzo 407213237Sgonzo return GPIO_PIN_GETCAPS(sc->sc_dev, devi->pins[pin], caps); 408213237Sgonzo} 409213237Sgonzo 410213237Sgonzostatic int 411213237Sgonzogpiobus_pin_set(device_t dev, device_t child, uint32_t pin, 412213237Sgonzo unsigned int value) 413213237Sgonzo{ 414213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 415213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 416213237Sgonzo 417213237Sgonzo if (pin >= devi->npins) 418213237Sgonzo return (EINVAL); 419213237Sgonzo 420213237Sgonzo return GPIO_PIN_SET(sc->sc_dev, devi->pins[pin], value); 421213237Sgonzo} 422213237Sgonzo 423213237Sgonzostatic int 424213237Sgonzogpiobus_pin_get(device_t dev, device_t child, uint32_t pin, 425213237Sgonzo unsigned int *value) 426213237Sgonzo{ 427213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 428213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 429213237Sgonzo 430213237Sgonzo if (pin >= devi->npins) 431213237Sgonzo return (EINVAL); 432213237Sgonzo 433213237Sgonzo return GPIO_PIN_GET(sc->sc_dev, devi->pins[pin], value); 434213237Sgonzo} 435213237Sgonzo 436213237Sgonzostatic int 437213237Sgonzogpiobus_pin_toggle(device_t dev, device_t child, uint32_t pin) 438213237Sgonzo{ 439213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 440213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 441213237Sgonzo 442213237Sgonzo if (pin >= devi->npins) 443213237Sgonzo return (EINVAL); 444213237Sgonzo 445213237Sgonzo return GPIO_PIN_TOGGLE(sc->sc_dev, devi->pins[pin]); 446213237Sgonzo} 447213237Sgonzo 448213237Sgonzostatic device_method_t gpiobus_methods[] = { 449213237Sgonzo /* Device interface */ 450213237Sgonzo DEVMETHOD(device_probe, gpiobus_probe), 451213237Sgonzo DEVMETHOD(device_attach, gpiobus_attach), 452213237Sgonzo DEVMETHOD(device_detach, gpiobus_detach), 453213237Sgonzo DEVMETHOD(device_shutdown, bus_generic_shutdown), 454213237Sgonzo DEVMETHOD(device_suspend, gpiobus_suspend), 455213237Sgonzo DEVMETHOD(device_resume, gpiobus_resume), 456213237Sgonzo 457213237Sgonzo /* Bus interface */ 458213237Sgonzo DEVMETHOD(bus_add_child, gpiobus_add_child), 459213237Sgonzo DEVMETHOD(bus_print_child, gpiobus_print_child), 460213237Sgonzo DEVMETHOD(bus_child_pnpinfo_str, gpiobus_child_pnpinfo_str), 461213237Sgonzo DEVMETHOD(bus_child_location_str, gpiobus_child_location_str), 462213237Sgonzo DEVMETHOD(bus_hinted_child, gpiobus_hinted_child), 463213237Sgonzo 464213237Sgonzo /* GPIO protocol */ 465213237Sgonzo DEVMETHOD(gpiobus_lock_bus, gpiobus_lock_bus), 466213237Sgonzo DEVMETHOD(gpiobus_unlock_bus, gpiobus_unlock_bus), 467213237Sgonzo DEVMETHOD(gpiobus_acquire_bus, gpiobus_acquire_bus), 468213237Sgonzo DEVMETHOD(gpiobus_release_bus, gpiobus_release_bus), 469213237Sgonzo DEVMETHOD(gpiobus_pin_getflags, gpiobus_pin_getflags), 470213237Sgonzo DEVMETHOD(gpiobus_pin_getcaps, gpiobus_pin_getcaps), 471213237Sgonzo DEVMETHOD(gpiobus_pin_setflags, gpiobus_pin_setflags), 472213237Sgonzo DEVMETHOD(gpiobus_pin_get, gpiobus_pin_get), 473213237Sgonzo DEVMETHOD(gpiobus_pin_set, gpiobus_pin_set), 474213237Sgonzo DEVMETHOD(gpiobus_pin_toggle, gpiobus_pin_toggle), 475213237Sgonzo 476227843Smarius DEVMETHOD_END 477213237Sgonzo}; 478213237Sgonzo 479215142Sthompsadriver_t gpiobus_driver = { 480213237Sgonzo "gpiobus", 481213237Sgonzo gpiobus_methods, 482213237Sgonzo sizeof(struct gpiobus_softc) 483213237Sgonzo}; 484213237Sgonzo 485213237Sgonzodevclass_t gpiobus_devclass; 486213237Sgonzo 487213237SgonzoDRIVER_MODULE(gpiobus, gpio, gpiobus_driver, gpiobus_devclass, 0, 0); 488213237SgonzoMODULE_VERSION(gpiobus, 1); 489