blob: c95e9c367a08c3a78efc9984b01b18dc84529e36 [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
76#if K3_CLUSTER1_MSMC_PORT != UNUSED
77 cmp x1, #K3_CLUSTER0_MSMC_PORT
78 b.eq out
79 add x0, x0, #K3_CLUSTER0_CORE_COUNT
80#if K3_CLUSTER2_MSMC_PORT != UNUSED
81 cmp x1, #K3_CLUSTER1_MSMC_PORT
82 b.eq out
83 add x0, x0, #K3_CLUSTER1_CORE_COUNT
84#if K3_CLUSTER3_MSMC_PORT != UNUSED
85 cmp x1, #K3_CLUSTER2_MSMC_PORT
86 b.eq out
87 add x0, x0, #K3_CLUSTER2_CORE_COUNT
88#endif /* K3_CLUSTER3_MSMC_PORT != UNUSED */
89#endif /* K3_CLUSTER2_MSMC_PORT != UNUSED */
90#endif /* K3_CLUSTER1_MSMC_PORT != UNUSED */
91
92out:
93 ret
94endfunc plat_my_core_pos
Nishanth Menonce976042016-10-14 01:13:44 +000095
96 /* ---------------------------------------------
97 * int plat_crash_console_init(void)
98 * Function to initialize the crash console
99 * without a C Runtime to print crash report.
100 * Clobber list : x0 - x4
101 * ---------------------------------------------
102 */
103func plat_crash_console_init
104 mov_imm x0, CRASH_CONSOLE_BASE
105 mov_imm x1, CRASH_CONSOLE_CLK
106 mov_imm x2, CRASH_CONSOLE_BAUD_RATE
107 mov w3, #0x0
108 b console_core_init
109
110endfunc plat_crash_console_init
111
112 /* ---------------------------------------------
113 * int plat_crash_console_putc(void)
114 * Function to print a character on the crash
115 * console without a C Runtime.
116 * Clobber list : x1, x2
117 * ---------------------------------------------
118 */
119func plat_crash_console_putc
120 mov_imm x1, CRASH_CONSOLE_BASE
121 b console_core_putc
122endfunc plat_crash_console_putc