blob: fffac6ddb0e00412fa76546cfdc0166eb5d4ed30 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001// 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>
David Brazdil0f672f62019-12-10 10:32:29 +000011#include <linux/seq_file.h>
12#include <asm/smp.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000013
14/*
15 * Possible interrupt causes:
16 */
David Brazdil0f672f62019-12-10 10:32:29 +000017#define INTERRUPT_CAUSE_SOFTWARE IRQ_S_SOFT
18#define INTERRUPT_CAUSE_TIMER IRQ_S_TIMER
19#define INTERRUPT_CAUSE_EXTERNAL IRQ_S_EXT
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000020
David Brazdil0f672f62019-12-10 10:32:29 +000021int arch_show_interrupts(struct seq_file *p, int prec)
22{
23 show_ipi_stats(p, prec);
24 return 0;
25}
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000026
David Brazdil0f672f62019-12-10 10:32:29 +000027asmlinkage __visible void __irq_entry do_IRQ(struct pt_regs *regs)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000028{
29 struct pt_regs *old_regs = set_irq_regs(regs);
30
31 irq_enter();
David Brazdil0f672f62019-12-10 10:32:29 +000032 switch (regs->scause & ~SCAUSE_IRQ_FLAG) {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000033 case INTERRUPT_CAUSE_TIMER:
34 riscv_timer_interrupt();
35 break;
36#ifdef CONFIG_SMP
37 case INTERRUPT_CAUSE_SOFTWARE:
38 /*
39 * We only use software interrupts to pass IPIs, so if a non-SMP
40 * system gets one, then we don't know what to do.
41 */
42 riscv_software_interrupt();
43 break;
44#endif
45 case INTERRUPT_CAUSE_EXTERNAL:
46 handle_arch_irq(regs);
47 break;
48 default:
David Brazdil0f672f62019-12-10 10:32:29 +000049 pr_alert("unexpected interrupt cause 0x%lx", regs->scause);
50 BUG();
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000051 }
52 irq_exit();
53
54 set_irq_regs(old_regs);
55}
56
57void __init init_IRQ(void)
58{
59 irqchip_init();
60}