blob: 1ab1af54c549d36d6b125fd39405f4ed0d1666ff [file] [log] [blame]
Benjamin Fairf807a342016-10-18 14:32:06 -05001/*
2 * Copyright (c) 2017-2018, 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#define K3_BOOT_REASON_COLD_RESET 0x1
12
13 /* ------------------------------------------------------------------
14 * uintptr_t plat_get_my_entrypoint(void)
15 * ------------------------------------------------------------------
16 *
17 * This function is called with the called with the MMU and caches
18 * disabled (SCTLR_EL3.M = 0 and SCTLR_EL3.C = 0). The function is
19 * responsible for distinguishing between a warm and cold reset for the
20 * current CPU using platform-specific means. If it's a warm reset,
21 * then it returns the warm reset entrypoint point provided to
22 * plat_setup_psci_ops() during BL31 initialization. If it's a cold
23 * reset then this function must return zero.
24 *
25 * This function does not follow the Procedure Call Standard used by
26 * the Application Binary Interface for the ARM 64-bit architecture.
27 * The caller should not assume that callee saved registers are
28 * preserved across a call to this function.
29 */
30 .globl plat_get_my_entrypoint
31func plat_get_my_entrypoint
32 ldr x0, k3_boot_reason_data_store
33 cmp x0, #K3_BOOT_REASON_COLD_RESET
34
35 /* We ONLY support cold boot at this point */
36 bne plat_unsupported_boot
37 mov x0, #0
38 ret
39
40 /*
41 * We self manage our boot reason.
42 * At load time, we have just a default reason - which is cold reset
43 */
44k3_boot_reason_data_store:
45 .word K3_BOOT_REASON_COLD_RESET
46
47plat_unsupported_boot:
48 b plat_unsupported_boot
49
50endfunc plat_get_my_entrypoint
51
52 /* ------------------------------------------------------------------
53 * unsigned int plat_my_core_pos(void)
54 * ------------------------------------------------------------------
55 *
56 * This function returns the index of the calling CPU which is used as a
57 * CPU-specific linear index into blocks of memory (for example while
58 * allocating per-CPU stacks). This function will be invoked very early
59 * in the initialization sequence which mandates that this function
60 * should be implemented in assembly and should not rely on the
61 * avalability of a C runtime environment. This function can clobber x0
62 * - x8 and must preserve x9 - x29.
63 *
64 * This function plays a crucial role in the power domain topology
65 * framework in PSCI and details of this can be found in Power Domain
66 * Topology Design.
67 */
68 .globl plat_my_core_pos
69func plat_my_core_pos
70 mrs x0, MPIDR_EL1
71
72 and x1, x0, #MPIDR_CLUSTER_MASK
73 lsr x1, x1, #MPIDR_AFF1_SHIFT
74 and x0, x0, #MPIDR_CPU_MASK
75
Andrew F. Davisb208ae32019-03-27 09:37:10 -050076 cmp x1, 0
Benjamin Fairf807a342016-10-18 14:32:06 -050077 b.eq out
78 add x0, x0, #K3_CLUSTER0_CORE_COUNT
Andrew F. Davisb208ae32019-03-27 09:37:10 -050079
80 cmp x1, 1
Benjamin Fairf807a342016-10-18 14:32:06 -050081 b.eq out
82 add x0, x0, #K3_CLUSTER1_CORE_COUNT
Andrew F. Davisb208ae32019-03-27 09:37:10 -050083
84 cmp x1, 2
Benjamin Fairf807a342016-10-18 14:32:06 -050085 b.eq out
86 add x0, x0, #K3_CLUSTER2_CORE_COUNT
Benjamin Fairf807a342016-10-18 14:32:06 -050087
88out:
89 ret
90endfunc plat_my_core_pos
Nishanth Menonce976042016-10-14 01:13:44 +000091
92 /* ---------------------------------------------
93 * int plat_crash_console_init(void)
94 * Function to initialize the crash console
95 * without a C Runtime to print crash report.
96 * Clobber list : x0 - x4
97 * ---------------------------------------------
98 */
Antonio Nino Diaz1eb64a12018-10-17 15:29:34 +010099 .globl plat_crash_console_init
Nishanth Menonce976042016-10-14 01:13:44 +0000100func plat_crash_console_init
101 mov_imm x0, CRASH_CONSOLE_BASE
102 mov_imm x1, CRASH_CONSOLE_CLK
103 mov_imm x2, CRASH_CONSOLE_BAUD_RATE
104 mov w3, #0x0
Antonio Nino Diaz1eb64a12018-10-17 15:29:34 +0100105 b console_16550_core_init
Nishanth Menonce976042016-10-14 01:13:44 +0000106endfunc plat_crash_console_init
107
108 /* ---------------------------------------------
109 * int plat_crash_console_putc(void)
110 * Function to print a character on the crash
111 * console without a C Runtime.
112 * Clobber list : x1, x2
113 * ---------------------------------------------
114 */
Antonio Nino Diaz1eb64a12018-10-17 15:29:34 +0100115 .globl plat_crash_console_putc
Nishanth Menonce976042016-10-14 01:13:44 +0000116func plat_crash_console_putc
117 mov_imm x1, CRASH_CONSOLE_BASE
Antonio Nino Diaz1eb64a12018-10-17 15:29:34 +0100118 b console_16550_core_putc
Nishanth Menonce976042016-10-14 01:13:44 +0000119endfunc plat_crash_console_putc
Antonio Nino Diaz1eb64a12018-10-17 15:29:34 +0100120
121 /* ---------------------------------------------
122 * int plat_crash_console_flush()
123 * Function to force a write of all buffered
124 * data that hasn't been output.
125 * Out : return -1 on error else return 0.
126 * Clobber list : x0, x1
127 * ---------------------------------------------
128 */
129 .globl plat_crash_console_flush
130func plat_crash_console_flush
131 mov_imm x0, CRASH_CONSOLE_BASE
132 b console_16550_core_flush
133endfunc plat_crash_console_flush