1 /* 2 * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /* Runtime C routines for errata workarounds and common routines */ 8 9 #include <arch.h> 10 #include <arch_helpers.h> 11 #include <cortex_a75.h> 12 #include <cortex_a510.h> 13 #include <cortex_a520.h> 14 #include <cortex_a710.h> 15 #include <cortex_a715.h> 16 #include <cortex_a720.h> 17 #include <cortex_a720_ae.h> 18 #include <cortex_a725.h> 19 #include <cortex_x2.h> 20 #include <cortex_x3.h> 21 #include <cortex_x4.h> 22 #include <cortex_x925.h> 23 #include <lib/cpus/cpu_ops.h> 24 #include <lib/cpus/errata.h> 25 #include <neoverse_n2.h> 26 #include <neoverse_n3.h> 27 #include <neoverse_v3.h> 28 29 bool check_if_trbe_disable_affected_core(void) 30 { 31 switch (EXTRACT_PARTNUM(read_midr())) { 32 #if ERRATA_A520_2938996 33 case EXTRACT_PARTNUM(CORTEX_A520_MIDR): 34 return check_erratum_cortex_a520_2938996(cpu_get_rev_var()) == ERRATA_APPLIES; 35 #endif 36 #if ERRATA_X4_2726228 37 case EXTRACT_PARTNUM(CORTEX_X4_MIDR): 38 return check_erratum_cortex_x4_2726228(cpu_get_rev_var()) == ERRATA_APPLIES; 39 #endif 40 #if ERRATA_A510_2971420 41 case EXTRACT_PARTNUM(CORTEX_A510_MIDR): 42 return check_erratum_cortex_a510_2971420(cpu_get_rev_var()) == ERRATA_APPLIES; 43 #endif 44 default: 45 break; 46 } 47 return false; 48 } 49 50 #if ERRATA_A75_764081 51 bool errata_a75_764081_applies(void) 52 { 53 long rev_var = cpu_get_rev_var(); 54 if (check_erratum_cortex_a75_764081(rev_var) == ERRATA_APPLIES) { 55 return true; 56 } 57 return false; 58 } 59 #endif /* ERRATA_A75_764081 */ 60 61 bool errata_ich_vmcr_el2_applies(void) 62 { 63 switch (EXTRACT_PARTNUM(read_midr())) { 64 #if ERRATA_A710_3701772 65 case EXTRACT_PARTNUM(CORTEX_A710_MIDR): 66 if (check_erratum_cortex_a710_3701772(cpu_get_rev_var()) == ERRATA_APPLIES) 67 return true; 68 break; 69 #endif /* ERRATA_A710_3701772 */ 70 71 #if ERRATA_A715_3699560 72 case EXTRACT_PARTNUM(CORTEX_A715_MIDR): 73 if (check_erratum_cortex_a715_3699560(cpu_get_rev_var()) == ERRATA_APPLIES) 74 return true; 75 break; 76 #endif /* ERRATA_A715_3699560 */ 77 78 #if ERRATA_A720_3699561 79 case EXTRACT_PARTNUM(CORTEX_A720_MIDR): 80 if (check_erratum_cortex_a720_3699561(cpu_get_rev_var()) == ERRATA_APPLIES) 81 return true;; 82 break; 83 #endif /* ERRATA_A720_3699561 */ 84 85 #if ERRATA_A720_AE_3699562 86 case EXTRACT_PARTNUM(CORTEX_A720_AE_MIDR): 87 if (check_erratum_cortex_a720_ae_3699562(cpu_get_rev_var()) == ERRATA_APPLIES) 88 return true; 89 break; 90 #endif /* ERRATA_A720_AE_3699562 */ 91 92 #if ERRATA_A725_3699564 93 case EXTRACT_PARTNUM(CORTEX_A725_MIDR): 94 if (check_erratum_cortex_a725_3699564(cpu_get_rev_var()) == ERRATA_APPLIES) 95 return true; 96 break; 97 #endif /* ERRATA_A725_3699564 */ 98 99 #if ERRATA_X2_3701772 100 case EXTRACT_PARTNUM(CORTEX_X2_MIDR): 101 if (check_erratum_cortex_x2_3701772(cpu_get_rev_var()) == ERRATA_APPLIES) 102 return true; 103 break; 104 #endif /* ERRATA_X2_3701772 */ 105 106 #if ERRATA_X3_3701769 107 case EXTRACT_PARTNUM(CORTEX_X3_MIDR): 108 if (check_erratum_cortex_x3_3701769(cpu_get_rev_var()) == ERRATA_APPLIES) 109 return true; 110 break; 111 #endif /* ERRATA_X3_3701769 */ 112 113 #if ERRATA_X4_3701758 114 case EXTRACT_PARTNUM(CORTEX_X4_MIDR): 115 if (check_erratum_cortex_x4_3701758(cpu_get_rev_var()) == ERRATA_APPLIES) 116 return true; 117 break; 118 #endif /* ERRATA_X4_3701758 */ 119 120 #if ERRATA_X925_3701747 121 case EXTRACT_PARTNUM(CORTEX_X925_MIDR): 122 if (check_erratum_cortex_x925_3701747(cpu_get_rev_var()) == ERRATA_APPLIES) 123 return true; 124 break; 125 #endif /* ERRATA_X925_3701747 */ 126 127 #if ERRATA_N2_3701773 128 case EXTRACT_PARTNUM(NEOVERSE_N2_MIDR): 129 if (check_erratum_neoverse_n2_3701773(cpu_get_rev_var()) == ERRATA_APPLIES) 130 return true; 131 break; 132 #endif /* ERRATA_N2_3701773 */ 133 134 #if ERRATA_N3_3699563 135 case EXTRACT_PARTNUM(NEOVERSE_N3_MIDR): 136 if (check_erratum_neoverse_n3_3699563(cpu_get_rev_var()) == ERRATA_APPLIES) 137 return true; 138 break; 139 #endif /* ERRATA_N3_3699563 */ 140 141 #if ERRATA_V3_3701767 142 case EXTRACT_PARTNUM(NEOVERSE_V3_MIDR): 143 if (check_erratum_neoverse_v3_3701767(cpu_get_rev_var()) == ERRATA_APPLIES) 144 return true; 145 break; 146 #endif /* ERRATA_V3_3701767 */ 147 148 default: 149 break; 150 } 151 152 return false; 153 } 154