2 * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <sys/param.h>
31 #include <sys/systm.h>
37 #include <sys/kernel.h>
38 #include <sys/malloc.h>
39 #include <sys/module.h>
41 #include <dev/gpio/gpiobusvar.h>
43 #include "gpiobus_if.h"
47 #define dprintf printf
49 #define dprintf(x, arg...)
52 static void gpiobus_print_pins(struct gpiobus_ivar *, char *, size_t);
53 static int gpiobus_parse_pins(struct gpiobus_softc *, device_t, int);
54 static int gpiobus_probe(device_t);
55 static int gpiobus_attach(device_t);
56 static int gpiobus_detach(device_t);
57 static int gpiobus_suspend(device_t);
58 static int gpiobus_resume(device_t);
59 static void gpiobus_probe_nomatch(device_t, device_t);
60 static int gpiobus_print_child(device_t, device_t);
61 static int gpiobus_child_location_str(device_t, device_t, char *, size_t);
62 static int gpiobus_child_pnpinfo_str(device_t, device_t, char *, size_t);
63 static device_t gpiobus_add_child(device_t, u_int, const char *, int);
64 static void gpiobus_hinted_child(device_t, const char *, int);
69 static int gpiobus_acquire_bus(device_t, device_t, int);
70 static void gpiobus_release_bus(device_t, device_t);
71 static int gpiobus_pin_setflags(device_t, device_t, uint32_t, uint32_t);
72 static int gpiobus_pin_getflags(device_t, device_t, uint32_t, uint32_t*);
73 static int gpiobus_pin_getcaps(device_t, device_t, uint32_t, uint32_t*);
74 static int gpiobus_pin_set(device_t, device_t, uint32_t, unsigned int);
75 static int gpiobus_pin_get(device_t, device_t, uint32_t, unsigned int*);
76 static int gpiobus_pin_toggle(device_t, device_t, uint32_t);
79 * XXX -> Move me to better place - gpio_subr.c?
80 * Also, this function must be changed when interrupt configuration
81 * data will be moved into struct resource.
86 gpio_alloc_intr_resource(device_t consumer_dev, int *rid, u_int alloc_flags,
87 gpio_pin_t pin, uint32_t intr_mode)
90 struct intr_map_data_gpio *gpio_data;
93 gpio_data = (struct intr_map_data_gpio *)intr_alloc_map_data(
94 INTR_MAP_DATA_GPIO, sizeof(*gpio_data), M_WAITOK | M_ZERO);
95 gpio_data->gpio_pin_num = pin->pin;
96 gpio_data->gpio_pin_flags = pin->flags;
97 gpio_data->gpio_intr_mode = intr_mode;
99 irq = intr_map_irq(pin->dev, 0, (struct intr_map_data *)gpio_data);
100 res = bus_alloc_resource(consumer_dev, SYS_RES_IRQ, rid, irq, irq, 1,
103 intr_free_intr_map_data((struct intr_map_data *)gpio_data);
106 rman_set_virtual(res, gpio_data);
111 gpio_alloc_intr_resource(device_t consumer_dev, int *rid, u_int alloc_flags,
112 gpio_pin_t pin, uint32_t intr_mode)
120 gpio_check_flags(uint32_t caps, uint32_t flags)
123 /* Filter unwanted flags. */
126 /* Cannot mix input/output together. */
127 if (flags & GPIO_PIN_INPUT && flags & GPIO_PIN_OUTPUT)
129 /* Cannot mix pull-up/pull-down together. */
130 if (flags & GPIO_PIN_PULLUP && flags & GPIO_PIN_PULLDOWN)
137 gpiobus_print_pins(struct gpiobus_ivar *devi, char *buf, size_t buflen)
140 int i, range_start, range_stop, need_coma;
142 if (devi->npins == 0)
146 range_start = range_stop = devi->pins[0];
147 for (i = 1; i < devi->npins; i++) {
148 if (devi->pins[i] != (range_stop + 1)) {
150 strlcat(buf, ",", buflen);
151 memset(tmp, 0, sizeof(tmp));
152 if (range_start != range_stop)
153 snprintf(tmp, sizeof(tmp) - 1, "%d-%d",
154 range_start, range_stop);
156 snprintf(tmp, sizeof(tmp) - 1, "%d",
158 strlcat(buf, tmp, buflen);
160 range_start = range_stop = devi->pins[i];
168 strlcat(buf, ",", buflen);
169 memset(tmp, 0, sizeof(tmp));
170 if (range_start != range_stop)
171 snprintf(tmp, sizeof(tmp) - 1, "%d-%d",
172 range_start, range_stop);
174 snprintf(tmp, sizeof(tmp) - 1, "%d",
176 strlcat(buf, tmp, buflen);
180 gpiobus_attach_bus(device_t dev)
184 busdev = device_add_child(dev, "gpiobus", -1);
187 if (device_add_child(dev, "gpioc", -1) == NULL) {
188 device_delete_child(dev, busdev);
192 ofw_gpiobus_register_provider(dev);
194 bus_generic_attach(dev);
200 gpiobus_detach_bus(device_t dev)
205 ofw_gpiobus_unregister_provider(dev);
207 err = bus_generic_detach(dev);
211 return (device_delete_children(dev));
215 gpiobus_init_softc(device_t dev)
217 struct gpiobus_softc *sc;
219 sc = GPIOBUS_SOFTC(dev);
221 sc->sc_dev = device_get_parent(dev);
222 sc->sc_intr_rman.rm_type = RMAN_ARRAY;
223 sc->sc_intr_rman.rm_descr = "GPIO Interrupts";
224 if (rman_init(&sc->sc_intr_rman) != 0 ||
225 rman_manage_region(&sc->sc_intr_rman, 0, ~0) != 0)
226 panic("%s: failed to set up rman.", __func__);
228 if (GPIO_PIN_MAX(sc->sc_dev, &sc->sc_npins) != 0)
231 KASSERT(sc->sc_npins >= 0, ("GPIO device with no pins"));
233 /* Pins = GPIO_PIN_MAX() + 1 */
236 sc->sc_pins = malloc(sizeof(*sc->sc_pins) * sc->sc_npins, M_DEVBUF,
238 if (sc->sc_pins == NULL)
241 /* Initialize the bus lock. */
242 GPIOBUS_LOCK_INIT(sc);
248 gpiobus_alloc_ivars(struct gpiobus_ivar *devi)
251 /* Allocate pins and flags memory. */
252 devi->pins = malloc(sizeof(uint32_t) * devi->npins, M_DEVBUF,
254 if (devi->pins == NULL)
256 devi->flags = malloc(sizeof(uint32_t) * devi->npins, M_DEVBUF,
258 if (devi->flags == NULL) {
259 free(devi->pins, M_DEVBUF);
267 gpiobus_free_ivars(struct gpiobus_ivar *devi)
271 free(devi->flags, M_DEVBUF);
275 free(devi->pins, M_DEVBUF);
281 gpiobus_acquire_pin(device_t bus, uint32_t pin)
283 struct gpiobus_softc *sc;
285 sc = device_get_softc(bus);
286 /* Consistency check. */
287 if (pin >= sc->sc_npins) {
289 "invalid pin %d, max: %d\n", pin, sc->sc_npins - 1);
292 /* Mark pin as mapped and give warning if it's already mapped. */
293 if (sc->sc_pins[pin].mapped) {
294 device_printf(bus, "warning: pin %d is already mapped\n", pin);
297 sc->sc_pins[pin].mapped = 1;
302 /* Release mapped pin */
304 gpiobus_release_pin(device_t bus, uint32_t pin)
306 struct gpiobus_softc *sc;
308 sc = device_get_softc(bus);
309 /* Consistency check. */
310 if (pin >= sc->sc_npins) {
312 "gpiobus_acquire_pin: invalid pin %d, max=%d\n",
313 pin, sc->sc_npins - 1);
317 if (!sc->sc_pins[pin].mapped) {
318 device_printf(bus, "gpiobus_acquire_pin: pin %d is not mapped\n", pin);
321 sc->sc_pins[pin].mapped = 0;
327 gpiobus_parse_pins(struct gpiobus_softc *sc, device_t child, int mask)
329 struct gpiobus_ivar *devi = GPIOBUS_IVAR(child);
333 for (i = 0; i < 32; i++) {
338 device_printf(child, "empty pin mask\n");
342 if (gpiobus_alloc_ivars(devi) != 0) {
343 device_printf(child, "cannot allocate device ivars\n");
347 for (i = 0; i < 32; i++) {
348 if ((mask & (1 << i)) == 0)
350 /* Reserve the GPIO pin. */
351 if (gpiobus_acquire_pin(sc->sc_busdev, i) != 0) {
352 gpiobus_free_ivars(devi);
355 devi->pins[npins++] = i;
356 /* Use the child name as pin name. */
357 GPIOBUS_PIN_SETNAME(sc->sc_busdev, i,
358 device_get_nameunit(child));
365 gpiobus_probe(device_t dev)
367 device_set_desc(dev, "GPIO bus");
369 return (BUS_PROBE_GENERIC);
373 gpiobus_attach(device_t dev)
377 err = gpiobus_init_softc(dev);
382 * Get parent's pins and mark them as unmapped
384 bus_generic_probe(dev);
385 bus_enumerate_hinted_children(dev);
387 return (bus_generic_attach(dev));
391 * Since this is not a self-enumerating bus, and since we always add
392 * children in attach, we have to always delete children here.
395 gpiobus_detach(device_t dev)
397 struct gpiobus_softc *sc;
398 struct gpiobus_ivar *devi;
402 sc = GPIOBUS_SOFTC(dev);
403 KASSERT(mtx_initialized(&sc->sc_mtx),
404 ("gpiobus mutex not initialized"));
405 GPIOBUS_LOCK_DESTROY(sc);
407 if ((err = bus_generic_detach(dev)) != 0)
410 if ((err = device_get_children(dev, &devlist, &ndevs)) != 0)
412 for (i = 0; i < ndevs; i++) {
413 devi = GPIOBUS_IVAR(devlist[i]);
414 gpiobus_free_ivars(devi);
415 resource_list_free(&devi->rl);
416 free(devi, M_DEVBUF);
417 device_delete_child(dev, devlist[i]);
419 free(devlist, M_TEMP);
420 rman_fini(&sc->sc_intr_rman);
422 for (i = 0; i < sc->sc_npins; i++) {
423 if (sc->sc_pins[i].name != NULL)
424 free(sc->sc_pins[i].name, M_DEVBUF);
425 sc->sc_pins[i].name = NULL;
427 free(sc->sc_pins, M_DEVBUF);
435 gpiobus_suspend(device_t dev)
438 return (bus_generic_suspend(dev));
442 gpiobus_resume(device_t dev)
445 return (bus_generic_resume(dev));
449 gpiobus_probe_nomatch(device_t dev, device_t child)
452 struct gpiobus_ivar *devi;
454 devi = GPIOBUS_IVAR(child);
455 memset(pins, 0, sizeof(pins));
456 gpiobus_print_pins(devi, pins, sizeof(pins));
458 device_printf(dev, "<unknown device> at pins %s", pins);
460 device_printf(dev, "<unknown device> at pin %s", pins);
461 resource_list_print_type(&devi->rl, "irq", SYS_RES_IRQ, "%jd");
466 gpiobus_print_child(device_t dev, device_t child)
470 struct gpiobus_ivar *devi;
472 devi = GPIOBUS_IVAR(child);
473 memset(pins, 0, sizeof(pins));
474 retval += bus_print_child_header(dev, child);
475 if (devi->npins > 0) {
477 retval += printf(" at pins ");
479 retval += printf(" at pin ");
480 gpiobus_print_pins(devi, pins, sizeof(pins));
481 retval += printf("%s", pins);
483 resource_list_print_type(&devi->rl, "irq", SYS_RES_IRQ, "%jd");
484 retval += bus_print_child_footer(dev, child);
490 gpiobus_child_location_str(device_t bus, device_t child, char *buf,
493 struct gpiobus_ivar *devi;
495 devi = GPIOBUS_IVAR(child);
497 strlcpy(buf, "pins=", buflen);
499 strlcpy(buf, "pin=", buflen);
500 gpiobus_print_pins(devi, buf, buflen);
506 gpiobus_child_pnpinfo_str(device_t bus, device_t child, char *buf,
515 gpiobus_add_child(device_t dev, u_int order, const char *name, int unit)
518 struct gpiobus_ivar *devi;
520 child = device_add_child_ordered(dev, order, name, unit);
523 devi = malloc(sizeof(struct gpiobus_ivar), M_DEVBUF, M_NOWAIT | M_ZERO);
525 device_delete_child(dev, child);
528 resource_list_init(&devi->rl);
529 device_set_ivars(child, devi);
535 gpiobus_hinted_child(device_t bus, const char *dname, int dunit)
537 struct gpiobus_softc *sc = GPIOBUS_SOFTC(bus);
538 struct gpiobus_ivar *devi;
542 child = BUS_ADD_CHILD(bus, 0, dname, dunit);
543 devi = GPIOBUS_IVAR(child);
544 resource_int_value(dname, dunit, "pins", &pins);
545 if (gpiobus_parse_pins(sc, child, pins)) {
546 resource_list_free(&devi->rl);
547 free(devi, M_DEVBUF);
548 device_delete_child(bus, child);
550 if (resource_int_value(dname, dunit, "irq", &irq) == 0) {
551 if (bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1) != 0)
553 "warning: bus_set_resource() failed\n");
558 gpiobus_set_resource(device_t dev, device_t child, int type, int rid,
559 rman_res_t start, rman_res_t count)
561 struct gpiobus_ivar *devi;
562 struct resource_list_entry *rle;
564 dprintf("%s: entry (%p, %p, %d, %d, %p, %ld)\n",
565 __func__, dev, child, type, rid, (void *)(intptr_t)start, count);
566 devi = GPIOBUS_IVAR(child);
567 rle = resource_list_add(&devi->rl, type, rid, start,
568 start + count - 1, count);
575 static struct resource *
576 gpiobus_alloc_resource(device_t bus, device_t child, int type, int *rid,
577 rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
579 struct gpiobus_softc *sc;
581 struct resource_list *rl;
582 struct resource_list_entry *rle;
585 if (type != SYS_RES_IRQ)
587 isdefault = (RMAN_IS_DEFAULT_RANGE(start, end) && count == 1);
590 rl = BUS_GET_RESOURCE_LIST(bus, child);
593 rle = resource_list_find(rl, type, *rid);
596 if (rle->res != NULL)
597 panic("%s: resource entry is busy", __func__);
602 sc = device_get_softc(bus);
603 rv = rman_reserve_resource(&sc->sc_intr_rman, start, end, count, flags,
607 rman_set_rid(rv, *rid);
608 if ((flags & RF_ACTIVE) != 0 &&
609 bus_activate_resource(child, type, *rid, rv) != 0) {
610 rman_release_resource(rv);
618 gpiobus_release_resource(device_t bus __unused, device_t child, int type,
619 int rid, struct resource *r)
623 if (rman_get_flags(r) & RF_ACTIVE) {
624 error = bus_deactivate_resource(child, type, rid, r);
629 return (rman_release_resource(r));
632 static struct resource_list *
633 gpiobus_get_resource_list(device_t bus __unused, device_t child)
635 struct gpiobus_ivar *ivar;
637 ivar = GPIOBUS_IVAR(child);
643 gpiobus_acquire_bus(device_t busdev, device_t child, int how)
645 struct gpiobus_softc *sc;
647 sc = device_get_softc(busdev);
648 GPIOBUS_ASSERT_UNLOCKED(sc);
650 if (sc->sc_owner != NULL) {
651 if (sc->sc_owner == child)
652 panic("%s: %s still owns the bus.",
653 device_get_nameunit(busdev),
654 device_get_nameunit(child));
655 if (how == GPIOBUS_DONTWAIT) {
657 return (EWOULDBLOCK);
659 while (sc->sc_owner != NULL)
660 mtx_sleep(sc, &sc->sc_mtx, 0, "gpiobuswait", 0);
662 sc->sc_owner = child;
669 gpiobus_release_bus(device_t busdev, device_t child)
671 struct gpiobus_softc *sc;
673 sc = device_get_softc(busdev);
674 GPIOBUS_ASSERT_UNLOCKED(sc);
676 if (sc->sc_owner == NULL)
677 panic("%s: %s releasing unowned bus.",
678 device_get_nameunit(busdev),
679 device_get_nameunit(child));
680 if (sc->sc_owner != child)
681 panic("%s: %s trying to release bus owned by %s",
682 device_get_nameunit(busdev),
683 device_get_nameunit(child),
684 device_get_nameunit(sc->sc_owner));
691 gpiobus_pin_setflags(device_t dev, device_t child, uint32_t pin,
694 struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev);
695 struct gpiobus_ivar *devi = GPIOBUS_IVAR(child);
698 if (pin >= devi->npins)
700 if (GPIO_PIN_GETCAPS(sc->sc_dev, devi->pins[pin], &caps) != 0)
702 if (gpio_check_flags(caps, flags) != 0)
705 return (GPIO_PIN_SETFLAGS(sc->sc_dev, devi->pins[pin], flags));
709 gpiobus_pin_getflags(device_t dev, device_t child, uint32_t pin,
712 struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev);
713 struct gpiobus_ivar *devi = GPIOBUS_IVAR(child);
715 if (pin >= devi->npins)
718 return GPIO_PIN_GETFLAGS(sc->sc_dev, devi->pins[pin], flags);
722 gpiobus_pin_getcaps(device_t dev, device_t child, uint32_t pin,
725 struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev);
726 struct gpiobus_ivar *devi = GPIOBUS_IVAR(child);
728 if (pin >= devi->npins)
731 return GPIO_PIN_GETCAPS(sc->sc_dev, devi->pins[pin], caps);
735 gpiobus_pin_set(device_t dev, device_t child, uint32_t pin,
738 struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev);
739 struct gpiobus_ivar *devi = GPIOBUS_IVAR(child);
741 if (pin >= devi->npins)
744 return GPIO_PIN_SET(sc->sc_dev, devi->pins[pin], value);
748 gpiobus_pin_get(device_t dev, device_t child, uint32_t pin,
751 struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev);
752 struct gpiobus_ivar *devi = GPIOBUS_IVAR(child);
754 if (pin >= devi->npins)
757 return GPIO_PIN_GET(sc->sc_dev, devi->pins[pin], value);
761 gpiobus_pin_toggle(device_t dev, device_t child, uint32_t pin)
763 struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev);
764 struct gpiobus_ivar *devi = GPIOBUS_IVAR(child);
766 if (pin >= devi->npins)
769 return GPIO_PIN_TOGGLE(sc->sc_dev, devi->pins[pin]);
773 gpiobus_pin_getname(device_t dev, uint32_t pin, char *name)
775 struct gpiobus_softc *sc;
777 sc = GPIOBUS_SOFTC(dev);
778 if (pin > sc->sc_npins)
780 /* Did we have a name for this pin ? */
781 if (sc->sc_pins[pin].name != NULL) {
782 memcpy(name, sc->sc_pins[pin].name, GPIOMAXNAME);
786 /* Return the default pin name. */
787 return (GPIO_PIN_GETNAME(device_get_parent(dev), pin, name));
791 gpiobus_pin_setname(device_t dev, uint32_t pin, const char *name)
793 struct gpiobus_softc *sc;
795 sc = GPIOBUS_SOFTC(dev);
796 if (pin > sc->sc_npins)
800 /* Save the pin name. */
801 if (sc->sc_pins[pin].name == NULL)
802 sc->sc_pins[pin].name = malloc(GPIOMAXNAME, M_DEVBUF,
804 strlcpy(sc->sc_pins[pin].name, name, GPIOMAXNAME);
809 static device_method_t gpiobus_methods[] = {
810 /* Device interface */
811 DEVMETHOD(device_probe, gpiobus_probe),
812 DEVMETHOD(device_attach, gpiobus_attach),
813 DEVMETHOD(device_detach, gpiobus_detach),
814 DEVMETHOD(device_shutdown, bus_generic_shutdown),
815 DEVMETHOD(device_suspend, gpiobus_suspend),
816 DEVMETHOD(device_resume, gpiobus_resume),
819 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
820 DEVMETHOD(bus_config_intr, bus_generic_config_intr),
821 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
822 DEVMETHOD(bus_set_resource, gpiobus_set_resource),
823 DEVMETHOD(bus_alloc_resource, gpiobus_alloc_resource),
824 DEVMETHOD(bus_release_resource, gpiobus_release_resource),
825 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
826 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
827 DEVMETHOD(bus_get_resource_list, gpiobus_get_resource_list),
828 DEVMETHOD(bus_add_child, gpiobus_add_child),
829 DEVMETHOD(bus_probe_nomatch, gpiobus_probe_nomatch),
830 DEVMETHOD(bus_print_child, gpiobus_print_child),
831 DEVMETHOD(bus_child_pnpinfo_str, gpiobus_child_pnpinfo_str),
832 DEVMETHOD(bus_child_location_str, gpiobus_child_location_str),
833 DEVMETHOD(bus_hinted_child, gpiobus_hinted_child),
836 DEVMETHOD(gpiobus_acquire_bus, gpiobus_acquire_bus),
837 DEVMETHOD(gpiobus_release_bus, gpiobus_release_bus),
838 DEVMETHOD(gpiobus_pin_getflags, gpiobus_pin_getflags),
839 DEVMETHOD(gpiobus_pin_getcaps, gpiobus_pin_getcaps),
840 DEVMETHOD(gpiobus_pin_setflags, gpiobus_pin_setflags),
841 DEVMETHOD(gpiobus_pin_get, gpiobus_pin_get),
842 DEVMETHOD(gpiobus_pin_set, gpiobus_pin_set),
843 DEVMETHOD(gpiobus_pin_toggle, gpiobus_pin_toggle),
844 DEVMETHOD(gpiobus_pin_getname, gpiobus_pin_getname),
845 DEVMETHOD(gpiobus_pin_setname, gpiobus_pin_setname),
850 driver_t gpiobus_driver = {
853 sizeof(struct gpiobus_softc)
856 devclass_t gpiobus_devclass;
858 EARLY_DRIVER_MODULE(gpiobus, gpio, gpiobus_driver, gpiobus_devclass, 0, 0,
859 BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
860 MODULE_VERSION(gpiobus, 1);