summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authormario.six@gdsys.cc <mario.six@gdsys.cc>2016-05-23 07:54:56 (GMT)
committerSimon Glass <sjg@chromium.org>2016-06-19 23:05:55 (GMT)
commitfc76b698736efa9d52e06aa09c03dc8ef10fd581 (patch)
treedc9ae4cd8f235d0218ddd834bbd85bf611250872 /drivers
parent5aeedebc33849efbbee2d422a4c7da8194e1b670 (diff)
downloadu-boot-fsl-qoriq-fc76b698736efa9d52e06aa09c03dc8ef10fd581.tar.xz
gpio: pca953x: Fix register reading past 8th GPIO
A bug in the pca953x driver prevents correct reading of GPIO input values beyond the 8th GPIO; all values are reported as zero. Setting of GPIO output values is not affected. This patch fixes the reading behavior. Signed-off-by: Mario Six <mario.six@gdsys.cc> Reviewed-by: Peng Fan <van.freenix@gmail.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/pca953x_gpio.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c
index 065b181..0410add 100644
--- a/drivers/gpio/pca953x_gpio.c
+++ b/drivers/gpio/pca953x_gpio.c
@@ -148,11 +148,13 @@ static int pca953x_get_value(struct udevice *dev, unsigned offset)
int ret;
u8 val = 0;
+ int off = offset % BANK_SZ;
+
ret = pca953x_read_single(dev, PCA953X_INPUT, &val, offset);
if (ret)
return ret;
- return (val >> offset) & 0x1;
+ return (val >> off) & 0x1;
}
static int pca953x_set_value(struct udevice *dev, unsigned offset,