1/* 2 * Copyright (c) 2017-2019, 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> 9#include <common/bl_common.h> 10#include <cortex_a55.h> 11#include <cpu_macros.S> 12#include <plat_macros.S> 13 14 /* -------------------------------------------------- 15 * Errata Workaround for Cortex A55 Errata #768277. 16 * This applies only to revision r0p0 of Cortex A55. 17 * Inputs: 18 * x0: variant[4:7] and revision[0:3] of current cpu. 19 * Shall clobber: x0-x17 20 * -------------------------------------------------- 21 */ 22func errata_a55_768277_wa 23 /* 24 * Compare x0 against revision r0p0 25 */ 26 mov x17, x30 27 bl check_errata_768277 28 cbz x0, 1f 29 mrs x1, CORTEX_A55_CPUACTLR_EL1 30 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_DUAL_ISSUE 31 msr CORTEX_A55_CPUACTLR_EL1, x1 32 isb 331: 34 ret x17 35endfunc errata_a55_768277_wa 36 37func check_errata_768277 38 mov x1, #0x00 39 b cpu_rev_var_ls 40endfunc check_errata_768277 41 42 /* ------------------------------------------------------------------ 43 * Errata Workaround for Cortex A55 Errata #778703. 44 * This applies only to revision r0p0 of Cortex A55 where L2 cache is 45 * not configured. 46 * Inputs: 47 * x0: variant[4:7] and revision[0:3] of current cpu. 48 * Shall clobber: x0-x17 49 * ------------------------------------------------------------------ 50 */ 51func errata_a55_778703_wa 52 /* 53 * Compare x0 against revision r0p0 and check that no private L2 cache 54 * is configured 55 */ 56 mov x17, x30 57 bl check_errata_778703 58 cbz x0, 1f 59 mrs x1, CORTEX_A55_CPUECTLR_EL1 60 orr x1, x1, #CORTEX_A55_CPUECTLR_EL1_L1WSCTL 61 msr CORTEX_A55_CPUECTLR_EL1, x1 62 mrs x1, CORTEX_A55_CPUACTLR_EL1 63 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_WRITE_STREAMING 64 msr CORTEX_A55_CPUACTLR_EL1, x1 65 isb 661: 67 ret x17 68endfunc errata_a55_778703_wa 69 70func check_errata_778703 71 mov x16, x30 72 mov x1, #0x00 73 bl cpu_rev_var_ls 74 /* 75 * Check that no private L2 cache is configured 76 */ 77 mrs x1, CORTEX_A55_CLIDR_EL1 78 and x1, x1, CORTEX_A55_CLIDR_EL1_CTYPE3 79 cmp x1, #0 80 mov x2, #ERRATA_NOT_APPLIES 81 csel x0, x0, x2, eq 82 ret x16 83endfunc check_errata_778703 84 85 /* -------------------------------------------------- 86 * Errata Workaround for Cortex A55 Errata #798797. 87 * This applies only to revision r0p0 of Cortex A55. 88 * Inputs: 89 * x0: variant[4:7] and revision[0:3] of current cpu. 90 * Shall clobber: x0-x17 91 * -------------------------------------------------- 92 */ 93func errata_a55_798797_wa 94 /* 95 * Compare x0 against revision r0p0 96 */ 97 mov x17, x30 98 bl check_errata_798797 99 cbz x0, 1f 100 mrs x1, CORTEX_A55_CPUACTLR_EL1 101 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_L1_PAGEWALKS 102 msr CORTEX_A55_CPUACTLR_EL1, x1 103 isb 1041: 105 ret x17 106endfunc errata_a55_798797_wa 107 108func check_errata_798797 109 mov x1, #0x00 110 b cpu_rev_var_ls 111endfunc check_errata_798797 112 113 /* -------------------------------------------------------------------- 114 * Errata Workaround for Cortex A55 Errata #846532. 115 * This applies only to revisions <= r0p1 of Cortex A55. 116 * Disabling dual-issue has a small impact on performance. Disabling a 117 * power optimization feature is an alternate workaround with no impact 118 * on performance but with an increase in power consumption (see errata 119 * notice). 120 * Inputs: 121 * x0: variant[4:7] and revision[0:3] of current cpu. 122 * Shall clobber: x0-x17 123 * -------------------------------------------------------------------- 124 */ 125func errata_a55_846532_wa 126 /* 127 * Compare x0 against revision r0p1 128 */ 129 mov x17, x30 130 bl check_errata_846532 131 cbz x0, 1f 132 mrs x1, CORTEX_A55_CPUACTLR_EL1 133 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_DUAL_ISSUE 134 msr CORTEX_A55_CPUACTLR_EL1, x1 135 isb 1361: 137 ret x17 138endfunc errata_a55_846532_wa 139 140func check_errata_846532 141 mov x1, #0x01 142 b cpu_rev_var_ls 143endfunc check_errata_846532 144 145 /* ----------------------------------------------------- 146 * Errata Workaround for Cortex A55 Errata #903758. 147 * This applies only to revisions <= r0p1 of Cortex A55. 148 * Inputs: 149 * x0: variant[4:7] and revision[0:3] of current cpu. 150 * Shall clobber: x0-x17 151 * ----------------------------------------------------- 152 */ 153func errata_a55_903758_wa 154 /* 155 * Compare x0 against revision r0p1 156 */ 157 mov x17, x30 158 bl check_errata_903758 159 cbz x0, 1f 160 mrs x1, CORTEX_A55_CPUACTLR_EL1 161 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_L1_PAGEWALKS 162 msr CORTEX_A55_CPUACTLR_EL1, x1 163 isb 1641: 165 ret x17 166endfunc errata_a55_903758_wa 167 168func check_errata_903758 169 mov x1, #0x01 170 b cpu_rev_var_ls 171endfunc check_errata_903758 172 173func cortex_a55_reset_func 174 mov x19, x30 175 176#if ERRATA_DSU_936184 177 bl errata_dsu_936184_wa 178#endif 179 180 bl cpu_get_rev_var 181 mov x18, x0 182 183#if ERRATA_A55_768277 184 mov x0, x18 185 bl errata_a55_768277_wa 186#endif 187 188#if ERRATA_A55_778703 189 mov x0, x18 190 bl errata_a55_778703_wa 191#endif 192 193#if ERRATA_A55_798797 194 mov x0, x18 195 bl errata_a55_798797_wa 196#endif 197 198#if ERRATA_A55_846532 199 mov x0, x18 200 bl errata_a55_846532_wa 201#endif 202 203#if ERRATA_A55_903758 204 mov x0, x18 205 bl errata_a55_903758_wa 206#endif 207 208 ret x19 209endfunc cortex_a55_reset_func 210 211 /* --------------------------------------------- 212 * HW will do the cache maintenance while powering down 213 * --------------------------------------------- 214 */ 215func cortex_a55_core_pwr_dwn 216 /* --------------------------------------------- 217 * Enable CPU power down bit in power control register 218 * --------------------------------------------- 219 */ 220 mrs x0, CORTEX_A55_CPUPWRCTLR_EL1 221 orr x0, x0, #CORTEX_A55_CORE_PWRDN_EN_MASK 222 msr CORTEX_A55_CPUPWRCTLR_EL1, x0 223 isb 224 ret 225endfunc cortex_a55_core_pwr_dwn 226 227#if REPORT_ERRATA 228/* 229 * Errata printing function for Cortex A55. Must follow AAPCS & can use stack. 230 */ 231func cortex_a55_errata_report 232 stp x8, x30, [sp, #-16]! 233 bl cpu_get_rev_var 234 mov x8, x0 235 236 /* 237 * Report all errata. The revision variant information is at x8, where 238 * "report_errata" is expecting it and it doesn't corrupt it. 239 */ 240 report_errata ERRATA_DSU_936184, cortex_a55, dsu_936184 241 report_errata ERRATA_A55_768277, cortex_a55, 768277 242 report_errata ERRATA_A55_778703, cortex_a55, 778703 243 report_errata ERRATA_A55_798797, cortex_a55, 798797 244 report_errata ERRATA_A55_846532, cortex_a55, 846532 245 report_errata ERRATA_A55_903758, cortex_a55, 903758 246 247 ldp x8, x30, [sp], #16 248 ret 249endfunc cortex_a55_errata_report 250#endif 251 252 /* --------------------------------------------- 253 * This function provides cortex_a55 specific 254 * register information for crash reporting. 255 * It needs to return with x6 pointing to 256 * a list of register names in ascii and 257 * x8 - x15 having values of registers to be 258 * reported. 259 * --------------------------------------------- 260 */ 261.section .rodata.cortex_a55_regs, "aS" 262cortex_a55_regs: /* The ascii list of register names to be reported */ 263 .asciz "cpuectlr_el1", "" 264 265func cortex_a55_cpu_reg_dump 266 adr x6, cortex_a55_regs 267 mrs x8, CORTEX_A55_CPUECTLR_EL1 268 ret 269endfunc cortex_a55_cpu_reg_dump 270 271declare_cpu_ops cortex_a55, CORTEX_A55_MIDR, \ 272 cortex_a55_reset_func, \ 273 cortex_a55_core_pwr_dwn 274