xref: /rk3399_ARM-atf/lib/cpus/errata_common.c (revision f2bd35282066f512c26d859aa086cff13955d76b)
1721249b0SArvind Ram Prakash /*
27455cd17SGovindraj Raja  * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved.
3721249b0SArvind Ram Prakash  *
4721249b0SArvind Ram Prakash  * SPDX-License-Identifier: BSD-3-Clause
5721249b0SArvind Ram Prakash  */
6721249b0SArvind Ram Prakash 
7721249b0SArvind Ram Prakash /* Runtime C routines for errata workarounds and common routines */
8721249b0SArvind Ram Prakash 
9721249b0SArvind Ram Prakash #include <arch.h>
10721249b0SArvind Ram Prakash #include <arch_helpers.h>
117455cd17SGovindraj Raja #include <cortex_a75.h>
12*f2bd3528SJohn Powell #include <cortex_a510.h>
13721249b0SArvind Ram Prakash #include <cortex_a520.h>
14463b5b4aSGovindraj Raja #include <cortex_a710.h>
1526437afdSGovindraj Raja #include <cortex_a715.h>
16050c4a38SGovindraj Raja #include <cortex_a720.h>
17af5ae9a7SGovindraj Raja #include <cortex_a720_ae.h>
18d732300bSGovindraj Raja #include <cortex_a725.h>
19ae6c7c97SGovindraj Raja #include <cortex_x2.h>
2077feb745SGovindraj Raja #include <cortex_x3.h>
21721249b0SArvind Ram Prakash #include <cortex_x4.h>
22511148efSGovindraj Raja #include <cortex_x925.h>
23721249b0SArvind Ram Prakash #include <lib/cpus/cpu_ops.h>
24721249b0SArvind Ram Prakash #include <lib/cpus/errata.h>
25adea6e52SGovindraj Raja #include <neoverse_n2.h>
26fded8392SGovindraj Raja #include <neoverse_n3.h>
27e25fc9dfSGovindraj Raja #include <neoverse_v3.h>
28721249b0SArvind Ram Prakash 
29*f2bd3528SJohn Powell bool check_if_trbe_disable_affected_core(void)
30721249b0SArvind Ram Prakash {
31*f2bd3528SJohn Powell 	switch (EXTRACT_PARTNUM(read_midr())) {
32*f2bd3528SJohn Powell #if ERRATA_A520_2938996
33*f2bd3528SJohn Powell 	case EXTRACT_PARTNUM(CORTEX_A520_MIDR):
34*f2bd3528SJohn Powell 		return check_erratum_cortex_a520_2938996(cpu_get_rev_var()) == ERRATA_APPLIES;
35721249b0SArvind Ram Prakash #endif
36*f2bd3528SJohn Powell #if ERRATA_X4_2726228
37*f2bd3528SJohn Powell 	case EXTRACT_PARTNUM(CORTEX_X4_MIDR):
38*f2bd3528SJohn Powell 		return check_erratum_cortex_x4_2726228(cpu_get_rev_var()) == ERRATA_APPLIES;
39*f2bd3528SJohn Powell #endif
40*f2bd3528SJohn Powell #if ERRATA_A510_2971420
41*f2bd3528SJohn Powell 	case EXTRACT_PARTNUM(CORTEX_A510_MIDR):
42*f2bd3528SJohn Powell 		return check_erratum_cortex_a510_2971420(cpu_get_rev_var()) == ERRATA_APPLIES;
43*f2bd3528SJohn Powell #endif
44*f2bd3528SJohn Powell 	default:
45*f2bd3528SJohn Powell 		break;
46*f2bd3528SJohn Powell 	}
47*f2bd3528SJohn Powell 	return false;
48*f2bd3528SJohn Powell }
497f152ea6SSona Mathew 
507f152ea6SSona Mathew #if ERRATA_A75_764081
517f152ea6SSona Mathew bool errata_a75_764081_applies(void)
527f152ea6SSona Mathew {
537f152ea6SSona Mathew 	long rev_var = cpu_get_rev_var();
547f152ea6SSona Mathew 	if (check_erratum_cortex_a75_764081(rev_var) == ERRATA_APPLIES) {
557f152ea6SSona Mathew 		return true;
567f152ea6SSona Mathew 	}
577f152ea6SSona Mathew 	return false;
587f152ea6SSona Mathew }
597f152ea6SSona Mathew #endif /* ERRATA_A75_764081 */
607455cd17SGovindraj Raja 
617455cd17SGovindraj Raja bool errata_ich_vmcr_el2_applies(void)
627455cd17SGovindraj Raja {
637455cd17SGovindraj Raja 	switch (EXTRACT_PARTNUM(read_midr())) {
64463b5b4aSGovindraj Raja #if ERRATA_A710_3701772
65463b5b4aSGovindraj Raja 	case EXTRACT_PARTNUM(CORTEX_A710_MIDR):
66463b5b4aSGovindraj Raja 		if (check_erratum_cortex_a710_3701772(cpu_get_rev_var()) == ERRATA_APPLIES)
67463b5b4aSGovindraj Raja 			return true;
68463b5b4aSGovindraj Raja 		break;
69463b5b4aSGovindraj Raja #endif /* ERRATA_A710_3701772 */
70463b5b4aSGovindraj Raja 
7126437afdSGovindraj Raja #if ERRATA_A715_3699560
7226437afdSGovindraj Raja 	case EXTRACT_PARTNUM(CORTEX_A715_MIDR):
7326437afdSGovindraj Raja 		if (check_erratum_cortex_a715_3699560(cpu_get_rev_var()) == ERRATA_APPLIES)
7426437afdSGovindraj Raja 			return true;
7526437afdSGovindraj Raja 		break;
7626437afdSGovindraj Raja #endif /* ERRATA_A715_3699560 */
7726437afdSGovindraj Raja 
78050c4a38SGovindraj Raja #if ERRATA_A720_3699561
79050c4a38SGovindraj Raja 	case EXTRACT_PARTNUM(CORTEX_A720_MIDR):
80050c4a38SGovindraj Raja 		if (check_erratum_cortex_a720_3699561(cpu_get_rev_var()) == ERRATA_APPLIES)
81050c4a38SGovindraj Raja 			return true;;
82050c4a38SGovindraj Raja 		break;
83050c4a38SGovindraj Raja #endif /* ERRATA_A720_3699561 */
84050c4a38SGovindraj Raja 
85af5ae9a7SGovindraj Raja #if ERRATA_A720_AE_3699562
86af5ae9a7SGovindraj Raja 	case EXTRACT_PARTNUM(CORTEX_A720_AE_MIDR):
87af5ae9a7SGovindraj Raja 		if (check_erratum_cortex_a720_ae_3699562(cpu_get_rev_var()) == ERRATA_APPLIES)
88af5ae9a7SGovindraj Raja 			return true;
89af5ae9a7SGovindraj Raja 		break;
90af5ae9a7SGovindraj Raja #endif /* ERRATA_A720_AE_3699562 */
91af5ae9a7SGovindraj Raja 
92d732300bSGovindraj Raja #if ERRATA_A725_3699564
93d732300bSGovindraj Raja 	case EXTRACT_PARTNUM(CORTEX_A725_MIDR):
94d732300bSGovindraj Raja 		if (check_erratum_cortex_a725_3699564(cpu_get_rev_var()) == ERRATA_APPLIES)
95d732300bSGovindraj Raja 			return true;
96d732300bSGovindraj Raja 		break;
97d732300bSGovindraj Raja #endif /* ERRATA_A725_3699564 */
98ae6c7c97SGovindraj Raja 
99ae6c7c97SGovindraj Raja #if ERRATA_X2_3701772
100ae6c7c97SGovindraj Raja 	case EXTRACT_PARTNUM(CORTEX_X2_MIDR):
101ae6c7c97SGovindraj Raja 		if (check_erratum_cortex_x2_3701772(cpu_get_rev_var()) == ERRATA_APPLIES)
102ae6c7c97SGovindraj Raja 			return true;
103ae6c7c97SGovindraj Raja 		break;
104ae6c7c97SGovindraj Raja #endif /* ERRATA_X2_3701772 */
105ae6c7c97SGovindraj Raja 
10677feb745SGovindraj Raja #if ERRATA_X3_3701769
10777feb745SGovindraj Raja 	case EXTRACT_PARTNUM(CORTEX_X3_MIDR):
10877feb745SGovindraj Raja 		if (check_erratum_cortex_x3_3701769(cpu_get_rev_var()) == ERRATA_APPLIES)
10977feb745SGovindraj Raja 			return true;
11077feb745SGovindraj Raja 		break;
11177feb745SGovindraj Raja #endif /* ERRATA_X3_3701769 */
11277feb745SGovindraj Raja 
11338401c53SGovindraj Raja #if ERRATA_X4_3701758
11438401c53SGovindraj Raja 	case EXTRACT_PARTNUM(CORTEX_X4_MIDR):
11538401c53SGovindraj Raja 		if (check_erratum_cortex_x4_3701758(cpu_get_rev_var()) == ERRATA_APPLIES)
11638401c53SGovindraj Raja 			return true;
11738401c53SGovindraj Raja 		break;
11838401c53SGovindraj Raja #endif /* ERRATA_X4_3701758 */
11938401c53SGovindraj Raja 
120511148efSGovindraj Raja #if ERRATA_X925_3701747
121511148efSGovindraj Raja 	case EXTRACT_PARTNUM(CORTEX_X925_MIDR):
122511148efSGovindraj Raja 		if (check_erratum_cortex_x925_3701747(cpu_get_rev_var()) == ERRATA_APPLIES)
123511148efSGovindraj Raja 			return true;
124511148efSGovindraj Raja 		break;
125511148efSGovindraj Raja #endif /* ERRATA_X925_3701747 */
126adea6e52SGovindraj Raja 
127adea6e52SGovindraj Raja #if ERRATA_N2_3701773
128adea6e52SGovindraj Raja 	case EXTRACT_PARTNUM(NEOVERSE_N2_MIDR):
129adea6e52SGovindraj Raja 		if (check_erratum_neoverse_n2_3701773(cpu_get_rev_var()) == ERRATA_APPLIES)
130adea6e52SGovindraj Raja 			return true;
131adea6e52SGovindraj Raja 		break;
132adea6e52SGovindraj Raja #endif /* ERRATA_N2_3701773 */
133adea6e52SGovindraj Raja 
134fded8392SGovindraj Raja #if ERRATA_N3_3699563
135fded8392SGovindraj Raja 	case EXTRACT_PARTNUM(NEOVERSE_N3_MIDR):
136fded8392SGovindraj Raja 		if (check_erratum_neoverse_n3_3699563(cpu_get_rev_var()) == ERRATA_APPLIES)
137fded8392SGovindraj Raja 			return true;
138fded8392SGovindraj Raja 		break;
139fded8392SGovindraj Raja #endif /* ERRATA_N3_3699563 */
140e25fc9dfSGovindraj Raja 
141e25fc9dfSGovindraj Raja #if ERRATA_V3_3701767
142e25fc9dfSGovindraj Raja 	case EXTRACT_PARTNUM(NEOVERSE_V3_MIDR):
143e25fc9dfSGovindraj Raja 		if (check_erratum_neoverse_v3_3701767(cpu_get_rev_var()) == ERRATA_APPLIES)
144e25fc9dfSGovindraj Raja 			return true;
145e25fc9dfSGovindraj Raja 		break;
146e25fc9dfSGovindraj Raja #endif /* ERRATA_V3_3701767 */
147e25fc9dfSGovindraj Raja 
1487455cd17SGovindraj Raja 	default:
1497455cd17SGovindraj Raja 		break;
1507455cd17SGovindraj Raja 	}
1517455cd17SGovindraj Raja 
1527455cd17SGovindraj Raja 	return false;
1537455cd17SGovindraj Raja }
154