1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/h8300/kernel/irq.c
5 * Copyright 2014-2015 Yoshinori Sato <ysato@users.sourceforge.jp>
8 #include <linux/init.h>
9 #include <linux/interrupt.h>
10 #include <linux/irq.h>
11 #include <linux/irqdomain.h>
12 #include <linux/of_irq.h>
13 #include <asm/traps.h>
15 #ifdef CONFIG_RAMKERNEL
16 typedef void (*h8300_vector
)(void);
18 static const h8300_vector __initconst trap_table
[] = {
28 static unsigned long __init
*get_vector_address(void)
30 unsigned long *rom_vector
= CPU_VECTOR
;
31 unsigned long base
, tmp
;
34 base
= rom_vector
[EXT_IRQ0
] & ADDR_MASK
;
36 /* check romvector format */
37 for (vec_no
= EXT_IRQ0
+ 1; vec_no
<= EXT_IRQ0
+EXT_IRQS
; vec_no
++) {
38 if ((base
+(vec_no
- EXT_IRQ0
)*4) !=
39 (rom_vector
[vec_no
] & ADDR_MASK
))
43 /* ramvector base address */
47 tmp
= ~(*(volatile unsigned long *)base
);
48 (*(volatile unsigned long *)base
) = tmp
;
49 if ((*(volatile unsigned long *)base
) != tmp
)
51 return (unsigned long *)base
;
54 static void __init
setup_vector(void)
57 unsigned long *ramvec
, *ramvec_p
;
58 const h8300_vector
*trap_entry
;
60 ramvec
= get_vector_address();
62 panic("interrupt vector serup failed.");
64 pr_debug("virtual vector at 0x%p\n", ramvec
);
66 /* create redirect table */
68 trap_entry
= trap_table
;
69 for (i
= 0; i
< NR_IRQS
; i
++) {
72 *ramvec_p
= VECTOR(*trap_entry
);
76 *ramvec_p
++ = REDIRECT(_interrupt_entry
);
78 _interrupt_redirect_table
= ramvec
;
81 void setup_vector(void)
87 void __init
init_IRQ(void)
93 asmlinkage
void do_IRQ(int irq
)
96 generic_handle_irq(irq
);