summaryrefslogtreecommitdiffstats
path: root/sys/arm/lpc
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2015-01-31 19:32:14 +0000
committerloos <loos@FreeBSD.org>2015-01-31 19:32:14 +0000
commit5e1a5939929b3ae8ec6f7e44ddd1b51b3c542cc6 (patch)
tree4edc5f6a6f697cb6c391fc6f0800ce835ba4024d /sys/arm/lpc
parent92c5395dfebe86676461d4e940ccf2b4249770e5 (diff)
downloadFreeBSD-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/lpc')
-rw-r--r--sys/arm/lpc/lpc_gpio.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/sys/arm/lpc/lpc_gpio.c b/sys/arm/lpc/lpc_gpio.c
index d9536a7..88f37b6 100644
--- a/sys/arm/lpc/lpc_gpio.c
+++ b/sys/arm/lpc/lpc_gpio.c
@@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$");
#include <machine/intr.h>
#include <machine/fdt.h>
+#include <dev/gpio/gpiobusvar.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -90,6 +91,7 @@ __FBSDID("$FreeBSD$");
struct lpc_gpio_softc
{
device_t lg_dev;
+ device_t lg_busdev;
struct resource * lg_res;
bus_space_tag_t lg_bst;
bus_space_handle_t lg_bsh;
@@ -135,6 +137,7 @@ static int lpc_gpio_probe(device_t);
static int lpc_gpio_attach(device_t);
static int lpc_gpio_detach(device_t);
+static device_t lpc_gpio_get_bus(device_t);
static int lpc_gpio_pin_max(device_t, int *);
static int lpc_gpio_pin_getcaps(device_t, uint32_t, uint32_t *);
static int lpc_gpio_pin_getflags(device_t, uint32_t, uint32_t *);
@@ -192,10 +195,13 @@ lpc_gpio_attach(device_t dev)
lpc_gpio_sc = sc;
- device_add_child(dev, "gpioc", -1);
- device_add_child(dev, "gpiobus", -1);
+ sc->lg_busdev = gpiobus_attach_bus(dev);
+ if (sc->lg_busdev == NULL) {
+ bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->lg_res);
+ return (ENXIO);
+ }
- return (bus_generic_attach(dev));
+ return (0);
}
static int
@@ -204,6 +210,16 @@ lpc_gpio_detach(device_t dev)
return (EBUSY);
}
+static device_t
+lpc_gpio_get_bus(device_t dev)
+{
+ struct lpc_gpio_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ return (sc->lg_busdev);
+}
+
static int
lpc_gpio_pin_max(device_t dev, int *npins)
{
@@ -527,6 +543,7 @@ static device_method_t lpc_gpio_methods[] = {
DEVMETHOD(device_detach, lpc_gpio_detach),
/* GPIO interface */
+ DEVMETHOD(gpio_get_bus, lpc_gpio_get_bus),
DEVMETHOD(gpio_pin_max, lpc_gpio_pin_max),
DEVMETHOD(gpio_pin_getcaps, lpc_gpio_pin_getcaps),
DEVMETHOD(gpio_pin_getflags, lpc_gpio_pin_getflags),
OpenPOWER on IntegriCloud