xref: /openbmc/linux/arch/riscv/kernel/irq.c (revision f8e17c17)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2012 Regents of the University of California
4  * Copyright (C) 2017 SiFive
5  * Copyright (C) 2018 Christoph Hellwig
6  */
7 
8 #include <linux/interrupt.h>
9 #include <linux/irqchip.h>
10 #include <linux/irqdomain.h>
11 #include <linux/seq_file.h>
12 #include <asm/smp.h>
13 
14 int arch_show_interrupts(struct seq_file *p, int prec)
15 {
16 	show_ipi_stats(p, prec);
17 	return 0;
18 }
19 
20 asmlinkage __visible void __irq_entry do_IRQ(struct pt_regs *regs)
21 {
22 	struct pt_regs *old_regs = set_irq_regs(regs);
23 
24 	irq_enter();
25 	switch (regs->cause & ~CAUSE_IRQ_FLAG) {
26 	case RV_IRQ_TIMER:
27 		riscv_timer_interrupt();
28 		break;
29 #ifdef CONFIG_SMP
30 	case RV_IRQ_SOFT:
31 		/*
32 		 * We only use software interrupts to pass IPIs, so if a non-SMP
33 		 * system gets one, then we don't know what to do.
34 		 */
35 		riscv_software_interrupt();
36 		break;
37 #endif
38 	case RV_IRQ_EXT:
39 		handle_arch_irq(regs);
40 		break;
41 	default:
42 		pr_alert("unexpected interrupt cause 0x%lx", regs->cause);
43 		BUG();
44 	}
45 	irq_exit();
46 
47 	set_irq_regs(old_regs);
48 }
49 
50 void __init init_IRQ(void)
51 {
52 	irqchip_init();
53 }
54