From patchwork Tue Jan 4 11:41:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Hellstrom X-Patchwork-Id: 77450 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id DB2C6B7103 for ; Tue, 4 Jan 2011 22:41:46 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751241Ab1ADLlp (ORCPT ); Tue, 4 Jan 2011 06:41:45 -0500 Received: from mail202c2.megamailservers.com ([69.49.111.103]:34440 "EHLO mail202c2.megamailservers.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063Ab1ADLlo (ORCPT ); Tue, 4 Jan 2011 06:41:44 -0500 X-POP-User: marko.gaisler.com Received: from localhost.localdomain (static-92-33-28-242.sme.bredbandsbolaget.se [92.33.28.242]) by mail202c2.megamailservers.com (8.13.6/8.13.1) with ESMTP id p04BfaGt015739; Tue, 4 Jan 2011 06:41:39 -0500 From: Daniel Hellstrom To: davem@davemloft.net Cc: sparclinux@vger.kernel.org, sam@ravnborg.org Subject: [PATCH 2/7] SPARC/LEON: added support for IRQAMP IRQ Controller Date: Tue, 4 Jan 2011 12:41:30 +0100 Message-Id: <1294141295-26584-2-git-send-email-daniel@gaisler.com> X-Mailer: git-send-email 1.5.4 In-Reply-To: <1294141295-26584-1-git-send-email-daniel@gaisler.com> References: <1294141295-26584-1-git-send-email-daniel@gaisler.com> X-CSC: 0 X-CHA: v=1.1 cv=CDb0R4Z6TO0sOUMNi4VR3AiCY0jfodj/AVBUGp8lLvg= c=1 sm=1 a=SkbBYX1IG70A:10 a=jXKJviUpWSOlMmIvGrHOfw==:17 a=ebG-ZW-8AAAA:8 a=9NHTXhh6841HBc1AoCMA:9 a=8SqnW3M4eK69OFW-YYoA:7 a=O8A3lRS8sa_4QYXP99Kqz5HX-6IA:4 a=cCYF7-FHeg4A:10 a=jXKJviUpWSOlMmIvGrHOfw==:117 Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org Needed for LEON AMP systems where different CPUs are routed to different IRQ controllers. This patch selects the IRQ Controller which has been routed to the boot CPU, it is up to the boot loader to configure the IRQ controller. Signed-off-by: Daniel Hellstrom --- arch/sparc/include/asm/leon.h | 12 ++++++++++++ arch/sparc/include/asm/leon_amba.h | 6 +++--- arch/sparc/kernel/leon_kernel.c | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/arch/sparc/include/asm/leon.h b/arch/sparc/include/asm/leon.h index 3ea5964..8580d17 100644 --- a/arch/sparc/include/asm/leon.h +++ b/arch/sparc/include/asm/leon.h @@ -224,6 +224,18 @@ static inline void sparc_leon3_disable_cache(void) "sta %%l2, [%%g0] 2\n\t" : : : "l1", "l2"); }; +static inline unsigned long sparc_leon3_asr17(void) +{ + u32 asr17; + __asm__ __volatile__ ("rd %%asr17, %0\n\t" : "=r"(asr17)); + return asr17; +}; + +static inline int sparc_leon3_cpuid(void) +{ + return sparc_leon3_asr17() >> 28; +} + #endif /*!__ASSEMBLY__*/ #ifdef CONFIG_SMP diff --git a/arch/sparc/include/asm/leon_amba.h b/arch/sparc/include/asm/leon_amba.h index 618e888..263c719 100644 --- a/arch/sparc/include/asm/leon_amba.h +++ b/arch/sparc/include/asm/leon_amba.h @@ -100,9 +100,8 @@ struct leon3_irqctrl_regs_map { u32 mpbroadcast; u32 notused02; u32 notused03; - u32 notused10; - u32 notused11; - u32 notused12; + u32 ampctrl; + u32 icsel[2]; u32 notused13; u32 notused20; u32 notused21; @@ -112,6 +111,7 @@ struct leon3_irqctrl_regs_map { u32 force[16]; /* Extended IRQ registers */ u32 intid[16]; /* 0xc0 */ + u32 unused[(0x1000-0x100)/4]; }; struct leon3_apbuart_regs_map { diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c index 80ba8f5..91a978f 100644 --- a/arch/sparc/kernel/leon_kernel.c +++ b/arch/sparc/kernel/leon_kernel.c @@ -108,6 +108,7 @@ void __init leon_init_timers(irq_handler_t counter_fn) struct device_node *rootnp, *np; struct property *pp; int len; + int cpu, icsel; leondebug_irq_disable = 0; leon_debug_irqout = 0; @@ -160,6 +161,19 @@ void __init leon_init_timers(irq_handler_t counter_fn) LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0); # endif + /* + * The IRQ controller may (if implemented) consist of multiple + * IRQ controllers, each mapped on a 4Kb boundary. + * Each CPU may be routed to different IRQCTRLs, however + * we assume that all CPUs (in SMP system) is routed to the + * same IRQ Controller, and for non-SMP only one IRQCTRL is + * accessed anyway. + * In AMP systems, Linux must run on CPU0 for the time being. + */ + cpu = sparc_leon3_cpuid(); + icsel = LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->icsel[cpu/8]); + icsel = (icsel >> ((7 - (cpu&0x7)) * 4)) & 0xf; + leon3_irqctrl_regs += icsel; } else { goto bad; }