aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorAndrew Chew <achew@nvidia.com>2013-07-26 16:39:53 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-08-16 09:04:40 -0400
commit8b628c659ce1e2a8714ebcfe55f80457a4ebe734 (patch)
tree05130f324a094949ee1a9b149ffe3b600877fe24 /drivers/gpio
parent5763318f562fc0b30f729dce531b2982e29db463 (diff)
gpio: palmas: Fix misreported GPIO out value
It seems that the value read back from the PALMAS_GPIO_DATA_IN register isn't valid if the GPIO direction is out. When that's the case, we can read back the PALMAS_GPIO_DATA_OUT register to get the proper output value. Signed-off-by: Andrew Chew <achew@nvidia.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-palmas.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c
index 09360c4b6386..8588af0f7661 100644
--- a/drivers/gpio/gpio-palmas.c
+++ b/drivers/gpio/gpio-palmas.c
@@ -43,9 +43,22 @@ static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset)
43 unsigned int val; 43 unsigned int val;
44 int ret; 44 int ret;
45 45
46 ret = palmas_read(palmas, PALMAS_GPIO_BASE, PALMAS_GPIO_DATA_IN, &val); 46 ret = palmas_read(palmas, PALMAS_GPIO_BASE, PALMAS_GPIO_DATA_DIR, &val);
47 if (ret < 0) { 47 if (ret < 0) {
48 dev_err(gc->dev, "GPIO_DATA_IN read failed, err = %d\n", ret); 48 dev_err(gc->dev, "GPIO_DATA_DIR read failed, err = %d\n", ret);
49 return ret;
50 }
51
52 if (val & (1 << offset)) {
53 ret = palmas_read(palmas, PALMAS_GPIO_BASE,
54 PALMAS_GPIO_DATA_OUT, &val);
55 } else {
56 ret = palmas_read(palmas, PALMAS_GPIO_BASE,
57 PALMAS_GPIO_DATA_IN, &val);
58 }
59 if (ret < 0) {
60 dev_err(gc->dev, "GPIO_DATA_IN/OUT read failed, err = %d\n",
61 ret);
49 return ret; 62 return ret;
50 } 63 }
51 return !!(val & BIT(offset)); 64 return !!(val & BIT(offset));