Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: tegra: read output value when gpio is set in direction_out

Read the output value when gpio is set for the output mode for
gpio_get_value(). Reading input value in direction out does not
give correct value.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Laxman Dewangan and committed by
Linus Walleij
195812e4 ed32620e

+5
+5
drivers/gpio/gpio-tegra.c
··· 134 134 135 135 static int tegra_gpio_get(struct gpio_chip *chip, unsigned offset) 136 136 { 137 + /* If gpio is in output mode then read from the out value */ 138 + if ((tegra_gpio_readl(GPIO_OE(offset)) >> GPIO_BIT(offset)) & 1) 139 + return (tegra_gpio_readl(GPIO_OUT(offset)) >> 140 + GPIO_BIT(offset)) & 0x1; 141 + 137 142 return (tegra_gpio_readl(GPIO_IN(offset)) >> GPIO_BIT(offset)) & 0x1; 138 143 } 139 144