Skip to content

Commit c725c91

Browse files
gmarullcarlescufi
authored andcommitted
arch: riscv: define RISC_IRQ_MSOFT/MEXT
Instead of relying on spread definitions within SoC files. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 452a2f6 commit c725c91

File tree

8 files changed

+20
-19
lines changed

8 files changed

+20
-19
lines changed

arch/riscv/core/irq_manage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ FUNC_NORETURN void z_irq_spurious(const void *unused)
2424

2525
LOG_ERR("Spurious interrupt detected! IRQ: %ld", mcause);
2626
#if defined(CONFIG_RISCV_HAS_PLIC)
27-
if (mcause == RISCV_MACHINE_EXT_IRQ) {
27+
if (mcause == RISCV_IRQ_MEXT) {
2828
unsigned int save_irq = riscv_plic_get_irq();
2929
const struct device *save_dev = riscv_plic_get_dev();
3030

arch/riscv/core/smp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <ksched.h>
1010
#include <zephyr/irq.h>
1111
#include <zephyr/sys/atomic.h>
12+
#include <zephyr/arch/riscv/irq.h>
1213
#include <zephyr/drivers/pm_cpu_ops.h>
1314

1415
volatile struct {
@@ -67,7 +68,7 @@ void arch_secondary_cpu_init(int hartid)
6768
z_riscv_pmp_init();
6869
#endif
6970
#ifdef CONFIG_SMP
70-
irq_enable(RISCV_MACHINE_SOFT_IRQ);
71+
irq_enable(RISCV_IRQ_MSOFT);
7172
#endif
7273
riscv_cpu_init[cpu_num].fn(riscv_cpu_init[cpu_num].arg);
7374
}
@@ -154,8 +155,8 @@ void arch_spin_relax(void)
154155
int arch_smp_init(void)
155156
{
156157

157-
IRQ_CONNECT(RISCV_MACHINE_SOFT_IRQ, 0, sched_ipi_handler, NULL, 0);
158-
irq_enable(RISCV_MACHINE_SOFT_IRQ);
158+
IRQ_CONNECT(RISCV_IRQ_MSOFT, 0, sched_ipi_handler, NULL, 0);
159+
irq_enable(RISCV_IRQ_MSOFT);
159160

160161
return 0;
161162
}

drivers/interrupt_controller/intc_swerv_pic.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <zephyr/device.h>
1616
#include <zephyr/sw_isr_table.h>
1717
#include <zephyr/irq.h>
18+
#include <zephyr/arch/riscv/irq.h>
1819

1920
#define SWERV_PIC_MAX_NUM CONFIG_NUM_IRQS
2021
#define SWERV_PIC_MAX_ID (SWERV_PIC_MAX_NUM + RISCV_MAX_GENERIC_IRQ)
@@ -176,14 +177,14 @@ static int swerv_pic_init(const struct device *dev)
176177
__asm__ swerv_pic_writecsr(meicurpl, 0);
177178

178179
/* Setup IRQ handler for SweRV PIC driver */
179-
IRQ_CONNECT(RISCV_MACHINE_EXT_IRQ,
180+
IRQ_CONNECT(RISCV_IRQ_MEXT,
180181
0,
181182
swerv_pic_irq_handler,
182183
NULL,
183184
0);
184185

185186
/* Enable IRQ for SweRV PIC driver */
186-
irq_enable(RISCV_MACHINE_EXT_IRQ);
187+
irq_enable(RISCV_IRQ_MEXT);
187188

188189
return 0;
189190
}

drivers/interrupt_controller/intc_vexriscv_litex.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <zephyr/irq.h>
1212
#include <zephyr/device.h>
1313
#include <zephyr/types.h>
14+
#include <zephyr/arch/riscv/irq.h>
1415

1516
#define IRQ_MASK DT_INST_REG_ADDR_BY_NAME(0, irq_mask)
1617
#define IRQ_PENDING DT_INST_REG_ADDR_BY_NAME(0, irq_pending)
@@ -122,9 +123,9 @@ int arch_irq_is_enabled(unsigned int irq)
122123
static int vexriscv_litex_irq_init(const struct device *dev)
123124
{
124125
__asm__ volatile ("csrrs x0, mie, %0"
125-
:: "r"(1 << RISCV_MACHINE_EXT_IRQ));
126+
:: "r"(1 << RISCV_IRQ_MEXT));
126127
vexriscv_litex_irq_setie(1);
127-
IRQ_CONNECT(RISCV_MACHINE_EXT_IRQ, 0, vexriscv_litex_irq_handler,
128+
IRQ_CONNECT(RISCV_IRQ_MEXT, 0, vexriscv_litex_irq_handler,
128129
NULL, 0);
129130

130131
return 0;

drivers/mbox/mbox_andes_plic_sw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ static void andes_plic_sw_irq_handler(const struct device *dev)
199199
static int mbox_andes_init(const struct device *dev)
200200
{
201201
/* Setup IRQ handler for PLIC SW driver */
202-
IRQ_CONNECT(RISCV_MACHINE_SOFT_IRQ, 1,
202+
IRQ_CONNECT(RISCV_IRQ_MSOFT, 1,
203203
andes_plic_sw_irq_handler, DEVICE_DT_INST_GET(0), 0);
204204

205205
#ifndef CONFIG_SMP
206-
irq_enable(RISCV_MACHINE_SOFT_IRQ);
206+
irq_enable(RISCV_IRQ_MSOFT);
207207
#endif
208208
return 0;
209209
}

include/zephyr/arch/riscv/irq.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ extern "C" {
3232
/** Environment Call from M-mode */
3333
#define RISCV_EXC_ECALLM 11
3434

35+
/* IRQs 0-15 (MCAUSE interrupt=1) */
36+
37+
/** Machine Software Interrupt */
38+
#define RISCV_IRQ_MSOFT 3
39+
/** Machine External Interrupt */
40+
#define RISCV_IRQ_MEXT 11
41+
3542
#ifdef CONFIG_64BIT
3643
#define RISCV_MCAUSE_IRQ_BIT (1 << 63)
3744
#else

soc/riscv/common/riscv-privileged/soc_common.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
#ifndef __SOC_COMMON_H_
1313
#define __SOC_COMMON_H_
1414

15-
/* IRQ numbers */
16-
#define RISCV_MACHINE_SOFT_IRQ 3 /* Machine Software Interrupt */
17-
#define RISCV_MACHINE_EXT_IRQ 11 /* Machine External Interrupt */
18-
1915
#ifndef _ASMLANGUAGE
2016

2117
#include <zephyr/drivers/interrupt_controller/riscv_clic.h>

soc/riscv/espressif_esp32/esp32c3/soc.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#include "esp32c3/clk.h"
1717
#endif
1818

19-
/* IRQ numbers */
20-
#define RISCV_MACHINE_SOFT_IRQ 3 /* Machine Software Interrupt */
21-
#define RISCV_MACHINE_TIMER_IRQ 7 /* Machine Timer Interrupt */
22-
#define RISCV_MACHINE_EXT_IRQ 11 /* Machine External Interrupt */
23-
2419
#ifndef _ASMLANGUAGE
2520

2621
void __esp_platform_start(void);

0 commit comments

Comments
 (0)