blob: 16691312154dc671b724c9c31091e195715d713d [file] [log] [blame]
Varun Wadekar91535cd2020-03-12 14:32:44 -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 3 for the Cortex-A53 cores and 4 to 5 for the Cortex-A57
18 * cores.
19 */
20func platform_get_core_pos
21 lsr x1, x0, #MPIDR_AFF0_SHIFT
22 and x1, x1, #MPIDR_AFFLVL_MASK /* core id */
23 lsr x2, x0, #MPIDR_AFF1_SHIFT
24 and x2, x2, #MPIDR_AFFLVL_MASK /* cluster id */
25
26 /* core_id >= PLATFORM_CORES_PER_CLUSTER */
27 mov x0, #-1
28 cmp x1, #(PLATFORM_CORES_PER_CLUSTER - 1)
29 b.gt 1f
30
31 /* cluster_id >= PLATFORM_CLUSTER_COUNT */
32 cmp x2, #(PLATFORM_CLUSTER_COUNT - 1)
33 b.gt 1f
34
35 /* CorePos = CoreId + (ClusterId * cpus per cluster) */
36 mov x3, #PLATFORM_CORES_PER_CLUSTER
37 mul x3, x3, x2
38 add x0, x1, x3
39
401:
41 ret
42endfunc platform_get_core_pos
43
44 /* ---------------------------------------------
45 * int plat_crash_console_init(void)
46 * Function to initialize the crash console
47 * without a C Runtime to print crash report.
48 * Clobber list : x0 - x4
49 * ---------------------------------------------
50 */
51func plat_crash_console_init
52 mov_imm x0, TEGRA194_UARTC_BASE
53 mov_imm x1, TEGRA194_CONSOLE_CLKRATE
54 mov_imm x2, TEGRA194_CONSOLE_BAUDRATE
55 b console_init
56endfunc plat_crash_console_init
57
58 /* ---------------------------------------------
59 * int plat_crash_console_putc(int c)
60 * Function to print a character on the crash
61 * console without a C Runtime.
62 * Clobber list : x1, x2
63 * ---------------------------------------------
64 */
65func plat_crash_console_putc
66 mov_imm x1, TEGRA194_UARTC_BASE
67 b console_putc
68endfunc plat_crash_console_putc
69
70 /* ---------------------------------------------
71 * int plat_crash_console_flush()
72 * Function to force a write of all buffered
73 * data that hasn't been output.
74 * Out : return -1 on error else return 0.
75 * Clobber list : r0 - r1
76 * ---------------------------------------------
77 */
78func plat_crash_console_flush
79 mov_imm x1, TEGRA194_UARTC_BASE
80 b console_flush
81endfunc plat_crash_console_flush