gpiobus.c revision 227701
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 227701 2011-11-19 10:11:50Z hselasky $"); 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 */ 232227701Shselasky device_delete_all_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 // struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 275213237Sgonzo 276213237Sgonzo snprintf(buf, buflen, "pins=?"); 277213237Sgonzo return (0); 278213237Sgonzo} 279213237Sgonzo 280213237Sgonzostatic int 281213237Sgonzogpiobus_child_pnpinfo_str(device_t bus, device_t child, char *buf, 282213237Sgonzo size_t buflen) 283213237Sgonzo{ 284213237Sgonzo 285213237Sgonzo *buf = '\0'; 286213237Sgonzo return (0); 287213237Sgonzo} 288213237Sgonzo 289213237Sgonzostatic device_t 290213237Sgonzogpiobus_add_child(device_t dev, u_int order, const char *name, int unit) 291213237Sgonzo{ 292213237Sgonzo device_t child; 293213237Sgonzo struct gpiobus_ivar *devi; 294213237Sgonzo 295213237Sgonzo child = device_add_child_ordered(dev, order, name, unit); 296213237Sgonzo if (child == NULL) 297213237Sgonzo return (child); 298213237Sgonzo devi = malloc(sizeof(struct gpiobus_ivar), M_DEVBUF, M_NOWAIT | M_ZERO); 299213237Sgonzo if (devi == NULL) { 300213237Sgonzo device_delete_child(dev, child); 301213237Sgonzo return (0); 302213237Sgonzo } 303213237Sgonzo device_set_ivars(child, devi); 304213237Sgonzo return (child); 305213237Sgonzo} 306213237Sgonzo 307213237Sgonzostatic void 308213237Sgonzogpiobus_hinted_child(device_t bus, const char *dname, int dunit) 309213237Sgonzo{ 310213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(bus); 311213237Sgonzo struct gpiobus_ivar *devi; 312213237Sgonzo device_t child; 313213237Sgonzo int pins; 314213237Sgonzo 315213237Sgonzo 316213237Sgonzo child = BUS_ADD_CHILD(bus, 0, dname, dunit); 317213237Sgonzo devi = GPIOBUS_IVAR(child); 318213237Sgonzo resource_int_value(dname, dunit, "pins", &pins); 319213237Sgonzo if (gpiobus_parse_pins(sc, child, pins)) 320213237Sgonzo device_delete_child(bus, child); 321213237Sgonzo} 322213237Sgonzo 323213237Sgonzostatic void 324213237Sgonzogpiobus_lock_bus(device_t busdev) 325213237Sgonzo{ 326213237Sgonzo struct gpiobus_softc *sc; 327213237Sgonzo 328213237Sgonzo sc = device_get_softc(busdev); 329213237Sgonzo GPIOBUS_ASSERT_UNLOCKED(sc); 330213237Sgonzo GPIOBUS_LOCK(sc); 331213237Sgonzo} 332213237Sgonzo 333213237Sgonzostatic void 334213237Sgonzogpiobus_unlock_bus(device_t busdev) 335213237Sgonzo{ 336213237Sgonzo struct gpiobus_softc *sc; 337213237Sgonzo 338213237Sgonzo sc = device_get_softc(busdev); 339213237Sgonzo GPIOBUS_ASSERT_LOCKED(sc); 340213237Sgonzo GPIOBUS_UNLOCK(sc); 341213237Sgonzo} 342213237Sgonzo 343213237Sgonzostatic void 344213237Sgonzogpiobus_acquire_bus(device_t busdev, device_t child) 345213237Sgonzo{ 346213237Sgonzo struct gpiobus_softc *sc; 347213237Sgonzo 348213237Sgonzo sc = device_get_softc(busdev); 349213237Sgonzo GPIOBUS_ASSERT_LOCKED(sc); 350213237Sgonzo 351213237Sgonzo if (sc->sc_owner) 352213237Sgonzo panic("rb_cpldbus: cannot serialize the access to device."); 353213237Sgonzo sc->sc_owner = child; 354213237Sgonzo} 355213237Sgonzo 356213237Sgonzostatic void 357213237Sgonzogpiobus_release_bus(device_t busdev, device_t child) 358213237Sgonzo{ 359213237Sgonzo struct gpiobus_softc *sc; 360213237Sgonzo 361213237Sgonzo sc = device_get_softc(busdev); 362213237Sgonzo GPIOBUS_ASSERT_LOCKED(sc); 363213237Sgonzo 364213237Sgonzo if (!sc->sc_owner) 365213237Sgonzo panic("rb_cpldbus: releasing unowned bus."); 366213237Sgonzo if (sc->sc_owner != child) 367213237Sgonzo panic("rb_cpldbus: you don't own the bus. game over."); 368213237Sgonzo 369213237Sgonzo sc->sc_owner = NULL; 370213237Sgonzo} 371213237Sgonzo 372213237Sgonzostatic int 373213237Sgonzogpiobus_pin_setflags(device_t dev, device_t child, uint32_t pin, 374213237Sgonzo uint32_t flags) 375213237Sgonzo{ 376213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 377213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 378213237Sgonzo 379213237Sgonzo if (pin >= devi->npins) 380213237Sgonzo return (EINVAL); 381213237Sgonzo 382213237Sgonzo return GPIO_PIN_SETFLAGS(sc->sc_dev, devi->pins[pin], flags); 383213237Sgonzo} 384213237Sgonzo 385213237Sgonzostatic int 386213237Sgonzogpiobus_pin_getflags(device_t dev, device_t child, uint32_t pin, 387213237Sgonzo uint32_t *flags) 388213237Sgonzo{ 389213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 390213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 391213237Sgonzo 392213237Sgonzo if (pin >= devi->npins) 393213237Sgonzo return (EINVAL); 394213237Sgonzo 395213237Sgonzo return GPIO_PIN_GETFLAGS(sc->sc_dev, devi->pins[pin], flags); 396213237Sgonzo} 397213237Sgonzo 398213237Sgonzostatic int 399213237Sgonzogpiobus_pin_getcaps(device_t dev, device_t child, uint32_t pin, 400213237Sgonzo uint32_t *caps) 401213237Sgonzo{ 402213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 403213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 404213237Sgonzo 405213237Sgonzo if (pin >= devi->npins) 406213237Sgonzo return (EINVAL); 407213237Sgonzo 408213237Sgonzo return GPIO_PIN_GETCAPS(sc->sc_dev, devi->pins[pin], caps); 409213237Sgonzo} 410213237Sgonzo 411213237Sgonzostatic int 412213237Sgonzogpiobus_pin_set(device_t dev, device_t child, uint32_t pin, 413213237Sgonzo unsigned int value) 414213237Sgonzo{ 415213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 416213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 417213237Sgonzo 418213237Sgonzo if (pin >= devi->npins) 419213237Sgonzo return (EINVAL); 420213237Sgonzo 421213237Sgonzo return GPIO_PIN_SET(sc->sc_dev, devi->pins[pin], value); 422213237Sgonzo} 423213237Sgonzo 424213237Sgonzostatic int 425213237Sgonzogpiobus_pin_get(device_t dev, device_t child, uint32_t pin, 426213237Sgonzo unsigned int *value) 427213237Sgonzo{ 428213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 429213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 430213237Sgonzo 431213237Sgonzo if (pin >= devi->npins) 432213237Sgonzo return (EINVAL); 433213237Sgonzo 434213237Sgonzo return GPIO_PIN_GET(sc->sc_dev, devi->pins[pin], value); 435213237Sgonzo} 436213237Sgonzo 437213237Sgonzostatic int 438213237Sgonzogpiobus_pin_toggle(device_t dev, device_t child, uint32_t pin) 439213237Sgonzo{ 440213237Sgonzo struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev); 441213237Sgonzo struct gpiobus_ivar *devi = GPIOBUS_IVAR(child); 442213237Sgonzo 443213237Sgonzo if (pin >= devi->npins) 444213237Sgonzo return (EINVAL); 445213237Sgonzo 446213237Sgonzo return GPIO_PIN_TOGGLE(sc->sc_dev, devi->pins[pin]); 447213237Sgonzo} 448213237Sgonzo 449213237Sgonzostatic device_method_t gpiobus_methods[] = { 450213237Sgonzo /* Device interface */ 451213237Sgonzo DEVMETHOD(device_probe, gpiobus_probe), 452213237Sgonzo DEVMETHOD(device_attach, gpiobus_attach), 453213237Sgonzo DEVMETHOD(device_detach, gpiobus_detach), 454213237Sgonzo DEVMETHOD(device_shutdown, bus_generic_shutdown), 455213237Sgonzo DEVMETHOD(device_suspend, gpiobus_suspend), 456213237Sgonzo DEVMETHOD(device_resume, gpiobus_resume), 457213237Sgonzo 458213237Sgonzo /* Bus interface */ 459213237Sgonzo DEVMETHOD(bus_add_child, gpiobus_add_child), 460213237Sgonzo DEVMETHOD(bus_print_child, gpiobus_print_child), 461213237Sgonzo DEVMETHOD(bus_driver_added, bus_generic_driver_added), 462213237Sgonzo DEVMETHOD(bus_child_pnpinfo_str, gpiobus_child_pnpinfo_str), 463213237Sgonzo DEVMETHOD(bus_child_location_str, gpiobus_child_location_str), 464213237Sgonzo DEVMETHOD(bus_hinted_child, gpiobus_hinted_child), 465213237Sgonzo 466213237Sgonzo /* GPIO protocol */ 467213237Sgonzo DEVMETHOD(gpiobus_lock_bus, gpiobus_lock_bus), 468213237Sgonzo DEVMETHOD(gpiobus_unlock_bus, gpiobus_unlock_bus), 469213237Sgonzo DEVMETHOD(gpiobus_acquire_bus, gpiobus_acquire_bus), 470213237Sgonzo DEVMETHOD(gpiobus_release_bus, gpiobus_release_bus), 471213237Sgonzo DEVMETHOD(gpiobus_pin_getflags, gpiobus_pin_getflags), 472213237Sgonzo DEVMETHOD(gpiobus_pin_getcaps, gpiobus_pin_getcaps), 473213237Sgonzo DEVMETHOD(gpiobus_pin_setflags, gpiobus_pin_setflags), 474213237Sgonzo DEVMETHOD(gpiobus_pin_get, gpiobus_pin_get), 475213237Sgonzo DEVMETHOD(gpiobus_pin_set, gpiobus_pin_set), 476213237Sgonzo DEVMETHOD(gpiobus_pin_toggle, gpiobus_pin_toggle), 477213237Sgonzo 478213237Sgonzo { 0, 0 } 479213237Sgonzo}; 480213237Sgonzo 481215142Sthompsadriver_t gpiobus_driver = { 482213237Sgonzo "gpiobus", 483213237Sgonzo gpiobus_methods, 484213237Sgonzo sizeof(struct gpiobus_softc) 485213237Sgonzo}; 486213237Sgonzo 487213237Sgonzodevclass_t gpiobus_devclass; 488213237Sgonzo 489213237SgonzoDRIVER_MODULE(gpiobus, gpio, gpiobus_driver, gpiobus_devclass, 0, 0); 490213237SgonzoMODULE_VERSION(gpiobus, 1); 491