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