blob: 100ffaa970eaf083d959c8d51780766d6171381b [file] [log] [blame]
John Tsichritzis4daa1de2018-07-23 09:11:59 +01001/*
Louis Mayencourt254f6f02019-04-09 14:11:06 +01002 * Copyright (c) 2019, 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>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <lib/cpus/errata_report.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
27
28func 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
42endfunc check_errata_dsu_798953
43
44 /* --------------------------------------------------
45 * Errata Workaround for DSU erratum #798953.
46 *
47 * Can clobber only: x0-x17
48 * --------------------------------------------------
49 */
50func 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
601:
61 ret x17
62endfunc errata_dsu_798953_wa
63
64 /* -----------------------------------------------------------------------
Louis Mayencourt254f6f02019-04-09 14:11:06 +010065 * 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 *
75 * Clobbers: x0-x3
76 * -----------------------------------------------------------------------
77 */
John Tsichritzis4daa1de2018-07-23 09:11:59 +010078 .globl check_errata_dsu_936184
79 .globl errata_dsu_936184_wa
80
81func check_errata_dsu_936184
82 mov x2, #ERRATA_NOT_APPLIES
83 mov x3, #ERRATA_APPLIES
84
John Tsichritzis13110b42018-08-22 10:40:33 +010085 /* Erratum applies only if DSU has the ACP interface */
John Tsichritzis4daa1de2018-07-23 09:11:59 +010086 mov x0, x2
87 mrs x1, CLUSTERCFR_EL1
88 ubfx x1, x1, #CLUSTERCFR_ACP_SHIFT, #1
89 cbz x1, 1f
90
91 /* If ACP is present, check if DSU is older than r2p0 */
92 mrs x1, CLUSTERIDR_EL1
93
94 /* DSU variant and revision bitfields in CLUSTERIDR are adjacent */
95 ubfx x0, x1, #CLUSTERIDR_REV_SHIFT,\
96 #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS)
Louis Mayencourt254f6f02019-04-09 14:11:06 +010097 mov x1, #(0x2 << CLUSTERIDR_VAR_SHIFT)
John Tsichritzis4daa1de2018-07-23 09:11:59 +010098 cmp x0, x1
99 csel x0, x2, x3, hs
1001:
101 ret
102endfunc check_errata_dsu_936184
103
Louis Mayencourt254f6f02019-04-09 14:11:06 +0100104 /* --------------------------------------------------
105 * Errata Workaround for DSU erratum #936184.
106 *
107 * Can clobber only: x0-x17
108 * --------------------------------------------------
109 */
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100110func errata_dsu_936184_wa
John Tsichritzis13110b42018-08-22 10:40:33 +0100111 mov x17, x30
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100112 bl check_errata_dsu_936184
113 cbz x0, 1f
114
115 /* If erratum applies, we set a mask to a DSU control register */
116 mrs x0, CLUSTERACTLR_EL1
117 ldr x1, =DSU_ERRATA_936184_MASK
118 orr x0, x0, x1
119 msr CLUSTERACTLR_EL1, x0
120 isb
1211:
John Tsichritzis13110b42018-08-22 10:40:33 +0100122 ret x17
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100123endfunc errata_dsu_936184_wa