linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 10/16] ARM: imx: add a legacy irqdomain for 3ds_debugboard
Date: Thu, 14 Jun 2012 13:59:41 +0800	[thread overview]
Message-ID: <1339653587-4832-11-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1339653587-4832-1-git-send-email-shawn.guo@linaro.org>

Call irq_alloc_descs to get the irq_base for 3ds_debugboard, and add
a legacy irqdomain using the irq_base, so that the mapping between
3ds_debugboard hardware irq and Linux irq number can be dynamically
handled by irqdomain.  As the result, the use of MXC_BOARD_IRQ_START
can be completely removed from 3ds_debugboard.c.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/plat-mxc/3ds_debugboard.c |   42 +++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/arch/arm/plat-mxc/3ds_debugboard.c b/arch/arm/plat-mxc/3ds_debugboard.c
index 3b48a08..5c10ad0 100644
--- a/arch/arm/plat-mxc/3ds_debugboard.c
+++ b/arch/arm/plat-mxc/3ds_debugboard.c
@@ -12,9 +12,11 @@
 
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/irqdomain.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/module.h>
 #include <linux/smsc911x.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/fixed.h>
@@ -48,26 +50,22 @@
 /* CPU ID and Personality ID */
 #define MCU_BOARD_ID_REG	0x68
 
-#define MXC_IRQ_TO_EXPIO(irq)   ((irq) - MXC_BOARD_IRQ_START)
-
-#define MXC_EXP_IO_BASE		(MXC_BOARD_IRQ_START)
 #define MXC_MAX_EXP_IO_LINES	16
 
 /* interrupts like external uart , external ethernet etc*/
-#define EXPIO_INT_ENET		(MXC_BOARD_IRQ_START + 0)
-#define EXPIO_INT_XUART_A	(MXC_BOARD_IRQ_START + 1)
-#define EXPIO_INT_XUART_B	(MXC_BOARD_IRQ_START + 2)
-#define EXPIO_INT_BUTTON_A	(MXC_BOARD_IRQ_START + 3)
-#define EXPIO_INT_BUTTON_B	(MXC_BOARD_IRQ_START + 4)
+#define EXPIO_INT_ENET		0
+#define EXPIO_INT_XUART_A	1
+#define EXPIO_INT_XUART_B	2
+#define EXPIO_INT_BUTTON_A	3
+#define EXPIO_INT_BUTTON_B	4
 
 static void __iomem *brd_io;
+static struct irq_domain *domain;
 
 static struct resource smsc911x_resources[] = {
 	{
 		.flags = IORESOURCE_MEM,
 	} , {
-		.start = EXPIO_INT_ENET,
-		.end = EXPIO_INT_ENET,
 		.flags = IORESOURCE_IRQ,
 	},
 };
@@ -99,11 +97,11 @@ static void mxc_expio_irq_handler(u32 irq, struct irq_desc *desc)
 	imr_val = __raw_readw(brd_io + INTR_MASK_REG);
 	int_valid = __raw_readw(brd_io + INTR_STATUS_REG) & ~imr_val;
 
-	expio_irq = MXC_BOARD_IRQ_START;
+	expio_irq = 0;
 	for (; int_valid != 0; int_valid >>= 1, expio_irq++) {
 		if ((int_valid & 1) == 0)
 			continue;
-		generic_handle_irq(expio_irq);
+		generic_handle_irq(irq_find_mapping(domain, expio_irq));
 	}
 
 	desc->irq_data.chip->irq_ack(&desc->irq_data);
@@ -117,7 +115,7 @@ static void mxc_expio_irq_handler(u32 irq, struct irq_desc *desc)
 static void expio_mask_irq(struct irq_data *d)
 {
 	u16 reg;
-	u32 expio = MXC_IRQ_TO_EXPIO(d->irq);
+	u32 expio = d->hwirq;
 
 	reg = __raw_readw(brd_io + INTR_MASK_REG);
 	reg |= (1 << expio);
@@ -126,7 +124,7 @@ static void expio_mask_irq(struct irq_data *d)
 
 static void expio_ack_irq(struct irq_data *d)
 {
-	u32 expio = MXC_IRQ_TO_EXPIO(d->irq);
+	u32 expio = d->hwirq;
 
 	__raw_writew(1 << expio, brd_io + INTR_RESET_REG);
 	__raw_writew(0, brd_io + INTR_RESET_REG);
@@ -136,7 +134,7 @@ static void expio_ack_irq(struct irq_data *d)
 static void expio_unmask_irq(struct irq_data *d)
 {
 	u16 reg;
-	u32 expio = MXC_IRQ_TO_EXPIO(d->irq);
+	u32 expio = d->hwirq;
 
 	reg = __raw_readw(brd_io + INTR_MASK_REG);
 	reg &= ~(1 << expio);
@@ -157,6 +155,7 @@ static struct regulator_consumer_supply dummy_supplies[] = {
 int __init mxc_expio_init(u32 base, u32 intr_gpio)
 {
 	u32 p_irq = gpio_to_irq(intr_gpio);
+	int irq_base;
 	int i;
 
 	brd_io = ioremap(BOARD_IO_ADDR(base), SZ_4K);
@@ -186,8 +185,15 @@ int __init mxc_expio_init(u32 base, u32 intr_gpio)
 	__raw_writew(0xFFFF, brd_io + INTR_RESET_REG);
 	__raw_writew(0, brd_io + INTR_RESET_REG);
 	__raw_writew(0x1F, brd_io + INTR_MASK_REG);
-	for (i = MXC_EXP_IO_BASE;
-	     i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES); i++) {
+
+	irq_base = irq_alloc_descs(-1, 0, MXC_MAX_EXP_IO_LINES, numa_node_id());
+	WARN_ON(irq_base < 0);
+
+	domain = irq_domain_add_legacy(NULL, MXC_MAX_EXP_IO_LINES, irq_base, 0,
+				       &irq_domain_simple_ops, NULL);
+	WARN_ON(!domain);
+
+	for (i = irq_base; i < irq_base + MXC_MAX_EXP_IO_LINES; i++) {
 		irq_set_chip_and_handler(i, &expio_irq_chip, handle_level_irq);
 		set_irq_flags(i, IRQF_VALID);
 	}
@@ -199,6 +205,8 @@ int __init mxc_expio_init(u32 base, u32 intr_gpio)
 
 	smsc911x_resources[0].start = LAN9217_BASE_ADDR(base);
 	smsc911x_resources[0].end = LAN9217_BASE_ADDR(base) + 0x100 - 1;
+	smsc911x_resources[1].start = irq_find_mapping(domain, EXPIO_INT_ENET);
+	smsc911x_resources[1].end = irq_find_mapping(domain, EXPIO_INT_ENET);
 	platform_device_register(&smsc_lan9217_device);
 
 	return 0;
-- 
1.7.5.4

  parent reply	other threads:[~2012-06-14  5:59 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14  5:59 [PATCH 00/16] Enable SPARSE_IRQ support for imx Shawn Guo
2012-06-14  5:59 ` [PATCH 01/16] ARM: imx: eliminate macro IMX_GPIO_TO_IRQ() Shawn Guo
2012-06-14  7:31   ` Dong Aisheng
2012-06-14  7:39     ` Shawn Guo
2012-06-14  8:04       ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 02/16] ARM: imx: eliminate macro IOMUX_TO_IRQ() Shawn Guo
2012-06-14  7:59   ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 03/16] ARM: imx: eliminate macro IRQ_GPIOx() Shawn Guo
2012-06-15  9:23   ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 04/16] gpio/mxc: move irq_domain_add_legacy call into gpio driver Shawn Guo
2012-06-15  9:26   ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 05/16] ARM: imx: move irq_domain_add_legacy call into tzic driver Shawn Guo
2012-06-15  9:29   ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 06/16] ARM: imx: move irq_domain_add_legacy call into avic driver Shawn Guo
2012-06-14  7:13   ` Shawn Guo
2012-06-15  9:30     ` Dong Aisheng
2012-07-06  6:26     ` [PATCH] ARM: imx: select IRQ_DOMAIN Uwe Kleine-König
2012-07-06  7:05       ` Shawn Guo
2012-07-06  7:07         ` Uwe Kleine-König
2012-07-06  7:12         ` Sascha Hauer
2012-07-06  7:18           ` [PATCH] ARM: imx: select USE_OF Uwe Kleine-König
2012-07-06  7:31             ` Shawn Guo
2012-07-06  7:47           ` [PATCH v2] " Uwe Kleine-König
2012-07-06  8:04             ` Shawn Guo
2012-07-06 19:15               ` Arnd Bergmann
2012-06-14  5:59 ` [PATCH 07/16] dma: ipu: remove the use of ipu_platform_data Shawn Guo
2012-06-14 10:26   ` Vinod Koul
2012-06-15  9:37   ` Dong Aisheng
2012-06-16  3:01     ` Shawn Guo
2012-06-18  8:19       ` Dong Aisheng
2012-06-18 14:02         ` Shawn Guo
2012-06-19  5:51           ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 08/16] ARM: imx: leave irq_base of wm8350_platform_data uninitialized Shawn Guo
2012-06-15 12:20   ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 09/16] ARM: imx: pass gpio than irq number into mxc_expio_init Shawn Guo
2012-06-15 12:21   ` Dong Aisheng
2012-06-14  5:59 ` Shawn Guo [this message]
2012-06-15 12:22   ` [PATCH 10/16] ARM: imx: add a legacy irqdomain for 3ds_debugboard Dong Aisheng
2012-06-14  5:59 ` [PATCH 11/16] ARM: imx: add a legacy irqdomain for mx31ads Shawn Guo
2012-06-18  8:20   ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 12/16] i2c: imx: remove unneeded mach/irqs.h inclusion Shawn Guo
2012-06-14  7:30   ` Wolfram Sang
2012-06-18  8:20   ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 13/16] ARM: imx: remove unneeded mach/irq.h inclusion Shawn Guo
2012-06-18  8:21   ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 14/16] tty: serial: imx: remove the use of MXC_INTERNAL_IRQS Shawn Guo
2012-06-14 15:37   ` Greg Kroah-Hartman
2012-06-18  8:22   ` Dong Aisheng
2012-06-14  5:59 ` [PATCH 15/16] ARM: fiq: save FIQ_START by passing absolute fiq number Shawn Guo
2012-06-18  8:39   ` Dong Aisheng
2012-06-18 14:31   ` Shawn Guo
2012-06-18 16:44     ` Russell King - ARM Linux
2012-06-19  5:26       ` Shawn Guo
2012-06-20 22:55         ` Russell King - ARM Linux
2012-06-20 23:40           ` Shawn Guo
2012-06-20 23:53           ` Shawn Guo
2012-06-21  7:37             ` Russell King - ARM Linux
2012-06-21  8:50           ` Shawn Guo
2012-06-25 16:10           ` Shawn Guo
2012-06-14  5:59 ` [PATCH 16/16] ARM: imx: enable SPARSE_IRQ for imx platform Shawn Guo
2012-06-14  7:40   ` Haojian Zhuang
2012-06-14  7:55     ` Shawn Guo
2012-06-18  8:48   ` Dong Aisheng
2012-06-18 15:04     ` Shawn Guo
2012-06-19  6:16       ` Dong Aisheng
2012-06-19  6:47         ` Shawn Guo
2012-06-19  7:21           ` Dong Aisheng
2012-06-19  7:43             ` Shawn Guo
2012-06-19 13:01               ` Dong Aisheng
2012-06-19 13:19                 ` [RFC PATCH 1/1] ARM: imx: enable SPARSE_IRQ for imx Dong Aisheng
2012-06-19 14:06                   ` Shawn Guo
2012-06-20  2:23                     ` Dong Aisheng
2012-06-20  5:40                       ` Shawn Guo
2012-06-20  6:40                         ` Dong Aisheng
2012-06-20 12:57                           ` Shawn Guo
2012-06-20 14:45                             ` Dong Aisheng
2012-06-14  8:00 ` [PATCH 00/16] Enable SPARSE_IRQ support " Sascha Hauer

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=1339653587-4832-11-git-send-email-shawn.guo@linaro.org \
    --to=shawn.guo@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).