1/*
2 * Copyright (c) 2016, 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
11	.globl pmu_cpuson_entrypoint
12	.macro pmusram_entry_func _name
13	.section .pmusram.entry, "ax"
14	.type \_name, %function
15	.func \_name
16	.cfi_startproc
17	\_name:
18	.endm
19
20pmusram_entry_func pmu_cpuson_entrypoint
21
22#if PSRAM_CHECK_WAKEUP_CPU
23check_wake_cpus:
24	mrs	x0, MPIDR_EL1
25	and	x1, x0, #MPIDR_CPU_MASK
26	and	x0, x0, #MPIDR_CLUSTER_MASK
27	orr	x0, x0, x1
28
29	/* primary_cpu */
30	ldr	w1, boot_mpidr
31	cmp	w0, w1
32	b.eq	sys_wakeup
33
34	/*
35	 * If the core is not the primary cpu,
36	 * force the core into wfe.
37	 */
38wfe_loop:
39	wfe
40	b	wfe_loop
41sys_wakeup:
42#endif
43
44#if PSRAM_DO_DDR_RESUME
45ddr_resume:
46	ldr	x2, =__bl31_sram_stack_end
47	mov     sp, x2
48	bl	dmc_resume
49#endif
50	bl	sram_restore
51sys_resume:
52	bl	psci_entrypoint
53endfunc pmu_cpuson_entrypoint
54