1/*
2 * Copyright (c) 2019, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <platform_def.h>
10#include <cpus_on_fixed_addr.h>
11
12	.globl sys_sleep_flag_sram
13	.globl pmu_cpuson_entrypoint
14
15	.macro pmusram_entry_func _name
16	.section .pmusram.entry, "ax"
17	.type \_name, %function
18	.cfi_startproc
19	\_name:
20	.endm
21
22pmusram_entry_func pmu_cpuson_entrypoint
23	adr	x5, sys_sleep_flag_sram
24	ldr	w2, [x5, #PSRAM_DT_PM_FLAG]
25
26	tbz	w2, #PM_WARM_BOOT_SHT, sys_resume_sp
27	ldr	x1, =platform_cpu_warmboot
28	br	x1
29sys_resume_sp:
30	adr	x5, sys_sleep_flag_sram
31	ldr	x1, [x5, #PSRAM_DT_SP]
32	mov	sp, x1
33ddr_resume:
34	ldr	x1, [x5, #PSRAM_DT_DDR_FUNC]
35	cmp	x1, #0
36	b.eq	sys_resume
37	blr	x1
38sys_resume:
39	ldr	x1, =bl31_warm_entrypoint
40	br	x1
41endfunc pmu_cpuson_entrypoint
42
43	.section .pmusram.data, "a"
44	.align  3
45sys_sleep_flag_sram:
46	.rept	PSRAM_DT_SIZE_WORDS
47	.word	0
48	.endr
49