xref: /rk3399_ARM-atf/lib/cpus/aarch64/cortex_a55.S (revision 01ec41a08da0f8dca3bb138aa0d974145dfd4c79)
1d40ab484SDavid Wang/*
2b62673c6SBoyan Karatotev * Copyright (c) 2017-2025, Arm Limited and Contributors. All rights reserved.
3d40ab484SDavid Wang *
4d40ab484SDavid Wang * SPDX-License-Identifier: BSD-3-Clause
5d40ab484SDavid Wang */
6d40ab484SDavid Wang
7d40ab484SDavid Wang#include <arch.h>
8d40ab484SDavid Wang#include <asm_macros.S>
909d40e0eSAntonio Nino Diaz#include <common/bl_common.h>
102a4b4b71SIsla Mitchell#include <cortex_a55.h>
11d40ab484SDavid Wang#include <cpu_macros.S>
12b62673c6SBoyan Karatotev#include <dsu_macros.S>
13d40ab484SDavid Wang#include <plat_macros.S>
14d40ab484SDavid Wang
15076b5f02SJohn Tsichritzis/* Hardware handled coherency */
16076b5f02SJohn Tsichritzis#if HW_ASSISTED_COHERENCY == 0
17076b5f02SJohn Tsichritzis#error "Cortex-A55 must be compiled with HW_ASSISTED_COHERENCY enabled"
18076b5f02SJohn Tsichritzis#endif
19076b5f02SJohn Tsichritzis
206cc743cfSSaurabh Gorecha	.globl cortex_a55_reset_func
216cc743cfSSaurabh Gorecha	.globl cortex_a55_core_pwr_dwn
221de3c3a9SGovindraj Raja
2389dba82dSBoyan Karatotevcpu_reset_prologue cortex_a55
2489dba82dSBoyan Karatotev
251de3c3a9SGovindraj Rajaworkaround_reset_start cortex_a55, ERRATUM(768277), ERRATA_A55_768277
26b6120c69SGovindraj Raja	sysreg_bit_set CORTEX_A55_CPUACTLR_EL1, CORTEX_A55_CPUACTLR_EL1_DISABLE_DUAL_ISSUE
271de3c3a9SGovindraj Rajaworkaround_reset_end cortex_a55, ERRATUM(768277)
281afeee92SAmbroise Vincent
291de3c3a9SGovindraj Rajacheck_erratum_ls cortex_a55, ERRATUM(768277), CPU_REV(0, 0)
301afeee92SAmbroise Vincent
311de3c3a9SGovindraj Rajaworkaround_reset_start cortex_a55, ERRATUM(778703), ERRATA_A55_778703
32b6120c69SGovindraj Raja	sysreg_bit_set CORTEX_A55_CPUECTLR_EL1, CORTEX_A55_CPUECTLR_EL1_L1WSCTL
33b6120c69SGovindraj Raja	sysreg_bit_set CORTEX_A55_CPUACTLR_EL1, CORTEX_A55_CPUACTLR_EL1_DISABLE_WRITE_STREAMING
341de3c3a9SGovindraj Rajaworkaround_reset_end cortex_a55, ERRATUM(778703)
35a6cc6610SAmbroise Vincent
361de3c3a9SGovindraj Rajacheck_erratum_custom_start cortex_a55, ERRATUM(778703)
37a6cc6610SAmbroise Vincent	mov	x16, x30
387791ce21SBoyan Karatotev	cpu_rev_var_ls	CPU_REV(0, 0)
39a6cc6610SAmbroise Vincent	/*
40a6cc6610SAmbroise Vincent	 * Check that no private L2 cache is configured
41a6cc6610SAmbroise Vincent	 */
42a6cc6610SAmbroise Vincent	mrs	x1, CORTEX_A55_CLIDR_EL1
43a6cc6610SAmbroise Vincent	and	x1, x1, CORTEX_A55_CLIDR_EL1_CTYPE3
44a6cc6610SAmbroise Vincent	cmp	x1, #0
45a6cc6610SAmbroise Vincent	mov	x2, #ERRATA_NOT_APPLIES
46a6cc6610SAmbroise Vincent	csel	x0, x0, x2, eq
47a6cc6610SAmbroise Vincent	ret	x16
481de3c3a9SGovindraj Rajacheck_erratum_custom_end cortex_a55, ERRATUM(778703)
49a6cc6610SAmbroise Vincent
501de3c3a9SGovindraj Rajaworkaround_reset_start cortex_a55, ERRATUM(798797), ERRATA_A55_798797
51b6120c69SGovindraj Raja	sysreg_bit_set CORTEX_A55_CPUACTLR_EL1, CORTEX_A55_CPUACTLR_EL1_DISABLE_L1_PAGEWALKS
521de3c3a9SGovindraj Rajaworkaround_reset_end cortex_a55, ERRATUM(798797)
536ab87d29SAmbroise Vincent
541de3c3a9SGovindraj Rajacheck_erratum_ls cortex_a55, ERRATUM(798797), CPU_REV(0, 0)
556ab87d29SAmbroise Vincent
56*106ca0cbSGovindraj Rajaworkaround_reset_start cortex_a55, ERRATUM(798953), ERRATA_DSU_798953
57*106ca0cbSGovindraj Raja	errata_dsu_798953_wa_impl
58*106ca0cbSGovindraj Rajaworkaround_reset_end cortex_a55, ERRATUM(798953)
59*106ca0cbSGovindraj Raja
60*106ca0cbSGovindraj Rajacheck_erratum_custom_start cortex_a55, ERRATUM(798953)
61*106ca0cbSGovindraj Raja	check_errata_dsu_798953_impl
62*106ca0cbSGovindraj Raja	ret
63*106ca0cbSGovindraj Rajacheck_erratum_custom_end cortex_a55, ERRATUM(798953)
64*106ca0cbSGovindraj Raja
651de3c3a9SGovindraj Rajaworkaround_reset_start cortex_a55, ERRATUM(846532), ERRATA_A55_846532
66b6120c69SGovindraj Raja	sysreg_bit_set CORTEX_A55_CPUACTLR_EL1, CORTEX_A55_CPUACTLR_EL1_DISABLE_DUAL_ISSUE
671de3c3a9SGovindraj Rajaworkaround_reset_end cortex_a55, ERRATUM(846532)
686e78973eSAmbroise Vincent
691de3c3a9SGovindraj Rajacheck_erratum_ls cortex_a55, ERRATUM(846532), CPU_REV(0, 1)
706e78973eSAmbroise Vincent
711de3c3a9SGovindraj Rajaworkaround_reset_start cortex_a55, ERRATUM(903758), ERRATA_A55_903758
72b6120c69SGovindraj Raja	sysreg_bit_set CORTEX_A55_CPUACTLR_EL1, CORTEX_A55_CPUACTLR_EL1_DISABLE_L1_PAGEWALKS
731de3c3a9SGovindraj Rajaworkaround_reset_end cortex_a55, ERRATUM(903758)
7447949f3fSAmbroise Vincent
751de3c3a9SGovindraj Rajacheck_erratum_ls cortex_a55, ERRATUM(903758), CPU_REV(0, 1)
7647949f3fSAmbroise Vincent
77*106ca0cbSGovindraj Rajaworkaround_reset_start cortex_a55, ERRATUM(936184), ERRATA_DSU_936184
78*106ca0cbSGovindraj Raja	errata_dsu_936184_wa_impl
79*106ca0cbSGovindraj Rajaworkaround_reset_end cortex_a55, ERRATUM(936184)
80*106ca0cbSGovindraj Raja
81*106ca0cbSGovindraj Rajacheck_erratum_custom_start cortex_a55, ERRATUM(936184)
82*106ca0cbSGovindraj Raja	check_errata_dsu_936184_impl
83*106ca0cbSGovindraj Raja	ret
84*106ca0cbSGovindraj Rajacheck_erratum_custom_end cortex_a55, ERRATUM(936184)
85*106ca0cbSGovindraj Raja
861de3c3a9SGovindraj Rajaworkaround_reset_start cortex_a55, ERRATUM(1221012), ERRATA_A55_1221012
879af07df0SAmbroise Vincent	mov	x0, #0x0020
889af07df0SAmbroise Vincent	movk	x0, #0x0850, lsl #16
899af07df0SAmbroise Vincent	msr	CPUPOR_EL3, x0
909af07df0SAmbroise Vincent	mov	x0, #0x0000
919af07df0SAmbroise Vincent	movk	x0, #0x1FF0, lsl #16
929af07df0SAmbroise Vincent	movk	x0, #0x2, lsl #32
939af07df0SAmbroise Vincent	msr	CPUPMR_EL3, x0
949af07df0SAmbroise Vincent	mov	x0, #0x03fd
959af07df0SAmbroise Vincent	movk	x0, #0x0110, lsl #16
969af07df0SAmbroise Vincent	msr	CPUPCR_EL3, x0
979af07df0SAmbroise Vincent	mov	x0, #0x1
989af07df0SAmbroise Vincent	msr	CPUPSELR_EL3, x0
999af07df0SAmbroise Vincent	mov	x0, #0x0040
1009af07df0SAmbroise Vincent	movk	x0, #0x08D0, lsl #16
1019af07df0SAmbroise Vincent	msr	CPUPOR_EL3, x0
1029af07df0SAmbroise Vincent	mov	x0, #0x0040
1039af07df0SAmbroise Vincent	movk	x0, #0x1FF0, lsl #16
1049af07df0SAmbroise Vincent	movk	x0, #0x2, lsl #32
1059af07df0SAmbroise Vincent	msr	CPUPMR_EL3, x0
1069af07df0SAmbroise Vincent	mov	x0, #0x03fd
1079af07df0SAmbroise Vincent	movk	x0, #0x0110, lsl #16
1089af07df0SAmbroise Vincent	msr	CPUPCR_EL3, x0
1091de3c3a9SGovindraj Rajaworkaround_reset_end cortex_a55, ERRATUM(1221012)
1109af07df0SAmbroise Vincent
1111de3c3a9SGovindraj Rajacheck_erratum_ls cortex_a55, ERRATUM(1221012), CPU_REV(1, 0)
1129af07df0SAmbroise Vincent
1131de3c3a9SGovindraj Rajacheck_erratum_chosen cortex_a55, ERRATUM(1530923), ERRATA_A55_1530923
114e1c49333SManish V Badarkhe
1151de3c3a9SGovindraj Raja/* erratum has no workaround in the cpu. Generic code must take care */
11689dba82dSBoyan Karatotevadd_erratum_entry cortex_a55, ERRATUM(1530923), ERRATA_A55_1530923
1171afeee92SAmbroise Vincent
1181de3c3a9SGovindraj Rajacpu_reset_func_start cortex_a55
1191de3c3a9SGovindraj Rajacpu_reset_func_end cortex_a55
1200e985d70SLouis Mayencourt
121d40ab484SDavid Wang	/* ---------------------------------------------
122d40ab484SDavid Wang	 * HW will do the cache maintenance while powering down
123d40ab484SDavid Wang	 * ---------------------------------------------
124d40ab484SDavid Wang	 */
125d40ab484SDavid Wangfunc cortex_a55_core_pwr_dwn
126b6120c69SGovindraj Raja	sysreg_bit_set CORTEX_A55_CPUPWRCTLR_EL1, CORTEX_A55_CORE_PWRDN_EN_MASK
127d40ab484SDavid Wang	isb
128d40ab484SDavid Wang	ret
129d40ab484SDavid Wangendfunc cortex_a55_core_pwr_dwn
130d40ab484SDavid Wang
131d40ab484SDavid Wang	/* ---------------------------------------------
132d40ab484SDavid Wang	 * This function provides cortex_a55 specific
133d40ab484SDavid Wang	 * register information for crash reporting.
134d40ab484SDavid Wang	 * It needs to return with x6 pointing to
135d40ab484SDavid Wang	 * a list of register names in ascii and
136d40ab484SDavid Wang	 * x8 - x15 having values of registers to be
137d40ab484SDavid Wang	 * reported.
138d40ab484SDavid Wang	 * ---------------------------------------------
139d40ab484SDavid Wang	 */
140d40ab484SDavid Wang.section .rodata.cortex_a55_regs, "aS"
141d40ab484SDavid Wangcortex_a55_regs:  /* The ascii list of register names to be reported */
142d40ab484SDavid Wang	.asciz	"cpuectlr_el1", ""
143d40ab484SDavid Wang
144d40ab484SDavid Wangfunc cortex_a55_cpu_reg_dump
145d40ab484SDavid Wang	adr	x6, cortex_a55_regs
146d40ab484SDavid Wang	mrs	x8, CORTEX_A55_CPUECTLR_EL1
147d40ab484SDavid Wang	ret
148d40ab484SDavid Wangendfunc cortex_a55_cpu_reg_dump
149d40ab484SDavid Wang
150d40ab484SDavid Wangdeclare_cpu_ops cortex_a55, CORTEX_A55_MIDR, \
1518a677180SJohn Tsichritzis	cortex_a55_reset_func, \
152d40ab484SDavid Wang	cortex_a55_core_pwr_dwn
153