mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
To: Sascha Hauer <sha@pengutronix.de>
Cc: barebox@lists.infradead.org,
	Andrey Gusakov <andrey.gusakov@cogentembedded.com>,
	Chris Healy <cphealy@gmail.com>
Subject: [PATCH] IMX gpio: use DR register to get gpio value
Date: Thu, 10 May 2018 20:49:59 +0300	[thread overview]
Message-ID: <20180510174959.14933-1-nikita.yoush@cogentembedded.com> (raw)

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

             reply	other threads:[~2018-05-10 17:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10 17:49 Nikita Yushchenko [this message]
2018-05-10 18:00 ` Fabio Estevam

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=20180510174959.14933-1-nikita.yoush@cogentembedded.com \
    --to=nikita.yoush@cogentembedded.com \
    --cc=andrey.gusakov@cogentembedded.com \
    --cc=barebox@lists.infradead.org \
    --cc=cphealy@gmail.com \
    --cc=sha@pengutronix.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