Skip to content

Commit 773f71f

Browse files
committed
arch: Allow to specify memory for S2RAM resume
If the area, dedicated for the interrupt stack is not available, allow to specify a memory region that will be used as the stack for the S2RAM resume logic. Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent 6614a3a commit 773f71f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

arch/arm/core/cortex_m/reset.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start)
101101
#endif /* CONFIG_INIT_ARCH_HW_AT_BOOT */
102102

103103
#if defined(CONFIG_PM_S2RAM)
104+
#if DT_NODE_EXISTS(DT_NODELABEL(pm_s2ram_stack)) &&\
105+
DT_NODE_HAS_COMPAT(DT_NODELABEL(pm_s2ram_stack), zephyr_memory_region)
106+
/* If the assumption that the interrupt stack may be safely used is not met,
107+
* use a predefined memory region to execute the S2RAM logic.
108+
*/
109+
ldr r0, =DT_REG_ADDR(DT_NODELABEL(pm_s2ram_stack)) + DT_REG_SIZE(DT_NODELABEL(pm_s2ram_stack))
110+
#else
104111
/*
105112
* Temporarily set MSP to interrupt stack so that arch_pm_s2ram_resume can
106113
* use stack for calling pm_s2ram_mark_check_and_clear.
@@ -113,6 +120,7 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start)
113120
* a short while, there is no change in behavior in either of the paths.
114121
*/
115122
ldr r0, =z_interrupt_stacks + CONFIG_ISR_STACK_SIZE + MPU_GUARD_ALIGN_AND_SIZE
123+
#endif
116124
msr msp, r0
117125

118126
bl arch_pm_s2ram_resume

boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,19 @@ zephyr_udc0: &usbhs {
332332

333333
/* Trim this RAM block for making room on all run-time common S2RAM cpu context. */
334334
&cpuapp_ram0 {
335-
reg = <0x22000000 (DT_SIZE_K(32) - 32)>;
336-
ranges = <0x0 0x22000000 (0x8000 - 0x20)>;
335+
reg = <0x22000000 (DT_SIZE_K(32) - 48)>;
336+
ranges = <0x0 0x22000000 (0x8000 - 0x30)>;
337337
};
338338

339339
/ {
340340
soc {
341+
/* temporary stack for S2RAM resume logic */
342+
pm_s2ram_stack: cpuapp_s2ram_stack@22007fd0 {
343+
compatible = "zephyr,memory-region", "mmio-sram";
344+
reg = <0x22007fd0 16>;
345+
zephyr,memory-region = "pm_s2ram_stack";
346+
};
347+
341348
/* run-time common S2RAM cpu context RAM */
342349
pm_s2ram: cpuapp_s2ram@22007fe0 {
343350
compatible = "zephyr,memory-region", "mmio-sram";

subsys/pm/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ config PM_S2RAM
4141
When enabled on Cortex-M, and a 'zephyr,memory-region' compatible node with nodelabel
4242
'pm_s2ram' is defined in DT, _cpu_context symbol (located in arch/arm/core/cortex_m/pm_s2ram.c)
4343
is placed in linker section given by 'zephyr,memory-region' property of aforementioned node.
44+
Additionally on Cortex-M, if a 'zephyr,memory-region' compatible node with nodelabel
45+
'pm_s2ram_stack' is defined in DT, this region will be used as a temporary program stack
46+
for the S2RAM resume logic. The assembly reset handling code itself makes a single push of
47+
the return address, but the SoC-specific function (pm_s2ram_mark_check_and_clear) must be
48+
analyzed to determine the required stack size.
4449

4550
config PM_S2RAM_CUSTOM_MARKING
4651
bool "Use custom marking functions"

0 commit comments

Comments
 (0)