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/* Hardware handled coherency */ 15#if HW_ASSISTED_COHERENCY == 0 16#error "Cortex-A55 must be compiled with HW_ASSISTED_COHERENCY enabled" 17#endif 18 19 /* -------------------------------------------------- 20 * Errata Workaround for Cortex A55 Errata #768277. 21 * This applies only to revision r0p0 of Cortex A55. 22 * Inputs: 23 * x0: variant[4:7] and revision[0:3] of current cpu. 24 * Shall clobber: x0-x17 25 * -------------------------------------------------- 26 */ 27func errata_a55_768277_wa 28 /* 29 * Compare x0 against revision r0p0 30 */ 31 mov x17, x30 32 bl check_errata_768277 33 cbz x0, 1f 34 mrs x1, CORTEX_A55_CPUACTLR_EL1 35 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_DUAL_ISSUE 36 msr CORTEX_A55_CPUACTLR_EL1, x1 37 isb 381: 39 ret x17 40endfunc errata_a55_768277_wa 41 42func check_errata_768277 43 mov x1, #0x00 44 b cpu_rev_var_ls 45endfunc check_errata_768277 46 47 /* ------------------------------------------------------------------ 48 * Errata Workaround for Cortex A55 Errata #778703. 49 * This applies only to revision r0p0 of Cortex A55 where L2 cache is 50 * not configured. 51 * Inputs: 52 * x0: variant[4:7] and revision[0:3] of current cpu. 53 * Shall clobber: x0-x17 54 * ------------------------------------------------------------------ 55 */ 56func errata_a55_778703_wa 57 /* 58 * Compare x0 against revision r0p0 and check that no private L2 cache 59 * is configured 60 */ 61 mov x17, x30 62 bl check_errata_778703 63 cbz x0, 1f 64 mrs x1, CORTEX_A55_CPUECTLR_EL1 65 orr x1, x1, #CORTEX_A55_CPUECTLR_EL1_L1WSCTL 66 msr CORTEX_A55_CPUECTLR_EL1, x1 67 mrs x1, CORTEX_A55_CPUACTLR_EL1 68 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_WRITE_STREAMING 69 msr CORTEX_A55_CPUACTLR_EL1, x1 70 isb 711: 72 ret x17 73endfunc errata_a55_778703_wa 74 75func check_errata_778703 76 mov x16, x30 77 mov x1, #0x00 78 bl cpu_rev_var_ls 79 /* 80 * Check that no private L2 cache is configured 81 */ 82 mrs x1, CORTEX_A55_CLIDR_EL1 83 and x1, x1, CORTEX_A55_CLIDR_EL1_CTYPE3 84 cmp x1, #0 85 mov x2, #ERRATA_NOT_APPLIES 86 csel x0, x0, x2, eq 87 ret x16 88endfunc check_errata_778703 89 90 /* -------------------------------------------------- 91 * Errata Workaround for Cortex A55 Errata #798797. 92 * This applies only to revision r0p0 of Cortex A55. 93 * Inputs: 94 * x0: variant[4:7] and revision[0:3] of current cpu. 95 * Shall clobber: x0-x17 96 * -------------------------------------------------- 97 */ 98func errata_a55_798797_wa 99 /* 100 * Compare x0 against revision r0p0 101 */ 102 mov x17, x30 103 bl check_errata_798797 104 cbz x0, 1f 105 mrs x1, CORTEX_A55_CPUACTLR_EL1 106 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_L1_PAGEWALKS 107 msr CORTEX_A55_CPUACTLR_EL1, x1 108 isb 1091: 110 ret x17 111endfunc errata_a55_798797_wa 112 113func check_errata_798797 114 mov x1, #0x00 115 b cpu_rev_var_ls 116endfunc check_errata_798797 117 118 /* -------------------------------------------------------------------- 119 * Errata Workaround for Cortex A55 Errata #846532. 120 * This applies only to revisions <= r0p1 of Cortex A55. 121 * Disabling dual-issue has a small impact on performance. Disabling a 122 * power optimization feature is an alternate workaround with no impact 123 * on performance but with an increase in power consumption (see errata 124 * notice). 125 * Inputs: 126 * x0: variant[4:7] and revision[0:3] of current cpu. 127 * Shall clobber: x0-x17 128 * -------------------------------------------------------------------- 129 */ 130func errata_a55_846532_wa 131 /* 132 * Compare x0 against revision r0p1 133 */ 134 mov x17, x30 135 bl check_errata_846532 136 cbz x0, 1f 137 mrs x1, CORTEX_A55_CPUACTLR_EL1 138 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_DUAL_ISSUE 139 msr CORTEX_A55_CPUACTLR_EL1, x1 140 isb 1411: 142 ret x17 143endfunc errata_a55_846532_wa 144 145func check_errata_846532 146 mov x1, #0x01 147 b cpu_rev_var_ls 148endfunc check_errata_846532 149 150 /* ----------------------------------------------------- 151 * Errata Workaround for Cortex A55 Errata #903758. 152 * This applies only to revisions <= r0p1 of Cortex A55. 153 * Inputs: 154 * x0: variant[4:7] and revision[0:3] of current cpu. 155 * Shall clobber: x0-x17 156 * ----------------------------------------------------- 157 */ 158func errata_a55_903758_wa 159 /* 160 * Compare x0 against revision r0p1 161 */ 162 mov x17, x30 163 bl check_errata_903758 164 cbz x0, 1f 165 mrs x1, CORTEX_A55_CPUACTLR_EL1 166 orr x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_L1_PAGEWALKS 167 msr CORTEX_A55_CPUACTLR_EL1, x1 168 isb 1691: 170 ret x17 171endfunc errata_a55_903758_wa 172 173func check_errata_903758 174 mov x1, #0x01 175 b cpu_rev_var_ls 176endfunc check_errata_903758 177 178 /* ----------------------------------------------------- 179 * Errata Workaround for Cortex A55 Errata #1221012. 180 * This applies only to revisions <= r1p0 of Cortex A55. 181 * Inputs: 182 * x0: variant[4:7] and revision[0:3] of current cpu. 183 * Shall clobber: x0-x17 184 * ----------------------------------------------------- 185 */ 186func errata_a55_1221012_wa 187 /* 188 * Compare x0 against revision r1p0 189 */ 190 mov x17, x30 191 bl check_errata_1221012 192 cbz x0, 1f 193 mov x0, #0x0020 194 movk x0, #0x0850, lsl #16 195 msr CPUPOR_EL3, x0 196 mov x0, #0x0000 197 movk x0, #0x1FF0, lsl #16 198 movk x0, #0x2, lsl #32 199 msr CPUPMR_EL3, x0 200 mov x0, #0x03fd 201 movk x0, #0x0110, lsl #16 202 msr CPUPCR_EL3, x0 203 mov x0, #0x1 204 msr CPUPSELR_EL3, x0 205 mov x0, #0x0040 206 movk x0, #0x08D0, lsl #16 207 msr CPUPOR_EL3, x0 208 mov x0, #0x0040 209 movk x0, #0x1FF0, lsl #16 210 movk x0, #0x2, lsl #32 211 msr CPUPMR_EL3, x0 212 mov x0, #0x03fd 213 movk x0, #0x0110, lsl #16 214 msr CPUPCR_EL3, x0 215 isb 2161: 217 ret x17 218endfunc errata_a55_1221012_wa 219 220func check_errata_1221012 221 mov x1, #0x10 222 b cpu_rev_var_ls 223endfunc check_errata_1221012 224 225func cortex_a55_reset_func 226 mov x19, x30 227 228#if ERRATA_DSU_798953 229 bl errata_dsu_798953_wa 230#endif 231 232#if ERRATA_DSU_936184 233 bl errata_dsu_936184_wa 234#endif 235 236 bl cpu_get_rev_var 237 mov x18, x0 238 239#if ERRATA_A55_768277 240 mov x0, x18 241 bl errata_a55_768277_wa 242#endif 243 244#if ERRATA_A55_778703 245 mov x0, x18 246 bl errata_a55_778703_wa 247#endif 248 249#if ERRATA_A55_798797 250 mov x0, x18 251 bl errata_a55_798797_wa 252#endif 253 254#if ERRATA_A55_846532 255 mov x0, x18 256 bl errata_a55_846532_wa 257#endif 258 259#if ERRATA_A55_903758 260 mov x0, x18 261 bl errata_a55_903758_wa 262#endif 263 264#if ERRATA_A55_1221012 265 mov x0, x18 266 bl errata_a55_1221012_wa 267#endif 268 269 ret x19 270endfunc cortex_a55_reset_func 271 272 /* --------------------------------------------- 273 * HW will do the cache maintenance while powering down 274 * --------------------------------------------- 275 */ 276func cortex_a55_core_pwr_dwn 277 /* --------------------------------------------- 278 * Enable CPU power down bit in power control register 279 * --------------------------------------------- 280 */ 281 mrs x0, CORTEX_A55_CPUPWRCTLR_EL1 282 orr x0, x0, #CORTEX_A55_CORE_PWRDN_EN_MASK 283 msr CORTEX_A55_CPUPWRCTLR_EL1, x0 284 isb 285 ret 286endfunc cortex_a55_core_pwr_dwn 287 288#if REPORT_ERRATA 289/* 290 * Errata printing function for Cortex A55. Must follow AAPCS & can use stack. 291 */ 292func cortex_a55_errata_report 293 stp x8, x30, [sp, #-16]! 294 bl cpu_get_rev_var 295 mov x8, x0 296 297 /* 298 * Report all errata. The revision variant information is at x8, where 299 * "report_errata" is expecting it and it doesn't corrupt it. 300 */ 301 report_errata ERRATA_DSU_798953, cortex_a55, dsu_798953 302 report_errata ERRATA_DSU_936184, cortex_a55, dsu_936184 303 report_errata ERRATA_A55_768277, cortex_a55, 768277 304 report_errata ERRATA_A55_778703, cortex_a55, 778703 305 report_errata ERRATA_A55_798797, cortex_a55, 798797 306 report_errata ERRATA_A55_846532, cortex_a55, 846532 307 report_errata ERRATA_A55_903758, cortex_a55, 903758 308 report_errata ERRATA_A55_1221012, cortex_a55, 1221012 309 310 ldp x8, x30, [sp], #16 311 ret 312endfunc cortex_a55_errata_report 313#endif 314 315 /* --------------------------------------------- 316 * This function provides cortex_a55 specific 317 * register information for crash reporting. 318 * It needs to return with x6 pointing to 319 * a list of register names in ascii and 320 * x8 - x15 having values of registers to be 321 * reported. 322 * --------------------------------------------- 323 */ 324.section .rodata.cortex_a55_regs, "aS" 325cortex_a55_regs: /* The ascii list of register names to be reported */ 326 .asciz "cpuectlr_el1", "" 327 328func cortex_a55_cpu_reg_dump 329 adr x6, cortex_a55_regs 330 mrs x8, CORTEX_A55_CPUECTLR_EL1 331 ret 332endfunc cortex_a55_cpu_reg_dump 333 334declare_cpu_ops cortex_a55, CORTEX_A55_MIDR, \ 335 cortex_a55_reset_func, \ 336 cortex_a55_core_pwr_dwn 337