Private
Public Access
2
0

gpio: Introduce mraa_gpio_init_by_name API

This commit introduces mraa_gpio_init_by_name API for initializing
a GPIO by its line name provided by the kernel. This feature depends
on the GPIO chardev support and also the line names present in devicetree
or board files. Accessing GPIO using its line name, removes the dependency
from MRAA specific pin mapping and provides a cleaner way to access GPIOs.
This will solve the issue created by an external gpiochip probing before
the SoC's internal gpio controller and thereby making the MRAA pin mapping
wrong.

Currently, this API only supports initializing a single GPIO at a time.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
This commit is contained in:
Manivannan Sadhasivam
2019-05-02 11:09:51 +05:30
committed by Manivannan Sadhasivam
parent 111e6be8f7
commit 0a12c5a017
5 changed files with 186 additions and 24 deletions

View File

@@ -64,6 +64,7 @@ mraa_boolean_t mraa_is_gpio_line_open_drain(mraa_gpiod_line_info *linfo);
mraa_boolean_t mraa_is_gpio_line_open_source(mraa_gpiod_line_info *linfo);
int mraa_get_number_of_gpio_chips();
int mraa_get_chip_infos(mraa_gpiod_chip_info*** cinfos);
/* Multiple gpio support. */
typedef struct _gpio_group* mraa_gpiod_group_t;

View File

@@ -174,6 +174,11 @@ struct _gpio {
++k) \
if (dev->gpio_group[k].is_required)
#define for_each_gpio_chip(cinfo, cinfos, num_chips) \
for (int idx = 0; \
idx < num_chips && (cinfo = cinfos[idx]); \
(idx++))
/**
* A structure representing a I2C bus
*/