All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio-rcar: Use OUTDT when reading GPIOs configured as output
@ 2013-06-16 23:41 Magnus Damm
  2013-06-17  8:35 ` Linus Walleij
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Magnus Damm @ 2013-06-16 23:41 UTC (permalink / raw)
  To: linux-sh

From: Magnus Damm <damm@opensource.se>

Testing on r8a7790 shows that INDT does not indicate the correct
pin state when reading a GPIO configured as output, so update
the gpio_rcar_get() function to handle this case.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 drivers/gpio/gpio-rcar.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- 0001/drivers/gpio/gpio-rcar.c
+++ work/drivers/gpio/gpio-rcar.c	2013-06-12 09:23:53.000000000 +0900
@@ -230,7 +230,14 @@ static int gpio_rcar_direction_input(str
 
 static int gpio_rcar_get(struct gpio_chip *chip, unsigned offset)
 {
-	return (int)(gpio_rcar_read(gpio_to_priv(chip), INDT) & BIT(offset));
+	u32 bit = BIT(offset);
+
+	/* testing on r8a7790 shows that INDT does not show correct pin state
+	 * when configured as output, so use OUTDT in case of output pins */
+	if (gpio_rcar_read(gpio_to_priv(chip), INOUTSEL) & bit)
+		return (int)(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit);
+	else
+		return (int)(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit);
 }
 
 static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-17 11:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-16 23:41 [PATCH] gpio-rcar: Use OUTDT when reading GPIOs configured as output Magnus Damm
2013-06-17  8:35 ` Linus Walleij
2013-06-17  9:22 ` Magnus Damm
2013-06-17 10:58 ` Laurent Pinchart
2013-06-17 11:45 ` Magnus Damm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.