blob: 38681b56f875b97343c9d0e7aaf5504e9acbf572 [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
anzhou113d2d22020-06-04 13:20:18 +080026 /* core_id > PLATFORM_CORES_PER_CLUSTER */
Varun Wadekar91535cd2020-03-12 14:32:44 -070027 mov x0, #-1
28 cmp x1, #(PLATFORM_CORES_PER_CLUSTER - 1)
anzhou113d2d22020-06-04 13:20:18 +080029 b.hi 1f
Varun Wadekar91535cd2020-03-12 14:32:44 -070030
anzhou113d2d22020-06-04 13:20:18 +080031 /* cluster_id > PLATFORM_CLUSTER_COUNT */
Varun Wadekar91535cd2020-03-12 14:32:44 -070032 cmp x2, #(PLATFORM_CLUSTER_COUNT - 1)
anzhou113d2d22020-06-04 13:20:18 +080033 b.hi 1f
Varun Wadekar91535cd2020-03-12 14:32:44 -070034
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
anzhou113d2d22020-06-04 13:20:18 +080052 mov_imm x0, TEGRA_UARTC_BASE
53 mov_imm x1, TEGRA_CONSOLE_CLKRATE
54 mov_imm x2, TEGRA_CONSOLE_BAUDRATE
Varun Wadekar91535cd2020-03-12 14:32:44 -070055 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
anzhou113d2d22020-06-04 13:20:18 +080066 mov_imm x1, TEGRA_UARTC_BASE
Varun Wadekar91535cd2020-03-12 14:32:44 -070067 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.
anzhou113d2d22020-06-04 13:20:18 +080075 * Clobber list : x0 - x1
Varun Wadekar91535cd2020-03-12 14:32:44 -070076 * ---------------------------------------------
77 */
78func plat_crash_console_flush
anzhou113d2d22020-06-04 13:20:18 +080079 mov_imm x1, TEGRA_UARTC_BASE
Varun Wadekar91535cd2020-03-12 14:32:44 -070080 b console_flush
81endfunc plat_crash_console_flush