1/* 2 * Copyright (c) 2019-2025, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7#ifndef DSU_MACROS_S 8#define DSU_MACROS_S 9 10#include <asm_macros.S> 11#include <dsu_def.h> 12#include <lib/cpus/errata.h> 13 14.macro check_errata_dsu_798953_impl 15 mov x2, #ERRATA_APPLIES 16 mov x3, #ERRATA_NOT_APPLIES 17 18 /* Check if DSU is equal to r0p0 */ 19 mrs x1, CLUSTERIDR_EL1 20 21 /* DSU variant and revision bitfields in CLUSTERIDR are adjacent */ 22 ubfx x0, x1, #CLUSTERIDR_REV_SHIFT,\ 23 #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS) 24 mov x1, #(0x0 << CLUSTERIDR_REV_SHIFT) 25 cmp x0, x1 26 csel x0, x2, x3, EQ 27.endm 28 29.macro errata_dsu_798953_wa_impl 30 /* If erratum applies, disable high-level clock gating */ 31 mrs x0, CLUSTERACTLR_EL1 32 orr x0, x0, #CLUSTERACTLR_EL1_DISABLE_CLOCK_GATING 33 msr CLUSTERACTLR_EL1, x0 34.endm 35 36.macro branch_if_scu_not_present _target:req 37 /* Check if the SCU L3 Unit is present on the DSU */ 38 mrs x0, CPUCFR_EL1 39 ubfx x0, x0, #SCU_SHIFT, #1 40 eor x0, x0, #1 41 /* If SCU is not present, return without applying patch */ 42 cmp x0, xzr 43 mov x0, #ERRATA_NOT_APPLIES 44 b.eq \_target 45.endm 46 47.macro check_errata_dsu_936184_impl 48 mov x0, #ERRATA_NOT_APPLIES 49 /* Erratum applies only if DSU has the ACP interface */ 50 mrs x1, CLUSTERCFR_EL1 51 ubfx x1, x1, #CLUSTERCFR_ACP_SHIFT, #1 52 cbz x1, 1f 53 54 /* If ACP is present, check if DSU is older than r2p0 */ 55 mrs x1, CLUSTERIDR_EL1 56 57 /* DSU variant and revision bitfields in CLUSTERIDR are adjacent */ 58 ubfx x2, x1, #CLUSTERIDR_REV_SHIFT,\ 59 #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS) 60 cmp x2, #(0x2 << CLUSTERIDR_VAR_SHIFT) 61 b.hs 1f 62 mov x0, #ERRATA_APPLIES 631: 64.endm 65 66.macro errata_dsu_936184_wa_impl 67 /* If erratum applies, we set a mask to a DSU control register */ 68 mrs x0, CLUSTERACTLR_EL1 69 ldr x1, =DSU_ERRATA_936184_MASK 70 orr x0, x0, x1 71 msr CLUSTERACTLR_EL1, x0 72.endm 73 74.macro check_errata_dsu_2313941_impl 75 mov x2, #ERRATA_APPLIES 76 mov x3, #ERRATA_NOT_APPLIES 77 78 /* Check if DSU version is less than or equal to r3p1 */ 79 mrs x1, CLUSTERIDR_EL1 80 81 mov x0, #ERRATA_NOT_APPLIES 82 /* DSU variant and revision bitfields in CLUSTERIDR are adjacent */ 83 ubfx x0, x1, #CLUSTERIDR_REV_SHIFT,\ 84 #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS) 85 mov x1, #(0x31 << CLUSTERIDR_REV_SHIFT) 86 cmp x0, x1 87 csel x0, x2, x3, LS 881: 89.endm 90 91.macro errata_dsu_2313941_wa_impl 92 /* If erratum applies, disable high-level clock gating */ 93 mrs x0, CLUSTERACTLR_EL1 94 orr x0, x0, #CLUSTERACTLR_EL1_DISABLE_SCLK_GATING 95 msr CLUSTERACTLR_EL1, x0 96.endm 97#endif /* DSU_MACROS_S */ 98