mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] IMX gpio: use DR register to get gpio value
@ 2018-05-10 17:49 Nikita Yushchenko
  2018-05-10 18:00 ` Fabio Estevam
  0 siblings, 1 reply; 2+ messages in thread
From: Nikita Yushchenko @ 2018-05-10 17:49 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox, Andrey Gusakov, Chris Healy

From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>

Reading PSR register report wrong value for pins
configured as output.
According DS: While the GPIO direction is set to input
(GPIO_GDIR = 0), a read access to GPIO_DR does not return
GPIO_DR data. Instead, it returns the GPIO_PSR data, which
is the corresponding input signal value.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
---
 drivers/gpio/gpio-imx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-imx.c b/drivers/gpio/gpio-imx.c
index d8bcea223..a9d44d4e6 100644
--- a/drivers/gpio/gpio-imx.c
+++ b/drivers/gpio/gpio-imx.c
@@ -108,9 +108,9 @@ static int imx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
 	void __iomem *base = imxgpio->base;
 	u32 val;
 
-	val = readl(base + imxgpio->regs->psr);
+	val = readl(base + imxgpio->regs->dr);
 
-	return val & (1 << gpio) ? 1 : 0;
+	return (val & (1 << gpio)) ? 1 : 0;
 }
 
 static int imx_get_direction(struct gpio_chip *chip, unsigned offset)
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2018-05-10 18:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10 17:49 [PATCH] IMX gpio: use DR register to get gpio value Nikita Yushchenko
2018-05-10 18:00 ` Fabio Estevam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox