From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752977AbcADE3E (ORCPT ); Sun, 3 Jan 2016 23:29:04 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:59385 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752944AbcADE27 (ORCPT ); Sun, 3 Jan 2016 23:28:59 -0500 From: Milo Kim To: CC: , , , , , , , Milo Kim Subject: [PATCH 16/19] irqchip: atmel-aic: get total number of IRQs from device node Date: Mon, 4 Jan 2016 13:28:40 +0900 Message-ID: <1451881723-2478-17-git-send-email-milo.kim@ti.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1451881723-2478-1-git-send-email-milo.kim@ti.com> References: <1451881723-2478-1-git-send-email-milo.kim@ti.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Jason Cooper Cc: Marc Zyngier Cc: Alexandre Belloni Cc: Boris BREZILLON Cc: Ludovic Desroches Cc: Nicolas Ferre Cc: linux-kernel@vger.kernel.org Signed-off-by: Milo Kim --- 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