Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 11 | #include <linux/seq_file.h> |
| 12 | #include <asm/smp.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 13 | |
| 14 | /* |
| 15 | * Possible interrupt causes: |
| 16 | */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 17 | #define INTERRUPT_CAUSE_SOFTWARE IRQ_S_SOFT |
| 18 | #define INTERRUPT_CAUSE_TIMER IRQ_S_TIMER |
| 19 | #define INTERRUPT_CAUSE_EXTERNAL IRQ_S_EXT |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 20 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 21 | int arch_show_interrupts(struct seq_file *p, int prec) |
| 22 | { |
| 23 | show_ipi_stats(p, prec); |
| 24 | return 0; |
| 25 | } |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 26 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 27 | asmlinkage __visible void __irq_entry do_IRQ(struct pt_regs *regs) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 28 | { |
| 29 | struct pt_regs *old_regs = set_irq_regs(regs); |
| 30 | |
| 31 | irq_enter(); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 32 | switch (regs->scause & ~SCAUSE_IRQ_FLAG) { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 33 | 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 Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 49 | pr_alert("unexpected interrupt cause 0x%lx", regs->scause); |
| 50 | BUG(); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 51 | } |
| 52 | irq_exit(); |
| 53 | |
| 54 | set_irq_regs(old_regs); |
| 55 | } |
| 56 | |
| 57 | void __init init_IRQ(void) |
| 58 | { |
| 59 | irqchip_init(); |
| 60 | } |