John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 1 | /* |
Bipin Ravi | af40d69 | 2021-12-22 14:35:21 -0600 | [diff] [blame] | 2 | * Copyright (c) 2019-2022, Arm Limited and Contributors. All rights reserved. |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <asm_macros.S> |
| 8 | #include <dsu_def.h> |
Boyan Karatotev | 5d38cb3 | 2023-01-27 09:37:07 +0000 | [diff] [blame] | 9 | #include <lib/cpus/errata.h> |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 10 | |
Louis Mayencourt | 254f6f0 | 2019-04-09 14:11:06 +0100 | [diff] [blame] | 11 | /* ----------------------------------------------------------------------- |
Louis Mayencourt | 4498b15 | 2019-04-09 16:29:01 +0100 | [diff] [blame] | 12 | * DSU erratum 798953 check function |
| 13 | * Checks the DSU variant, revision and configuration to determine if |
| 14 | * the erratum applies. Erratum applies on all configurations of the |
| 15 | * DSU and if revision-variant is r0p0. |
| 16 | * |
| 17 | * The erratum was fixed in r0p1. |
| 18 | * |
| 19 | * This function is called from both assembly and C environment. So it |
| 20 | * follows AAPCS. |
| 21 | * |
| 22 | * Clobbers: x0-x3 |
| 23 | * ----------------------------------------------------------------------- |
| 24 | */ |
| 25 | .globl check_errata_dsu_798953 |
| 26 | .globl errata_dsu_798953_wa |
| 27 | |
| 28 | func check_errata_dsu_798953 |
| 29 | mov x2, #ERRATA_APPLIES |
| 30 | mov x3, #ERRATA_NOT_APPLIES |
| 31 | |
| 32 | /* Check if DSU is equal to r0p0 */ |
| 33 | mrs x1, CLUSTERIDR_EL1 |
| 34 | |
| 35 | /* DSU variant and revision bitfields in CLUSTERIDR are adjacent */ |
| 36 | ubfx x0, x1, #CLUSTERIDR_REV_SHIFT,\ |
| 37 | #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS) |
| 38 | mov x1, #(0x0 << CLUSTERIDR_REV_SHIFT) |
| 39 | cmp x0, x1 |
| 40 | csel x0, x2, x3, EQ |
| 41 | ret |
| 42 | endfunc check_errata_dsu_798953 |
| 43 | |
| 44 | /* -------------------------------------------------- |
| 45 | * Errata Workaround for DSU erratum #798953. |
| 46 | * |
| 47 | * Can clobber only: x0-x17 |
| 48 | * -------------------------------------------------- |
| 49 | */ |
| 50 | func errata_dsu_798953_wa |
| 51 | mov x17, x30 |
| 52 | bl check_errata_dsu_798953 |
| 53 | cbz x0, 1f |
| 54 | |
| 55 | /* If erratum applies, disable high-level clock gating */ |
| 56 | mrs x0, CLUSTERACTLR_EL1 |
| 57 | orr x0, x0, #CLUSTERACTLR_EL1_DISABLE_CLOCK_GATING |
| 58 | msr CLUSTERACTLR_EL1, x0 |
| 59 | isb |
| 60 | 1: |
| 61 | ret x17 |
| 62 | endfunc errata_dsu_798953_wa |
| 63 | |
| 64 | /* ----------------------------------------------------------------------- |
Louis Mayencourt | 254f6f0 | 2019-04-09 14:11:06 +0100 | [diff] [blame] | 65 | * DSU erratum 936184 check function |
| 66 | * Checks the DSU variant, revision and configuration to determine if |
| 67 | * the erratum applies. Erratum applies if ACP interface is present |
| 68 | * in the DSU and revision-variant < r2p0. |
| 69 | * |
| 70 | * The erratum was fixed in r2p0. |
| 71 | * |
| 72 | * This function is called from both assembly and C environment. So it |
| 73 | * follows AAPCS. |
| 74 | * |
Pramod Kumar | f01ea60 | 2020-02-05 11:27:57 +0530 | [diff] [blame] | 75 | * Clobbers: x0-x15 |
Louis Mayencourt | 254f6f0 | 2019-04-09 14:11:06 +0100 | [diff] [blame] | 76 | * ----------------------------------------------------------------------- |
| 77 | */ |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 78 | .globl check_errata_dsu_936184 |
| 79 | .globl errata_dsu_936184_wa |
Pramod Kumar | f01ea60 | 2020-02-05 11:27:57 +0530 | [diff] [blame] | 80 | .weak is_scu_present_in_dsu |
| 81 | |
| 82 | /* -------------------------------------------------------------------- |
| 83 | * Default behaviour respresents SCU is always present with DSU. |
| 84 | * CPUs can override this definition if required. |
| 85 | * |
| 86 | * Can clobber only: x0-x14 |
| 87 | * -------------------------------------------------------------------- |
| 88 | */ |
| 89 | func is_scu_present_in_dsu |
| 90 | mov x0, #1 |
| 91 | ret |
| 92 | endfunc is_scu_present_in_dsu |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 93 | |
| 94 | func check_errata_dsu_936184 |
Pramod Kumar | f01ea60 | 2020-02-05 11:27:57 +0530 | [diff] [blame] | 95 | mov x15, x30 |
| 96 | bl is_scu_present_in_dsu |
| 97 | cmp x0, xzr |
| 98 | /* Default error status */ |
| 99 | mov x0, #ERRATA_NOT_APPLIES |
| 100 | |
| 101 | /* If SCU is not present, return without applying patch */ |
| 102 | b.eq 1f |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 103 | |
John Tsichritzis | 13110b4 | 2018-08-22 10:40:33 +0100 | [diff] [blame] | 104 | /* Erratum applies only if DSU has the ACP interface */ |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 105 | mrs x1, CLUSTERCFR_EL1 |
| 106 | ubfx x1, x1, #CLUSTERCFR_ACP_SHIFT, #1 |
| 107 | cbz x1, 1f |
| 108 | |
| 109 | /* If ACP is present, check if DSU is older than r2p0 */ |
| 110 | mrs x1, CLUSTERIDR_EL1 |
| 111 | |
| 112 | /* DSU variant and revision bitfields in CLUSTERIDR are adjacent */ |
Pramod Kumar | f01ea60 | 2020-02-05 11:27:57 +0530 | [diff] [blame] | 113 | ubfx x2, x1, #CLUSTERIDR_REV_SHIFT,\ |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 114 | #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS) |
Pramod Kumar | f01ea60 | 2020-02-05 11:27:57 +0530 | [diff] [blame] | 115 | cmp x2, #(0x2 << CLUSTERIDR_VAR_SHIFT) |
| 116 | b.hs 1f |
| 117 | mov x0, #ERRATA_APPLIES |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 118 | 1: |
Pramod Kumar | f01ea60 | 2020-02-05 11:27:57 +0530 | [diff] [blame] | 119 | ret x15 |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 120 | endfunc check_errata_dsu_936184 |
| 121 | |
Louis Mayencourt | 254f6f0 | 2019-04-09 14:11:06 +0100 | [diff] [blame] | 122 | /* -------------------------------------------------- |
| 123 | * Errata Workaround for DSU erratum #936184. |
| 124 | * |
| 125 | * Can clobber only: x0-x17 |
| 126 | * -------------------------------------------------- |
| 127 | */ |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 128 | func errata_dsu_936184_wa |
John Tsichritzis | 13110b4 | 2018-08-22 10:40:33 +0100 | [diff] [blame] | 129 | mov x17, x30 |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 130 | bl check_errata_dsu_936184 |
| 131 | cbz x0, 1f |
| 132 | |
| 133 | /* If erratum applies, we set a mask to a DSU control register */ |
| 134 | mrs x0, CLUSTERACTLR_EL1 |
| 135 | ldr x1, =DSU_ERRATA_936184_MASK |
| 136 | orr x0, x0, x1 |
| 137 | msr CLUSTERACTLR_EL1, x0 |
| 138 | isb |
| 139 | 1: |
John Tsichritzis | 13110b4 | 2018-08-22 10:40:33 +0100 | [diff] [blame] | 140 | ret x17 |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 141 | endfunc errata_dsu_936184_wa |
Bipin Ravi | af40d69 | 2021-12-22 14:35:21 -0600 | [diff] [blame] | 142 | |
| 143 | /* ----------------------------------------------------------------------- |
| 144 | * DSU erratum 2313941 check function |
| 145 | * Checks the DSU variant, revision and configuration to determine if |
| 146 | * the erratum applies. Erratum applies on all configurations of the |
| 147 | * DSU and if revision-variant is r0p0, r1p0, r2p0, r2p1, r3p0, r3p1. |
| 148 | * |
| 149 | * The erratum is still open. |
| 150 | * |
| 151 | * This function is called from both assembly and C environment. So it |
| 152 | * follows AAPCS. |
| 153 | * |
| 154 | * Clobbers: x0-x3 |
| 155 | * ----------------------------------------------------------------------- |
| 156 | */ |
| 157 | .globl check_errata_dsu_2313941 |
| 158 | .globl errata_dsu_2313941_wa |
| 159 | |
| 160 | func check_errata_dsu_2313941 |
| 161 | mov x2, #ERRATA_APPLIES |
| 162 | mov x3, #ERRATA_NOT_APPLIES |
| 163 | |
| 164 | /* Check if DSU version is less than or equal to r3p1 */ |
| 165 | mrs x1, CLUSTERIDR_EL1 |
| 166 | |
| 167 | /* DSU variant and revision bitfields in CLUSTERIDR are adjacent */ |
| 168 | ubfx x0, x1, #CLUSTERIDR_REV_SHIFT,\ |
| 169 | #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS) |
| 170 | mov x1, #(0x31 << CLUSTERIDR_REV_SHIFT) |
| 171 | cmp x0, x1 |
| 172 | csel x0, x2, x3, LS |
| 173 | ret |
| 174 | endfunc check_errata_dsu_2313941 |
| 175 | |
| 176 | /* -------------------------------------------------- |
| 177 | * Errata Workaround for DSU erratum #2313941. |
| 178 | * |
| 179 | * Can clobber only: x0-x17 |
| 180 | * -------------------------------------------------- |
| 181 | */ |
| 182 | func errata_dsu_2313941_wa |
| 183 | mov x17, x30 |
| 184 | bl check_errata_dsu_2313941 |
| 185 | cbz x0, 1f |
| 186 | |
| 187 | /* If erratum applies, disable high-level clock gating */ |
| 188 | mrs x0, CLUSTERACTLR_EL1 |
| 189 | orr x0, x0, #CLUSTERACTLR_EL1_DISABLE_SCLK_GATING |
| 190 | msr CLUSTERACTLR_EL1, x0 |
| 191 | isb |
| 192 | 1: |
| 193 | ret x17 |
| 194 | endfunc errata_dsu_2313941_wa |
| 195 | |