linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@stericsson.com>
To: <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>
Cc: Stephen Warren <swarren@nvidia.com>,
	Anmar Oueja <anmar.oueja@linaro.org>,
	Lee Jones <lee.jones@linaro.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 01/14] mfd: ab8500: prepare to handle AB8500 GPIO's IRQs correctly
Date: Tue, 5 Feb 2013 20:48:22 +0100	[thread overview]
Message-ID: <1360093715-6348-2-git-send-email-linus.walleij@stericsson.com> (raw)
In-Reply-To: <1360093715-6348-1-git-send-email-linus.walleij@stericsson.com>

From: Lee Jones <lee.jones@linaro.org>

In an upcoming patch, the gpio-ab8500 driver will relinquish all
IRQ handling capability and pass it back into the AB8500 core
driver. This will aid in reducing massive code duplication within
the kernel. Also, most of the functionality is already in the
AB8500 core driver, as the GPIO IRQs are actually sandwiched
between lots of other IRQs which the core driver already handles.

All we're doing here is providing the core driver with knowledge
that each GPIO has two IRQs assigned to it; one for rising and
a separate one for falling.

Cc: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Sam, it'd be nice if you could ACK these first four patches,
the series basically simplifies things a lot by not cascading
the AB8500 IRQs and duplicate code in the pinctrl driver.
---
 drivers/mfd/ab8500-core.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index e1650ba..e1ba0be 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -367,16 +367,40 @@ static void ab8500_irq_mask(struct irq_data *data)
 	int mask = 1 << (offset % 8);
 
 	ab8500->mask[index] |= mask;
+
+	/* The AB8500 GPIOs have two interrupts each (rising & falling). */
+	if (offset >= AB8500_INT_GPIO6R && offset <= AB8500_INT_GPIO41R)
+		ab8500->mask[index + 2] |= mask;
+	if (offset >= AB9540_INT_GPIO50R && offset <= AB9540_INT_GPIO54R)
+		ab8500->mask[index + 1] |= mask;
+	if (offset == AB8540_INT_GPIO43R || offset == AB8540_INT_GPIO44R)
+		ab8500->mask[index] |= (mask >> 1);
 }
 
 static void ab8500_irq_unmask(struct irq_data *data)
 {
 	struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data);
+	unsigned int type = irqd_get_trigger_type(data);
 	int offset = data->hwirq;
 	int index = offset / 8;
 	int mask = 1 << (offset % 8);
 
-	ab8500->mask[index] &= ~mask;
+	if (type & IRQ_TYPE_EDGE_RISING)
+		ab8500->mask[index] &= ~mask;
+
+	/* The AB8500 GPIOs have two interrupts each (rising & falling). */
+	if (type & IRQ_TYPE_EDGE_FALLING) {
+		if (offset >= AB8500_INT_GPIO6R && offset <= AB8500_INT_GPIO41R)
+			ab8500->mask[index + 2] &= ~mask;
+		else if (offset >= AB9540_INT_GPIO50R && offset <= AB9540_INT_GPIO54R)
+			ab8500->mask[index + 1] &= ~mask;
+		else if (offset == AB8540_INT_GPIO43R || offset == AB8540_INT_GPIO44R)
+			ab8500->mask[index] &= ~(mask >> 1);
+		else
+			ab8500->mask[index] &= ~mask;
+	} else
+		/* Satisfies the case where type is not set. */
+		ab8500->mask[index] &= ~mask;
 }
 
 static struct irq_chip ab8500_irq_chip = {
-- 
1.7.11.3


  reply	other threads:[~2013-02-05 19:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-05 19:48 [PATCH 00/14] reform the ABx500 IRQ handling Linus Walleij
2013-02-05 19:48 ` Linus Walleij [this message]
2013-02-05 19:48 ` [PATCH 02/14] mfd: ab8500: provide a irq_set_type() function Linus Walleij
2013-02-07  0:07   ` Stephen Warren
     [not found]     ` <CAF2Aj3iO+6j+T5C0X2Hh6TsvT4yaJ2cai6cC9DaiRAwL9n-dVw@mail.gmail.com>
2013-02-07 10:01       ` Linus Walleij
2013-02-05 19:48 ` [PATCH 03/14] mfd: ab8500: ensure new AB8500 pinctrl driver is probed correctly Linus Walleij
2013-02-07  0:08   ` Stephen Warren
2013-02-05 19:48 ` [PATCH 04/14] mfd: ab8500: allow AB9540 based devices to use ABX500 pinctrl Linus Walleij
2013-02-05 19:48 ` [PATCH 05/14] pinctrl/abx500: prevent error path from corrupting returning error Linus Walleij
2013-02-05 19:48 ` [PATCH 06/14] pinctrl/abx500: align GPIO cluster boundaries Linus Walleij
2013-02-05 19:48 ` [PATCH 07/14] pinctrl/abx500: move IRQ handling to ab8500-core Linus Walleij
2013-02-05 19:48 ` [PATCH 08/14] pinctrl/abx500: replace IRQ offsets with table read-in values Linus Walleij
2013-02-05 19:48 ` [PATCH 09/14] pinctrl/abx500: use direct IRQ defines Linus Walleij
2013-02-07  0:13   ` Stephen Warren
     [not found]     ` <CAF2Aj3jHe+mP0dU_BHThBV-va_iJLcFQedmWQOTaYafAZM1Yxg@mail.gmail.com>
2013-02-07 17:59       ` Stephen Warren
2013-02-08  8:25         ` Lee Jones
2013-02-08 17:06           ` Stephen Warren
2013-02-07 19:10       ` Linus Walleij
2013-02-05 19:48 ` [PATCH 10/14] pinctrl/abx500: add Device Tree support Linus Walleij
2013-02-05 19:48 ` [PATCH 11/14] ARM: ux500: remove irq_base property from platform_data Linus Walleij
2013-02-10  2:42   ` Olof Johansson
2013-02-10 15:01     ` Linus Walleij
2013-02-05 19:48 ` [PATCH 12/14] ARM: ux500: use real AB8500 IRQ numbers instead of virtual ones Linus Walleij
2013-02-05 19:48 ` [PATCH 13/14] ARM: ux500: enable AB8500 GPIO for HREF Linus Walleij
2013-02-07  0:17   ` Stephen Warren
2013-02-07  8:30     ` Arnd Bergmann
2013-02-05 19:48 ` [PATCH 14/14] ARM: ux500: allow Snowball access to the AB8500 GPIO pins Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360093715-6348-2-git-send-email-linus.walleij@stericsson.com \
    --to=linus.walleij@stericsson.com \
    --cc=anmar.oueja@linaro.org \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    --cc=swarren@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).