mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Milo Kim <milo.kim@ti.com>
To: <tglx@linutronix.de>
Cc: <jason@lakedaemon.net>, <marc.zyngier@arm.com>,
	<alexandre.belloni@free-electrons.com>,
	<boris.brezillon@free-electrons.com>,
	<ludovic.desroches@atmel.com>, <nicolas.ferre@atmel.com>,
	<linux-kernel@vger.kernel.org>, Milo Kim <milo.kim@ti.com>
Subject: [PATCH 15/19] irqchip: atmel-aic: add common interrupt handler
Date: Mon, 4 Jan 2016 13:28:39 +0900	[thread overview]
Message-ID: <1451881723-2478-16-git-send-email-milo.kim@ti.com> (raw)
In-Reply-To: <1451881723-2478-1-git-send-email-milo.kim@ti.com>

AIC and AIC5 have same interrupt handling process.
  1. Read IVR (Interrupt Vector Register) to get a HW IRQ number.
  2. Read ISR (Interrupt Status Register) to get current IRQ source number.
  3. Indicate the interrupt handling is complete if no interrupt condition.
     Otherwise, handle current interrupt.

With aic_reg_data configuration, two handlers can be combined.
And irq_domain also can be moved to common part.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Boris BREZILLON <boris.brezillon@free-electrons.com>
Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Milo Kim <milo.kim@ti.com>
---
 drivers/irqchip/irq-atmel-aic-common.c | 24 ++++++++++++++++++++++++
 drivers/irqchip/irq-atmel-aic.c        | 25 -------------------------
 drivers/irqchip/irq-atmel-aic5.c       | 24 ------------------------
 3 files changed, 24 insertions(+), 49 deletions(-)

diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c
index 67f9204..3d8cc8d 100644
--- a/drivers/irqchip/irq-atmel-aic-common.c
+++ b/drivers/irqchip/irq-atmel-aic-common.c
@@ -17,11 +17,15 @@
 #include <linux/errno.h>
 #include <linux/io.h>
 #include <linux/irq.h>
+#include <linux/irqdesc.h>
 #include <linux/irqdomain.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/slab.h>
 
+#include <asm/exception.h>
+#include <asm/mach/irq.h>
+
 #include "irq-atmel-aic-common.h"
 
 #define NR_AIC_IRQS			32
@@ -129,8 +133,23 @@ static const struct aic_reg_offset aic5_regs = {
 	.isr	= AT91_AIC5_ISR,
 };
 
+static struct irq_domain *aic_domain;
 static const struct aic_reg_offset *aic_reg_data;
 
+static asmlinkage void __exception_irq_entry
+aic_handle(struct pt_regs *regs)
+{
+	struct irq_chip_generic *gc = irq_get_domain_generic_chip(aic_domain,
+								  0);
+	u32 hwirq = irq_reg_readl(gc, aic_reg_data->ivr);
+	u32 status = irq_reg_readl(gc, aic_reg_data->isr);
+
+	if (!status)
+		irq_reg_writel(gc, 0, aic_reg_data->eoi);
+	else
+		handle_domain_irq(aic_domain, hwirq, regs);
+}
+
 static inline bool aic_is_ssr_used(void)
 {
 	return aic_reg_data->ssr != AT91_INVALID_OFFSET;
@@ -483,6 +502,9 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
 	int ret;
 	int i;
 
+	if (aic_domain)
+		return ERR_PTR(-EEXIST);
+
 	nchips = DIV_ROUND_UP(nirqs, AIC_IRQS_PER_CHIP);
 
 	reg_base = of_iomap(node, 0);
@@ -532,8 +554,10 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
 		gc->private = &aic[i];
 	}
 
+	aic_domain = domain;
 	aic_common_ext_irq_of_init(domain);
 	aic_hw_init(domain);
+	set_handle_irq(aic_handle);
 
 	return domain;
 
diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c
index ef2cfb8..44cedce 100644
--- a/drivers/irqchip/irq-atmel-aic.c
+++ b/drivers/irqchip/irq-atmel-aic.c
@@ -55,40 +55,15 @@
 #define AT91_AIC_SPU			0x134
 #define AT91_AIC_DCR			0x138
 
-static struct irq_domain *aic_domain;
-
-static asmlinkage void __exception_irq_entry
-aic_handle(struct pt_regs *regs)
-{
-	struct irq_domain_chip_generic *dgc = aic_domain->gc;
-	struct irq_chip_generic *gc = dgc->gc[0];
-	u32 irqnr;
-	u32 irqstat;
-
-	irqnr = irq_reg_readl(gc, AT91_AIC_IVR);
-	irqstat = irq_reg_readl(gc, AT91_AIC_ISR);
-
-	if (!irqstat)
-		irq_reg_writel(gc, 0, AT91_AIC_EOICR);
-	else
-		handle_domain_irq(aic_domain, irqnr, regs);
-}
-
 static int __init aic_of_init(struct device_node *node,
 			      struct device_node *parent)
 {
 	struct irq_domain *domain;
 
-	if (aic_domain)
-		return -EEXIST;
-
 	domain = aic_common_of_init(node, "atmel-aic", NR_AIC_IRQS);
 	if (IS_ERR(domain))
 		return PTR_ERR(domain);
 
-	aic_domain = domain;
-	set_handle_irq(aic_handle);
-
 	return 0;
 }
 IRQCHIP_DECLARE(at91rm9200_aic, "atmel,at91rm9200-aic", aic_of_init);
diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
index 4551bf6..d09cefe 100644
--- a/drivers/irqchip/irq-atmel-aic5.c
+++ b/drivers/irqchip/irq-atmel-aic5.c
@@ -65,24 +65,6 @@
 #define AT91_AIC5_FFDR			0x54
 #define AT91_AIC5_FFSR			0x58
 
-static struct irq_domain *aic5_domain;
-
-static asmlinkage void __exception_irq_entry
-aic5_handle(struct pt_regs *regs)
-{
-	struct irq_chip_generic *bgc = irq_get_domain_generic_chip(aic5_domain, 0);
-	u32 irqnr;
-	u32 irqstat;
-
-	irqnr = irq_reg_readl(bgc, AT91_AIC5_IVR);
-	irqstat = irq_reg_readl(bgc, AT91_AIC5_ISR);
-
-	if (!irqstat)
-		irq_reg_writel(bgc, 0, AT91_AIC5_EOICR);
-	else
-		handle_domain_irq(aic5_domain, irqnr, regs);
-}
-
 static int __init aic5_of_init(struct device_node *node,
 			       struct device_node *parent,
 			       int nirqs)
@@ -92,16 +74,10 @@ static int __init aic5_of_init(struct device_node *node,
 	if (nirqs > NR_AIC5_IRQS)
 		return -EINVAL;
 
-	if (aic5_domain)
-		return -EEXIST;
-
 	domain = aic_common_of_init(node, "atmel-aic5", nirqs);
 	if (IS_ERR(domain))
 		return PTR_ERR(domain);
 
-	aic5_domain = domain;
-	set_handle_irq(aic5_handle);
-
 	return 0;
 }
 
-- 
2.6.4


  parent reply	other threads:[~2016-01-04  4:30 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04  4:28 [PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Milo Kim
2016-01-04  4:28 ` [PATCH 01/19] irqchip: atmel-aic: fix wrong bit operation for IRQ priority Milo Kim
2016-01-04  8:11   ` Boris Brezillon
2016-01-04  4:28 ` [PATCH 02/19] irqchip: atmel-aic: clean up RTC interrupt code Milo Kim
2016-01-04  8:16   ` Boris Brezillon
2016-01-04  4:28 ` [PATCH 03/19] irqchip: atmel-aic: clean up RTT " Milo Kim
2016-01-04  8:17   ` Boris Brezillon
2016-01-04  4:28 ` [PATCH 04/19] irqchip: atmel-aic: replace magic numbers with named constant Milo Kim
2016-01-04  8:29   ` Boris Brezillon
2016-01-04  4:28 ` [PATCH 05/19] irqchip: atmel-aic: use simple constant to get number of interrupts per chip Milo Kim
2016-01-04  8:33   ` Boris Brezillon
2016-01-04  4:28 ` [PATCH 06/19] irqchip: atmel-aic: introduce register data structure Milo Kim
2016-01-04  8:53   ` Boris Brezillon
2016-01-06  8:30     ` Milo Kim
2016-01-04  4:28 ` [PATCH 07/19] irqchip: atmel-aic: make common IRQ domain translate function Milo Kim
2016-01-04  4:28 ` [PATCH 08/19] irqchip: atmel-aic: add common mask and unmask functions Milo Kim
2016-01-04  8:48   ` Boris Brezillon
2016-01-04  4:28 ` [PATCH 09/19] irqchip: atmel-aic: add common retrigger function Milo Kim
2016-01-04  4:28 ` [PATCH 10/19] irqchip: atmel-aic: add common set_type function Milo Kim
2016-01-04  4:28 ` [PATCH 11/19] irqchip: atmel-aic: add common PM IRQ chip operation Milo Kim
2016-01-04  4:28 ` [PATCH 12/19] irqchip: atmel-aic: use EOI register data in aic_reg_data Milo Kim
2016-01-04  4:28 ` [PATCH 13/19] irqchip: atmel-aic: clean up irq_chip_generic Milo Kim
2016-01-04  4:28 ` [PATCH 14/19] irqchip: atmel-aic: add common HW init function Milo Kim
2016-01-04  4:28 ` Milo Kim [this message]
2016-01-04  4:28 ` [PATCH 16/19] irqchip: atmel-aic: get total number of IRQs from device node Milo Kim
2016-01-04  4:28 ` [PATCH 17/19] irqchip: atmel-aic: use unified IRQ chip initialization function Milo Kim
2016-01-04  4:28 ` [PATCH 18/19] irqchip: atmel-aic: use unified AIC driver Milo Kim
2016-01-04  4:28 ` [PATCH 19/19] irqchip: atmel-aic: rename AIC driver and fix Kconfig Milo Kim
2016-01-04  9:02 ` [PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Boris Brezillon
2016-01-04  9:37   ` Nicolas Ferre
2016-01-06  7:55     ` Milo Kim
2016-01-06  7:48   ` Milo Kim
2016-01-06  9:07     ` Boris Brezillon
2016-01-06 14:49       ` Jason Cooper
2016-01-07  7:48       ` Milo Kim

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=1451881723-2478-16-git-send-email-milo.kim@ti.com \
    --to=milo.kim@ti.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@atmel.com \
    --cc=marc.zyngier@arm.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®