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 16/19] irqchip: atmel-aic: get total number of IRQs from device node
Date: Mon, 4 Jan 2016 13:28:40 +0900	[thread overview]
Message-ID: <1451881723-2478-17-git-send-email-milo.kim@ti.com> (raw)
In-Reply-To: <1451881723-2478-1-git-send-email-milo.kim@ti.com>

aic_common_of_init() needs an argument for number of interrupts.
Argument, 'nirqs' can be ignored if device compatible string is used.
This patch provides unified way to get total number of interrupts.
Chip specific register data is assigned as well.

Use single constant total AIC IRQ number, 'NR_AT91RM9200_IRQS'.

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 | 38 ++++++++++++++++++++++++++++++----
 drivers/irqchip/irq-atmel-aic-common.h |  4 +---
 drivers/irqchip/irq-atmel-aic.c        |  2 +-
 drivers/irqchip/irq-atmel-aic5.c       | 37 +++++----------------------------
 4 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c
index 3d8cc8d..deec551 100644
--- a/drivers/irqchip/irq-atmel-aic-common.c
+++ b/drivers/irqchip/irq-atmel-aic-common.c
@@ -28,7 +28,11 @@
 
 #include "irq-atmel-aic-common.h"
 
-#define NR_AIC_IRQS			32
+#define AIC_IRQS_PER_CHIP		32
+#define NR_AT91RM9200_IRQS		32
+#define NR_SAMA5D2_IRQS			77
+#define NR_SAMA5D3_IRQS			48
+#define NR_SAMA5D4_IRQS			68
 
 #define AT91_AIC_SMR_BASE		0
 #define AT91_AIC_SVR_BASE		0x80
@@ -425,6 +429,30 @@ static void aic_pm_shutdown(struct irq_data *d)
 #define aic_pm_shutdown	NULL
 #endif /* CONFIG_PM */
 
+static int __init aic_get_num_chips(struct device_node *node)
+{
+	int nirqs;
+
+	/* Get total number of IRQs and configure register data */
+	if (of_device_is_compatible(node, "atmel,at91rm9200-aic")) {
+		nirqs = NR_AT91RM9200_IRQS;
+		aic_reg_data = &aic_regs;
+	} else if (of_device_is_compatible(node, "atmel,sama5d2-aic")) {
+		nirqs = NR_SAMA5D2_IRQS;
+		aic_reg_data = &aic5_regs;
+	} else if (of_device_is_compatible(node, "atmel,sama5d3-aic")) {
+		nirqs = NR_SAMA5D3_IRQS;
+		aic_reg_data = &aic5_regs;
+	} else if (of_device_is_compatible(node, "atmel,sama5d4-aic")) {
+		nirqs = NR_SAMA5D4_IRQS;
+		aic_reg_data = &aic5_regs;
+	} else {
+		return -EINVAL;
+	}
+
+	return DIV_ROUND_UP(nirqs, AIC_IRQS_PER_CHIP);
+}
+
 static void __init aic_common_ext_irq_of_init(struct irq_domain *domain)
 {
 	struct device_node *node = irq_domain_get_of_node(domain);
@@ -486,13 +514,13 @@ static void __init aic_hw_init(struct irq_domain *domain)
 		irq_reg_writel(gc, 0xffffffff, aic_reg_data->idcr);
 		irq_reg_writel(gc, 0xffffffff, aic_reg_data->iccr);
 
-		for (i = 0; i < NR_AIC_IRQS; i++)
+		for (i = 0; i < NR_AT91RM9200_IRQS; i++)
 			irq_reg_writel(gc, i, aic_reg_data->svr + (i * 4));
 	}
 }
 
 struct irq_domain *__init aic_common_of_init(struct device_node *node,
-					     const char *name, int nirqs)
+					     const char *name)
 {
 	struct irq_chip_generic *gc;
 	struct irq_domain *domain;
@@ -505,7 +533,9 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
 	if (aic_domain)
 		return ERR_PTR(-EEXIST);
 
-	nchips = DIV_ROUND_UP(nirqs, AIC_IRQS_PER_CHIP);
+	nchips = aic_get_num_chips(node);
+	if (nchips < 0)
+		return ERR_PTR(-EINVAL);
 
 	reg_base = of_iomap(node, 0);
 	if (!reg_base)
diff --git a/drivers/irqchip/irq-atmel-aic-common.h b/drivers/irqchip/irq-atmel-aic-common.h
index bf721b8..4170133 100644
--- a/drivers/irqchip/irq-atmel-aic-common.h
+++ b/drivers/irqchip/irq-atmel-aic-common.h
@@ -16,9 +16,7 @@
 #ifndef __IRQ_ATMEL_AIC_COMMON_H
 #define __IRQ_ATMEL_AIC_COMMON_H
 
-#define AIC_IRQS_PER_CHIP	32
-
 struct irq_domain *__init aic_common_of_init(struct device_node *node,
-					     const char *name, int nirqs);
+					     const char *name);
 
 #endif /* __IRQ_ATMEL_AIC_COMMON_H */
diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c
index 44cedce..980197f 100644
--- a/drivers/irqchip/irq-atmel-aic.c
+++ b/drivers/irqchip/irq-atmel-aic.c
@@ -60,7 +60,7 @@ static int __init aic_of_init(struct device_node *node,
 {
 	struct irq_domain *domain;
 
-	domain = aic_common_of_init(node, "atmel-aic", NR_AIC_IRQS);
+	domain = aic_common_of_init(node, "atmel-aic");
 	if (IS_ERR(domain))
 		return PTR_ERR(domain);
 
diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
index d09cefe..dcf4711 100644
--- a/drivers/irqchip/irq-atmel-aic5.c
+++ b/drivers/irqchip/irq-atmel-aic5.c
@@ -66,44 +66,17 @@
 #define AT91_AIC5_FFSR			0x58
 
 static int __init aic5_of_init(struct device_node *node,
-			       struct device_node *parent,
-			       int nirqs)
+			       struct device_node *parent)
 {
 	struct irq_domain *domain;
 
-	if (nirqs > NR_AIC5_IRQS)
-		return -EINVAL;
-
-	domain = aic_common_of_init(node, "atmel-aic5", nirqs);
+	domain = aic_common_of_init(node, "atmel-aic5");
 	if (IS_ERR(domain))
 		return PTR_ERR(domain);
 
 	return 0;
 }
 
-#define NR_SAMA5D2_IRQS		77
-
-static int __init sama5d2_aic5_of_init(struct device_node *node,
-				       struct device_node *parent)
-{
-	return aic5_of_init(node, parent, NR_SAMA5D2_IRQS);
-}
-IRQCHIP_DECLARE(sama5d2_aic5, "atmel,sama5d2-aic", sama5d2_aic5_of_init);
-
-#define NR_SAMA5D3_IRQS		48
-
-static int __init sama5d3_aic5_of_init(struct device_node *node,
-				       struct device_node *parent)
-{
-	return aic5_of_init(node, parent, NR_SAMA5D3_IRQS);
-}
-IRQCHIP_DECLARE(sama5d3_aic5, "atmel,sama5d3-aic", sama5d3_aic5_of_init);
-
-#define NR_SAMA5D4_IRQS		68
-
-static int __init sama5d4_aic5_of_init(struct device_node *node,
-				       struct device_node *parent)
-{
-	return aic5_of_init(node, parent, NR_SAMA5D4_IRQS);
-}
-IRQCHIP_DECLARE(sama5d4_aic5, "atmel,sama5d4-aic", sama5d4_aic5_of_init);
+IRQCHIP_DECLARE(sama5d2_aic5, "atmel,sama5d2-aic", aic5_of_init);
+IRQCHIP_DECLARE(sama5d3_aic5, "atmel,sama5d3-aic", aic5_of_init);
+IRQCHIP_DECLARE(sama5d4_aic5, "atmel,sama5d4-aic", aic5_of_init);
-- 
2.6.4


  parent reply	other threads:[~2016-01-04  4:29 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 ` [PATCH 15/19] irqchip: atmel-aic: add common interrupt handler Milo Kim
2016-01-04  4:28 ` Milo Kim [this message]
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-17-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®