From 4ea4b03070b9ca04fbaefa2f36d73261d00f1345 Mon Sep 17 00:00:00 2001 From: Adam Kondraciuk Date: Wed, 18 Sep 2024 17:58:24 +0200 Subject: [PATCH] [nrf_noup] soc: nordic: nrf54h20: Add LRC around idle Add LRC domain power management around idle. The Fast Clock Domain needs to be forced-on during CPU idle. Also the force needs to be disabled on idle-exit. Signed-off-by: Adam Kondraciuk --- soc/nordic/nrf54h/Kconfig.soc | 1 + soc/nordic/nrf54h/power.c | 13 +++++++------ soc/nordic/nrf54h/soc.c | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/soc/nordic/nrf54h/Kconfig.soc b/soc/nordic/nrf54h/Kconfig.soc index 100923206fd..a54bbabbaa8 100644 --- a/soc/nordic/nrf54h/Kconfig.soc +++ b/soc/nordic/nrf54h/Kconfig.soc @@ -6,6 +6,7 @@ config SOC_NRF54H20 bool select SOC_SERIES_NRF54HX + select ARM_ON_ENTER_CPU_IDLE_HOOK if PM_S2RAM help nRF54H20 diff --git a/soc/nordic/nrf54h/power.c b/soc/nordic/nrf54h/power.c index d55cd556e31..e9d8d5120a0 100644 --- a/soc/nordic/nrf54h/power.c +++ b/soc/nordic/nrf54h/power.c @@ -33,6 +33,10 @@ static void suspend_common(void) /* Disable retention */ nrf_lrcconf_retain_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, false); + + + /* TODO: Move it around k_cpu_idle() implementation. */ + nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_MAIN, false); nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, false); } @@ -43,10 +47,6 @@ void nrf_poweroff(void) nrf_lrcconf_retain_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_MAIN, false); - /* TODO: Move it around k_cpu_idle() implementation. */ - nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_MAIN, false); - nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, false); - suspend_common(); nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_SYSTEMOFFREADY); @@ -94,8 +94,6 @@ static int sys_suspend_to_ram(void) nrf_resetinfo_resetreas_local_set(NRF_RESETINFO, NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK); nrf_resetinfo_restore_valid_set(NRF_RESETINFO, true); - nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, false); - nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_MAIN, false); suspend_common(); @@ -141,5 +139,8 @@ void pm_state_set(enum pm_state state, uint8_t substate_id) void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id) { + if (state == PM_STATE_SUSPEND_TO_IDLE) { + nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, false); + } irq_unlock(0); } diff --git a/soc/nordic/nrf54h/soc.c b/soc/nordic/nrf54h/soc.c index b93658b55d4..61a1561f1e5 100644 --- a/soc/nordic/nrf54h/soc.c +++ b/soc/nordic/nrf54h/soc.c @@ -122,6 +122,8 @@ bool z_arm_on_enter_cpu_idle(void) #ifdef CONFIG_LOG_FRONTEND_STMESP log_frontend_stmesp_pre_sleep(); #endif + nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, + !IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD)); return true; }