1/* 2 * Copyright (c) 2021, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7#include <arch.h> 8#include <asm_macros.S> 9#include <common/bl_common.h> 10#include <cortex_x2.h> 11#include <cpu_macros.S> 12#include <plat_macros.S> 13 14/* Hardware handled coherency */ 15#if HW_ASSISTED_COHERENCY == 0 16#error "Cortex X2 must be compiled with HW_ASSISTED_COHERENCY enabled" 17#endif 18 19/* 64-bit only core */ 20#if CTX_INCLUDE_AARCH32_REGS == 1 21#error "Cortex X2 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" 22#endif 23 24 /* -------------------------------------------------- 25 * Errata Workaround for Cortex X2 Errata #2083908. 26 * This applies to revision r2p0 and is open. 27 * x0: variant[4:7] and revision[0:3] of current cpu. 28 * Shall clobber: x0-x2, x17 29 * -------------------------------------------------- 30 */ 31func errata_cortex_x2_2083908_wa 32 /* Check workaround compatibility. */ 33 mov x17, x30 34 bl check_errata_2083908 35 cbz x0, 1f 36 37 /* Apply the workaround by setting bit 13 in CPUACTLR5_EL1. */ 38 mrs x1, CORTEX_X2_CPUACTLR5_EL1 39 orr x1, x1, #BIT(13) 40 msr CORTEX_X2_CPUACTLR5_EL1, x1 41 421: 43 ret x17 44endfunc errata_cortex_x2_2083908_wa 45 46func check_errata_2083908 47 /* Applies to r2p0 */ 48 mov x1, #0x20 49 mov x2, #0x20 50 b cpu_rev_var_range 51endfunc check_errata_2083908 52 53 /* ---------------------------------------------------- 54 * HW will do the cache maintenance while powering down 55 * ---------------------------------------------------- 56 */ 57func cortex_x2_core_pwr_dwn 58 /* --------------------------------------------------- 59 * Enable CPU power down bit in power control register 60 * --------------------------------------------------- 61 */ 62 mrs x0, CORTEX_X2_CPUPWRCTLR_EL1 63 orr x0, x0, #CORTEX_X2_CPUPWRCTLR_EL1_CORE_PWRDN_BIT 64 msr CORTEX_X2_CPUPWRCTLR_EL1, x0 65 isb 66 ret 67endfunc cortex_x2_core_pwr_dwn 68 69 /* 70 * Errata printing function for Cortex X2. Must follow AAPCS. 71 */ 72#if REPORT_ERRATA 73func cortex_x2_errata_report 74 stp x8, x30, [sp, #-16]! 75 76 bl cpu_get_rev_var 77 mov x8, x0 78 79 /* 80 * Report all errata. The revision-variant information is passed to 81 * checking functions of each errata. 82 */ 83 report_errata ERRATA_X2_2083908, cortex_x2, 2083908 84 85 ldp x8, x30, [sp], #16 86 ret 87endfunc cortex_x2_errata_report 88#endif 89 90func cortex_x2_reset_func 91 mov x19, x30 92 93 /* Disable speculative loads */ 94 msr SSBS, xzr 95 isb 96 97 /* Get the CPU revision and stash it in x18. */ 98 bl cpu_get_rev_var 99 mov x18, x0 100 101#if ERRATA_X2_2083908 102 mov x0, x18 103 bl errata_cortex_x2_2083908_wa 104#endif 105 106 ret x19 107endfunc cortex_x2_reset_func 108 109 /* --------------------------------------------- 110 * This function provides Cortex X2 specific 111 * register information for crash reporting. 112 * It needs to return with x6 pointing to 113 * a list of register names in ascii and 114 * x8 - x15 having values of registers to be 115 * reported. 116 * --------------------------------------------- 117 */ 118.section .rodata.cortex_x2_regs, "aS" 119cortex_x2_regs: /* The ascii list of register names to be reported */ 120 .asciz "cpuectlr_el1", "" 121 122func cortex_x2_cpu_reg_dump 123 adr x6, cortex_x2_regs 124 mrs x8, CORTEX_X2_CPUECTLR_EL1 125 ret 126endfunc cortex_x2_cpu_reg_dump 127 128declare_cpu_ops cortex_x2, CORTEX_X2_MIDR, \ 129 cortex_x2_reset_func, \ 130 cortex_x2_core_pwr_dwn 131