16#ifndef ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_RISCV_APLIC_H_
17#define ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_RISCV_APLIC_H_
28#define APLIC_DOMAINCFG 0x0000
30#define APLIC_SOURCECFG_BASE 0x0004
32#define APLIC_SETIP_BASE 0x1C00
34#define APLIC_SETIPNUM 0x1CDC
36#define APLIC_CLRIP_BASE 0x1D00
38#define APLIC_CLRIPNUM 0x1DDC
40#define APLIC_SETIE_BASE 0x1E00
42#define APLIC_SETIENUM 0x1EDC
44#define APLIC_CLRIE_BASE 0x1F00
46#define APLIC_CLRIENUM 0x1FDC
48#define APLIC_MSIADDRCFG 0x1BC0
50#define APLIC_MSIADDRCFGH 0x1BC4
52#define APLIC_SMSIADDRCFG 0x1BC8
54#define APLIC_SMSIADDRCFGH 0x1BCC
56#define APLIC_GENMSI 0x3000
58#define APLIC_TARGET_BASE 0x3004
67#define APLIC_DOMAINCFG_IE BIT(8)
69#define APLIC_DOMAINCFG_DM BIT(2)
71#define APLIC_DOMAINCFG_BE BIT(0)
81#define APLIC_MSIADDRCFGH_L_BIT 31
83#define APLIC_MSIADDRCFGH_HHXS_SHIFT 24
85#define APLIC_MSIADDRCFGH_HHXS_MASK 0x1F
87#define APLIC_MSIADDRCFGH_LHXS_SHIFT 20
89#define APLIC_MSIADDRCFGH_LHXS_MASK 0x7
91#define APLIC_MSIADDRCFGH_HHXW_SHIFT 16
93#define APLIC_MSIADDRCFGH_HHXW_MASK 0x7
95#define APLIC_MSIADDRCFGH_LHXW_SHIFT 12
97#define APLIC_MSIADDRCFGH_LHXW_MASK 0xF
99#define APLIC_MSIADDRCFGH_BAPPN_MASK 0xFFF
108#define APLIC_SOURCECFG_D_BIT 10
110#define APLIC_SOURCECFG_SM_MASK 0x7
112#define APLIC_SM_INACTIVE 0x0
114#define APLIC_SM_DETACHED 0x1
116#define APLIC_SM_EDGE_RISE 0x4
118#define APLIC_SM_EDGE_FALL 0x5
120#define APLIC_SM_LEVEL_HIGH 0x6
122#define APLIC_SM_LEVEL_LOW 0x7
131#define APLIC_TARGET_HART_SHIFT 18
133#define APLIC_TARGET_HART_MASK 0x3FFF
135#define APLIC_TARGET_MSI_DEL BIT(11)
137#define APLIC_TARGET_EIID_MASK 0x7FF
146#define APLIC_GENMSI_HART_SHIFT 18
148#define APLIC_GENMSI_HART_MASK 0x3FFF
150#define APLIC_GENMSI_CONTEXT_SHIFT 13
152#define APLIC_GENMSI_CONTEXT_MASK 0x1F
154#define APLIC_GENMSI_BUSY BIT(12)
156#define APLIC_GENMSI_MMSI_MODE BIT(11)
158#define APLIC_GENMSI_EIID_MASK 0x7FF
227#ifdef CONFIG_RISCV_APLIC_MSI
252int riscv_aplic_msi_inject_software_interrupt(
const struct device *dev,
uint32_t eiid,
298#ifdef CONFIG_RISCV_APLIC_MSI
307static inline void riscv_aplic_msi_inject_genmsi(
uint32_t hart,
uint32_t eiid)
312 riscv_aplic_msi_inject_software_interrupt(dev, eiid, hart, 0);
static uint32_t aplic_target_off(unsigned int src)
Calculate target register offset for a source.
Definition riscv_aplic.h:178
int riscv_aplic_domain_enable(const struct device *dev, bool enable)
Enable or disable the APLIC domain.
static uint32_t aplic_sourcecfg_off(unsigned int src)
Calculate sourcecfg register offset for a source.
Definition riscv_aplic.h:167
static void riscv_aplic_enable_source(unsigned int src)
Enable an interrupt source (convenience wrapper).
Definition riscv_aplic.h:273
#define APLIC_SOURCECFG_BASE
Source configuration registers base offset.
Definition riscv_aplic.h:30
const struct device * riscv_aplic_get_dev(void)
Get the APLIC device instance.
static void riscv_aplic_disable_source(unsigned int src)
Disable an interrupt source (convenience wrapper).
Definition riscv_aplic.h:289
uint32_t riscv_aplic_get_num_sources(const struct device *dev)
Get the number of interrupt sources.
int riscv_aplic_enable_src(const struct device *dev, unsigned int src, bool enable)
Enable or disable an interrupt source.
#define APLIC_TARGET_BASE
Target registers base offset.
Definition riscv_aplic.h:58
int riscv_aplic_config_src(const struct device *dev, unsigned int src, unsigned int sm)
Configure an interrupt source mode.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:513