Skip to content

Commit a7d8120

Browse files
Rafal-Nordiclstnl
authored andcommitted
[nrf fromlist] arch:riscv: Support for Direct ISRs for RISCV targets
Added support for Direct ISRs in the multithreaded enviroment Signed-off-by: Rafal Dyla <[email protected]>
1 parent e883bc6 commit a7d8120

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

arch/riscv/core/irq_manage.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <zephyr/arch/riscv/csr.h>
1111
#include <zephyr/irq_multilevel.h>
1212
#include <zephyr/sw_isr_table.h>
13+
#include <zephyr/pm/pm.h>
1314

1415
#ifdef CONFIG_RISCV_HAS_PLIC
1516
#include <zephyr/drivers/interrupt_controller/riscv_plic.h>
@@ -75,3 +76,20 @@ int arch_irq_disconnect_dynamic(unsigned int irq, unsigned int priority,
7576
}
7677
#endif /* CONFIG_SHARED_INTERRUPTS */
7778
#endif /* CONFIG_DYNAMIC_INTERRUPTS */
79+
80+
#ifdef CONFIG_PM
81+
void _arch_isr_direct_pm(void)
82+
{
83+
unsigned int key;
84+
85+
/* irq_lock() does what we want for this CPU */
86+
key = irq_lock();
87+
88+
if (_kernel.idle) {
89+
_kernel.idle = 0;
90+
pm_system_resume();
91+
}
92+
93+
irq_unlock(key);
94+
}
95+
#endif

drivers/timer/nrf_grtc_timer.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,26 @@ uint32_t sys_clock_elapsed(void)
453453
return last_elapsed / CYC_PER_TICK;
454454
}
455455

456+
#if !defined(CONFIG_GEN_SW_ISR_TABLE)
457+
ISR_DIRECT_DECLARE(nrfx_grtc_direct_irq_handler)
458+
{
459+
nrfx_grtc_irq_handler();
460+
ISR_DIRECT_PM();
461+
return 1;
462+
}
463+
#endif
464+
456465
static int sys_clock_driver_init(void)
457466
{
458467
nrfx_err_t err_code;
459468

469+
#if defined(CONFIG_GEN_SW_ISR_TABLE)
460470
IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_isr,
461471
nrfx_grtc_irq_handler, 0);
472+
#else
473+
IRQ_DIRECT_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_grtc_direct_irq_handler, 0);
474+
irq_enable(DT_IRQN(GRTC_NODE));
475+
#endif
462476

463477
#if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && NRF_GRTC_HAS_CLKSEL
464478
#if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC)

include/zephyr/arch/riscv/irq.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ extern void z_riscv_irq_vector_set(unsigned int irq);
8383
z_riscv_irq_vector_set(irq_p); \
8484
}
8585

86+
#ifdef CONFIG_PM
87+
extern void _arch_isr_direct_pm(void);
88+
#define ARCH_ISR_DIRECT_PM() _arch_isr_direct_pm()
89+
#else
90+
#define ARCH_ISR_DIRECT_PM() do { } while (false)
91+
#endif
92+
8693
#define ARCH_ISR_DIRECT_HEADER() arch_isr_direct_header()
8794
#define ARCH_ISR_DIRECT_FOOTER(swap) arch_isr_direct_footer(swap)
8895

0 commit comments

Comments
 (0)