Skip to content

Commit a466da0

Browse files
committed
mpsl: provide implementation for NVM low-latency request and release
The MPSL library expects implementations of two new public functions declared in mpsl.h. MPSL calls them to request and release low-latency mode on the NVM controller. The integration layer supplies this for all MPSL users in the SDK. It builds on the nrf_sys_event subsystem, which is required whenever MPSL is enabled in the application configuration. Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
1 parent 4d2d902 commit a466da0

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

subsys/mpsl/init/mpsl_init.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#if IS_ENABLED(CONFIG_SOC_COMPATIBLE_NRF54LX)
2424
#include <nrfx_power.h>
2525
#endif
26+
#if IS_ENABLED(CONFIG_SOC_SERIES_NRF54L)
27+
#include <nrf_sys_event.h>
28+
#endif
29+
2630
#if defined(CONFIG_SOC_SERIES_NRF54H)
2731
#include <hal/nrf_dppi.h>
2832
#endif
@@ -190,6 +194,12 @@ static struct k_work mpsl_low_prio_work;
190194
struct k_work_q mpsl_work_q;
191195
static K_THREAD_STACK_DEFINE(mpsl_work_stack, CONFIG_MPSL_WORK_STACK_SIZE);
192196

197+
#if IS_ENABLED(CONFIG_SOC_SERIES_NRF54L) && !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE)
198+
#if IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY)
199+
static int m_nvm_low_latency_event_handle = -1;
200+
#endif /* IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY) */
201+
#endif /* IS_ENABLED(CONFIG_SOC_SERIES_NRF54L) && !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE) */
202+
193203
#define MPSL_TIMESLOT_SESSION_COUNT (\
194204
CONFIG_MPSL_TIMESLOT_SESSION_COUNT + \
195205
CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL_TIMESLOT_SESSION_COUNT)
@@ -603,6 +613,35 @@ void mpsl_lowpower_request_callback(void)
603613
nrf_power_task_trigger(NRF_POWER, NRF_POWER_TASK_LOWPWR);
604614
#endif
605615
}
616+
617+
void mpsl_nvm_low_latency_request_callback(void)
618+
{
619+
#if IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY) && !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE)
620+
int event_handle = nrf_sys_event_register(0, true);
621+
622+
if (event_handle < 0) {
623+
LOG_ERR("NVM low latency request has failed (%d)", event_handle);
624+
}
625+
626+
m_nvm_low_latency_event_handle = event_handle;
627+
#endif /* IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY) && \
628+
!IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE) */
629+
}
630+
631+
void mpsl_nvm_low_latency_release_callback(void)
632+
{
633+
#if IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY) && !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE)
634+
635+
int ret = nrf_sys_event_unregister(m_nvm_low_latency_event_handle, false);
636+
if (ret != 0) {
637+
LOG_ERR("NVM low latency release has failed (%d)", ret);
638+
}
639+
640+
m_nvm_low_latency_event_handle = -1;
641+
#endif /* IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY) && \
642+
!IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE) */
643+
}
644+
606645
#endif /* defined(CONFIG_SOC_COMPATIBLE_NRF54LX) */
607646

608647
#if defined(CONFIG_MPSL_USE_EXTERNAL_CLOCK_CONTROL)

0 commit comments

Comments
 (0)