diff options
author | Magnus Damm <damm@opensource.se> | 2013-06-16 19:41:52 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-06-17 04:34:36 -0400 |
commit | ae9550f635533b1ca5d0b50e24a720426ad237c6 (patch) | |
tree | e705e0d097e9110b4c581ab34e99d0624f0b5995 /drivers/gpio/gpio-rcar.c | |
parent | cd73891647a19f4b52f23d23f5c68175b93b56fe (diff) |
gpio-rcar: Use OUTDT when reading GPIOs configured as output
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>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-rcar.c')
-rw-r--r-- | drivers/gpio/gpio-rcar.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index b4ca450947b8..6b78ad96d3d4 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c | |||
@@ -214,7 +214,14 @@ static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset) | |||
214 | 214 | ||
215 | static int gpio_rcar_get(struct gpio_chip *chip, unsigned offset) | 215 | static int gpio_rcar_get(struct gpio_chip *chip, unsigned offset) |
216 | { | 216 | { |
217 | return (int)(gpio_rcar_read(gpio_to_priv(chip), INDT) & BIT(offset)); | 217 | u32 bit = BIT(offset); |
218 | |||
219 | /* testing on r8a7790 shows that INDT does not show correct pin state | ||
220 | * when configured as output, so use OUTDT in case of output pins */ | ||
221 | if (gpio_rcar_read(gpio_to_priv(chip), INOUTSEL) & bit) | ||
222 | return (int)(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit); | ||
223 | else | ||
224 | return (int)(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit); | ||
218 | } | 225 | } |
219 | 226 | ||
220 | static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value) | 227 | static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value) |