aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnup Patel <Anup.Patel@wdc.com>2019-04-25 04:38:37 -0400
committerPalmer Dabbelt <palmer@sifive.com>2019-05-16 23:42:11 -0400
commit6dcaf00487ca10d87e53fc8decb2e30f113c955d (patch)
treec29258bf0e09194fe983e03278fa106f22fb87a0
parent196a14d45161b320ec8bddf5321b1c5ed89f2d7f (diff)
RISC-V: Add interrupt related SCAUSE defines in asm/csr.h
This patch adds SCAUSE interrupt flag and SCAUSE interrupt related defines to asm/csr.h. We also use these defines in kernel/irq.c and express SIE/SIP flags in-terms of SCAUSE interrupt causes. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
-rw-r--r--arch/riscv/include/asm/csr.h21
-rw-r--r--arch/riscv/kernel/irq.c16
2 files changed, 21 insertions, 16 deletions
diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h
index 2ae54a7386f1..a89a9bf2c7f2 100644
--- a/arch/riscv/include/asm/csr.h
+++ b/arch/riscv/include/asm/csr.h
@@ -51,10 +51,18 @@
51#define SATP_MODE SATP_MODE_39 51#define SATP_MODE SATP_MODE_39
52#endif 52#endif
53 53
54/* Interrupt Enable and Interrupt Pending flags */ 54/* SCAUSE */
55#define SIE_SSIE _AC(0x00000002, UL) /* Software Interrupt Enable */ 55#define SCAUSE_IRQ_FLAG (_AC(1, UL) << (__riscv_xlen - 1))
56#define SIE_STIE _AC(0x00000020, UL) /* Timer Interrupt Enable */ 56
57#define SIE_SEIE _AC(0x00000200, UL) /* External Interrupt Enable */ 57#define IRQ_U_SOFT 0
58#define IRQ_S_SOFT 1
59#define IRQ_M_SOFT 3
60#define IRQ_U_TIMER 4
61#define IRQ_S_TIMER 5
62#define IRQ_M_TIMER 7
63#define IRQ_U_EXT 8
64#define IRQ_S_EXT 9
65#define IRQ_M_EXT 11
58 66
59#define EXC_INST_MISALIGNED 0 67#define EXC_INST_MISALIGNED 0
60#define EXC_INST_ACCESS 1 68#define EXC_INST_ACCESS 1
@@ -66,6 +74,11 @@
66#define EXC_LOAD_PAGE_FAULT 13 74#define EXC_LOAD_PAGE_FAULT 13
67#define EXC_STORE_PAGE_FAULT 15 75#define EXC_STORE_PAGE_FAULT 15
68 76
77/* SIE (Interrupt Enable) and SIP (Interrupt Pending) flags */
78#define SIE_SSIE (_AC(0x1, UL) << IRQ_S_SOFT)
79#define SIE_STIE (_AC(0x1, UL) << IRQ_S_TIMER)
80#define SIE_SEIE (_AC(0x1, UL) << IRQ_S_EXT)
81
69#ifndef __ASSEMBLY__ 82#ifndef __ASSEMBLY__
70 83
71#define csr_swap(csr, val) \ 84#define csr_swap(csr, val) \
diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c
index c738132eecf8..6d8659388c49 100644
--- a/arch/riscv/kernel/irq.c
+++ b/arch/riscv/kernel/irq.c
@@ -14,17 +14,9 @@
14/* 14/*
15 * Possible interrupt causes: 15 * Possible interrupt causes:
16 */ 16 */
17#define INTERRUPT_CAUSE_SOFTWARE 1 17#define INTERRUPT_CAUSE_SOFTWARE IRQ_S_SOFT
18#define INTERRUPT_CAUSE_TIMER 5 18#define INTERRUPT_CAUSE_TIMER IRQ_S_TIMER
19#define INTERRUPT_CAUSE_EXTERNAL 9 19#define INTERRUPT_CAUSE_EXTERNAL IRQ_S_EXT
20
21/*
22 * The high order bit of the trap cause register is always set for
23 * interrupts, which allows us to differentiate them from exceptions
24 * quickly. The INTERRUPT_CAUSE_* macros don't contain that bit, so we
25 * need to mask it off.
26 */
27#define INTERRUPT_CAUSE_FLAG (1UL << (__riscv_xlen - 1))
28 20
29int arch_show_interrupts(struct seq_file *p, int prec) 21int arch_show_interrupts(struct seq_file *p, int prec)
30{ 22{
@@ -37,7 +29,7 @@ asmlinkage void __irq_entry do_IRQ(struct pt_regs *regs)
37 struct pt_regs *old_regs = set_irq_regs(regs); 29 struct pt_regs *old_regs = set_irq_regs(regs);
38 30
39 irq_enter(); 31 irq_enter();
40 switch (regs->scause & ~INTERRUPT_CAUSE_FLAG) { 32 switch (regs->scause & ~SCAUSE_IRQ_FLAG) {
41 case INTERRUPT_CAUSE_TIMER: 33 case INTERRUPT_CAUSE_TIMER:
42 riscv_timer_interrupt(); 34 riscv_timer_interrupt();
43 break; 35 break;