gpio: adp5588: get value from data out when dir is out
PATCH 1/2 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.
--- drivers/gpio/gpio-adp5588.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpio/gpio-adp5588.c +13 -2
@@ -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,
Signature · 1 line
1.8.5.3
PATCH 2/2 input: adp5588-keys: 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.
--- drivers/input/keyboard/adp5588-keys.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/input/keyboard/adp5588-keys.c +11 -1
@@ -76,8 +76,18 @@ static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);unsigned int bank =ADP5588_BANK (kpad->gpiomap[off]);unsigned int bit =ADP5588_BIT (kpad->gpiomap[off]); +int val; -return !!(adp5588_read (kpad->client,GPIO_DAT_STAT1 + bank) & bit); +mutex_lock (&kpad->gpio_lock); + +if (kpad->dir[bank] & bit) + val = kpad->dat_out[bank]; +else + val =adp5588_read (kpad->client,GPIO_DAT_STAT1 + bank); + +mutex_unlock (&kpad->gpio_lock); + +return !!(val & bit); } static void adp5588_gpio_set_value(struct gpio_chip *chip,
Signature · 1 line
1.8.5.3
-----Original Message-----
From: Jean-Francois Dagenais [mailto:[email protected]]
Sent: Montag, 10. Februar 2014 18:05
To: Hennerich, Michael; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Jean-Francois Dagenais
Subject: [PATCH 1/2] 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.
--- drivers/gpio/gpio-adp5588.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpio/gpio-adp5588.c +13 -3
@@ -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, --
1.8.5.3
Quoted 11 lines · Jean-Francois Dagenais
As discussed here: http://ez.analog.com/message/35852,
the 5587 revC and 5588 revB spec sheets contain a mistake in theGPIO_DAT_STATxregister 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 Jean-Francois Dagenais <[email protected]>
Patch applied with Michael's ACK.
Yours,
Linus Walleij
Re: [PATCH 2/2] input: adp5588-keys: get value from data out when dir is out
In reply to Jean-Francois DagenaisQuoted 11 lines · Jean-Francois Dagenais
As discussed here: http://ez.analog.com/message/35852,
the 5587 revC and 5588 revB spec sheets contain a mistake in theGPIO_DAT_STATxregister 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 Jean-Francois Dagenais <[email protected]>
Applied, thank you.
Quoted 31 lines
--- drivers/input/keyboard/adp5588-keys.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/input/keyboard/adp5588-keys.c +11
-1@@ -76,8 +76,18 @@ static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);unsigned int bank =ADP5588_BANK (kpad->gpiomap[off]);unsigned int bit =ADP5588_BIT (kpad->gpiomap[off]); +int val; -return !!(adp5588_read (kpad->client,GPIO_DAT_STAT1 + bank) & bit); +mutex_lock (&kpad->gpio_lock); + +if (kpad->dir[bank] & bit) + val = kpad->dat_out[bank]; +else + val =adp5588_read (kpad->client,GPIO_DAT_STAT1 + bank); + +mutex_unlock (&kpad->gpio_lock); + +return !!(val & bit); } static void adp5588_gpio_set_value(struct gpio_chip *chip,Signature · 1 line
1.8.5.3
Signature · 1 line
Dmitry