summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2018-03-24 23:03:59 +0000
committerian <ian@FreeBSD.org>2018-03-24 23:03:59 +0000
commit09d5c254a02553df035c76c1bcda4d87af60dde4 (patch)
treedf31558987ac55245fb9137e94f535ff5aafb18d
parent53c86efaf6dffcee96ae56f1bbc8d02cb1737c16 (diff)
downloadFreeBSD-src-09d5c254a02553df035c76c1bcda4d87af60dde4.zip
FreeBSD-src-09d5c254a02553df035c76c1bcda4d87af60dde4.tar.gz
MFC r329537:
Provide a public function to acquire a gpio pin by giving the property name and index. A private function to do exactly that already existed, so this renames gpio_pin_get_by_ofw_impl() to gpio_pin_get_by_ofw_propidx() and provides a declaration for it in a public header. Previously there were functions to get a pin by property name (assuming there would only be one pin defined for the name), or by index (asuming the property has the standard name "gpios"). It turns out there are devicetree bindings that describe properties with names other than "gpios" which can describe multiple pins. Hence the need to retrieve the Nth item from a named property.
-rw-r--r--sys/dev/gpio/gpiobusvar.h2
-rw-r--r--sys/dev/gpio/ofw_gpiobus.c8
2 files changed, 6 insertions, 4 deletions
diff --git a/sys/dev/gpio/gpiobusvar.h b/sys/dev/gpio/gpiobusvar.h
index 30d0f50..e34142e 100644
--- a/sys/dev/gpio/gpiobusvar.h
+++ b/sys/dev/gpio/gpiobusvar.h
@@ -133,6 +133,8 @@ int gpio_pin_get_by_ofw_idx(device_t consumer, phandle_t node,
int idx, gpio_pin_t *gpio);
int gpio_pin_get_by_ofw_property(device_t consumer, phandle_t node,
char *name, gpio_pin_t *gpio);
+int gpio_pin_get_by_ofw_propidx(device_t consumer, phandle_t node,
+ char *name, int idx, gpio_pin_t *gpio);
void gpio_pin_release(gpio_pin_t gpio);
int gpio_pin_getcaps(gpio_pin_t pin, uint32_t *caps);
int gpio_pin_is_active(gpio_pin_t pin, bool *active);
diff --git a/sys/dev/gpio/ofw_gpiobus.c b/sys/dev/gpio/ofw_gpiobus.c
index c4a0b73..34bfbdb 100644
--- a/sys/dev/gpio/ofw_gpiobus.c
+++ b/sys/dev/gpio/ofw_gpiobus.c
@@ -57,8 +57,8 @@ static int ofw_gpiobus_parse_gpios_impl(device_t, phandle_t, char *,
* tree consumers.
*
*/
-static int
-gpio_pin_get_by_ofw_impl(device_t consumer, phandle_t cnode,
+int
+gpio_pin_get_by_ofw_propidx(device_t consumer, phandle_t cnode,
char *prop_name, int idx, gpio_pin_t *out_pin)
{
phandle_t xref;
@@ -112,7 +112,7 @@ gpio_pin_get_by_ofw_idx(device_t consumer, phandle_t node,
int idx, gpio_pin_t *pin)
{
- return (gpio_pin_get_by_ofw_impl(consumer, node, "gpios", idx, pin));
+ return (gpio_pin_get_by_ofw_propidx(consumer, node, "gpios", idx, pin));
}
int
@@ -120,7 +120,7 @@ gpio_pin_get_by_ofw_property(device_t consumer, phandle_t node,
char *name, gpio_pin_t *pin)
{
- return (gpio_pin_get_by_ofw_impl(consumer, node, name, 0, pin));
+ return (gpio_pin_get_by_ofw_propidx(consumer, node, name, 0, pin));
}
int
OpenPOWER on IntegriCloud