public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] gpio: omap_gpio: Add xlate function to support GPIO_ACTIVE_LOW
Date: Wed,  5 Sep 2018 04:35:28 -0500	[thread overview]
Message-ID: <20180905093531.28968-1-aford173@gmail.com> (raw)

The gpio driver doesn't current support knowing whether or not
GPIO is active low or high.  It simply returns the value.  The
side effect of this, is that the MMC routines which check
the status card detect or write protect must use a u-boot specific
dts modification to enable inverting the pin values when
GPIO_ACTIVE_LOW is used.  This allows the invert option to be removed

Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index 555eba2662..0ecd2f374a 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -24,6 +24,7 @@
 #include <asm/io.h>
 #include <linux/errno.h>
 #include <malloc.h>
+#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -275,12 +276,25 @@ static int omap_gpio_get_function(struct udevice *dev, unsigned offset)
 		return GPIOF_INPUT;
 }
 
+static int omap_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
+			   struct ofnode_phandle_args *args)
+{
+	desc->offset = args->args[0];
+
+	if (args->args[1] & GPIO_ACTIVE_LOW)
+		desc->flags = GPIOD_ACTIVE_LOW;
+	else
+		desc->flags = 0;
+	return 0;
+}
+
 static const struct dm_gpio_ops gpio_omap_ops = {
 	.direction_input	= omap_gpio_direction_input,
 	.direction_output	= omap_gpio_direction_output,
 	.get_value		= omap_gpio_get_value,
 	.set_value		= omap_gpio_set_value,
 	.get_function		= omap_gpio_get_function,
+	.xlate                  = omap_gpio_xlate,
 };
 
 static int omap_gpio_probe(struct udevice *dev)
-- 
2.17.1

             reply	other threads:[~2018-09-05  9:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05  9:35 Adam Ford [this message]
2018-09-05  9:35 ` [U-Boot] [PATCH 2/3] mmc: omap_mmc: Remove invert references with gpio xlate available Adam Ford
2018-09-05 12:34   ` Jean-Jacques Hiblot
2018-09-05  9:35 ` [U-Boot] [PATCH 3/3] ARM: DTS: various omap3: Remove cd-inverted from u-boot.dtsi Adam Ford
2018-09-05 12:23   ` Jean-Jacques Hiblot
2018-09-05 12:48     ` Adam Ford
2018-09-05 12:29 ` [U-Boot] [PATCH 1/3] gpio: omap_gpio: Add xlate function to support GPIO_ACTIVE_LOW Jean-Jacques Hiblot
2018-09-05 12:51   ` Adam Ford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180905093531.28968-1-aford173@gmail.com \
    --to=aford173@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox