All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Grant Likely <grant.likely@secretlab.ca>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-omap@vger.kernel.org>
Subject: [PATCH] gpio: twl4030: Correct status reporting when the GPIO is used as output
Date: Wed, 5 Dec 2012 10:49:45 +0100	[thread overview]
Message-ID: <1354700985-4453-1-git-send-email-peter.ujfalusi@ti.com> (raw)

When the GPIO is configured as output we need to read the GPIODATAOUT*
register to get correct information. When the GPIO is output the GPIODATAIN*
registers report 0 all the time (no feedback from output path).

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/gpio/gpio-twl4030.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index 55b4fe4..e7aa620 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -191,13 +191,19 @@ static int twl4030_get_gpio_datain(int gpio)
 	u8 d_bnk = gpio >> 3;
 	u8 d_off = gpio & 0x7;
 	u8 base = 0;
+	int direction;
 	int ret = 0;
 
 	if (unlikely((gpio >= TWL4030_GPIO_MAX)
 		|| !(gpio_usage_count & BIT(gpio))))
 		return -EPERM;
 
-	base = REG_GPIODATAIN1 + d_bnk;
+	direction = gpio_twl4030_read(REG_GPIODATADIR1 + d_bnk);
+	if (direction > 0 && (direction >> d_off) & 0x1)
+		base = REG_SETGPIODATAOUT1 + d_bnk;
+	else
+		base = REG_GPIODATAIN1 + d_bnk;
+
 	ret = gpio_twl4030_read(base);
 	if (ret > 0)
 		ret = (ret >> d_off) & 0x1;
-- 
1.8.0


WARNING: multiple messages have this Message-ID (diff)
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Grant Likely <grant.likely@secretlab.ca>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org
Subject: [PATCH] gpio: twl4030: Correct status reporting when the GPIO is used as output
Date: Wed, 5 Dec 2012 10:49:45 +0100	[thread overview]
Message-ID: <1354700985-4453-1-git-send-email-peter.ujfalusi@ti.com> (raw)

When the GPIO is configured as output we need to read the GPIODATAOUT*
register to get correct information. When the GPIO is output the GPIODATAIN*
registers report 0 all the time (no feedback from output path).

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/gpio/gpio-twl4030.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index 55b4fe4..e7aa620 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -191,13 +191,19 @@ static int twl4030_get_gpio_datain(int gpio)
 	u8 d_bnk = gpio >> 3;
 	u8 d_off = gpio & 0x7;
 	u8 base = 0;
+	int direction;
 	int ret = 0;
 
 	if (unlikely((gpio >= TWL4030_GPIO_MAX)
 		|| !(gpio_usage_count & BIT(gpio))))
 		return -EPERM;
 
-	base = REG_GPIODATAIN1 + d_bnk;
+	direction = gpio_twl4030_read(REG_GPIODATADIR1 + d_bnk);
+	if (direction > 0 && (direction >> d_off) & 0x1)
+		base = REG_SETGPIODATAOUT1 + d_bnk;
+	else
+		base = REG_GPIODATAIN1 + d_bnk;
+
 	ret = gpio_twl4030_read(base);
 	if (ret > 0)
 		ret = (ret >> d_off) & 0x1;
-- 
1.8.0


             reply	other threads:[~2012-12-05  9:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05  9:49 Peter Ujfalusi [this message]
2012-12-05  9:49 ` [PATCH] gpio: twl4030: Correct status reporting when the GPIO is used as output Peter Ujfalusi
2012-12-05 22:48 ` Grant Likely
2012-12-06 10:55   ` Peter Ujfalusi
2012-12-06 10:55     ` Peter Ujfalusi

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=1354700985-4453-1-git-send-email-peter.ujfalusi@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    /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 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.