diff options
author | loos <loos@FreeBSD.org> | 2015-01-31 19:32:14 +0000 |
---|---|---|
committer | loos <loos@FreeBSD.org> | 2015-01-31 19:32:14 +0000 |
commit | 5e1a5939929b3ae8ec6f7e44ddd1b51b3c542cc6 (patch) | |
tree | 4edc5f6a6f697cb6c391fc6f0800ce835ba4024d /sys/arm/broadcom/bcm2835/bcm2835_gpio.c | |
parent | 92c5395dfebe86676461d4e940ccf2b4249770e5 (diff) | |
download | FreeBSD-src-5e1a5939929b3ae8ec6f7e44ddd1b51b3c542cc6.zip FreeBSD-src-5e1a5939929b3ae8ec6f7e44ddd1b51b3c542cc6.tar.gz |
Implement GPIO_GET_BUS() method for all GPIO drivers.
Add helper routines to deal with attach and detach of gpiobus and gpioc
devices that are common to all drivers.
Diffstat (limited to 'sys/arm/broadcom/bcm2835/bcm2835_gpio.c')
-rw-r--r-- | sys/arm/broadcom/bcm2835/bcm2835_gpio.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c index 43a1ddc..2a3cebd 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include <machine/intr.h> #include <dev/fdt/fdt_common.h> +#include <dev/gpio/gpiobusvar.h> #include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_bus_subr.h> @@ -83,6 +84,7 @@ struct bcm_gpio_sysctl { struct bcm_gpio_softc { device_t sc_dev; + device_t sc_busdev; struct mtx sc_mtx; struct resource * sc_res[BCM_GPIO_IRQS + 1]; bus_space_tag_t sc_bst; @@ -317,6 +319,16 @@ bcm_gpio_pin_configure(struct bcm_gpio_softc *sc, struct gpio_pin *pin, BCM_GPIO_UNLOCK(sc); } +static device_t +bcm_gpio_get_bus(device_t dev) +{ + struct bcm_gpio_softc *sc; + + sc = device_get_softc(dev); + + return (sc->sc_busdev); +} + static int bcm_gpio_pin_max(device_t dev, int *maxpin) { @@ -709,13 +721,12 @@ bcm_gpio_attach(device_t dev) i++; } sc->sc_gpio_npins = i; - bcm_gpio_sysctl_init(sc); + sc->sc_busdev = gpiobus_attach_bus(dev); + if (sc->sc_busdev == NULL) + goto fail; - device_add_child(dev, "gpioc", -1); - device_add_child(dev, "gpiobus", -1); - - return (bus_generic_attach(dev)); + return (0); fail: bus_release_resources(dev, bcm_gpio_res_spec, sc->sc_res); @@ -746,6 +757,7 @@ static device_method_t bcm_gpio_methods[] = { DEVMETHOD(device_detach, bcm_gpio_detach), /* GPIO protocol */ + DEVMETHOD(gpio_get_bus, bcm_gpio_get_bus), DEVMETHOD(gpio_pin_max, bcm_gpio_pin_max), DEVMETHOD(gpio_pin_getname, bcm_gpio_pin_getname), DEVMETHOD(gpio_pin_getflags, bcm_gpio_pin_getflags), |