diff mbox

[U-Boot,1/7] dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Message ID 1459525662-28032-2-git-send-email-eric@nelint.com
State Changes Requested
Delegated to: Simon Glass
Headers show

Commit Message

Eric Nelson April 1, 2016, 3:47 p.m. UTC
Device tree parsing of GPIO nodes is currently ignoring flags
and architecture-specific xlate routines are handling the
parsing of GPIO_ACTIVE_LOW.

Since GPIO_ACTIVE_LOW isn't specific to a particular device
type, this patch adds support at a global level and removes
the need for many of the driver-specific xlate routines.

Signed-off-by: Eric Nelson <eric@nelint.com>
---
 drivers/gpio/gpio-uclass.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index b58d4e6..a3cbb83 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -6,6 +6,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <dt-bindings/gpio/gpio.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
@@ -118,12 +119,15 @@  static int gpio_find_and_xlate(struct gpio_desc *desc,
 {
 	struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
 
+	desc->offset = -1;
+	desc->flags = 0;
 	/* Use the first argument as the offset by default */
-	if (args->args_count > 0)
+	if (args->args_count > 0) {
 		desc->offset = args->args[0];
-	else
-		desc->offset = -1;
-	desc->flags = 0;
+		if ((args->args_count > 1) &&
+		    (args->args[1] & GPIO_ACTIVE_LOW))
+			desc->flags = GPIOD_ACTIVE_LOW;
+	}
 
 	return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
 }