summaryrefslogtreecommitdiffstats
path: root/sys/arm/samsung/exynos/exynos5_pad.c
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/samsung/exynos/exynos5_pad.c
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/samsung/exynos/exynos5_pad.c')
-rw-r--r--sys/arm/samsung/exynos/exynos5_pad.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/sys/arm/samsung/exynos/exynos5_pad.c b/sys/arm/samsung/exynos/exynos5_pad.c
index 0e58bf5..19fa583 100644
--- a/sys/arm/samsung/exynos/exynos5_pad.c
+++ b/sys/arm/samsung/exynos/exynos5_pad.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/gpio.h>
+#include <dev/gpio/gpiobusvar.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -82,6 +83,7 @@ __FBSDID("$FreeBSD$");
/*
* GPIO interface
*/
+static device_t pad_get_bus(device_t);
static int pad_pin_max(device_t, int *);
static int pad_pin_getcaps(device_t, uint32_t, uint32_t *);
static int pad_pin_getname(device_t, uint32_t, char *);
@@ -111,6 +113,7 @@ struct pad_softc {
struct gpio_pin gpio_pins[MAX_NGPIO];
void *gpio_ih[MAX_PORTS];
device_t dev;
+ device_t busdev;
int model;
struct resource_spec *pad_spec;
struct gpio_bank *gpio_map;
@@ -558,11 +561,11 @@ pad_attach(device_t dev)
snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,
"pad%d.%d", device_get_unit(dev), i);
}
+ sc->busdev = gpiobus_attach_bus(dev);
+ if (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:
for (i = 0; i < sc->nports; i++) {
@@ -576,6 +579,16 @@ fail:
return (ENXIO);
}
+static device_t
+pad_get_bus(device_t dev)
+{
+ struct pad_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ return (sc->busdev);
+}
+
static int
pad_pin_max(device_t dev, int *maxpin)
{
@@ -817,6 +830,7 @@ static device_method_t pad_methods[] = {
DEVMETHOD(device_attach, pad_attach),
/* GPIO protocol */
+ DEVMETHOD(gpio_get_bus, pad_get_bus),
DEVMETHOD(gpio_pin_max, pad_pin_max),
DEVMETHOD(gpio_pin_getname, pad_pin_getname),
DEVMETHOD(gpio_pin_getcaps, pad_pin_getcaps),
OpenPOWER on IntegriCloud