summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-11-22 09:45:24 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-11-27 12:07:20 +0100
commit9edaf7570b2b8b98291181db15885ccbe0eb5202 (patch)
tree189421a60f1b4af5b114e5197415311550ab3fa8 /drivers
parent17a517c0fcf21cbd1882108c18fa845930927563 (diff)
downloadbarebox-9edaf7570b2b8b98291181db15885ccbe0eb5202.tar.gz
barebox-9edaf7570b2b8b98291181db15885ccbe0eb5202.tar.xz
of/gpio: Support gpio-line-names property
GPIOs can be given names with the gpio-line-names device tree property. This patch adds support for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpiolib.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 057cea43cc..9764ddf0f0 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -428,11 +428,25 @@ static int of_hog_gpio(struct device_node *np, struct gpio_chip *chip,
static int of_gpiochip_scan_hogs(struct gpio_chip *chip)
{
struct device_node *np;
- int ret, i;
+ int ret, i, count;
if (!IS_ENABLED(CONFIG_OFDEVICE) || !chip->dev->device_node)
return 0;
+ count = of_property_count_strings(chip->dev->device_node, "gpio-line-names");
+
+ if (count > 0) {
+ const char **arr = xzalloc(count * sizeof(char *));
+
+ of_property_read_string_array(chip->dev->device_node,
+ "gpio-line-names", arr, count);
+
+ for (i = 0; i < chip->ngpio && i < count; i++)
+ gpio_desc[chip->base + i].name = xstrdup(arr[i]);
+
+ free(arr);
+ }
+
for_each_available_child_of_node(chip->dev->device_node, np) {
if (!of_property_read_bool(np, "gpio-hog"))
continue;