Skip to content

Commit ef5c28c

Browse files
raffi-gcarlescufi
authored andcommitted
riscv: irq: Set selective hardware vectoring
The mechanism for hardware vectoring has changed in the clic spec (https://github.com/riscv/riscv-fast-interrupt) in 2019. Before vectoring was enabled via `mode` bits in `mtvec`. Support for this was added in fc480c9. With more current clic implementations, this does not work anymore. Changing the `mode` bits is reserved. Vectoring can be enabled individually in the `shv` bit of `clicintattr[i]`. Since the old mechanism is still used, I added a new Kconfig for it. If this Kconfig is not set, we use the `shv` bit for harware vectoring. Signed-off-by: Greter Raffael <[email protected]>
1 parent bc2e157 commit ef5c28c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

drivers/interrupt_controller/Kconfig.clic

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ config NUCLEI_ECLIC
88
select MULTI_LEVEL_INTERRUPTS
99
help
1010
Interrupt controller for Nuclei SoC core.
11+
12+
config LEGACY_CLIC
13+
bool "Use the legacy clic specification"
14+
depends on RISCV_HAS_CLIC
15+
help
16+
Enables legacy clic, where smclicshv extension is not supported and
17+
hardware vectoring is set via mode bits of mtvec.

drivers/interrupt_controller/intc_nuclei_eclic.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,19 @@ void riscv_clic_irq_priority_set(uint32_t irq, uint32_t pri, uint32_t flags)
156156

157157
ECLIC_CTRL[irq].INTCTRL = intctrl;
158158

159-
ECLIC_CTRL[irq].INTATTR.b.shv = 0;
160-
ECLIC_CTRL[irq].INTATTR.b.trg = (uint8_t)(flags & CLIC_INTATTR_TRIG_Msk);
159+
union CLICINTATTR intattr = {.w = 0};
160+
#if defined(CONFIG_RISCV_VECTORED_MODE) && !defined(CONFIG_LEGACY_CLIC)
161+
/*
162+
* Set Selective Hardware Vectoring.
163+
* Legacy SiFive does not implement smclicshv extension and vectoring is
164+
* enabled in the mode bits of mtvec.
165+
*/
166+
intattr.b.shv = 1;
167+
#else
168+
intattr.b.shv = 0;
169+
#endif
170+
intattr.b.trg = (uint8_t)(flags & CLIC_INTATTR_TRIG_Msk);
171+
ECLIC_CTRL[irq].INTATTR = intattr;
161172
}
162173

163174
static int nuclei_eclic_init(const struct device *dev)

0 commit comments

Comments
 (0)