svn commit: r265310 - in head/sys/dev: gpio ofw
Luiz Otavio O Souza
loos at FreeBSD.org
Sun May 4 04:01:28 UTC 2014
Author: loos
Date: Sun May 4 04:01:26 2014
New Revision: 265310
URL: http://svnweb.freebsd.org/changeset/base/265310
Log:
Move gpiobus routines to dev/gpio. Avoid polluting ofw_bus with bus
specific parts.
Requested by: nwhitehorn
Modified:
head/sys/dev/gpio/gpio_if.m
head/sys/dev/gpio/gpiobus.c
head/sys/dev/gpio/gpiobusvar.h
head/sys/dev/gpio/ofw_gpiobus.c
head/sys/dev/ofw/ofw_bus.h
head/sys/dev/ofw/ofw_bus_if.m
Modified: head/sys/dev/gpio/gpio_if.m
==============================================================================
--- head/sys/dev/gpio/gpio_if.m Sun May 4 03:37:39 2014 (r265309)
+++ head/sys/dev/gpio/gpio_if.m Sun May 4 04:01:26 2014 (r265310)
@@ -31,6 +31,32 @@
INTERFACE gpio;
+CODE {
+ static gpio_map_gpios_t gpio_default_map_gpios;
+
+ int
+ gpio_default_map_gpios(device_t bus, phandle_t dev,
+ phandle_t gparent, int gcells, pcell_t *gpios, uint32_t *pin,
+ uint32_t *flags)
+ {
+ /* Propagate up the bus hierarchy until someone handles it. */
+ if (device_get_parent(bus) != NULL)
+ return (GPIO_MAP_GPIOS(device_get_parent(bus), dev,
+ gparent, gcells, gpios, pin, flags));
+
+ /* If that fails, then assume the FreeBSD defaults. */
+ *pin = gpios[0];
+ if (gcells == 2 || gcells == 3)
+ *flags = gpios[gcells - 1];
+
+ return (0);
+ }
+};
+
+HEADER {
+ #include <dev/ofw/openfirm.h>
+};
+
#
# Get total number of pins
#
@@ -100,3 +126,16 @@ METHOD int pin_setflags {
uint32_t pin_num;
uint32_t flags;
};
+
+#
+# Allow the GPIO controller to map the gpio-specifier on its own.
+#
+METHOD int map_gpios {
+ device_t bus;
+ phandle_t dev;
+ phandle_t gparent;
+ int gcells;
+ pcell_t *gpios;
+ uint32_t *pin;
+ uint32_t *flags;
+} DEFAULT gpio_default_map_gpios;
Modified: head/sys/dev/gpio/gpiobus.c
==============================================================================
--- head/sys/dev/gpio/gpiobus.c Sun May 4 03:37:39 2014 (r265309)
+++ head/sys/dev/gpio/gpiobus.c Sun May 4 04:01:26 2014 (r265310)
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <dev/gpio/gpiobusvar.h>
-#include "gpio_if.h"
#include "gpiobus_if.h"
static int gpiobus_parse_pins(struct gpiobus_softc *, device_t, int);
Modified: head/sys/dev/gpio/gpiobusvar.h
==============================================================================
--- head/sys/dev/gpio/gpiobusvar.h Sun May 4 03:37:39 2014 (r265309)
+++ head/sys/dev/gpio/gpiobusvar.h Sun May 4 04:01:26 2014 (r265310)
@@ -39,6 +39,8 @@
#include <dev/ofw/ofw_bus_subr.h>
#endif
+#include "gpio_if.h"
+
#define GPIOBUS_IVAR(d) (struct gpiobus_ivar *) device_get_ivars(d)
#define GPIOBUS_SOFTC(d) (struct gpiobus_softc *) device_get_softc(d)
#define GPIOBUS_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
@@ -72,6 +74,13 @@ struct ofw_gpiobus_devinfo {
struct ofw_bus_devinfo opd_obdinfo;
};
+static __inline int
+gpio_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells,
+ pcell_t *gpios, uint32_t *pin, uint32_t *flags)
+{
+ return (GPIO_MAP_GPIOS(bus, dev, gparent, gcells, gpios, pin, flags));
+}
+
device_t ofw_gpiobus_add_fdt_child(device_t, phandle_t);
#endif
void gpiobus_print_pins(struct gpiobus_ivar *);
Modified: head/sys/dev/gpio/ofw_gpiobus.c
==============================================================================
--- head/sys/dev/gpio/ofw_gpiobus.c Sun May 4 03:37:39 2014 (r265309)
+++ head/sys/dev/gpio/ofw_gpiobus.c Sun May 4 04:01:26 2014 (r265310)
@@ -39,8 +39,6 @@ __FBSDID("$FreeBSD$");
#include <dev/gpio/gpiobusvar.h>
#include <dev/ofw/ofw_bus.h>
-#include "gpio_if.h"
-
static int ofw_gpiobus_parse_gpios(struct gpiobus_softc *,
struct gpiobus_ivar *, phandle_t);
static struct ofw_gpiobus_devinfo *ofw_gpiobus_setup_devinfo(device_t,
@@ -180,7 +178,7 @@ ofw_gpiobus_parse_gpios(struct gpiobus_s
}
/* Get the GPIO pin number and flags. */
- if (ofw_bus_map_gpios(sc->sc_dev, child, gpio, cells,
+ if (gpio_map_gpios(sc->sc_dev, child, gpio, cells,
&gpios[i + 1], &dinfo->pins[j], &dinfo->flags[j]) != 0) {
ofw_gpiobus_free_ivars(dinfo);
free(gpios, M_DEVBUF);
Modified: head/sys/dev/ofw/ofw_bus.h
==============================================================================
--- head/sys/dev/ofw/ofw_bus.h Sun May 4 03:37:39 2014 (r265309)
+++ head/sys/dev/ofw/ofw_bus.h Sun May 4 04:01:26 2014 (r265310)
@@ -76,12 +76,4 @@ ofw_bus_map_intr(device_t dev, phandle_t
return (OFW_BUS_MAP_INTR(dev, dev, iparent, icells, intr));
}
-static __inline int
-ofw_bus_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells,
- pcell_t *gpios, uint32_t *pin, uint32_t *flags)
-{
- return (OFW_BUS_MAP_GPIOS(bus, dev, gparent, gcells, gpios, pin,
- flags));
-}
-
#endif /* !_DEV_OFW_OFW_BUS_H_ */
Modified: head/sys/dev/ofw/ofw_bus_if.m
==============================================================================
--- head/sys/dev/ofw/ofw_bus_if.m Sun May 4 03:37:39 2014 (r265309)
+++ head/sys/dev/ofw/ofw_bus_if.m Sun May 4 04:01:26 2014 (r265310)
@@ -58,7 +58,6 @@ CODE {
static ofw_bus_get_node_t ofw_bus_default_get_node;
static ofw_bus_get_type_t ofw_bus_default_get_type;
static ofw_bus_map_intr_t ofw_bus_default_map_intr;
- static ofw_bus_map_gpios_t ofw_bus_default_map_gpios;
static const struct ofw_bus_devinfo *
ofw_bus_default_get_devinfo(device_t bus, device_t dev)
@@ -114,24 +113,6 @@ CODE {
/* If that fails, then assume a one-domain system */
return (interrupt[0]);
}
-
- int
- ofw_bus_default_map_gpios(device_t bus, phandle_t dev,
- phandle_t gparent, int gcells, pcell_t *gpios, uint32_t *pin,
- uint32_t *flags)
- {
- /* Propagate up the bus hierarchy until someone handles it. */
- if (device_get_parent(bus) != NULL)
- return OFW_BUS_MAP_GPIOS(device_get_parent(bus), dev,
- gparent, gcells, gpios, pin, flags);
-
- /* If that fails, then assume the FreeBSD defaults. */
- *pin = gpios[0];
- if (gcells == 2 || gcells == 3)
- *flags = gpios[gcells - 1];
-
- return (0);
- }
};
# Get the ofw_bus_devinfo struct for the device dev on the bus. Used for bus
@@ -188,14 +169,3 @@ METHOD int map_intr {
int icells;
pcell_t *interrupt;
} DEFAULT ofw_bus_default_map_intr;
-
-# Map the GPIO controller specific gpio-specifier to GPIO pin and flags.
-METHOD int map_gpios {
- device_t bus;
- phandle_t dev;
- phandle_t gparent;
- int gcells;
- pcell_t *gpios;
- uint32_t *pin;
- uint32_t *flags;
-} DEFAULT ofw_bus_default_map_gpios;
More information about the svn-src-head
mailing list