David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 1 | /* |
Ambroise Vincent | 7927fa0 | 2019-02-21 16:20:43 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | #include <common/bl_common.h> |
Isla Mitchell | 9930501 | 2017-07-11 14:54:08 +0100 | [diff] [blame] | 10 | #include <cortex_a55.h> |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 11 | #include <cpu_macros.S> |
| 12 | #include <plat_macros.S> |
| 13 | |
Ambroise Vincent | 7927fa0 | 2019-02-21 16:20:43 +0000 | [diff] [blame] | 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 | */ |
| 22 | func 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 |
| 33 | 1: |
| 34 | ret x17 |
| 35 | endfunc errata_a55_768277_wa |
| 36 | |
| 37 | func check_errata_768277 |
| 38 | mov x1, #0x00 |
| 39 | b cpu_rev_var_ls |
| 40 | endfunc check_errata_768277 |
| 41 | |
Ambroise Vincent | 6f31960 | 2019-02-21 16:25:37 +0000 | [diff] [blame^] | 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 | */ |
| 51 | func 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 |
| 66 | 1: |
| 67 | ret x17 |
| 68 | endfunc errata_a55_778703_wa |
| 69 | |
| 70 | func 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 |
| 83 | endfunc check_errata_778703 |
| 84 | |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 85 | func cortex_a55_reset_func |
| 86 | mov x19, x30 |
Ambroise Vincent | 7927fa0 | 2019-02-21 16:20:43 +0000 | [diff] [blame] | 87 | |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 88 | #if ERRATA_DSU_936184 |
| 89 | bl errata_dsu_936184_wa |
| 90 | #endif |
Ambroise Vincent | 7927fa0 | 2019-02-21 16:20:43 +0000 | [diff] [blame] | 91 | |
| 92 | bl cpu_get_rev_var |
| 93 | mov x18, x0 |
| 94 | |
| 95 | #if ERRATA_A55_768277 |
| 96 | mov x0, x18 |
| 97 | bl errata_a55_768277_wa |
| 98 | #endif |
| 99 | |
Ambroise Vincent | 6f31960 | 2019-02-21 16:25:37 +0000 | [diff] [blame^] | 100 | #if ERRATA_A55_778703 |
| 101 | mov x0, x18 |
| 102 | bl errata_a55_778703_wa |
| 103 | #endif |
| 104 | |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 105 | ret x19 |
| 106 | endfunc cortex_a55_reset_func |
| 107 | |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 108 | /* --------------------------------------------- |
| 109 | * HW will do the cache maintenance while powering down |
| 110 | * --------------------------------------------- |
| 111 | */ |
| 112 | func cortex_a55_core_pwr_dwn |
| 113 | /* --------------------------------------------- |
| 114 | * Enable CPU power down bit in power control register |
| 115 | * --------------------------------------------- |
| 116 | */ |
| 117 | mrs x0, CORTEX_A55_CPUPWRCTLR_EL1 |
| 118 | orr x0, x0, #CORTEX_A55_CORE_PWRDN_EN_MASK |
| 119 | msr CORTEX_A55_CPUPWRCTLR_EL1, x0 |
| 120 | isb |
| 121 | ret |
| 122 | endfunc cortex_a55_core_pwr_dwn |
| 123 | |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 124 | #if REPORT_ERRATA |
| 125 | /* |
| 126 | * Errata printing function for Cortex A55. Must follow AAPCS & can use stack. |
| 127 | */ |
| 128 | func cortex_a55_errata_report |
| 129 | stp x8, x30, [sp, #-16]! |
| 130 | bl cpu_get_rev_var |
| 131 | mov x8, x0 |
| 132 | |
| 133 | /* |
| 134 | * Report all errata. The revision variant information is at x8, where |
| 135 | * "report_errata" is expecting it and it doesn't corrupt it. |
| 136 | */ |
| 137 | report_errata ERRATA_DSU_936184, cortex_a55, dsu_936184 |
Ambroise Vincent | 7927fa0 | 2019-02-21 16:20:43 +0000 | [diff] [blame] | 138 | report_errata ERRATA_A55_768277, cortex_a55, 768277 |
Ambroise Vincent | 6f31960 | 2019-02-21 16:25:37 +0000 | [diff] [blame^] | 139 | report_errata ERRATA_A55_778703, cortex_a55, 778703 |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 140 | |
| 141 | ldp x8, x30, [sp], #16 |
| 142 | ret |
| 143 | endfunc cortex_a55_errata_report |
| 144 | #endif |
| 145 | |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 146 | /* --------------------------------------------- |
| 147 | * This function provides cortex_a55 specific |
| 148 | * register information for crash reporting. |
| 149 | * It needs to return with x6 pointing to |
| 150 | * a list of register names in ascii and |
| 151 | * x8 - x15 having values of registers to be |
| 152 | * reported. |
| 153 | * --------------------------------------------- |
| 154 | */ |
| 155 | .section .rodata.cortex_a55_regs, "aS" |
| 156 | cortex_a55_regs: /* The ascii list of register names to be reported */ |
| 157 | .asciz "cpuectlr_el1", "" |
| 158 | |
| 159 | func cortex_a55_cpu_reg_dump |
| 160 | adr x6, cortex_a55_regs |
| 161 | mrs x8, CORTEX_A55_CPUECTLR_EL1 |
| 162 | ret |
| 163 | endfunc cortex_a55_cpu_reg_dump |
| 164 | |
| 165 | declare_cpu_ops cortex_a55, CORTEX_A55_MIDR, \ |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 166 | cortex_a55_reset_func, \ |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 167 | cortex_a55_core_pwr_dwn |