Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / h8300 / kernel / irq.c
blob834e4d7b1bcf8aad6d809342894fb74725642c43
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * linux/arch/h8300/kernel/irq.c
5 * Copyright 2014-2015 Yoshinori Sato <ysato@users.sourceforge.jp>
6 */
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[] = {
19 0, 0, 0, 0,
20 _trace_break,
21 0, 0,
22 _nmi,
23 _system_call,
24 0, 0,
25 _trace_break,
28 static unsigned long __init *get_vector_address(void)
30 unsigned long *rom_vector = CPU_VECTOR;
31 unsigned long base, tmp;
32 int vec_no;
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))
40 return NULL;
43 /* ramvector base address */
44 base -= EXT_IRQ0*4;
46 /* writerble? */
47 tmp = ~(*(volatile unsigned long *)base);
48 (*(volatile unsigned long *)base) = tmp;
49 if ((*(volatile unsigned long *)base) != tmp)
50 return NULL;
51 return (unsigned long *)base;
54 static void __init setup_vector(void)
56 int i;
57 unsigned long *ramvec, *ramvec_p;
58 const h8300_vector *trap_entry;
60 ramvec = get_vector_address();
61 if (ramvec == NULL)
62 panic("interrupt vector serup failed.");
63 else
64 pr_debug("virtual vector at 0x%p\n", ramvec);
66 /* create redirect table */
67 ramvec_p = ramvec;
68 trap_entry = trap_table;
69 for (i = 0; i < NR_IRQS; i++) {
70 if (i < 12) {
71 if (*trap_entry)
72 *ramvec_p = VECTOR(*trap_entry);
73 ramvec_p++;
74 trap_entry++;
75 } else
76 *ramvec_p++ = REDIRECT(_interrupt_entry);
78 _interrupt_redirect_table = ramvec;
80 #else
81 void setup_vector(void)
83 /* noting do */
85 #endif
87 void __init init_IRQ(void)
89 setup_vector();
90 irqchip_init();
93 asmlinkage void do_IRQ(int irq)
95 irq_enter();
96 generic_handle_irq(irq);
97 irq_exit();