Skip to content

Commit d6f5f6e

Browse files
committed
RISC-V: Add AIA related CSR defines
The RISC-V AIA specification improves handling per-HART local interrupts in a backward compatible manner. This patch adds defines for new RISC-V AIA CSRs. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Anup Patel <anup@brainfault.org> Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 90deec5 commit d6f5f6e

1 file changed

Lines changed: 94 additions & 1 deletion

File tree

  • arch/riscv/include/asm

arch/riscv/include/asm/csr.h

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define _ASM_RISCV_CSR_H
88

99
#include <asm/asm.h>
10-
#include <linux/const.h>
10+
#include <linux/bits.h>
1111

1212
/* Status register flags */
1313
#define SR_SIE _AC(0x00000002, UL) /* Supervisor Interrupt Enable */
@@ -73,7 +73,10 @@
7373
#define IRQ_S_EXT 9
7474
#define IRQ_VS_EXT 10
7575
#define IRQ_M_EXT 11
76+
#define IRQ_S_GEXT 12
7677
#define IRQ_PMU_OVF 13
78+
#define IRQ_LOCAL_MAX (IRQ_PMU_OVF + 1)
79+
#define IRQ_LOCAL_MASK GENMASK((IRQ_LOCAL_MAX - 1), 0)
7780

7881
/* Exception causes */
7982
#define EXC_INST_MISALIGNED 0
@@ -156,6 +159,27 @@
156159
(_AC(1, UL) << IRQ_S_TIMER) | \
157160
(_AC(1, UL) << IRQ_S_EXT))
158161

162+
/* AIA CSR bits */
163+
#define TOPI_IID_SHIFT 16
164+
#define TOPI_IID_MASK GENMASK(11, 0)
165+
#define TOPI_IPRIO_MASK GENMASK(7, 0)
166+
#define TOPI_IPRIO_BITS 8
167+
168+
#define TOPEI_ID_SHIFT 16
169+
#define TOPEI_ID_MASK GENMASK(10, 0)
170+
#define TOPEI_PRIO_MASK GENMASK(10, 0)
171+
172+
#define ISELECT_IPRIO0 0x30
173+
#define ISELECT_IPRIO15 0x3f
174+
#define ISELECT_MASK GENMASK(8, 0)
175+
176+
#define HVICTL_VTI BIT(30)
177+
#define HVICTL_IID GENMASK(27, 16)
178+
#define HVICTL_IID_SHIFT 16
179+
#define HVICTL_DPR BIT(9)
180+
#define HVICTL_IPRIOM BIT(8)
181+
#define HVICTL_IPRIO GENMASK(7, 0)
182+
159183
/* xENVCFG flags */
160184
#define ENVCFG_STCE (_AC(1, ULL) << 63)
161185
#define ENVCFG_PBMTE (_AC(1, ULL) << 62)
@@ -250,6 +274,18 @@
250274
#define CSR_STIMECMP 0x14D
251275
#define CSR_STIMECMPH 0x15D
252276

277+
/* Supervisor-Level Window to Indirectly Accessed Registers (AIA) */
278+
#define CSR_SISELECT 0x150
279+
#define CSR_SIREG 0x151
280+
281+
/* Supervisor-Level Interrupts (AIA) */
282+
#define CSR_STOPEI 0x15c
283+
#define CSR_STOPI 0xdb0
284+
285+
/* Supervisor-Level High-Half CSRs (AIA) */
286+
#define CSR_SIEH 0x114
287+
#define CSR_SIPH 0x154
288+
253289
#define CSR_VSSTATUS 0x200
254290
#define CSR_VSIE 0x204
255291
#define CSR_VSTVEC 0x205
@@ -279,8 +315,32 @@
279315
#define CSR_HGATP 0x680
280316
#define CSR_HGEIP 0xe12
281317

318+
/* Virtual Interrupts and Interrupt Priorities (H-extension with AIA) */
319+
#define CSR_HVIEN 0x608
320+
#define CSR_HVICTL 0x609
321+
#define CSR_HVIPRIO1 0x646
322+
#define CSR_HVIPRIO2 0x647
323+
324+
/* VS-Level Window to Indirectly Accessed Registers (H-extension with AIA) */
325+
#define CSR_VSISELECT 0x250
326+
#define CSR_VSIREG 0x251
327+
328+
/* VS-Level Interrupts (H-extension with AIA) */
329+
#define CSR_VSTOPEI 0x25c
330+
#define CSR_VSTOPI 0xeb0
331+
332+
/* Hypervisor and VS-Level High-Half CSRs (H-extension with AIA) */
333+
#define CSR_HIDELEGH 0x613
334+
#define CSR_HVIENH 0x618
335+
#define CSR_HVIPH 0x655
336+
#define CSR_HVIPRIO1H 0x656
337+
#define CSR_HVIPRIO2H 0x657
338+
#define CSR_VSIEH 0x214
339+
#define CSR_VSIPH 0x254
340+
282341
#define CSR_MSTATUS 0x300
283342
#define CSR_MISA 0x301
343+
#define CSR_MIDELEG 0x303
284344
#define CSR_MIE 0x304
285345
#define CSR_MTVEC 0x305
286346
#define CSR_MENVCFG 0x30a
@@ -297,6 +357,25 @@
297357
#define CSR_MIMPID 0xf13
298358
#define CSR_MHARTID 0xf14
299359

360+
/* Machine-Level Window to Indirectly Accessed Registers (AIA) */
361+
#define CSR_MISELECT 0x350
362+
#define CSR_MIREG 0x351
363+
364+
/* Machine-Level Interrupts (AIA) */
365+
#define CSR_MTOPEI 0x35c
366+
#define CSR_MTOPI 0xfb0
367+
368+
/* Virtual Interrupts for Supervisor Level (AIA) */
369+
#define CSR_MVIEN 0x308
370+
#define CSR_MVIP 0x309
371+
372+
/* Machine-Level High-Half CSRs (AIA) */
373+
#define CSR_MIDELEGH 0x313
374+
#define CSR_MIEH 0x314
375+
#define CSR_MVIENH 0x318
376+
#define CSR_MVIPH 0x319
377+
#define CSR_MIPH 0x354
378+
300379
#ifdef CONFIG_RISCV_M_MODE
301380
# define CSR_STATUS CSR_MSTATUS
302381
# define CSR_IE CSR_MIE
@@ -307,6 +386,13 @@
307386
# define CSR_TVAL CSR_MTVAL
308387
# define CSR_IP CSR_MIP
309388

389+
# define CSR_IEH CSR_MIEH
390+
# define CSR_ISELECT CSR_MISELECT
391+
# define CSR_IREG CSR_MIREG
392+
# define CSR_IPH CSR_MIPH
393+
# define CSR_TOPEI CSR_MTOPEI
394+
# define CSR_TOPI CSR_MTOPI
395+
310396
# define SR_IE SR_MIE
311397
# define SR_PIE SR_MPIE
312398
# define SR_PP SR_MPP
@@ -324,6 +410,13 @@
324410
# define CSR_TVAL CSR_STVAL
325411
# define CSR_IP CSR_SIP
326412

413+
# define CSR_IEH CSR_SIEH
414+
# define CSR_ISELECT CSR_SISELECT
415+
# define CSR_IREG CSR_SIREG
416+
# define CSR_IPH CSR_SIPH
417+
# define CSR_TOPEI CSR_STOPEI
418+
# define CSR_TOPI CSR_STOPI
419+
327420
# define SR_IE SR_SIE
328421
# define SR_PIE SR_SPIE
329422
# define SR_PP SR_SPP

0 commit comments

Comments
 (0)