[U-Boot] [PATCH] dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Peng Fan van.freenix at gmail.com
Tue Mar 29 06:57:30 CEST 2016


Hi Eric,

On Fri, Mar 25, 2016 at 01:12:11PM -0700, Eric Nelson wrote:
>Device tree parsing of GPIO nodes is currently ignoring flags.
>
>Add support for GPIO_ACTIVE_LOW by checking for the presence
>of the flag and setting the desc->flags field to the driver
>model constant GPIOD_ACTIVE_LOW.

You may need to try this: https://patchwork.ozlabs.org/patch/597363/

Regards,
Peng.

>
>Signed-off-by: Eric Nelson <eric at nelint.com>
>---
> drivers/gpio/gpio-uclass.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
>index b58d4e6..6d30612 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,16 @@ static int gpio_find_and_xlate(struct gpio_desc *desc,
> {
> 	struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
> 
>+	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];
>+		if ((args->args_count > 1) &&
>+		    (args->args[1] & GPIO_ACTIVE_LOW))
>+			desc->flags = GPIOD_ACTIVE_LOW;
>+	}
> 	else
> 		desc->offset = -1;
>-	desc->flags = 0;
> 
> 	return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
> }
>-- 
>2.6.2
>
>_______________________________________________
>U-Boot mailing list
>U-Boot at lists.denx.de
>http://lists.denx.de/mailman/listinfo/u-boot


More information about the U-Boot mailing list