Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 20 | func 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 | |
anzhou | 113d2d2 | 2020-06-04 13:20:18 +0800 | [diff] [blame] | 26 | /* core_id > PLATFORM_CORES_PER_CLUSTER */ |
Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 27 | mov x0, #-1 |
| 28 | cmp x1, #(PLATFORM_CORES_PER_CLUSTER - 1) |
anzhou | 113d2d2 | 2020-06-04 13:20:18 +0800 | [diff] [blame] | 29 | b.hi 1f |
Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 30 | |
anzhou | 113d2d2 | 2020-06-04 13:20:18 +0800 | [diff] [blame] | 31 | /* cluster_id > PLATFORM_CLUSTER_COUNT */ |
Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 32 | cmp x2, #(PLATFORM_CLUSTER_COUNT - 1) |
anzhou | 113d2d2 | 2020-06-04 13:20:18 +0800 | [diff] [blame] | 33 | b.hi 1f |
Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 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 | |
| 40 | 1: |
| 41 | ret |
| 42 | endfunc 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 | */ |
| 51 | func plat_crash_console_init |
anzhou | 113d2d2 | 2020-06-04 13:20:18 +0800 | [diff] [blame] | 52 | mov_imm x0, TEGRA_UARTC_BASE |
| 53 | mov_imm x1, TEGRA_CONSOLE_CLKRATE |
| 54 | mov_imm x2, TEGRA_CONSOLE_BAUDRATE |
Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 55 | b console_init |
| 56 | endfunc 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 | */ |
| 65 | func plat_crash_console_putc |
anzhou | 113d2d2 | 2020-06-04 13:20:18 +0800 | [diff] [blame] | 66 | mov_imm x1, TEGRA_UARTC_BASE |
Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 67 | b console_putc |
| 68 | endfunc 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. |
anzhou | 113d2d2 | 2020-06-04 13:20:18 +0800 | [diff] [blame] | 75 | * Clobber list : x0 - x1 |
Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 76 | * --------------------------------------------- |
| 77 | */ |
| 78 | func plat_crash_console_flush |
anzhou | 113d2d2 | 2020-06-04 13:20:18 +0800 | [diff] [blame] | 79 | mov_imm x1, TEGRA_UARTC_BASE |
Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 80 | b console_flush |
| 81 | endfunc plat_crash_console_flush |