ARM: Subarch IRQ handler macro support
Magnus Damm
maintainercover ARM: Subarch IRQ handler macro support
ARM: Subarch IRQ handler macro support
[PATCH 01/02][RFC] ARM: Introduce Subarch IRQ handler macros [PATCH 02/02][RFC] ARM: shmobile: Use Subarch IRQ handler for INTC
These patches add a macro for per-subarch use together with some example code that shows how to use it.
The first patch simply breaks out code from the irq_handler macro in entry-armv.S to the new macro arch_irq_handler that is put in a shared header file. The new header file also adds the new macro arch_irq_handler_default which replaces previous code in the entry-armv.S file.
Patch number two gives an example on how to make use of the macro arch_irq_handler on the SH-Mobile ARM subarch. Compile-time tested on top of RMKs devel tree with the CONFIG_MULTI_IRQ_HANDLER patch by Eric Miao. Please note that this patch isn't suitable for merge since it needs to be reworked to fit on the sh-2.6 tree where the rest of the SH-Mobile changes are.
In short, the per-subarch code is reduced to the following on the sh7372 uniprocessor:
+#include <asm/entry-macro-multi.S>
+
+#define INTFLGA 0xe6980018
+
+ .macro get_irqnr_preamble, base, tmp + ldr \base, =INTFLGA + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #0 + beq 1000f + /* intevt to irq number */ + lsr \irqnr, \irqnr, #0x5 + subs \irqnr, \irqnr, #16
+1000:
+ .endm
+
+ arch_irq_handler shmobile_handle_irq_intc
This code depends on the following patch by Eric Miao:
[PATCH] ARM: Allow machine to specify it's own IRQ handlers at run-time
Comments are more than welcome!
--- arch/arm/include/asm/entry-macro-multi.S | 43 +++++++++++++++++++++ arch/arm/kernel/entry-armv.S | 31 --------------- arch/arm/mach-shmobile/Kconfig | 3 + arch/arm/mach-shmobile/Makefile | 12 ++++- arch/arm/mach-shmobile/board-ap4evb.c | 1 arch/arm/mach-shmobile/board-g3evm.c | 1 arch/arm/mach-shmobile/board-g4evm.c | 1 arch/arm/mach-shmobile/entry-intc.S | 30 ++++++++++++++ arch/arm/mach-shmobile/include/mach/common.h | 1 arch/arm/mach-shmobile/include/mach/entry-macro.S | 27 ------------- arch/arm/mach-shmobile/include/mach/hardware.h | 3 - 11 files changed, 91 insertions(+), 62 deletions(-)
Magnus Damm
maintainerRFC PATCH 1/2 ARM: Introduce Subarch IRQ handler macros
From: Magnus Damm <[email protected]>
Break out code from the irq_handler macro into the two macros arch_irq_handler and arch_irq_handler_default.
Put the macros in the header file "entry-macro-multi.S"
The macro arch_irq_handler_default is designed to be used by the irq_handler macro in entry-armv.S while arch_irq_handler is suitable for per-subarch use.
---
arch/arm/include/asm/entry-macro-multi.S | 43 ++++++++++++++++++++++++++++++ arch/arm/kernel/entry-armv.S | 31 +-------------------- 2 files changed, 45 insertions(+), 29 deletions(-)
arch/arm/include/asm/entry-macro-multi.S new file +43 -0
@@ -0,0 +1,43 @@ +/* + * Interrupt handling. Preserves r7, r8, r9 + */ + .macro arch_irq_handler_default + get_irqnr_preamble r5, lr +1: get_irqnr_and_base r0, r6, r5, lr + movne r1, sp + @ + @ routine called with r0 = irq number, r1 = struct pt_regs * + @ + adrne lr, BSYM(1b) + bne asm_do_IRQ + +#ifdef CONFIG_SMP + /* + * XXX + * + * this macro assumes that irqstat (r6) and base (r5) are + * preserved from get_irqnr_and_base above + */ + ALT_SMP(test_for_ipi r0, r6, r5, lr) + ALT_UP_B(9998f) + movne r1, sp + adrne lr, BSYM(1b) + bne do_IPI + +#ifdef CONFIG_LOCAL_TIMERS + test_for_ltirq r0, r6, r5, lr + movne r0, sp + adrne lr, BSYM(1b) + bne do_local_timer +#endif +9998: +#endif + .endm + + .macro arch_irq_handler, symbol_name + .align 5 + .global \symbol_name +\symbol_name: + arch_irq_handler_default + mov pc, lr + .endm
arch/arm/kernel/entry-armv.S +2 -29
@@ -19,6 +19,7 @@ #include <asm/glue.h> #include <asm/vfpmacros.h> #include <mach/entry-macro.S> +#include <asm/entry-macro-multi.S> #include <asm/thread_notify.h> #include <asm/unwind.h> #include <asm/unistd.h>
@@ -38,35 +39,7 @@ adrne lr, BSYM(9997f) ldrne pc, [r1] #endif - get_irqnr_preamble r5, lr -1: get_irqnr_and_base r0, r6, r5, lr - movne r1, sp - @ - @ routine called with r0 = irq number, r1 = struct pt_regs * - @ - adrne lr, BSYM(1b) - bne asm_do_IRQ - -#ifdef CONFIG_SMP - /* - * XXX - * - * this macro assumes that irqstat (r6) and base (r5) are - * preserved from get_irqnr_and_base above - */ - ALT_SMP(test_for_ipi r0, r6, r5, lr) - ALT_UP_B(9997f) - movne r1, sp - adrne lr, BSYM(1b) - bne do_IPI - -#ifdef CONFIG_LOCAL_TIMERS - test_for_ltirq r0, r6, r5, lr - movne r0, sp - adrne lr, BSYM(1b) - bne do_local_timer -#endif -#endif + arch_irq_handler_default 9997: .endm
Magnus Damm
maintainerRFC PATCH 2/2 ARM: shmobile: Use Subarch IRQ handler for INTC
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Example code that shows how to use arch_irq_handler together with the handle_irq callback on SH-Mobile ARM.
---
arch/arm/mach-shmobile/Kconfig | 3 ++ arch/arm/mach-shmobile/Makefile | 12 ++++++-- arch/arm/mach-shmobile/board-ap4evb.c | 1 arch/arm/mach-shmobile/board-g3evm.c | 1 arch/arm/mach-shmobile/board-g4evm.c | 1 arch/arm/mach-shmobile/entry-intc.S | 30 +++++++++++++++++++++ arch/arm/mach-shmobile/include/mach/common.h | 1 arch/arm/mach-shmobile/include/mach/entry-macro.S | 27 ------------------ arch/arm/mach-shmobile/include/mach/hardware.h | 3 -- 9 files changed, 46 insertions(+), 33 deletions(-)
arch/arm/mach-shmobile/Kconfig +3 -0
@@ -9,6 +9,7 @@ config ARCH_SH7367 select CLKDEV_LOOKUP select SH_CLK_CPG select GENERIC_CLOCKEVENTS + select MULTI_IRQ_HANDLER config ARCH_SH7377 bool "SH-Mobile G4 (SH7377)"
@@ -17,6 +18,7 @@ config ARCH_SH7377 select CLKDEV_LOOKUP select SH_CLK_CPG select GENERIC_CLOCKEVENTS + select MULTI_IRQ_HANDLER config ARCH_SH7372 bool "SH-Mobile AP4 (SH7372)"
@@ -25,6 +27,7 @@ config ARCH_SH7372 select CLKDEV_LOOKUP select SH_CLK_CPG select GENERIC_CLOCKEVENTS + select MULTI_IRQ_HANDLER comment "SH-Mobile Board Type"
arch/arm/mach-shmobile/Makefile +9 -3
@@ -6,9 +6,15 @@ obj-y := timer.o console.o clock.o pm_runtime.o # CPU objects -obj-$(CONFIG_ARCH_SH7367) += setup-sh7367.o clock-sh7367.o intc-sh7367.o -obj-$(CONFIG_ARCH_SH7377) += setup-sh7377.o clock-sh7377.o intc-sh7377.o -obj-$(CONFIG_ARCH_SH7372) += setup-sh7372.o clock-sh7372.o intc-sh7372.o +obj-$(CONFIG_ARCH_SH7367) += setup-sh7367.o clock-sh7367.o +obj-$(CONFIG_ARCH_SH7377) += setup-sh7377.o clock-sh7377.o +obj-$(CONFIG_ARCH_SH7372) += setup-sh7372.o clock-sh7372.o + +# IRQ objects +irq-$(CONFIG_ARCH_SH7367) += intc-sh7367.o entry-intc.o +irq-$(CONFIG_ARCH_SH7377) += intc-sh7377.o entry-intc.o +irq-$(CONFIG_ARCH_SH7372) += intc-sh7372.o entry-intc.o +obj-y += $(irq-y) # Pinmux setup pfc-$(CONFIG_ARCH_SH7367) := pfc-sh7367.o
arch/arm/mach-shmobile/board-ap4evb.c +1 -0
@@ -1356,6 +1356,7 @@ static struct sys_timer ap4evb_timer = {MACHINE_START (AP4EVB ,"ap4evb" ) .map_io = ap4evb_map_io, .init_irq = sh7372_init_irq, + .handle_irq = shmobile_handle_irq_intc, .init_machine = ap4evb_init, .timer = &ap4evb_timer,MACHINE_END
arch/arm/mach-shmobile/board-g3evm.c +1 -0
@@ -367,6 +367,7 @@ static struct sys_timer g3evm_timer = {MACHINE_START (G3EVM ,"g3evm" ) .map_io = g3evm_map_io, .init_irq = sh7367_init_irq, + .handle_irq = shmobile_handle_irq_intc, .init_machine = g3evm_init, .timer = &g3evm_timer,MACHINE_END
arch/arm/mach-shmobile/board-g4evm.c +1 -0
@@ -394,6 +394,7 @@ static struct sys_timer g4evm_timer = {MACHINE_START (G4EVM ,"g4evm" ) .map_io = g4evm_map_io, .init_irq = sh7377_init_irq, + .handle_irq = shmobile_handle_irq_intc, .init_machine = g4evm_init, .timer = &g4evm_timer,MACHINE_END
arch/arm/mach-shmobile/entry-intc.S new file +30 -0
@@ -0,0 +1,30 @@ +/* + * ARM Interrupt demux handler using INTC + * + * Copyright (C) 2010 Magnus Damm + * Copyright (C) 2008 Renesas Solutions Corp. + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include <asm/entry-macro-multi.S> + +#define INTFLGA 0xe6980018 + + .macro get_irqnr_preamble, base, tmp + ldr \base, =INTFLGA + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \irqnr, [\base] + cmp \irqnr, #0 + beq 1000f + /* intevt to irq number */ + lsr \irqnr, \irqnr, #0x5 + subs \irqnr, \irqnr, #16 +1000: + .endm + + arch_irq_handler shmobile_handle_irq_intc
arch/arm/mach-shmobile/include/mach/common.h +1 -0
@@ -5,6 +5,7 @@ extern struct sys_timer shmobile_timer;extern void shmobile_setup_console (void );struct clk ;extern int clk_init (void ); +extern void shmobile_handle_irq_intc (struct pt_regs *);extern void sh7367_init_irq (void );extern void sh7367_add_early_devices (void );
arch/arm/mach-shmobile/include/mach/entry-macro.S +0 -27
@@ -1,39 +1,12 @@ -/* - * Copyright (C) 2008 Renesas Solutions Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include <mach/hardware.h> -#include <mach/irqs.h> .macro disable_fiq .endm .macro get_irqnr_preamble, base, tmp - ldr \base, =INTFLGA .endm .macro arch_ret_to_user, tmp1, tmp2 .endm .macro get_irqnr_and_base, irqnr, irqstat, base, tmp - ldr \irqnr, [\base] - cmp \irqnr, #0 - beq 1000f - /* intevt to irq number */ - lsr \irqnr, \irqnr, #0x5 - subs \irqnr, \irqnr, #16 - -1000: .endm
arch/arm/mach-shmobile/include/mach/hardware.h +0 -3
@@ -1,7 +1,4 @@#ifndef __ASM_MACH_HARDWARE_H#define __ASM_MACH_HARDWARE_H -/* INTFLGA register - used by low level interrupt code in entry-macro.S */ -#define INTFLGA 0xe6980018 -#endif /* __ASM_MACH_HARDWARE_H */