1/* 2 * Copyright (c) 2019-2023, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7#include <asm_macros.S> 8#include <dsu_def.h> 9#include <lib/cpus/errata.h> 10 11 /* ----------------------------------------------------------------------- 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 .globl dsu_pwr_dwn 28 29func 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 43endfunc check_errata_dsu_798953 44 45 /* -------------------------------------------------- 46 * Errata Workaround for DSU erratum #798953. 47 * 48 * Can clobber only: x0-x8 49 * -------------------------------------------------- 50 */ 51func errata_dsu_798953_wa 52 mov x8, x30 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 611: 62 ret x8 63endfunc errata_dsu_798953_wa 64 65 /* ----------------------------------------------------------------------- 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 * 76 * Clobbers: x0-x4 77 * ----------------------------------------------------------------------- 78 */ 79 .globl check_errata_dsu_936184 80 .globl errata_dsu_936184_wa 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 * 87 * Can clobber only: x0-x3 88 * -------------------------------------------------------------------- 89 */ 90func is_scu_present_in_dsu 91 mov x0, #1 92 ret 93endfunc is_scu_present_in_dsu 94 95func check_errata_dsu_936184 96 mov x4, x30 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 104 105 /* Erratum applies only if DSU has the ACP interface */ 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 */ 114 ubfx x2, x1, #CLUSTERIDR_REV_SHIFT,\ 115 #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS) 116 cmp x2, #(0x2 << CLUSTERIDR_VAR_SHIFT) 117 b.hs 1f 118 mov x0, #ERRATA_APPLIES 1191: 120 ret x4 121endfunc check_errata_dsu_936184 122 123 /* -------------------------------------------------- 124 * Errata Workaround for DSU erratum #936184. 125 * 126 * Can clobber only: x0-x8 127 * -------------------------------------------------- 128 */ 129func errata_dsu_936184_wa 130 mov x8, x30 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 1401: 141 ret x8 142endfunc errata_dsu_936184_wa 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 * 155 * Clobbers: x0-x4 156 * ----------------------------------------------------------------------- 157 */ 158 .globl check_errata_dsu_2313941 159 .globl errata_dsu_2313941_wa 160 161func check_errata_dsu_2313941 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 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 1831: 184 ret x4 185endfunc check_errata_dsu_2313941 186 187 /* -------------------------------------------------- 188 * Errata Workaround for DSU erratum #2313941. 189 * 190 * Can clobber only: x0-x8 191 * -------------------------------------------------- 192 */ 193func errata_dsu_2313941_wa 194 mov x8, x30 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 2031: 204 ret x8 205endfunc errata_dsu_2313941_wa 206 207 /* --------------------------------------------- 208 * controls power features of the cluster 209 * 1. Cache portion power not request 210 * 2. Disable the retention circuit 211 * --------------------------------------------- 212 */ 213func dsu_pwr_dwn 214 msr CLUSTERPWRCTLR_EL1, xzr 215 isb 216 ret 217endfunc dsu_pwr_dwn 218