lkml.org 
[lkml]   [2012]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] gpio: twl4030: Correct status reporting when the GPIO is used as output
Date
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


\
 
 \ /
  Last update: 2012-12-05 11:22    [W:0.039 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site