From be220d5fa55408fedec59f194c59eb95dc2d1573 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Mon, 25 Apr 2011 21:02:41 +0530 Subject: mfd: tps6591x: Implementing input mode of tps6591x-gpio Implemention direction_input() of the tps6591x-gpio and returing correct value from gpio based on direction. Change-Id: I114a7101c2a14b61b2e475bdab547ea7601f6b93 Reviewed-on: http://git-master/r/29627 Reviewed-by: Laxman Dewangan Tested-by: Laxman Dewangan Reviewed-by: Scott Williams --- drivers/mfd/tps6591x.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) mode change 100755 => 100644 drivers/mfd/tps6591x.c (limited to 'drivers/mfd') diff --git a/drivers/mfd/tps6591x.c b/drivers/mfd/tps6591x.c old mode 100755 new mode 100644 index 3a8fb9aadbe7..0852eb43c2aa --- a/drivers/mfd/tps6591x.c +++ b/drivers/mfd/tps6591x.c @@ -289,7 +289,10 @@ static int tps6591x_gpio_get(struct gpio_chip *gc, unsigned offset) if (ret) return ret; - return val & 0x1; + if (val & 0x4) + return val & 0x1; + else + return ((val & 0x2)? 1: 0); } static void tps6591x_gpio_set(struct gpio_chip *chip, unsigned offset, @@ -304,8 +307,18 @@ static void tps6591x_gpio_set(struct gpio_chip *chip, unsigned offset, static int tps6591x_gpio_input(struct gpio_chip *gc, unsigned offset) { - /* FIXME: add handling of GPIOs as dedicated inputs */ - return -ENOSYS; + struct tps6591x *tps6591x = container_of(gc, struct tps6591x, gpio); + uint8_t reg_val; + int ret; + + ret = __tps6591x_read(tps6591x->client, TPS6591X_GPIO_BASE_ADDR + + offset, ®_val); + if (ret) + return ret; + + reg_val &= ~0x4; + return __tps6591x_write(tps6591x->client, TPS6591X_GPIO_BASE_ADDR + + offset, reg_val); } static int tps6591x_gpio_output(struct gpio_chip *gc, unsigned offset, -- cgit v1.2.3