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.
This commit is contained in:
Ian Lepore 2018-02-18 23:08:43 +00:00
parent 5e2d748931
commit dc027dc6e2
2 changed files with 6 additions and 4 deletions

View File

@ -136,6 +136,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);

View File

@ -59,8 +59,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;
@ -114,7 +114,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
@ -122,7 +122,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