Skip to content

Commit fa39722

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 0e8239a commit fa39722

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
@@ -455,12 +455,26 @@ uint32_t sys_clock_elapsed(void)
455455
return (uint32_t)(counter_sub(counter(), last_count) / CYC_PER_TICK);
456456
}
457457

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

471+
#if defined(CONFIG_GEN_SW_ISR_TABLE)
462472
IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_isr,
463473
nrfx_grtc_irq_handler, 0);
474+
#else
475+
IRQ_DIRECT_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_grtc_direct_irq_handler, 0);
476+
irq_enable(DT_IRQN(GRTC_NODE));
477+
#endif
464478

465479
#if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && NRF_GRTC_HAS_CLKSEL
466480
#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)