Skip to content

Commit 9c01b7e

Browse files
Rafal-Nordicrlubos
authored andcommitted
[nrf fromtree] arch: riscv: Support for Direct ISRs for RISCV targets
Added missing features and configuration to support Direct ISRs Signed-off-by: Rafal Dyla <[email protected]> (cherry picked from commit 3cf2627)
1 parent 36d18bb commit 9c01b7e

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

arch/riscv/core/irq_manage.c

Lines changed: 17 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,19 @@ 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+
key = irq_lock();
86+
87+
if (_kernel.idle) {
88+
_kernel.idle = 0;
89+
pm_system_resume();
90+
}
91+
92+
irq_unlock(key);
93+
}
94+
#endif

drivers/timer/nrf_grtc_timer.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,27 @@ uint32_t sys_clock_elapsed(void)
459459
return (uint32_t)(counter_sub(counter(), last_count) / CYC_PER_TICK);
460460
}
461461

462+
#if !defined(CONFIG_GEN_SW_ISR_TABLE)
463+
ISR_DIRECT_DECLARE(nrfx_grtc_direct_irq_handler)
464+
{
465+
nrfx_grtc_irq_handler();
466+
ISR_DIRECT_PM();
467+
return 1;
468+
}
469+
#endif
470+
462471
static int sys_clock_driver_init(void)
463472
{
464473
nrfx_err_t err_code;
465474

475+
#if defined(CONFIG_GEN_SW_ISR_TABLE)
466476
IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_isr,
467477
nrfx_grtc_irq_handler, 0);
478+
#else
479+
IRQ_DIRECT_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority),
480+
nrfx_grtc_direct_irq_handler, 0);
481+
irq_enable(DT_IRQN(GRTC_NODE));
482+
#endif
468483

469484
#if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && NRF_GRTC_HAS_CLKSEL
470485
#if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC)

include/zephyr/arch/riscv/irq.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ 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() \
91+
do { \
92+
} while (false)
93+
#endif
94+
8695
#define ARCH_ISR_DIRECT_HEADER() arch_isr_direct_header()
8796
#define ARCH_ISR_DIRECT_FOOTER(swap) arch_isr_direct_footer(swap)
8897

0 commit comments

Comments
 (0)