Skip to contentSkip to conversation

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

PATCH Applied Jean-Francois Dagenais 4 participants 5 messages Feb 10, 2014 – Feb 15, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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
index 3f190e6..7d3c8d9 100644
@@ -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
#1 lore raw

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
index bb3b57b..5ef7fcf 100644
@@ -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
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] input: adp5588-keys: get value from data out when dir is out

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 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.

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
index bb3b57b..5ef7fcf 100644
@@ -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
maintainer Acked-by on v1 1/2
#3 lore raw
In reply to Jean-Francois Dagenais

-----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

#4 lore raw
In reply to Jean-Francois Dagenais
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 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.

Patch applied with Michael's ACK.

Yours,
Linus Walleij