diff options
author | dim <dim@FreeBSD.org> | 2015-01-31 20:49:30 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-01-31 20:49:30 +0000 |
commit | de7d9ba1a12bd2fffbea1f10e14038dfdbf7e5bb (patch) | |
tree | b819b6880c6321c816607340c0c038316ef603c1 /sys/mips | |
parent | df65628757d0e5e83d144c151eccd7cc129d160a (diff) | |
download | FreeBSD-src-de7d9ba1a12bd2fffbea1f10e14038dfdbf7e5bb.zip FreeBSD-src-de7d9ba1a12bd2fffbea1f10e14038dfdbf7e5bb.tar.gz |
Merge ^/head r277975 through r277998.
Diffstat (limited to 'sys/mips')
-rw-r--r-- | sys/mips/atheros/ar71xx_gpio.c | 24 | ||||
-rw-r--r-- | sys/mips/atheros/ar71xx_gpiovar.h | 1 | ||||
-rw-r--r-- | sys/mips/cavium/octeon_gpio.c | 25 | ||||
-rw-r--r-- | sys/mips/cavium/octeon_gpiovar.h | 1 | ||||
-rw-r--r-- | sys/mips/rt305x/rt305x_gpio.c | 25 | ||||
-rw-r--r-- | sys/mips/rt305x/rt305x_gpiovar.h | 1 |
6 files changed, 63 insertions, 14 deletions
diff --git a/sys/mips/atheros/ar71xx_gpio.c b/sys/mips/atheros/ar71xx_gpio.c index b48e4a6..a029b59 100644 --- a/sys/mips/atheros/ar71xx_gpio.c +++ b/sys/mips/atheros/ar71xx_gpio.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include <mips/atheros/ar71xx_gpiovar.h> #include <mips/atheros/ar933xreg.h> #include <mips/atheros/ar934xreg.h> +#include <dev/gpio/gpiobusvar.h> #include "gpio_if.h" @@ -79,6 +80,7 @@ static void ar71xx_gpio_intr(void *arg); /* * GPIO interface */ +static device_t ar71xx_gpio_get_bus(device_t); static int ar71xx_gpio_pin_max(device_t dev, int *maxpin); static int ar71xx_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps); static int ar71xx_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t @@ -135,6 +137,16 @@ ar71xx_gpio_pin_configure(struct ar71xx_gpio_softc *sc, struct gpio_pin *pin, } } +static device_t +ar71xx_gpio_get_bus(device_t dev) +{ + struct ar71xx_gpio_softc *sc; + + sc = device_get_softc(dev); + + return (sc->busdev); +} + static int ar71xx_gpio_pin_max(device_t dev, int *maxpin) { @@ -433,10 +445,13 @@ ar71xx_gpio_attach(device_t dev) ar71xx_gpio_pin_set(dev, j, 1); } } - device_add_child(dev, "gpioc", -1); - device_add_child(dev, "gpiobus", -1); + sc->busdev = gpiobus_attach_bus(dev); + if (sc->busdev == NULL) { + ar71xx_gpio_detach(dev); + return (ENXIO); + } - return (bus_generic_attach(dev)); + return (0); } static int @@ -446,7 +461,7 @@ ar71xx_gpio_detach(device_t dev) KASSERT(mtx_initialized(&sc->gpio_mtx), ("gpio mutex not initialized")); - bus_generic_detach(dev); + gpiobus_detach_bus(dev); if (sc->gpio_ih) bus_teardown_intr(dev, sc->gpio_irq_res, sc->gpio_ih); if (sc->gpio_irq_res) @@ -468,6 +483,7 @@ static device_method_t ar71xx_gpio_methods[] = { DEVMETHOD(device_detach, ar71xx_gpio_detach), /* GPIO protocol */ + DEVMETHOD(gpio_get_bus, ar71xx_gpio_get_bus), DEVMETHOD(gpio_pin_max, ar71xx_gpio_pin_max), DEVMETHOD(gpio_pin_getname, ar71xx_gpio_pin_getname), DEVMETHOD(gpio_pin_getflags, ar71xx_gpio_pin_getflags), diff --git a/sys/mips/atheros/ar71xx_gpiovar.h b/sys/mips/atheros/ar71xx_gpiovar.h index 32337cc..47b6e64 100644 --- a/sys/mips/atheros/ar71xx_gpiovar.h +++ b/sys/mips/atheros/ar71xx_gpiovar.h @@ -57,6 +57,7 @@ struct ar71xx_gpio_softc { device_t dev; + device_t busdev; struct mtx gpio_mtx; struct resource *gpio_mem_res; int gpio_mem_rid; diff --git a/sys/mips/cavium/octeon_gpio.c b/sys/mips/cavium/octeon_gpio.c index 1053976..58aea5a 100644 --- a/sys/mips/cavium/octeon_gpio.c +++ b/sys/mips/cavium/octeon_gpio.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include <mips/cavium/octeon_irq.h> #include <mips/cavium/octeon_gpiovar.h> +#include <dev/gpio/gpiobusvar.h> #include "gpio_if.h" @@ -90,6 +91,7 @@ static void octeon_gpio_intr(void *arg); /* * GPIO interface */ +static device_t octeon_gpio_get_bus(device_t); static int octeon_gpio_pin_max(device_t dev, int *maxpin); static int octeon_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps); static int octeon_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t @@ -134,6 +136,16 @@ octeon_gpio_pin_configure(struct octeon_gpio_softc *sc, struct gpio_pin *pin, GPIO_UNLOCK(sc); } +static device_t +octeon_gpio_get_bus(device_t dev) +{ + struct octeon_gpio_softc *sc; + + sc = device_get_softc(dev); + + return (sc->busdev); +} + static int octeon_gpio_pin_max(device_t dev, int *maxpin) { @@ -434,11 +446,13 @@ octeon_gpio_attach(device_t dev) gpio_cfgx.s.int_en, gpio_cfgx.s.int_type ? "rising edge" : "level"); } } + sc->busdev = gpiobus_attach_bus(dev); + if (sc->busdev == NULL) { + octeon_gpio_detach(dev); + return (ENXIO); + } - device_add_child(dev, "gpioc", -1); - device_add_child(dev, "gpiobus", -1); - - return (bus_generic_attach(dev)); + return (0); } static int @@ -457,7 +471,7 @@ octeon_gpio_detach(device_t dev) bus_release_resource(dev, SYS_RES_IRQ, sc->gpio_irq_rid[i], sc->gpio_irq_res[i]); } - bus_generic_detach(dev); + gpiobus_detach_bus(dev); mtx_destroy(&sc->gpio_mtx); return(0); @@ -470,6 +484,7 @@ static device_method_t octeon_gpio_methods[] = { DEVMETHOD(device_detach, octeon_gpio_detach), /* GPIO protocol */ + DEVMETHOD(gpio_get_bus, octeon_gpio_get_bus), DEVMETHOD(gpio_pin_max, octeon_gpio_pin_max), DEVMETHOD(gpio_pin_getname, octeon_gpio_pin_getname), DEVMETHOD(gpio_pin_getflags, octeon_gpio_pin_getflags), diff --git a/sys/mips/cavium/octeon_gpiovar.h b/sys/mips/cavium/octeon_gpiovar.h index a9b814f..4cf007d3 100644 --- a/sys/mips/cavium/octeon_gpiovar.h +++ b/sys/mips/cavium/octeon_gpiovar.h @@ -43,6 +43,7 @@ struct octeon_gpio_softc { device_t dev; + device_t busdev; struct mtx gpio_mtx; struct resource *gpio_irq_res[OCTEON_GPIO_IRQS]; int gpio_irq_rid[OCTEON_GPIO_IRQS]; diff --git a/sys/mips/rt305x/rt305x_gpio.c b/sys/mips/rt305x/rt305x_gpio.c index bf03bd1..1ce02d7 100644 --- a/sys/mips/rt305x/rt305x_gpio.c +++ b/sys/mips/rt305x/rt305x_gpio.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include <mips/rt305x/rt305x_gpio.h> #include <mips/rt305x/rt305x_gpiovar.h> #include <mips/rt305x/rt305x_sysctlvar.h> +#include <dev/gpio/gpiobusvar.h> #include "gpio_if.h" @@ -84,6 +85,7 @@ void rt305x_set_int_status(device_t, uint32_t); /* * GPIO interface */ +static device_t rt305x_gpio_get_bus(device_t); static int rt305x_gpio_pin_max(device_t dev, int *maxpin); static int rt305x_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps); static int rt305x_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t @@ -157,6 +159,16 @@ rt305x_gpio_pin_configure(struct rt305x_gpio_softc *sc, struct gpio_pin *pin, GPIO_UNLOCK(sc); } +static device_t +rt305x_gpio_get_bus(device_t dev) +{ + struct rt305x_gpio_softc *sc; + + sc = device_get_softc(dev); + + return (sc->busdev); +} + static int rt305x_gpio_pin_max(device_t dev, int *maxpin) { @@ -501,11 +513,13 @@ rt305x_gpio_attach(device_t dev) device_printf(dev, "\tUse reset_gpio %d\n", sc->reset_gpio); } #endif + sc->busdev = gpiobus_attach_bus(dev); + if (sc->busdev == NULL) { + rt305x_gpio_detach(dev); + return (ENXIO); + } - device_add_child(dev, "gpioc", -1); - device_add_child(dev, "gpiobus", -1); - - return (bus_generic_attach(dev)); + return (0); } static int @@ -515,7 +529,7 @@ rt305x_gpio_detach(device_t dev) KASSERT(mtx_initialized(&sc->gpio_mtx), ("gpio mutex not initialized")); - bus_generic_detach(dev); + gpiobus_detach_bus(dev); if (sc->gpio_ih) bus_teardown_intr(dev, sc->gpio_irq_res, sc->gpio_ih); if (sc->gpio_irq_res) @@ -589,6 +603,7 @@ static device_method_t rt305x_gpio_methods[] = { DEVMETHOD(device_detach, rt305x_gpio_detach), /* GPIO protocol */ + DEVMETHOD(gpio_get_bus, rt305x_gpio_get_bus), DEVMETHOD(gpio_pin_max, rt305x_gpio_pin_max), DEVMETHOD(gpio_pin_getname, rt305x_gpio_pin_getname), DEVMETHOD(gpio_pin_getflags, rt305x_gpio_pin_getflags), diff --git a/sys/mips/rt305x/rt305x_gpiovar.h b/sys/mips/rt305x/rt305x_gpiovar.h index 85cd6f6..d486838 100644 --- a/sys/mips/rt305x/rt305x_gpiovar.h +++ b/sys/mips/rt305x/rt305x_gpiovar.h @@ -30,6 +30,7 @@ struct rt305x_gpio_softc { device_t dev; + device_t busdev; struct mtx gpio_mtx; struct resource *gpio_mem_res; int gpio_mem_rid; |