blob: 5f9eab41eb1bc75e0b004a1ae5729c11ae729b2c [file] [log] [blame]
Sumit Garg38172022018-06-15 13:48:11 +05301/*
Jassi Brar2244bf12022-03-03 15:24:31 -06002 * Copyright (c) 2018-2022, ARM Limited and Contributors. All rights reserved.
Sumit Garg38172022018-06-15 13:48:11 +05303 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <assert_macros.S>
10#include <platform_def.h>
11
12 .global sq_calc_core_pos
13 .global plat_my_core_pos
14 .global platform_mem_init
15 .global plat_is_my_cpu_primary
16 .global plat_secondary_cold_boot_setup
Sumit Garg84711f92018-06-15 14:34:42 +053017 .global plat_crash_console_init
18 .global plat_crash_console_putc
19 .global plat_crash_console_flush
Sumit Garg38172022018-06-15 13:48:11 +053020
21/*
22 * unsigned int sq_calc_core_pos(u_register_t mpidr)
23 * core_pos = (cluster_id * max_cpus_per_cluster) + core_id
24 */
25func sq_calc_core_pos
26 and x1, x0, #MPIDR_CPU_MASK
27 and x0, x0, #MPIDR_CLUSTER_MASK
28 add x0, x1, x0, lsr #7
29 ret
30endfunc sq_calc_core_pos
31
32func plat_my_core_pos
33 mrs x0, mpidr_el1
34 b sq_calc_core_pos
35endfunc plat_my_core_pos
36
37func platform_mem_init
38 ret
39endfunc platform_mem_init
40
41/*
42 * Secondary CPUs are placed in a holding pen, waiting for their mailbox
43 * to be populated. Note that all CPUs share the same mailbox ; therefore,
44 * populating it will release all CPUs from their holding pen. If
45 * finer-grained control is needed then this should be handled in the
46 * code that secondary CPUs jump to.
47 */
48func plat_secondary_cold_boot_setup
Jassi Brar2244bf12022-03-03 15:24:31 -060049#if !RESET_TO_BL31
50 mov_imm x0, BL2_MAILBOX_BASE
51 ldr x0, [x0]
52#else
Sumit Garg38172022018-06-15 13:48:11 +053053 ldr x0, sq_sec_entrypoint
Jassi Brar2244bf12022-03-03 15:24:31 -060054#endif
Sumit Garg38172022018-06-15 13:48:11 +053055
56 /* Wait until the mailbox gets populated */
57poll_mailbox:
58 cbz x0, 1f
59 br x0
601:
61 wfe
62 b poll_mailbox
63endfunc plat_secondary_cold_boot_setup
64
65/*
66 * Find out whether the current cpu is the primary
67 * cpu (applicable only after a cold boot)
68 */
69func plat_is_my_cpu_primary
70 mov x9, x30
71 bl plat_my_core_pos
72 ldr x1, =SQ_BOOT_CFG_ADDR
73 ldr x1, [x1]
74 ubfx x1, x1, #PLAT_SQ_PRIMARY_CPU_SHIFT, \
75 #PLAT_SQ_PRIMARY_CPU_BIT_WIDTH
76 cmp x0, x1
77 cset w0, eq
78 ret x9
79endfunc plat_is_my_cpu_primary
Sumit Garg84711f92018-06-15 14:34:42 +053080
81/*
82 * int plat_crash_console_init(void)
83 * Function to initialize the crash console
84 * without a C Runtime to print crash report.
85 * Clobber list : x0, x1, x2
86 */
87func plat_crash_console_init
88 mov_imm x0, PLAT_SQ_BOOT_UART_BASE
89 mov_imm x1, PLAT_SQ_BOOT_UART_CLK_IN_HZ
90 mov_imm x2, SQ_CONSOLE_BAUDRATE
91 b console_pl011_core_init
92endfunc plat_crash_console_init
93
94/*
95 * int plat_crash_console_putc(int c)
96 * Function to print a character on the crash
97 * console without a C Runtime.
98 * Clobber list : x1, x2
99 */
100func plat_crash_console_putc
101 mov_imm x1, PLAT_SQ_BOOT_UART_BASE
102 b console_pl011_core_putc
103endfunc plat_crash_console_putc
104
105/*
Jimmy Brisson39f9eee2020-08-05 13:44:05 -0500106 * void plat_crash_console_flush(int c)
Sumit Garg84711f92018-06-15 14:34:42 +0530107 * Function to force a write of all buffered
108 * data that hasn't been output.
Jimmy Brisson39f9eee2020-08-05 13:44:05 -0500109 * Out : void.
Sumit Garg84711f92018-06-15 14:34:42 +0530110 * Clobber list : x0, x1
111 */
112func plat_crash_console_flush
113 mov_imm x0, PLAT_SQ_BOOT_UART_BASE
114 b console_pl011_core_flush
115endfunc plat_crash_console_flush