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