Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 992196f2 authored by Jean-Francois Dagenais's avatar Jean-Francois Dagenais Committed by Linus Walleij
Browse files

gpio: adp5588: get value from data out when dir is out

As discussed here: http://ez.analog.com/message/35852

,
the 5587 revC and 5588 revB spec sheets contain a mistake
in the GPIO_DAT_STATx register description.

According to R.Shnell at ADI, as well as my own
observations, it should read:
"GPIO data status (shows GPIO state when read for inputs)".

This commit changes the get value function accordingly.

Signed-off-by: default avatarJean-Francois Dagenais <jeff.dagenais@gmail.com>
Acked-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 390d82e3
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -67,9 +67,20 @@ static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off)
{
	struct adp5588_gpio *dev =
	    container_of(chip, struct adp5588_gpio, gpio_chip);
	unsigned bank = ADP5588_BANK(off);
	unsigned bit = ADP5588_BIT(off);
	int val;

	return !!(adp5588_gpio_read(dev->client,
		  GPIO_DAT_STAT1 + ADP5588_BANK(off)) & ADP5588_BIT(off));
	mutex_lock(&dev->lock);

	if (dev->dir[bank] & bit)
		val = dev->dat_out[bank];
	else
		val = adp5588_gpio_read(dev->client, GPIO_DAT_STAT1 + bank);

	mutex_unlock(&dev->lock);

	return !!(val & bit);
}

static void adp5588_gpio_set_value(struct gpio_chip *chip,