aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-11-13 05:50:22 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-11-13 05:50:22 -0500
commit24b35ed9a84ab1e7ad96c67434841120ca7fbf36 (patch)
tree54ce2241c790ed49839ff41f4cfa71bfd0d81a2e /drivers/gpio
parent9298539c0472c1bd7516c62d444e561493e3f26c (diff)
gpio: htc-egpio: read output value from cache
When the hardware is in output mode, reading the value from the hardware is not giving the correct value back. Instead read the value from the cache so we get the right value. Suggested-by: Russell King <linux@arm.linux.org.uk> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-htc-egpio.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
index 27af52850927..271356effb2e 100644
--- a/drivers/gpio/gpio-htc-egpio.c
+++ b/drivers/gpio/gpio-htc-egpio.c
@@ -160,10 +160,14 @@ static int egpio_get(struct gpio_chip *chip, unsigned offset)
160 bit = egpio_bit(ei, offset); 160 bit = egpio_bit(ei, offset);
161 reg = egpio->reg_start + egpio_pos(ei, offset); 161 reg = egpio->reg_start + egpio_pos(ei, offset);
162 162
163 value = egpio_readw(ei, reg); 163 if (test_bit(offset, &egpio->is_out)) {
164 pr_debug("readw(%p + %x) = %x\n", 164 return !!(egpio->cached_values & (1 << offset));
165 ei->base_addr, reg << ei->bus_shift, value); 165 } else {
166 return !!(value & bit); 166 value = egpio_readw(ei, reg);
167 pr_debug("readw(%p + %x) = %x\n",
168 ei->base_addr, reg << ei->bus_shift, value);
169 return !!(value & bit);
170 }
167} 171}
168 172
169static int egpio_direction_input(struct gpio_chip *chip, unsigned offset) 173static int egpio_direction_input(struct gpio_chip *chip, unsigned offset)