blob: 606f2d0f9038cff477f56b684d28ab5f55ab39d6 [file] [log] [blame]
Haojian Zhuang602362d2017-06-01 12:15:14 +08001/*
Antonio Nino Diaz1eb64a12018-10-17 15:29:34 +01002 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
Haojian Zhuang602362d2017-06-01 12:15:14 +08003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
Haojian Zhuang1b5c2252017-06-01 15:20:46 +08009#include <cortex_a53.h>
10#include <cortex_a73.h>
Haojian Zhuang602362d2017-06-01 12:15:14 +080011#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 Diaz1eb64a12018-10-17 15:29:34 +010017 .globl plat_crash_console_flush
Haojian Zhuang602362d2017-06-01 12:15:14 +080018 .globl plat_report_exception
19 .globl plat_reset_handler
Haojian Zhuang1b5c2252017-06-01 15:20:46 +080020 .globl clr_ex
21 .globl nop
Haojian Zhuang602362d2017-06-01 12:15:14 +080022
23func 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
29endfunc 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 */
38func platform_mem_init
39 ret
40endfunc 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 */
49func 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 Forissier3fb19df2018-11-08 09:59:29 +010053 b console_pl011_core_init
Haojian Zhuang602362d2017-06-01 12:15:14 +080054endfunc 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 */
63func plat_crash_console_putc
64 mov_imm x1, CRASH_CONSOLE_BASE
Jerome Forissier3fb19df2018-11-08 09:59:29 +010065 b console_pl011_core_putc
Haojian Zhuang602362d2017-06-01 12:15:14 +080066endfunc plat_crash_console_putc
67
68 /* ---------------------------------------------
Antonio Nino Diaz1eb64a12018-10-17 15:29:34 +010069 * 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 */
76func plat_crash_console_flush
77 mov_imm x0, CRASH_CONSOLE_BASE
Jerome Forissier3fb19df2018-11-08 09:59:29 +010078 b console_pl011_core_flush
Antonio Nino Diaz1eb64a12018-10-17 15:29:34 +010079endfunc plat_crash_console_flush
80
81 /* ---------------------------------------------
Haojian Zhuang602362d2017-06-01 12:15:14 +080082 * 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 */
89func 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
125plat_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
140plat_report_end:
141 mov x30, x8
142 ret
143endfunc plat_report_exception
144
145 /* -----------------------------------------------------
146 * void plat_reset_handler(void);
147 * -----------------------------------------------------
148 */
149func plat_reset_handler
150 ret
151endfunc plat_reset_handler
152
Haojian Zhuang1b5c2252017-06-01 15:20:46 +0800153 /* -----------------------------------------------------
Haojian Zhuang1b5c2252017-06-01 15:20:46 +0800154 * void clrex(void);
155 * -----------------------------------------------------
156 */
157func clr_ex
158 clrex
159 ret
160endfunc clr_ex
161
162 /* -----------------------------------------------------
163 * void nop(void);
164 * -----------------------------------------------------
165 */
166func nop
167 nop
168 ret
169endfunc nop
170
Haojian Zhuang602362d2017-06-01 12:15:14 +0800171.section .rodata.rev_err_str, "aS"
172plat_err_str:
173 .asciz "\nPlatform exception reporting:"
174esr_el3_str:
175 .asciz "\nESR_EL3: "
176elr_el3_str:
177 .asciz "\nELR_EL3: "
178esr_el1_str:
179 .asciz "\nESR_EL1: "
180elr_el1_str:
181 .asciz "\nELR_EL1: "