Skip to content

Commit 9a6ef7e

Browse files
committed
mpsl: unify CONSTLAT/low-power hooks; add NVM low-latency handling
The `mpsl_constlat_request_callback` and `mpsl_lowpower_request- _callback` will be replaced with a single low-latency acquire/release API. The new API is added in this commit. The former one will be removed in followin commit when the modified MPSL library is available in nrfxlib. The MPSL library expects implementations of the new public functions handle acquire/release of low-latency mode on the NVM controller. The integration layer supplies this for all MPSL users in the SDK. The implementation allows to control the NVM latency by nrf_sys_event subsystem. For that an application has the select the NRF_SYS_EVENT KConfig. As of now the new API and NVM latency control is required for nRF54Lxx SoCs. Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
1 parent 6e12907 commit 9a6ef7e

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

subsys/mpsl/init/mpsl_init.c

Lines changed: 75 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,14 @@ 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+
#else
201+
static uint32_t m_rram_lowpower_config;
202+
#endif /* IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY) */
203+
#endif /* IS_ENABLED(CONFIG_SOC_SERIES_NRF54L) && !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE) */
204+
193205
#define MPSL_TIMESLOT_SESSION_COUNT (\
194206
CONFIG_MPSL_TIMESLOT_SESSION_COUNT + \
195207
CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL_TIMESLOT_SESSION_COUNT)
@@ -603,6 +615,69 @@ void mpsl_lowpower_request_callback(void)
603615
nrf_power_task_trigger(NRF_POWER, NRF_POWER_TASK_LOWPWR);
604616
#endif
605617
}
618+
619+
void mpsl_low_latency_acquire_callback(void)
620+
{
621+
#if IS_ENABLED(CONFIG_SOC_SERIES_NRF54L) && !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE)
622+
#if IS_ENABLED(CONFIG_NRF_SYS_EVENT)
623+
int err;
624+
625+
err = nrf_sys_event_request_global_constlat();
626+
if (err) {
627+
LOG_ERR("NVM low latency request has failed (%d)", err);
628+
}
629+
#elif IS_ENABLED(CONFIG_NRFX_POWER)
630+
nrfx_power_constlat_mode_request();
631+
#else
632+
nrf_power_task_trigger(NRF_POWER, NRF_POWER_TASK_CONSTLAT);
633+
#endif /* IS_ENABLED(CONFIG_NRF_SYS_EVENT) */
634+
635+
#if IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY)
636+
int event_handle;
637+
638+
event_handle = nrf_sys_event_register(0, true);
639+
if (event_handle < 0) {
640+
LOG_ERR("NVM low latency request has failed (%d)", event_handle);
641+
}
642+
643+
m_nvm_low_latency_event_handle = event_handle;
644+
#else
645+
m_rram_lowpower_config = NRF_RRAMC->POWER.LOWPOWERCONFIG;
646+
NRF_RRAMC->POWER.LOWPOWERCONFIG = RRAMC_POWER_LOWPOWERCONFIG_MODE_Standby
647+
<< RRAMC_POWER_LOWPOWERCONFIG_MODE_Pos;
648+
#endif /* IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY) */
649+
#endif /* IS_ENABLED(CONFIG_SOC_SERIES_NRF54L) && !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE) */
650+
}
651+
652+
void mpsl_low_latency_release_callback(void)
653+
{
654+
#if IS_ENABLED(CONFIG_SOC_SERIES_NRF54L) && !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE)
655+
656+
#if IS_ENABLED(CONFIG_NRF_SYS_EVENT)
657+
int ret;
658+
659+
ret = nrf_sys_event_release_global_constlat();
660+
if (ret) {
661+
LOG_ERR("NVM low latency release has failed (%d)", ret);
662+
}
663+
#elif IS_ENABLED(CONFIG_NRFX_POWER)
664+
nrfx_power_constlat_mode_free();
665+
#else
666+
nrf_power_task_trigger(NRF_POWER, NRF_POWER_TASK_LOWPWR);
667+
#endif /* IS_ENABLED(CONFIG_NRF_SYS_EVENT) */
668+
669+
#if IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY)
670+
ret = nrf_sys_event_unregister(m_nvm_low_latency_event_handle, false);
671+
if (ret != 0) {
672+
LOG_ERR("NVM low latency release has failed (%d)", ret);
673+
}
674+
675+
m_nvm_low_latency_event_handle = -1;
676+
#else
677+
NRF_RRAMC->POWER.LOWPOWERCONFIG = m_rram_lowpower_config;
678+
#endif /* IS_ENABLED(CONFIG_NRF_SYS_EVENT_IRQ_LATENCY) */
679+
#endif /* IS_ENABLED(CONFIG_SOC_SERIES_NRF54L) && !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE) */
680+
}
606681
#endif /* defined(CONFIG_SOC_COMPATIBLE_NRF54LX) */
607682

608683
#if defined(CONFIG_MPSL_USE_EXTERNAL_CLOCK_CONTROL)

0 commit comments

Comments
 (0)