Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arch/arm/core/cortex_m/pm_s2ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ __noinit
#endif
_cpu_context_t _cpu_context;

#ifndef CONFIG_PM_S2RAM_CUSTOM_MARKING
#ifndef CONFIG_HAS_PM_S2RAM_CUSTOM_MARKING
/**
* S2RAM Marker
*/
Expand All @@ -50,4 +50,4 @@ bool pm_s2ram_mark_check_and_clear(void)
return false;
}

#endif /* CONFIG_PM_S2RAM_CUSTOM_MARKING */
#endif /* CONFIG_HAS_PM_S2RAM_CUSTOM_MARKING */
8 changes: 4 additions & 4 deletions include/zephyr/arch/common/pm_s2ram.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ int arch_pm_s2ram_suspend(pm_s2ram_system_off_fn_t system_off);
* Function is called when system state is stored to RAM, just before going to system
* off.
*
* Default implementation is setting a magic word in RAM. CONFIG_PM_S2RAM_CUSTOM_MARKING
* allows custom implementation.
* Default implementation is setting a magic word in RAM used if
* CONFIG_HAS_PM_S2RAM_CUSTOM_MARKING is not set.
*/
void pm_s2ram_mark_set(void);

Expand All @@ -74,8 +74,8 @@ void pm_s2ram_mark_set(void);
* Function is used to determine if resuming after suspend-to-RAM shall be performed
* or standard boot code shall be executed.
*
* Default implementation is checking a magic word in RAM. CONFIG_PM_S2RAM_CUSTOM_MARKING
* allows custom implementation.
* Default implementation is checking a magic word in RAM used if
* CONFIG_HAS_PM_S2RAM_CUSTOM_MARKING is not set.
*
* @retval true if marking is found which indicates resuming after suspend-to-RAM.
* @retval false if marking is not found which indicates standard boot.
Expand Down
2 changes: 0 additions & 2 deletions samples/boards/nordic/spis_wakeup/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ CONFIG_SPI_SLAVE=y
CONFIG_GPIO=y

CONFIG_PM=y
CONFIG_PM_S2RAM=y
CONFIG_PM_S2RAM_CUSTOM_MARKING=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

Expand Down
2 changes: 0 additions & 2 deletions samples/boards/nordic/spis_wakeup/wakeup_trigger/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ CONFIG_SPI_NRFX_WAKE_TIMEOUT_US=500
CONFIG_GPIO=y

CONFIG_PM=y
CONFIG_PM_S2RAM=y
CONFIG_PM_S2RAM_CUSTOM_MARKING=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

Expand Down
1 change: 0 additions & 1 deletion samples/boards/st/power_mgmt/suspend_to_ram/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
CONFIG_PM_DEVICE_SYSTEM_MANAGED=y
CONFIG_PM_S2RAM=y
CONFIG_ADC=y
CONFIG_ENTROPY_GENERATOR=y
CONFIG_SPI=y
Expand Down
1 change: 1 addition & 0 deletions soc/nordic/nrf54h/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ config SOC_NRF54H20_CPUAPP_COMMON
select NRFS_HAS_TEMP_SERVICE
select NRFS_HAS_VBUS_DETECTOR_SERVICE
select HAS_PM
select HAS_PM_S2RAM_CUSTOM_MARKING
select HAS_POWEROFF

config SOC_NRF54H20_CPUAPP
Expand Down
8 changes: 8 additions & 0 deletions soc/nordic/nrf54h/pm_s2ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ typedef struct {

struct backup {
_nvic_context_t nvic_context;
#if defined(CONFIG_MPU)
_mpu_context_t mpu_context;
#endif
_scb_context_t scb_context;
#if defined(CONFIG_FPU) && !defined(CONFIG_FPU_SHARING)
_fpu_context_t fpu_context;
Expand All @@ -88,6 +90,7 @@ static __noinit struct backup backup_data;
extern void z_arm_configure_static_mpu_regions(void);
extern int z_arm_mpu_init(void);

#if defined(CONFIG_MPU)
/* MPU registers cannot be simply copied because content of RBARx RLARx registers
* depends on region which is selected by RNR register.
*/
Expand Down Expand Up @@ -130,6 +133,7 @@ static void mpu_restore(_mpu_context_t *backup)
MPU->RNR = rnr;
MPU->CTRL = backup->CTRL;
}
#endif /* defined(CONFIG_MPU) */

static void nvic_save(_nvic_context_t *backup)
{
Expand Down Expand Up @@ -245,7 +249,9 @@ int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off)
fpu_power_down();
#endif
nvic_save(&backup_data.nvic_context);
#if defined(CONFIG_MPU)
mpu_save(&backup_data.mpu_context);
#endif
ret = arch_pm_s2ram_suspend(system_off);
/* Cache and FPU are powered down so power up is needed even if s2ram failed. */
nrf_power_up_cache();
Expand All @@ -260,7 +266,9 @@ int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off)
return ret;
}

#if defined(CONFIG_MPU)
mpu_restore(&backup_data.mpu_context);
#endif
nvic_restore(&backup_data.nvic_context);
scb_restore(&backup_data.scb_context);

Expand Down
28 changes: 16 additions & 12 deletions subsys/pm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ config HAS_PM
This option must be selected by SoCs that provide PM hooks, that is,
calls to configure low-power states.

config HAS_PM_S2RAM_CUSTOM_MARKING
bool
depends on HAS_PM
help
By default a magic word in RAM is used to mark entering suspend-to-RAM. If this
option is selected, a custom implementation of functions which handle the marking
must be provided.

config PM
bool "System Power Management"
depends on SYS_CLOCK_EXISTS && HAS_PM
Expand All @@ -33,21 +41,17 @@ config PM_STATS
help
Enable System Power Management Stats.

DT_POWER_STATE_COMPAT := zephyr,power-state

config PM_S2RAM
bool "Suspend-to-RAM (S2RAM)"
bool
default y
depends on ARCH_HAS_SUSPEND_TO_RAM
depends on $(dt_compat_any_has_prop,$(DT_POWER_STATE_COMPAT),power-state-name,suspend-to-ram)
help
This option enables suspend-to-RAM (S2RAM).
When enabled on Cortex-M, and a 'zephyr,memory-region' compatible node with nodelabel
'pm_s2ram' is defined in DT, _cpu_context symbol (located in arch/arm/core/cortex_m/pm_s2ram.c)
is placed in linker section given by 'zephyr,memory-region' property of aforementioned node.

config PM_S2RAM_CUSTOM_MARKING
bool "Use custom marking functions"
depends on PM_S2RAM
help
By default a magic word in RAM is used to mark entering suspend-to-RAM. Enabling
this option allows custom implementation of functions which handle the marking.
This option enables the SoC specific implementations of suspend-to-ram (S2RAM)
sleep states if PM is enabled and one or more suspend-to-ram sleep states are
enabled in the devicetree.

config PM_NEED_ALL_DEVICES_IDLE
bool "System Low Power Mode Needs All Devices Idle"
Expand Down