Skip to content

Commit e5d5510

Browse files
committed
[nrf fromlist] 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. Upstream PR #: 95914 Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
1 parent 1123b56 commit e5d5510

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

arch/arm/core/cortex_m/reset.S

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

8585
#if defined(CONFIG_PM_S2RAM)
86+
#if DT_NODE_EXISTS(DT_NODELABEL(pm_s2ram_stack)) &&\
87+
DT_NODE_HAS_COMPAT(DT_NODELABEL(pm_s2ram_stack), zephyr_memory_region)
88+
/* If the assumption that the interrupt stack may be safely used is not met,
89+
* use a predefined memory region to execute the S2RAM logic.
90+
*/
91+
ldr r0, =DT_REG_ADDR(DT_NODELABEL(pm_s2ram_stack)) + DT_REG_SIZE(DT_NODELABEL(pm_s2ram_stack))
92+
#else
8693
/*
8794
* Temporarily set MSP to interrupt stack so that arch_pm_s2ram_resume can
8895
* use stack for calling pm_s2ram_mark_check_and_clear.
@@ -95,6 +102,7 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start)
95102
* a short while, there is no change in behavior in either of the paths.
96103
*/
97104
ldr r0, =z_interrupt_stacks + CONFIG_ISR_STACK_SIZE + MPU_GUARD_ALIGN_AND_SIZE
105+
#endif
98106
msr msp, r0
99107

100108
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
@@ -343,12 +343,19 @@ zephyr_udc0: &usbhs {
343343

344344
/* Trim this RAM block for making room on all run-time common S2RAM cpu context. */
345345
&cpuapp_ram0 {
346-
reg = <0x22000000 (DT_SIZE_K(32) - 32)>;
347-
ranges = <0x0 0x22000000 (0x8000 - 0x20)>;
346+
reg = <0x22000000 (DT_SIZE_K(32) - 48)>;
347+
ranges = <0x0 0x22000000 (0x8000 - 0x30)>;
348348
};
349349

350350
/ {
351351
soc {
352+
/* temporary stack for S2RAM resume logic */
353+
pm_s2ram_stack: cpuapp_s2ram_stack@22007fd0 {
354+
compatible = "zephyr,memory-region", "mmio-sram";
355+
reg = <0x22007fd0 16>;
356+
zephyr,memory-region = "pm_s2ram_stack";
357+
};
358+
352359
/* run-time common S2RAM cpu context RAM */
353360
pm_s2ram: cpuapp_s2ram@22007fe0 {
354361
compatible = "zephyr,memory-region", "mmio-sram";

0 commit comments

Comments
 (0)