131b39455SGovindraj Raja/* 2050c4a38SGovindraj Raja * Copyright (c) 2021-2025, Arm Limited. All rights reserved. 331b39455SGovindraj Raja * 431b39455SGovindraj Raja * SPDX-License-Identifier: BSD-3-Clause 531b39455SGovindraj Raja */ 631b39455SGovindraj Raja 731b39455SGovindraj Raja#include <arch.h> 831b39455SGovindraj Raja#include <asm_macros.S> 931b39455SGovindraj Raja#include <common/bl_common.h> 1031b39455SGovindraj Raja#include <cortex_a720.h> 1131b39455SGovindraj Raja#include <cpu_macros.S> 12efc945f1SArvind Ram Prakash#include <dsu_macros.S> 1331b39455SGovindraj Raja#include <plat_macros.S> 1431b39455SGovindraj Raja#include "wa_cve_2022_23960_bhb_vector.S" 1531b39455SGovindraj Raja 1631b39455SGovindraj Raja/* Hardware handled coherency */ 1731b39455SGovindraj Raja#if HW_ASSISTED_COHERENCY == 0 1831b39455SGovindraj Raja#error "Cortex A720 must be compiled with HW_ASSISTED_COHERENCY enabled" 1931b39455SGovindraj Raja#endif 2031b39455SGovindraj Raja 2131b39455SGovindraj Raja/* 64-bit only core */ 2231b39455SGovindraj Raja#if CTX_INCLUDE_AARCH32_REGS == 1 2331b39455SGovindraj Raja#error "Cortex A720 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" 2431b39455SGovindraj Raja#endif 2531b39455SGovindraj Raja 2689dba82dSBoyan Karatotevcpu_reset_prologue cortex_a720 2789dba82dSBoyan Karatotev 28050c4a38SGovindraj Raja.global check_erratum_cortex_a720_3699561 29050c4a38SGovindraj Raja 30217a79c4SJohn Powellworkaround_reset_start cortex_a720, ERRATUM(2729604), ERRATA_A720_2729604 31217a79c4SJohn Powell sysreg_bit_set CORTEX_A720_CPUACTLR_EL1, (BIT(60) | BIT(61)) 32217a79c4SJohn Powellworkaround_reset_end cortex_a720, ERRATUM(2729604) 33217a79c4SJohn Powell 34217a79c4SJohn Powellcheck_erratum_ls cortex_a720, ERRATUM(2729604), CPU_REV(0, 1) 35217a79c4SJohn Powell 36b1bde25eSArvind Ram Prakashworkaround_reset_start cortex_a720, ERRATUM(2792132), ERRATA_A720_2792132 37b1bde25eSArvind Ram Prakash sysreg_bit_set CORTEX_A720_CPUACTLR2_EL1, BIT(26) 38b1bde25eSArvind Ram Prakashworkaround_reset_end cortex_a720, ERRATUM(2792132) 39b1bde25eSArvind Ram Prakash 40b1bde25eSArvind Ram Prakashcheck_erratum_ls cortex_a720, ERRATUM(2792132), CPU_REV(0, 1) 41b1bde25eSArvind Ram Prakash 4212140908SSona Mathewworkaround_reset_start cortex_a720, ERRATUM(2844092), ERRATA_A720_2844092 4312140908SSona Mathew sysreg_bit_set CORTEX_A720_CPUACTLR4_EL1, BIT(11) 4412140908SSona Mathewworkaround_reset_end cortex_a720, ERRATUM(2844092) 4512140908SSona Mathew 4612140908SSona Mathewcheck_erratum_ls cortex_a720, ERRATUM(2844092), CPU_REV(0, 1) 4712140908SSona Mathew 48efc945f1SArvind Ram Prakashworkaround_reset_start cortex_a720, ERRATUM(2900952), ERRATA_DSU_2900952 49efc945f1SArvind Ram Prakash errata_dsu_2900952_wa_apply 50efc945f1SArvind Ram Prakashworkaround_reset_end cortex_a720, ERRATUM(2900952) 51efc945f1SArvind Ram Prakash 52efc945f1SArvind Ram Prakashcheck_erratum_custom_start cortex_a720, ERRATUM(2900952) 53efc945f1SArvind Ram Prakash check_errata_dsu_2900952_applies 54efc945f1SArvind Ram Prakash ret 55efc945f1SArvind Ram Prakashcheck_erratum_custom_end cortex_a720, ERRATUM(2900952) 56efc945f1SArvind Ram Prakash 57152f4cfaSBipin Raviworkaround_reset_start cortex_a720, ERRATUM(2926083), ERRATA_A720_2926083 58152f4cfaSBipin Ravi/* Erratum 2926083 workaround is required only if SPE is enabled */ 59152f4cfaSBipin Ravi#if ENABLE_SPE_FOR_NS != 0 60152f4cfaSBipin Ravi /* Check if Static profiling extension is implemented or present. */ 61152f4cfaSBipin Ravi mrs x1, id_aa64dfr0_el1 62152f4cfaSBipin Ravi ubfx x0, x1, ID_AA64DFR0_PMS_SHIFT, #4 63152f4cfaSBipin Ravi cbz x0, 1f 64152f4cfaSBipin Ravi /* Apply the workaround by setting CPUACTLR_EL1[58:57] = 0b11. */ 65152f4cfaSBipin Ravi sysreg_bit_set CORTEX_A720_CPUACTLR_EL1, BIT(57) 66152f4cfaSBipin Ravi sysreg_bit_set CORTEX_A720_CPUACTLR_EL1, BIT(58) 67152f4cfaSBipin Ravi1: 68152f4cfaSBipin Ravi#endif 69152f4cfaSBipin Raviworkaround_reset_end cortex_a720, ERRATUM(2926083) 70152f4cfaSBipin Ravi 71152f4cfaSBipin Ravicheck_erratum_ls cortex_a720, ERRATUM(2926083), CPU_REV(0, 1) 72152f4cfaSBipin Ravi 737385213eSBipin Raviworkaround_reset_start cortex_a720, ERRATUM(2940794), ERRATA_A720_2940794 747385213eSBipin Ravi sysreg_bit_set CORTEX_A720_CPUACTLR2_EL1, BIT(37) 757385213eSBipin Raviworkaround_reset_end cortex_a720, ERRATUM(2940794) 767385213eSBipin Ravi 777385213eSBipin Ravicheck_erratum_ls cortex_a720, ERRATUM(2940794), CPU_REV(0, 1) 787385213eSBipin Ravi 79*816a999cSJohn Powelladd_erratum_entry cortex_a720, ERRATUM(3699561), ERRATA_A720_3699561 80*816a999cSJohn Powell 81*816a999cSJohn Powellcheck_erratum_ls cortex_a720, ERRATUM(3699561), CPU_REV(0, 2) 82*816a999cSJohn Powell 8387e69a8fSJohn Powellworkaround_reset_start cortex_a720, ERRATUM(3711910), ERRATA_A720_3711910 8487e69a8fSJohn Powell mov x0, #5 8587e69a8fSJohn Powell msr CORTEX_A720_CPUPSELR_EL3, x0 8687e69a8fSJohn Powell ldr x0, =0xD503329F 8787e69a8fSJohn Powell msr CORTEX_A720_CPUPOR_EL3, x0 8887e69a8fSJohn Powell ldr x0, =0xFFFFF3FF 8987e69a8fSJohn Powell msr CORTEX_A720_CPUPMR_EL3, x0 9087e69a8fSJohn Powell ldr x0, =0x1004003F1 9187e69a8fSJohn Powell msr CORTEX_A720_CPUPCR_EL3, x0 9287e69a8fSJohn Powellworkaround_reset_end cortex_a720, ERRATUM(3711910) 9387e69a8fSJohn Powell 9487e69a8fSJohn Powellcheck_erratum_ls cortex_a720, ERRATUM(3711910), CPU_REV(0, 2) 9587e69a8fSJohn Powell 96e4883071SGovindraj Rajacpu_reset_func_start cortex_a720 97e4883071SGovindraj Raja /* Disable speculative loads */ 98e4883071SGovindraj Raja msr SSBS, xzr 992590e819SBoyan Karatotev enable_mpmm 100e4883071SGovindraj Rajacpu_reset_func_end cortex_a720 10131b39455SGovindraj Raja 10231b39455SGovindraj Raja /* ---------------------------------------------------- 10331b39455SGovindraj Raja * HW will do the cache maintenance while powering down 10431b39455SGovindraj Raja * ---------------------------------------------------- 10531b39455SGovindraj Raja */ 10631b39455SGovindraj Rajafunc cortex_a720_core_pwr_dwn 10731b39455SGovindraj Raja /* --------------------------------------------------- 10831b39455SGovindraj Raja * Enable CPU power down bit in power control register 10931b39455SGovindraj Raja * --------------------------------------------------- 11031b39455SGovindraj Raja */ 111e4883071SGovindraj Raja sysreg_bit_set CORTEX_A720_CPUPWRCTLR_EL1, CORTEX_A720_CPUPWRCTLR_EL1_CORE_PWRDN_BIT 112e4883071SGovindraj Raja 11331b39455SGovindraj Raja isb 11431b39455SGovindraj Raja ret 11531b39455SGovindraj Rajaendfunc cortex_a720_core_pwr_dwn 11631b39455SGovindraj Raja 11731b39455SGovindraj Raja /* --------------------------------------------- 11831b39455SGovindraj Raja * This function provides Cortex A720-specific 11931b39455SGovindraj Raja * register information for crash reporting. 12031b39455SGovindraj Raja * It needs to return with x6 pointing to 12131b39455SGovindraj Raja * a list of register names in ascii and 12231b39455SGovindraj Raja * x8 - x15 having values of registers to be 12331b39455SGovindraj Raja * reported. 12431b39455SGovindraj Raja * --------------------------------------------- 12531b39455SGovindraj Raja */ 12631b39455SGovindraj Raja.section .rodata.cortex_a720_regs, "aS" 12731b39455SGovindraj Rajacortex_a720_regs: /* The ascii list of register names to be reported */ 12831b39455SGovindraj Raja .asciz "cpuectlr_el1", "" 12931b39455SGovindraj Raja 13031b39455SGovindraj Rajafunc cortex_a720_cpu_reg_dump 13131b39455SGovindraj Raja adr x6, cortex_a720_regs 13231b39455SGovindraj Raja mrs x8, CORTEX_A720_CPUECTLR_EL1 13331b39455SGovindraj Raja ret 13431b39455SGovindraj Rajaendfunc cortex_a720_cpu_reg_dump 13531b39455SGovindraj Raja 13631b39455SGovindraj Rajadeclare_cpu_ops cortex_a720, CORTEX_A720_MIDR, \ 13731b39455SGovindraj Raja cortex_a720_reset_func, \ 13831b39455SGovindraj Raja cortex_a720_core_pwr_dwn 139