dsu_helpers.S 3.81 KB
Newer Older
1
/*
2
 * Copyright (c) 2019-2020, ARM Limited and Contributors. All rights reserved.
3
4
5
6
7
8
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <asm_macros.S>
#include <dsu_def.h>
9
#include <lib/cpus/errata_report.h>
10

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
	/* -----------------------------------------------------------------------
	 * DSU erratum 798953 check function
	 * Checks the DSU variant, revision and configuration to determine if
	 * the erratum applies. Erratum applies on all configurations of the
	 * DSU and if revision-variant is r0p0.
	 *
	 * The erratum was fixed in r0p1.
	 *
	 * This function is called from both assembly and C environment. So it
	 * follows AAPCS.
	 *
	 * Clobbers: x0-x3
	 * -----------------------------------------------------------------------
	 */
	.globl	check_errata_dsu_798953
	.globl	errata_dsu_798953_wa

func check_errata_dsu_798953
	mov	x2, #ERRATA_APPLIES
	mov	x3, #ERRATA_NOT_APPLIES

	/* Check if DSU is equal to r0p0 */
	mrs	x1, CLUSTERIDR_EL1

	/* DSU variant and revision bitfields in CLUSTERIDR are adjacent */
	ubfx	x0, x1, #CLUSTERIDR_REV_SHIFT,\
			#(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS)
	mov	x1, #(0x0 << CLUSTERIDR_REV_SHIFT)
	cmp	x0, x1
	csel	x0, x2, x3, EQ
	ret
endfunc check_errata_dsu_798953

	/* --------------------------------------------------
	 * Errata Workaround for DSU erratum #798953.
	 *
	 * Can clobber only: x0-x17
	 * --------------------------------------------------
	 */
func errata_dsu_798953_wa
	mov	x17, x30
	bl	check_errata_dsu_798953
	cbz	x0, 1f

	/* If erratum applies, disable high-level clock gating */
	mrs	x0, CLUSTERACTLR_EL1
	orr	x0, x0, #CLUSTERACTLR_EL1_DISABLE_CLOCK_GATING
	msr	CLUSTERACTLR_EL1, x0
	isb
1:
	ret	x17
endfunc errata_dsu_798953_wa

64
65
66
67
68
69
70
71
72
73
74
	/* -----------------------------------------------------------------------
	 * DSU erratum 936184 check function
	 * Checks the DSU variant, revision and configuration to determine if
	 * the erratum applies. Erratum applies if ACP interface is present
	 * in the DSU and revision-variant < r2p0.
	 *
	 * The erratum was fixed in r2p0.
	 *
	 * This function is called from both assembly and C environment. So it
	 * follows AAPCS.
	 *
75
	 * Clobbers: x0-x15
76
77
	 * -----------------------------------------------------------------------
	 */
78
79
	.globl	check_errata_dsu_936184
	.globl	errata_dsu_936184_wa
80
81
82
83
84
85
86
87
88
89
90
91
92
	.weak	is_scu_present_in_dsu

	/* --------------------------------------------------------------------
	 * Default behaviour respresents SCU is always present with DSU.
	 * CPUs can override this definition if required.
	 *
	 * Can clobber only: x0-x14
	 * --------------------------------------------------------------------
	 */
func is_scu_present_in_dsu
	mov	x0, #1
	ret
endfunc is_scu_present_in_dsu
93
94

func check_errata_dsu_936184
95
96
97
98
99
100
101
102
	mov	x15, x30
	bl	is_scu_present_in_dsu
	cmp	x0, xzr
	/* Default error status */
	mov	x0, #ERRATA_NOT_APPLIES

	/* If SCU is not present, return without applying patch */
	b.eq	1f
103

104
	/* Erratum applies only if DSU has the ACP interface */
105
106
107
108
109
110
111
112
	mrs	x1, CLUSTERCFR_EL1
	ubfx	x1, x1, #CLUSTERCFR_ACP_SHIFT, #1
	cbz	x1, 1f

	/* If ACP is present, check if DSU is older than r2p0 */
	mrs	x1, CLUSTERIDR_EL1

	/* DSU variant and revision bitfields in CLUSTERIDR are adjacent */
113
	ubfx	x2, x1, #CLUSTERIDR_REV_SHIFT,\
114
			#(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS)
115
116
117
	cmp x2, #(0x2 << CLUSTERIDR_VAR_SHIFT)
	b.hs	1f
	mov	x0, #ERRATA_APPLIES
118
1:
119
	ret	x15
120
121
endfunc check_errata_dsu_936184

122
123
124
125
126
127
	/* --------------------------------------------------
	 * Errata Workaround for DSU erratum #936184.
	 *
	 * Can clobber only: x0-x17
	 * --------------------------------------------------
	 */
128
func errata_dsu_936184_wa
129
	mov	x17, x30
130
131
132
133
134
135
136
137
138
139
	bl	check_errata_dsu_936184
	cbz	x0, 1f

	/* If erratum applies, we set a mask to a DSU control register */
	mrs	x0, CLUSTERACTLR_EL1
	ldr	x1, =DSU_ERRATA_936184_MASK
	orr	x0, x0, x1
	msr	CLUSTERACTLR_EL1, x0
	isb
1:
140
	ret	x17
141
endfunc errata_dsu_936184_wa