blob: 3c5bf2ea14e4314343cd38706d3a5059092bf728 [file] [log] [blame]
John Tsichritzis4daa1de2018-07-23 09:11:59 +01001/*
Kathleen Capella11437c12023-06-06 15:50:28 -04002 * Copyright (c) 2019-2023, Arm Limited and Contributors. All rights reserved.
John Tsichritzis4daa1de2018-07-23 09:11:59 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <asm_macros.S>
8#include <dsu_def.h>
Boyan Karatotev5d38cb32023-01-27 09:37:07 +00009#include <lib/cpus/errata.h>
John Tsichritzis4daa1de2018-07-23 09:11:59 +010010
Louis Mayencourt254f6f02019-04-09 14:11:06 +010011 /* -----------------------------------------------------------------------
Louis Mayencourt4498b152019-04-09 16:29:01 +010012 * 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 Xu9b9e5222022-09-30 08:56:21 +000027 .globl dsu_pwr_dwn
Louis Mayencourt4498b152019-04-09 16:29:01 +010028
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 *
Kathleen Capella11437c12023-06-06 15:50:28 -040048 * Can clobber only: x0-x8
Louis Mayencourt4498b152019-04-09 16:29:01 +010049 * --------------------------------------------------
50 */
51func errata_dsu_798953_wa
Kathleen Capella11437c12023-06-06 15:50:28 -040052 mov x8, x30
Louis Mayencourt4498b152019-04-09 16:29:01 +010053 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:
Kathleen Capella11437c12023-06-06 15:50:28 -040062 ret x8
Louis Mayencourt4498b152019-04-09 16:29:01 +010063endfunc errata_dsu_798953_wa
64
65 /* -----------------------------------------------------------------------
Louis Mayencourt254f6f02019-04-09 14:11:06 +010066 * 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 Capella11437c12023-06-06 15:50:28 -040076 * Clobbers: x0-x4
Louis Mayencourt254f6f02019-04-09 14:11:06 +010077 * -----------------------------------------------------------------------
78 */
John Tsichritzis4daa1de2018-07-23 09:11:59 +010079 .globl check_errata_dsu_936184
80 .globl errata_dsu_936184_wa
Pramod Kumarf01ea602020-02-05 11:27:57 +053081 .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 Capella11437c12023-06-06 15:50:28 -040087 * Can clobber only: x0-x3
Pramod Kumarf01ea602020-02-05 11:27:57 +053088 * --------------------------------------------------------------------
89 */
90func is_scu_present_in_dsu
91 mov x0, #1
92 ret
93endfunc is_scu_present_in_dsu
John Tsichritzis4daa1de2018-07-23 09:11:59 +010094
95func check_errata_dsu_936184
Kathleen Capella11437c12023-06-06 15:50:28 -040096 mov x4, x30
Pramod Kumarf01ea602020-02-05 11:27:57 +053097 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 Tsichritzis4daa1de2018-07-23 09:11:59 +0100104
John Tsichritzis13110b42018-08-22 10:40:33 +0100105 /* Erratum applies only if DSU has the ACP interface */
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100106 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 Kumarf01ea602020-02-05 11:27:57 +0530114 ubfx x2, x1, #CLUSTERIDR_REV_SHIFT,\
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100115 #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS)
Pramod Kumarf01ea602020-02-05 11:27:57 +0530116 cmp x2, #(0x2 << CLUSTERIDR_VAR_SHIFT)
117 b.hs 1f
118 mov x0, #ERRATA_APPLIES
John Tsichritzis4daa1de2018-07-23 09:11:59 +01001191:
Kathleen Capella11437c12023-06-06 15:50:28 -0400120 ret x4
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100121endfunc check_errata_dsu_936184
122
Louis Mayencourt254f6f02019-04-09 14:11:06 +0100123 /* --------------------------------------------------
124 * Errata Workaround for DSU erratum #936184.
125 *
Kathleen Capella11437c12023-06-06 15:50:28 -0400126 * Can clobber only: x0-x8
Louis Mayencourt254f6f02019-04-09 14:11:06 +0100127 * --------------------------------------------------
128 */
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100129func errata_dsu_936184_wa
Kathleen Capella11437c12023-06-06 15:50:28 -0400130 mov x8, x30
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100131 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:
Kathleen Capella11437c12023-06-06 15:50:28 -0400141 ret x8
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100142endfunc errata_dsu_936184_wa
Bipin Raviaf40d692021-12-22 14:35:21 -0600143
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 Juszkiewicz71c62722023-11-14 10:38:49 +0100155 * Clobbers: x0-x4
Bipin Raviaf40d692021-12-22 14:35:21 -0600156 * -----------------------------------------------------------------------
157 */
158 .globl check_errata_dsu_2313941
159 .globl errata_dsu_2313941_wa
160
161func check_errata_dsu_2313941
Marcin Juszkiewicz71c62722023-11-14 10:38:49 +0100162 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 Raviaf40d692021-12-22 14:35:21 -0600171 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 Juszkiewicz71c62722023-11-14 10:38:49 +01001831:
184 ret x4
Bipin Raviaf40d692021-12-22 14:35:21 -0600185endfunc check_errata_dsu_2313941
186
187 /* --------------------------------------------------
188 * Errata Workaround for DSU erratum #2313941.
189 *
Kathleen Capella11437c12023-06-06 15:50:28 -0400190 * Can clobber only: x0-x8
Bipin Raviaf40d692021-12-22 14:35:21 -0600191 * --------------------------------------------------
192 */
193func errata_dsu_2313941_wa
Kathleen Capella11437c12023-06-06 15:50:28 -0400194 mov x8, x30
Bipin Raviaf40d692021-12-22 14:35:21 -0600195 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:
Kathleen Capella11437c12023-06-06 15:50:28 -0400204 ret x8
Bipin Raviaf40d692021-12-22 14:35:21 -0600205endfunc errata_dsu_2313941_wa
shengfei Xu9b9e5222022-09-30 08:56:21 +0000206
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