blob: 7ffbe3e9717633fc7390039451c87591f2f7b28e [file] [log] [blame]
Varun Wadekardbf8a2f2020-06-23 08:13:57 -07001/*
2 * Copyright (c) 2020, NVIDIA CORPORATION. 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 platform_get_core_pos
12 .globl plat_crash_console_init
13 .globl plat_crash_console_putc
14 .globl plat_crash_console_flush
15
16 /*
17 * Return 0 to 7 as logical CPU IDs
18 */
19func platform_get_core_pos
20 lsr x1, x0, #MPIDR_AFF0_SHIFT
21 and x1, x1, #MPIDR_AFFLVL_MASK /* core id */
22 lsr x2, x0, #MPIDR_AFF1_SHIFT
23 and x2, x2, #MPIDR_AFFLVL_MASK /* cluster id */
24
25 /* core_id > PLATFORM_CORES_CLUSTER1 */
26 mov x0, #-1
27 cmp x1, #(PLATFORM_CORES_CLUSTER1 - 1)
28 b.hi 1f
29
30 /* cluster_id > PLATFORM_CLUSTER_COUNT */
31 cmp x2, #(PLATFORM_CLUSTER_COUNT - 1)
32 b.hi 1f
33
34 /* CorePos = CoreId + (ClusterId * cpus per cluster) */
35 mov x3, #PLATFORM_CORES_CLUSTER1
36 mul x3, x2, x3
37 add x0, x1, x3
38
391:
40 ret
41endfunc platform_get_core_pos
42
43 /* ---------------------------------------------
44 * int plat_crash_console_init(void)
45 * Function to initialize the crash console
46 * without a C Runtime to print crash report.
47 * Clobber list : x0 - x4
48 * ---------------------------------------------
49 */
50func plat_crash_console_init
51 mov_imm x0, TEGRA_UARTA_BASE
52 mov_imm x1, TEGRA_CONSOLE_CLKRATE
53 mov_imm x2, TEGRA_CONSOLE_BAUDRATE
54 b console_init
55endfunc plat_crash_console_init
56
57 /* ---------------------------------------------
58 * int plat_crash_console_putc(int c)
59 * Function to print a character on the crash
60 * console without a C Runtime.
61 * Clobber list : x1, x2
62 * ---------------------------------------------
63 */
64func plat_crash_console_putc
65 mov_imm x1, TEGRA_UARTA_BASE
66 b console_putc
67endfunc plat_crash_console_putc
68
69 /* ---------------------------------------------
70 * int plat_crash_console_flush()
71 * Function to force a write of all buffered
72 * data that hasn't been output.
73 * Out : return -1 on error else return 0.
74 * Clobber list : x0 - x1
75 * ---------------------------------------------
76 */
77func plat_crash_console_flush
78 mov_imm x1, TEGRA_UARTA_BASE
79 b console_flush
80endfunc plat_crash_console_flush