linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] gpio: zynq: Take bank offset into account when reporting a IRQ
@ 2014-07-18  9:52 Lars-Peter Clausen
  2014-07-18  9:52 ` [PATCH 2/3] gpio: zynq: Clear pending interrupt when enabling " Lars-Peter Clausen
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Lars-Peter Clausen @ 2014-07-18  9:52 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot
  Cc: Michal Simek, Harini Katakam, linux-gpio, Lars-Peter Clausen

When looking up the IRQ the bank offset needs to be taken into account.
Otherwise interrupts for banks other than bank 0 get incorrectly reported as
interrupts for bank 0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/gpio/gpio-zynq.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index c0c53fd..8e6a32f 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -136,6 +136,29 @@ static inline void zynq_gpio_get_bank_pin(unsigned int pin_num,
 }
 
 /**
+ * zynq_gpio_get_bank_pin - Gets the pin number of the first pin in a bank
+ * @bank: The bank for which to return the first pin number
+ *
+ * Returns the pin number of the first pin in the specified bank
+ */
+static int zynq_gpio_get_bank_offset(unsigned int bank)
+{
+	switch (bank) {
+	case 0:
+		return ZYNQ_GPIO_BANK0_PIN_MIN;
+	case 1:
+		return ZYNQ_GPIO_BANK1_PIN_MIN;
+	case 2:
+		return ZYNQ_GPIO_BANK2_PIN_MIN;
+	case 3:
+		return ZYNQ_GPIO_BANK3_PIN_MIN;
+	default:
+		/* We'll never get here */
+		return -1;
+	}
+}
+
+/**
  * zynq_gpio_get_value - Get the state of the specified pin of GPIO device
  * @chip:	gpio_chip instance to be worked on
  * @pin:	gpio pin number within the device
@@ -419,11 +442,12 @@ static void zynq_gpio_irqhandler(unsigned int irq, struct irq_desc *desc)
 		if (int_sts) {
 			int offset;
 			unsigned long pending = int_sts;
+			int bank_offset = zynq_gpio_get_bank_offset(bank_num);
 
 			for_each_set_bit(offset, &pending, 32) {
 				unsigned int gpio_irq =
 					irq_find_mapping(gpio->chip.irqdomain,
-							offset);
+							 offset + bank_offset);
 				generic_handle_irq(gpio_irq);
 			}
 
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-08-11  7:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-18  9:52 [PATCH 1/3] gpio: zynq: Take bank offset into account when reporting a IRQ Lars-Peter Clausen
2014-07-18  9:52 ` [PATCH 2/3] gpio: zynq: Clear pending interrupt when enabling " Lars-Peter Clausen
2014-07-23 14:31   ` Linus Walleij
2014-07-23 17:42     ` Sören Brinkmann
2014-07-24  0:08       ` Alexandre Courbot
2014-07-24  7:36       ` Harini Katakam
2014-07-18  9:52 ` [PATCH 3/3] gpio: zynq: Fix IRQ handlers Lars-Peter Clausen
2014-07-18  9:58   ` Varka Bhadram
2014-07-23 14:36   ` Linus Walleij
2014-07-31 16:19     ` Sören Brinkmann
2014-08-11  7:03   ` Linus Walleij
2014-07-19  4:14 ` [PATCH 1/3] gpio: zynq: Take bank offset into account when reporting a IRQ Alexandre Courbot
2014-07-23 14:22   ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).