blob: 98767649d8d1aa7a529cd4528007137cbb332082 [file] [log] [blame]
Angel Ponsa2ee7612020-04-04 18:51:15 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi40a3e322015-06-22 19:41:29 +02002
3#include <arch/asm.h>
Furquan Shaikh25fbe2a2015-07-10 15:29:13 -07004#include <cpu/cortex_a57.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +02005
Furquan Shaikh25fbe2a2015-07-10 15:29:13 -07006/*
7 * It is observed that BTB contains stale data after power on reset. This could
8 * lead to unexpected branching and crashes at random intervals during the boot
9 * flow. Thus, invalidate the BTB immediately after power on reset.
10 */
11.macro t210_a57_fixup
Patrick Georgi40a3e322015-06-22 19:41:29 +020012 /*
13 * Invalidate BTB along with I$ to remove any stale entries
14 * from the branch predictor array.
15 */
16 mrs x0, CPUACTLR_EL1
Furquan Shaikh25fbe2a2015-07-10 15:29:13 -070017 orr x0, x0, #BTB_INVALIDATE
Patrick Georgi40a3e322015-06-22 19:41:29 +020018 msr CPUACTLR_EL1, x0 /* invalidate BTB and I$ together */
19 dsb sy
20 isb
21 ic iallu /* invalidate */
22 dsb sy
23 isb
24
Furquan Shaikh25fbe2a2015-07-10 15:29:13 -070025 bic x0, x0, #BTB_INVALIDATE
Patrick Georgi40a3e322015-06-22 19:41:29 +020026 msr CPUACTLR_EL1, x0 /* restore original CPUACTLR_EL1 */
27 dsb sy
28 isb
29
30 .rept 7
31 nop /* wait */
32 .endr
33
34 /*
35 * Extract OSLK bit and check if it is '1'. This bit remains '0'
36 * for A53. If '1', turn off regional clock gating and request
37 * warm reset.
38 */
39 mrs x0, oslsr_el1
40 and x0, x0, #2 /* extract oslk bit */
41 mrs x1, mpidr_el1
42 bics xzr, x0, x1, lsr #7 /* 0 if slow cluster */
Furquan Shaikh25fbe2a2015-07-10 15:29:13 -070043 b.eq 1000f
Patrick Georgi40a3e322015-06-22 19:41:29 +020044 mov x0, xzr
45 msr oslar_el1, x0 /* os lock stays 0 across warm reset */
46 mov x3, #3
47 movz x4, #0x8000, lsl #48
48 msr CPUACTLR_EL1, x4 /* turn off RCG */
49 isb
50 msr rmr_el3, x3 /* request warm reset */
51 isb
52 dsb sy
53 wfi
54
55 /*
56 * These nops are here so that speculative execution won't harm us
57 * before we are done warm reset.
58 */
59 .rept 65
60 nop
61 .endr
62
Furquan Shaikh25fbe2a2015-07-10 15:29:13 -0700631000:
64 /* Restore os lock */
Patrick Georgi40a3e322015-06-22 19:41:29 +020065 mov x0, #1
66 msr oslar_el1, x0
Furquan Shaikh25fbe2a2015-07-10 15:29:13 -070067.endm
Patrick Georgi40a3e322015-06-22 19:41:29 +020068
Furquan Shaikh25fbe2a2015-07-10 15:29:13 -070069ENTRY(stage_entry)
70 t210_a57_fixup
Furquan Shaikh25fbe2a2015-07-10 15:29:13 -070071
Julius Werner7dcf9d52015-10-16 13:10:02 -070072 /* Initialize PSTATE, SCTLR and caches to clean state, set up stack. */
73 bl arm64_init_cpu
74
75 /* Jump to Tegra-specific C entry point. */
76 bl ramstage_entry
77ENDPROC(stage_entry)