99#include <zephyr/pm/policy.h>
1010#include <zephyr/arch/common/pm_s2ram.h>
1111#include <hal/nrf_resetinfo.h>
12- #include <hal/nrf_lrcconf.h>
1312#include <hal/nrf_memconf.h>
1413#include <zephyr/cache.h>
1514#include <power.h>
15+ #include <soc_lrcconf.h>
1616#include "pm_s2ram.h"
1717
18+ #if !defined(CONFIG_SOC_NRF54H20_CPURAD )
19+ static sys_snode_t pm_node ;
20+ #endif
21+
1822static void suspend_common (void )
1923{
2024
@@ -31,21 +35,21 @@ static void suspend_common(void)
3135 RAMBLOCK_CONTROL_BIT_ICACHE , false);
3236 }
3337
38+ #if !defined(CONFIG_SOC_NRF54H20_CPURAD )
39+ soc_lrcconf_poweron_release (& pm_node , NRF_LRCCONF_POWER_DOMAIN_0 );
3440 /* Disable retention */
3541 nrf_lrcconf_retain_set (NRF_LRCCONF010 , NRF_LRCCONF_POWER_DOMAIN_0 , false);
36- nrf_lrcconf_poweron_force_set ( NRF_LRCCONF010 , NRF_LRCCONF_POWER_DOMAIN_0 , false);
42+ #endif
3743}
3844
3945void nrf_poweroff (void )
4046{
4147 nrf_resetinfo_resetreas_local_set (NRF_RESETINFO , 0 );
4248 nrf_resetinfo_restore_valid_set (NRF_RESETINFO , false);
4349
50+ #if !defined(CONFIG_SOC_NRF54H20_CPURAD )
4451 nrf_lrcconf_retain_set (NRF_LRCCONF010 , NRF_LRCCONF_POWER_MAIN , false);
45-
46- /* TODO: Move it around k_cpu_idle() implementation. */
47- nrf_lrcconf_poweron_force_set (NRF_LRCCONF010 , NRF_LRCCONF_POWER_MAIN , false);
48- nrf_lrcconf_poweron_force_set (NRF_LRCCONF010 , NRF_LRCCONF_POWER_DOMAIN_0 , false);
52+ #endif
4953
5054 suspend_common ();
5155
@@ -59,7 +63,7 @@ void nrf_poweroff(void)
5963 CODE_UNREACHABLE ;
6064}
6165
62- #if IS_ENABLED (CONFIG_PM_S2RAM )
66+ #if defined (CONFIG_PM_S2RAM )
6367/* Resume domain after local suspend to RAM. */
6468static void sys_resume (void )
6569{
@@ -77,12 +81,10 @@ static void sys_resume(void)
7781 sys_cache_data_enable ();
7882 }
7983
84+ #if !defined(CONFIG_SOC_NRF54H20_CPURAD )
8085 /* Re-enable domain retention. */
8186 nrf_lrcconf_retain_set (NRF_LRCCONF010 , NRF_LRCCONF_POWER_DOMAIN_0 , true);
82-
83- /* TODO: Move it around k_cpu_idle() implementation. */
84- nrf_lrcconf_poweron_force_set (NRF_LRCCONF010 , NRF_LRCCONF_POWER_MAIN ,
85- !IS_ENABLED (CONFIG_SOC_NRF54H20_CPURAD ));
87+ #endif
8688}
8789
8890/* Function called during local domain suspend to RAM. */
@@ -94,8 +96,6 @@ static int sys_suspend_to_ram(void)
9496 nrf_resetinfo_resetreas_local_set (NRF_RESETINFO ,
9597 NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK );
9698 nrf_resetinfo_restore_valid_set (NRF_RESETINFO , true);
97- nrf_lrcconf_poweron_force_set (NRF_LRCCONF010 , NRF_LRCCONF_POWER_DOMAIN_0 , false);
98- nrf_lrcconf_poweron_force_set (NRF_LRCCONF010 , NRF_LRCCONF_POWER_MAIN , false);
9999
100100 suspend_common ();
101101
@@ -126,20 +126,32 @@ static void do_suspend_to_ram(void)
126126
127127 sys_resume ();
128128}
129- #endif /* IS_ENABLED (CONFIG_PM_S2RAM) */
129+ #endif /* defined (CONFIG_PM_S2RAM) */
130130
131131void pm_state_set (enum pm_state state , uint8_t substate_id )
132132{
133133 if (state != PM_STATE_SUSPEND_TO_RAM ) {
134134 k_cpu_idle ();
135135 return ;
136136 }
137- #if IS_ENABLED (CONFIG_PM_S2RAM )
137+ #if defined (CONFIG_PM_S2RAM )
138138 do_suspend_to_ram ();
139139#endif
140140}
141141
142142void pm_state_exit_post_ops (enum pm_state state , uint8_t substate_id )
143143{
144+ #if !defined(CONFIG_SOC_NRF54H20_CPURAD )
145+ if (state == PM_STATE_SUSPEND_TO_IDLE ) {
146+ soc_lrcconf_poweron_release (& pm_node , NRF_LRCCONF_POWER_DOMAIN_0 );
147+ }
148+ #endif
144149 irq_unlock (0 );
145150}
151+
152+ #if !defined(CONFIG_SOC_NRF54H20_CPURAD )
153+ void pm_state_enter_idle_prepare (void )
154+ {
155+ soc_lrcconf_poweron_request (& pm_node , NRF_LRCCONF_POWER_DOMAIN_0 );
156+ }
157+ #endif
0 commit comments