Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 1eb64a1 | 2018-10-17 15:29:34 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
Haojian Zhuang | 1b5c225 | 2017-06-01 15:20:46 +0800 | [diff] [blame] | 9 | #include <cortex_a53.h> |
| 10 | #include <cortex_a73.h> |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 11 | #include "../hikey960_def.h" |
| 12 | |
| 13 | .globl plat_my_core_pos |
| 14 | .globl platform_mem_init |
| 15 | .globl plat_crash_console_init |
| 16 | .globl plat_crash_console_putc |
Antonio Nino Diaz | 1eb64a1 | 2018-10-17 15:29:34 +0100 | [diff] [blame] | 17 | .globl plat_crash_console_flush |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 18 | .globl plat_report_exception |
| 19 | .globl plat_reset_handler |
Haojian Zhuang | 1b5c225 | 2017-06-01 15:20:46 +0800 | [diff] [blame] | 20 | .globl clr_ex |
| 21 | .globl nop |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 22 | |
| 23 | func plat_my_core_pos |
| 24 | mrs x0, mpidr_el1 |
| 25 | and x1, x0, #MPIDR_CPU_MASK |
| 26 | and x0, x0, #MPIDR_CLUSTER_MASK |
| 27 | add x0, x1, x0, LSR #6 |
| 28 | ret |
| 29 | endfunc plat_my_core_pos |
| 30 | |
| 31 | /* ----------------------------------------------------- |
| 32 | * void platform_mem_init(void); |
| 33 | * |
| 34 | * We don't need to carry out any memory initialization |
| 35 | * on HIKEY. The Secure RAM is accessible straight away. |
| 36 | * ----------------------------------------------------- |
| 37 | */ |
| 38 | func platform_mem_init |
| 39 | ret |
| 40 | endfunc platform_mem_init |
| 41 | |
| 42 | /* --------------------------------------------- |
| 43 | * int plat_crash_console_init(void) |
| 44 | * Function to initialize the crash console |
| 45 | * without a C Runtime to print crash report. |
| 46 | * Clobber list : x0, x1, x2 |
| 47 | * --------------------------------------------- |
| 48 | */ |
| 49 | func plat_crash_console_init |
| 50 | mov_imm x0, CRASH_CONSOLE_BASE |
| 51 | mov_imm x1, PL011_UART_CLK_IN_HZ |
| 52 | mov_imm x2, PL011_BAUDRATE |
Jerome Forissier | 3fb19df | 2018-11-08 09:59:29 +0100 | [diff] [blame] | 53 | b console_pl011_core_init |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 54 | endfunc plat_crash_console_init |
| 55 | |
| 56 | /* --------------------------------------------- |
| 57 | * int plat_crash_console_putc(int c) |
| 58 | * Function to print a character on the crash |
| 59 | * console without a C Runtime. |
| 60 | * Clobber list : x1, x2 |
| 61 | * --------------------------------------------- |
| 62 | */ |
| 63 | func plat_crash_console_putc |
| 64 | mov_imm x1, CRASH_CONSOLE_BASE |
Jerome Forissier | 3fb19df | 2018-11-08 09:59:29 +0100 | [diff] [blame] | 65 | b console_pl011_core_putc |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 66 | endfunc plat_crash_console_putc |
| 67 | |
| 68 | /* --------------------------------------------- |
Antonio Nino Diaz | 1eb64a1 | 2018-10-17 15:29:34 +0100 | [diff] [blame] | 69 | * int plat_crash_console_flush() |
| 70 | * Function to force a write of all buffered |
| 71 | * data that hasn't been output. |
| 72 | * Out : return -1 on error else return 0. |
| 73 | * Clobber list : x0, x1 |
| 74 | * --------------------------------------------- |
| 75 | */ |
| 76 | func plat_crash_console_flush |
| 77 | mov_imm x0, CRASH_CONSOLE_BASE |
Jerome Forissier | 3fb19df | 2018-11-08 09:59:29 +0100 | [diff] [blame] | 78 | b console_pl011_core_flush |
Antonio Nino Diaz | 1eb64a1 | 2018-10-17 15:29:34 +0100 | [diff] [blame] | 79 | endfunc plat_crash_console_flush |
| 80 | |
| 81 | /* --------------------------------------------- |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 82 | * void plat_report_exception(unsigned int type) |
| 83 | * Function to report an unhandled exception |
| 84 | * with platform-specific means. |
| 85 | * On HIKEY platform, it updates the LEDs |
| 86 | * to indicate where we are |
| 87 | * --------------------------------------------- |
| 88 | */ |
| 89 | func plat_report_exception |
| 90 | mov x8, x30 |
| 91 | |
| 92 | /* Turn on LED according to x0 (0 -- f) */ |
| 93 | ldr x2, =0xf7020000 |
| 94 | and x1, x0, #1 |
| 95 | str w1, [x2, #4] |
| 96 | and x1, x0, #2 |
| 97 | str w1, [x2, #8] |
| 98 | and x1, x0, #4 |
| 99 | str w1, [x2, #16] |
| 100 | and x1, x0, #8 |
| 101 | str w1, [x2, #32] |
| 102 | |
| 103 | mrs x2, currentel |
| 104 | and x2, x2, #0x0c |
| 105 | /* Check EL1 */ |
| 106 | cmp x2, #0x04 |
| 107 | beq plat_report_el1 |
| 108 | |
| 109 | adr x4, plat_err_str |
| 110 | bl asm_print_str |
| 111 | |
| 112 | adr x4, esr_el3_str |
| 113 | bl asm_print_str |
| 114 | |
| 115 | mrs x4, esr_el3 |
| 116 | bl asm_print_hex |
| 117 | |
| 118 | adr x4, elr_el3_str |
| 119 | bl asm_print_str |
| 120 | |
| 121 | mrs x4, elr_el3 |
| 122 | bl asm_print_hex |
| 123 | b plat_report_end |
| 124 | |
| 125 | plat_report_el1: |
| 126 | adr x4, plat_err_str |
| 127 | bl asm_print_str |
| 128 | |
| 129 | adr x4, esr_el1_str |
| 130 | bl asm_print_str |
| 131 | |
| 132 | mrs x4, esr_el1 |
| 133 | bl asm_print_hex |
| 134 | |
| 135 | adr x4, elr_el1_str |
| 136 | bl asm_print_str |
| 137 | |
| 138 | mrs x4, elr_el1 |
| 139 | bl asm_print_hex |
| 140 | plat_report_end: |
| 141 | mov x30, x8 |
| 142 | ret |
| 143 | endfunc plat_report_exception |
| 144 | |
| 145 | /* ----------------------------------------------------- |
| 146 | * void plat_reset_handler(void); |
| 147 | * ----------------------------------------------------- |
| 148 | */ |
| 149 | func plat_reset_handler |
| 150 | ret |
| 151 | endfunc plat_reset_handler |
| 152 | |
Haojian Zhuang | 1b5c225 | 2017-06-01 15:20:46 +0800 | [diff] [blame] | 153 | /* ----------------------------------------------------- |
Haojian Zhuang | 1b5c225 | 2017-06-01 15:20:46 +0800 | [diff] [blame] | 154 | * void clrex(void); |
| 155 | * ----------------------------------------------------- |
| 156 | */ |
| 157 | func clr_ex |
| 158 | clrex |
| 159 | ret |
| 160 | endfunc clr_ex |
| 161 | |
| 162 | /* ----------------------------------------------------- |
| 163 | * void nop(void); |
| 164 | * ----------------------------------------------------- |
| 165 | */ |
| 166 | func nop |
| 167 | nop |
| 168 | ret |
| 169 | endfunc nop |
| 170 | |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 171 | .section .rodata.rev_err_str, "aS" |
| 172 | plat_err_str: |
| 173 | .asciz "\nPlatform exception reporting:" |
| 174 | esr_el3_str: |
| 175 | .asciz "\nESR_EL3: " |
| 176 | elr_el3_str: |
| 177 | .asciz "\nELR_EL3: " |
| 178 | esr_el1_str: |
| 179 | .asciz "\nESR_EL1: " |
| 180 | elr_el1_str: |
| 181 | .asciz "\nELR_EL1: " |