1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2021 Western Digital Corporation or its affiliates.
4  * Copyright (C) 2022 Ventana Micro Systems Inc.
5  */
6 #ifndef __KVM_RISCV_AIA_IMSIC_H
7 #define __KVM_RISCV_AIA_IMSIC_H
8 
9 #include <linux/bitops.h>
10 
11 #define APLIC_MAX_IDC			BIT(14)
12 #define APLIC_MAX_SOURCE		1024
13 
14 #define APLIC_DOMAINCFG			0x0000
15 #define APLIC_DOMAINCFG_RDONLY		0x80000000
16 #define APLIC_DOMAINCFG_IE		BIT(8)
17 #define APLIC_DOMAINCFG_DM		BIT(2)
18 #define APLIC_DOMAINCFG_BE		BIT(0)
19 
20 #define APLIC_SOURCECFG_BASE		0x0004
21 #define APLIC_SOURCECFG_D		BIT(10)
22 #define APLIC_SOURCECFG_CHILDIDX_MASK	0x000003ff
23 #define APLIC_SOURCECFG_SM_MASK	0x00000007
24 #define APLIC_SOURCECFG_SM_INACTIVE	0x0
25 #define APLIC_SOURCECFG_SM_DETACH	0x1
26 #define APLIC_SOURCECFG_SM_EDGE_RISE	0x4
27 #define APLIC_SOURCECFG_SM_EDGE_FALL	0x5
28 #define APLIC_SOURCECFG_SM_LEVEL_HIGH	0x6
29 #define APLIC_SOURCECFG_SM_LEVEL_LOW	0x7
30 
31 #define APLIC_IRQBITS_PER_REG		32
32 
33 #define APLIC_SETIP_BASE		0x1c00
34 #define APLIC_SETIPNUM			0x1cdc
35 
36 #define APLIC_CLRIP_BASE		0x1d00
37 #define APLIC_CLRIPNUM			0x1ddc
38 
39 #define APLIC_SETIE_BASE		0x1e00
40 #define APLIC_SETIENUM			0x1edc
41 
42 #define APLIC_CLRIE_BASE		0x1f00
43 #define APLIC_CLRIENUM			0x1fdc
44 
45 #define APLIC_SETIPNUM_LE		0x2000
46 #define APLIC_SETIPNUM_BE		0x2004
47 
48 #define APLIC_GENMSI			0x3000
49 
50 #define APLIC_TARGET_BASE		0x3004
51 #define APLIC_TARGET_HART_IDX_SHIFT	18
52 #define APLIC_TARGET_HART_IDX_MASK	0x3fff
53 #define APLIC_TARGET_GUEST_IDX_SHIFT	12
54 #define APLIC_TARGET_GUEST_IDX_MASK	0x3f
55 #define APLIC_TARGET_IPRIO_MASK	0xff
56 #define APLIC_TARGET_EIID_MASK	0x7ff
57 
58 #endif
59