From patchwork Tue Jan 10 10:24:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 135195 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5C266B6FC2 for ; Tue, 10 Jan 2012 21:30:27 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RkYvE-0002BQ-7P; Tue, 10 Jan 2012 10:27:16 +0000 Received: from moutng.kundenserver.de ([212.227.126.171]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RkYvA-0002Aq-G5 for linux-arm-kernel@lists.infradead.org; Tue, 10 Jan 2012 10:27:13 +0000 Received: from benhur.adnet.avionic-design.de (p548E11A3.dip0.t-ipconnect.de [84.142.17.163]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0Lapqe-1SQXTb1IYi-00kZtb; Tue, 10 Jan 2012 11:24:24 +0100 Received: from mailbox.adnet.avionic-design.de (add-virt-zarafa.adnet.avionic-design.de [172.20.129.9]) by benhur.adnet.avionic-design.de (Postfix) with ESMTP id F10272C4114; Tue, 10 Jan 2012 11:24:24 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id 197872A28187; Tue, 10 Jan 2012 11:24:22 +0100 (CET) X-Virus-Scanned: amavisd-new at avionic-design.de Received: from mailbox.adnet.avionic-design.de ([127.0.0.1]) by localhost (mailbox.avionic-design.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M4FyhvFilJCY; Tue, 10 Jan 2012 11:24:20 +0100 (CET) Received: from localhost (avionic-0098.adnet.avionic-design.de [172.20.31.233]) (Authenticated sender: thierry.reding) by mailbox.adnet.avionic-design.de (Postfix) with ESMTPA id A9B322A280A4; Tue, 10 Jan 2012 11:24:19 +0100 (CET) From: Thierry Reding To: devicetree-discuss@lists.ozlabs.org Subject: [PATCH v2] irqdomain: Initialize number of IRQs for simple domains Date: Tue, 10 Jan 2012 11:24:11 +0100 Message-Id: <1326191059-26411-1-git-send-email-thierry.reding@avionic-design.de> X-Mailer: git-send-email 1.7.8.3 X-Provags-ID: V02:K0:AU8lQvAYeoFkGOe8t19ptl2UJLtdMp0A6ITJYyoxyJU HnVbSox6mrBeWgMdXgiBqExLjZUueVYGZvIHQ3jOK9zD8NEXfd 9FIb+f3sZ+aBynLwgc4ErQ2jiyh7O8Rl5VX0Czb7dRvMFjoTM4 4Bd8Z0P/p5Ld7/ajrEybeURgbEUKl7Akd9V8T0cRuoFG790Oi5 3I2N+lHrov2wwkZ1coWM5qHTKBHSA+hg4sVjy65biw+cGXuYwz Rt2rJ3iY76PRgRJpwixFuCW2TpX/6oHhVLgnY0LNkQvD67JxDT /973hgDhDsK2snwITpLshF+fBvt3cxAnEKbao7wm4hUAjBxQNE JyTtSmYKjeAwK5wZF2D556hl/SckHeENlkCTZblEF1eFwTOUEY IiXM91Hov2ch02d4SMBWaNFLj7WXGN/ntUlYMP/xCqNdXwnvYA 6E2n6 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.4 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.171 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.5 SINGLE_HEADER_1K A single header contains 1K-2K characters Cc: Tony Lindgren , Catalin Marinas , Thierry Reding , Nicolas Ferre , Grant Likely , Daniel Walker , Jamie Iles , Russell King , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , David Brown , Jean-Christophe Plagniol-Villard , "open list:ARM/QUALCOMM MSM..." , Rob Herring , Barry Song , Thomas Gleixner , "open list:OMAP SUPPORT" , Andrew Victor , "open list:ARM/ATMEL AT91RM9..." , open list , Bryan Huntsman , Sascha Hauer , Shawn Guo , David Woodhouse X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org The irq_domain_add() function needs the number of interrupts in the domain to properly initialize them. In addition the allocated domain is now returned by the irq_domain_{add,generate}_simple() helpers. Signed-off-by: Thierry Reding Acked-by: Nicolas Ferre Acked-by: David Brown Reviewed-by: Jamie Iles Acked-by: Shawn Guo --- Note: This patch should not be applied yet. There is a conflict with a pending patch[0] by Benoit Cousson that will obsolete the OMAP2 hunk in this patch. [0]: http://www.spinics.net/lists/linux-omap/msg62124.html Changes in v2: - Don't use ERR_PTR, keep the WARN_ON(1) and return NULL as requested by Grant Likely. - Integrate i.MX cleanup patch by Shawn Guo. arch/arm/mach-at91/board-dt.c | 2 +- arch/arm/mach-imx/imx51-dt.c | 13 +++++++++++-- arch/arm/mach-imx/imx53-dt.c | 13 +++++++++++-- arch/arm/mach-imx/mach-imx6q.c | 6 +++++- arch/arm/mach-msm/board-msm8x60.c | 2 +- arch/arm/mach-omap2/board-generic.c | 2 +- arch/arm/mach-prima2/irq.c | 2 +- arch/arm/mach-versatile/core.c | 6 ++++-- arch/arm/plat-mxc/include/mach/irqs.h | 13 +++++++------ arch/arm/plat-mxc/tzic.c | 2 -- include/linux/irqdomain.h | 27 ++++++++++++++++++++++----- kernel/irq/irqdomain.c | 26 ++++++++++++++++++-------- 12 files changed, 82 insertions(+), 32 deletions(-) diff --git a/arch/arm/mach-at91/board-dt.c b/arch/arm/mach-at91/board-dt.c index bb6b434..40e5b6c 100644 --- a/arch/arm/mach-at91/board-dt.c +++ b/arch/arm/mach-at91/board-dt.c @@ -95,7 +95,7 @@ static const struct of_device_id aic_of_match[] __initconst = { static void __init at91_dt_init_irq(void) { - irq_domain_generate_simple(aic_of_match, 0xfffff000, 0); + irq_domain_generate_simple(aic_of_match, 0xfffff000, 0, NR_AIC_IRQS); at91_init_irq_default(); } diff --git a/arch/arm/mach-imx/imx51-dt.c b/arch/arm/mach-imx/imx51-dt.c index e6bad17..811ce88 100644 --- a/arch/arm/mach-imx/imx51-dt.c +++ b/arch/arm/mach-imx/imx51-dt.c @@ -47,7 +47,12 @@ static const struct of_dev_auxdata imx51_auxdata_lookup[] __initconst = { static int __init imx51_tzic_add_irq_domain(struct device_node *np, struct device_node *interrupt_parent) { - irq_domain_add_simple(np, 0); + struct irq_domain *domain; + + domain = irq_domain_add_simple(np, 0, TZIC_NUM_IRQS); + if (!domain) + return -ENOMEM; + return 0; } @@ -55,9 +60,13 @@ static int __init imx51_gpio_add_irq_domain(struct device_node *np, struct device_node *interrupt_parent) { static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS; + struct irq_domain *domain; gpio_irq_base -= 32; - irq_domain_add_simple(np, gpio_irq_base); + + domain = irq_domain_add_simple(np, gpio_irq_base, 32); + if (!domain) + return -ENOMEM; return 0; } diff --git a/arch/arm/mach-imx/imx53-dt.c b/arch/arm/mach-imx/imx53-dt.c index 05ebb3e..458ec03 100644 --- a/arch/arm/mach-imx/imx53-dt.c +++ b/arch/arm/mach-imx/imx53-dt.c @@ -51,7 +51,12 @@ static const struct of_dev_auxdata imx53_auxdata_lookup[] __initconst = { static int __init imx53_tzic_add_irq_domain(struct device_node *np, struct device_node *interrupt_parent) { - irq_domain_add_simple(np, 0); + struct irq_domain *domain; + + domain = irq_domain_add_simple(np, 0, TZIC_NUM_IRQS); + if (!domain) + return -ENOMEM; + return 0; } @@ -59,9 +64,13 @@ static int __init imx53_gpio_add_irq_domain(struct device_node *np, struct device_node *interrupt_parent) { static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS; + struct irq_domain *domain; gpio_irq_base -= 32; - irq_domain_add_simple(np, gpio_irq_base); + + domain = irq_domain_add_simple(np, gpio_irq_base, 32); + if (!domain) + return -ENOMEM; return 0; } diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index c257281..4955920 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c @@ -95,9 +95,13 @@ static int __init imx6q_gpio_add_irq_domain(struct device_node *np, struct device_node *interrupt_parent) { static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS; + struct irq_domain *domain; gpio_irq_base -= 32; - irq_domain_add_simple(np, gpio_irq_base); + + domain = irq_domain_add_simple(np, gpio_irq_base, 32); + if (!domain) + return -ENOMEM; return 0; } diff --git a/arch/arm/mach-msm/board-msm8x60.c b/arch/arm/mach-msm/board-msm8x60.c index 0a11342..4d26707 100644 --- a/arch/arm/mach-msm/board-msm8x60.c +++ b/arch/arm/mach-msm/board-msm8x60.c @@ -85,7 +85,7 @@ static void __init msm8x60_dt_init(void) node = of_find_matching_node_by_address(NULL, msm_dt_gic_match, MSM8X60_QGIC_DIST_PHYS); if (node) - irq_domain_add_simple(node, GIC_SPI_START); + irq_domain_add_simple(node, GIC_SPI_START, NR_MSM_IRQS); if (of_machine_is_compatible("qcom,msm8660-surf")) { printk(KERN_INFO "Init surf UART registers\n"); diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c index d587560..32f5d9b 100644 --- a/arch/arm/mach-omap2/board-generic.c +++ b/arch/arm/mach-omap2/board-generic.c @@ -67,7 +67,7 @@ static void __init omap_generic_init(void) { struct device_node *node = of_find_matching_node(NULL, intc_match); if (node) - irq_domain_add_simple(node, 0); + irq_domain_add_simple(node, 0, INTCPS_NR_IRQS); omap_sdrc_init(NULL, NULL); diff --git a/arch/arm/mach-prima2/irq.c b/arch/arm/mach-prima2/irq.c index d93ceef..da0c1df 100644 --- a/arch/arm/mach-prima2/irq.c +++ b/arch/arm/mach-prima2/irq.c @@ -68,7 +68,7 @@ void __init sirfsoc_of_irq_init(void) if (!sirfsoc_intc_base) panic("unable to map intc cpu registers\n"); - irq_domain_add_simple(np, 0); + irq_domain_add_simple(np, 0, NR_IRQS); of_node_put(np); diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index 02b7b93..df7266a 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c @@ -99,12 +99,14 @@ static const struct of_device_id sic_of_match[] __initconst = { void __init versatile_init_irq(void) { vic_init(VA_VIC_BASE, IRQ_VIC_START, ~0, 0); - irq_domain_generate_simple(vic_of_match, VERSATILE_VIC_BASE, IRQ_VIC_START); + irq_domain_generate_simple(vic_of_match, VERSATILE_VIC_BASE, + IRQ_VIC_START, IRQ_VIC_END - IRQ_VIC_START + 1); writel(~0, VA_SIC_BASE + SIC_IRQ_ENABLE_CLEAR); fpga_irq_init(IRQ_VICSOURCE31, ~PIC_MASK, &sic_irq); - irq_domain_generate_simple(sic_of_match, VERSATILE_SIC_BASE, IRQ_SIC_START); + irq_domain_generate_simple(sic_of_match, VERSATILE_SIC_BASE, + IRQ_SIC_START, IRQ_SIC_END - IRQ_SIC_START + 1); /* * Interrupts on secondary controller from 0 to 8 are routed to diff --git a/arch/arm/plat-mxc/include/mach/irqs.h b/arch/arm/plat-mxc/include/mach/irqs.h index fd9efb0..70376e0 100644 --- a/arch/arm/plat-mxc/include/mach/irqs.h +++ b/arch/arm/plat-mxc/include/mach/irqs.h @@ -13,19 +13,20 @@ #include +#define GIC_NUM_IRQS 160 +#define TZIC_NUM_IRQS 128 +#define AVIC_NUM_IRQS 64 + /* - * SoCs with GIC interrupt controller have 160 IRQs, those with TZIC - * have 128 IRQs, and those with AVIC have 64. - * * To support single image, the biggest number should be defined on * top of the list. */ #if defined CONFIG_ARM_GIC -#define MXC_INTERNAL_IRQS 160 +#define MXC_INTERNAL_IRQS GIC_NUM_IRQS #elif defined CONFIG_MXC_TZIC -#define MXC_INTERNAL_IRQS 128 +#define MXC_INTERNAL_IRQS TZIC_NUM_IRQS #else -#define MXC_INTERNAL_IRQS 64 +#define MXC_INTERNAL_IRQS AVIC_NUM_IRQS #endif #define MXC_GPIO_IRQ_START MXC_INTERNAL_IRQS diff --git a/arch/arm/plat-mxc/tzic.c b/arch/arm/plat-mxc/tzic.c index 98308ec..98b23b8 100644 --- a/arch/arm/plat-mxc/tzic.c +++ b/arch/arm/plat-mxc/tzic.c @@ -50,8 +50,6 @@ void __iomem *tzic_base; /* Used as irq controller base in entry-macro.S */ -#define TZIC_NUM_IRQS 128 - #ifdef CONFIG_FIQ static int tzic_set_irq_fiq(unsigned int irq, unsigned int type) { diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index bd4272b..6bf9a1c 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -15,6 +15,7 @@ #ifndef _LINUX_IRQDOMAIN_H #define _LINUX_IRQDOMAIN_H +#include #include #include @@ -96,12 +97,28 @@ extern struct irq_domain_ops irq_domain_simple_ops; #endif /* CONFIG_IRQ_DOMAIN */ #if defined(CONFIG_IRQ_DOMAIN) && defined(CONFIG_OF_IRQ) -extern void irq_domain_add_simple(struct device_node *controller, int irq_base); -extern void irq_domain_generate_simple(const struct of_device_id *match, - u64 phys_base, unsigned int irq_start); +extern struct irq_domain *irq_domain_add_simple(struct device_node *controller, + unsigned int irq_base, + unsigned int nr_irq); +extern struct irq_domain *irq_domain_generate_simple(const struct of_device_id *match, + u64 phys_base, + unsigned int irq_start, + unsigned int nr_irq); #else /* CONFIG_IRQ_DOMAIN && CONFIG_OF_IRQ */ -static inline void irq_domain_generate_simple(const struct of_device_id *match, - u64 phys_base, unsigned int irq_start) { } +static inline struct irq_domain *irq_domain_add_simple(struct device_node *controller, + int irq_base, + unsigned int nr_irq) +{ + return NULL; +} + +static inline struct irq_domain *irq_domain_generate_simple(const struct of_device_id *match, + u64 phys_base, + unsigned int irq_start, + unsigned int nr_irq) +{ + return NULL; +} #endif /* CONFIG_IRQ_DOMAIN && CONFIG_OF_IRQ */ #endif /* _LINUX_IRQDOMAIN_H */ diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 1f9e265..133d28b 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -147,36 +147,46 @@ int irq_domain_simple_dt_translate(struct irq_domain *d, } /** - * irq_domain_create_simple() - Set up a 'simple' translation range + * irq_domain_add_simple() - Set up a 'simple' translation range */ -void irq_domain_add_simple(struct device_node *controller, int irq_base) +struct irq_domain *irq_domain_add_simple(struct device_node *controller, + unsigned int irq_base, + unsigned int nr_irq) { struct irq_domain *domain; domain = kzalloc(sizeof(*domain), GFP_KERNEL); if (!domain) { WARN_ON(1); - return; + return NULL; } domain->irq_base = irq_base; + domain->nr_irq = nr_irq; domain->of_node = of_node_get(controller); domain->ops = &irq_domain_simple_ops; irq_domain_add(domain); + + return domain; } EXPORT_SYMBOL_GPL(irq_domain_add_simple); -void irq_domain_generate_simple(const struct of_device_id *match, - u64 phys_base, unsigned int irq_start) +struct irq_domain *irq_domain_generate_simple(const struct of_device_id *match, + u64 phys_base, + unsigned int irq_start, + unsigned int nr_irq) { + struct irq_domain *domain = NULL; struct device_node *node; - pr_info("looking for phys_base=%llx, irq_start=%i\n", - (unsigned long long) phys_base, (int) irq_start); + pr_info("looking for phys_base=%llx, irq_start=%u, nr_irq=%u\n", + (unsigned long long) phys_base, irq_start, nr_irq); node = of_find_matching_node_by_address(NULL, match, phys_base); if (node) - irq_domain_add_simple(node, irq_start); + domain = irq_domain_add_simple(node, irq_start, nr_irq); else pr_info("no node found\n"); + + return domain; } EXPORT_SYMBOL_GPL(irq_domain_generate_simple); #endif /* CONFIG_OF_IRQ */