|
23 | 23 | #if IS_ENABLED(CONFIG_SOC_COMPATIBLE_NRF54LX) |
24 | 24 | #include <nrfx_power.h> |
25 | 25 | #endif |
| 26 | +#if IS_ENABLED(CONFIG_SOC_SERIES_NRF54L) |
| 27 | +#include <nrf_sys_event.h> |
| 28 | +#endif |
| 29 | + |
26 | 30 | #if defined(CONFIG_SOC_SERIES_NRF54H) |
27 | 31 | #include <hal/nrf_dppi.h> |
28 | 32 | #endif |
@@ -190,6 +194,14 @@ static struct k_work mpsl_low_prio_work; |
190 | 194 | struct k_work_q mpsl_work_q; |
191 | 195 | static K_THREAD_STACK_DEFINE(mpsl_work_stack, CONFIG_MPSL_WORK_STACK_SIZE); |
192 | 196 |
|
| 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 | + |
193 | 205 | #define MPSL_TIMESLOT_SESSION_COUNT (\ |
194 | 206 | CONFIG_MPSL_TIMESLOT_SESSION_COUNT + \ |
195 | 207 | CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL_TIMESLOT_SESSION_COUNT) |
@@ -603,6 +615,69 @@ void mpsl_lowpower_request_callback(void) |
603 | 615 | nrf_power_task_trigger(NRF_POWER, NRF_POWER_TASK_LOWPWR); |
604 | 616 | #endif |
605 | 617 | } |
| 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 | +} |
606 | 681 | #endif /* defined(CONFIG_SOC_COMPATIBLE_NRF54LX) */ |
607 | 682 |
|
608 | 683 | #if defined(CONFIG_MPSL_USE_EXTERNAL_CLOCK_CONTROL) |
|
0 commit comments