xref: /rk3399_ARM-atf/plat/intel/soc/common/aarch64/plat_helpers.S (revision 530ceda57288aa931d0c8ba7b3066340d587cc9b)
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 <cpu_macros.S>
10#include <platform_def.h>
11
12	.globl	plat_secondary_cold_boot_setup
13	.globl	platform_is_primary_cpu
14	.globl	plat_is_my_cpu_primary
15	.globl	plat_my_core_pos
16	.globl	plat_crash_console_init
17	.globl	plat_crash_console_putc
18	.globl  plat_crash_console_flush
19	.globl	platform_mem_init
20
21	.globl plat_get_my_entrypoint
22
23	/* -----------------------------------------------------
24	 * void plat_secondary_cold_boot_setup (void);
25	 *
26	 * This function performs any platform specific actions
27	 * needed for a secondary cpu after a cold reset e.g
28	 * mark the cpu's presence, mechanism to place it in a
29	 * holding pen etc.
30	 * -----------------------------------------------------
31	 */
32func plat_secondary_cold_boot_setup
33	/* Wait until the it gets reset signal from rstmgr gets populated */
34poll_mailbox:
35	wfi
36
37	mov_imm	x0, PLAT_SEC_ENTRY
38	ldr	x1, [x0]
39	mov_imm	x2, PLAT_CPUID_RELEASE
40	ldr	x3, [x2]
41	mrs	x4, mpidr_el1
42	and	x4, x4, #0xff
43	cmp	x3, x4
44	b.ne	poll_mailbox
45	br	x1
46endfunc plat_secondary_cold_boot_setup
47
48func platform_is_primary_cpu
49	and	x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
50	cmp	x0, #PLAT_PRIMARY_CPU
51	cset	x0, eq
52	ret
53endfunc platform_is_primary_cpu
54
55func plat_is_my_cpu_primary
56	mrs	x0, mpidr_el1
57	b   platform_is_primary_cpu
58endfunc plat_is_my_cpu_primary
59
60func plat_my_core_pos
61	mrs	x0, mpidr_el1
62	and	x1, x0, #MPIDR_CPU_MASK
63	and	x0, x0, #MPIDR_CLUSTER_MASK
64	add	x0, x1, x0, LSR #6
65	ret
66endfunc plat_my_core_pos
67
68func plat_get_my_entrypoint
69	mov_imm	x1, PLAT_SEC_ENTRY
70	ldr	x0, [x1]
71	ret
72endfunc plat_get_my_entrypoint
73
74	/* ---------------------------------------------
75	 * int plat_crash_console_init(void)
76	 * Function to initialize the crash console
77	 * without a C Runtime to print crash report.
78	 * Clobber list : x0, x1, x2
79	 * ---------------------------------------------
80	 */
81func plat_crash_console_init
82	mov_imm	x0, PLAT_UART0_BASE
83	mov_imm	x1, PLAT_UART_CLOCK
84	mov_imm	x2, PLAT_BAUDRATE
85	b	console_16550_core_init
86endfunc plat_crash_console_init
87
88	/* ---------------------------------------------
89	 * int plat_crash_console_putc(void)
90	 * Function to print a character on the crash
91	 * console without a C Runtime.
92	 * Clobber list : x1, x2
93	 * ---------------------------------------------
94	 */
95func plat_crash_console_putc
96	mov_imm x1, PLAT_UART0_BASE
97	b	console_16550_core_putc
98endfunc plat_crash_console_putc
99
100func plat_crash_console_flush
101	mov_imm x0, CRASH_CONSOLE_BASE
102	b	console_16550_core_flush
103endfunc plat_crash_console_flush
104
105
106	/* --------------------------------------------------------
107	 * void platform_mem_init (void);
108	 *
109	 * Any memory init, relocation to be done before the
110	 * platform boots. Called very early in the boot process.
111	 * --------------------------------------------------------
112	 */
113func platform_mem_init
114	mov	x0, #0
115	ret
116endfunc platform_mem_init
117