| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <console/console.h> |
| 10 |
#include <device/pci.h> |
| 11 |
#include <device/pci_ids.h> |
| 12 |
#include <cpu/x86/mp.h> |
| 13 |
#include <cpu/x86/msr.h> |
| 14 |
#include <cpu/intel/microcode.h> |
| 15 |
#include <cpu/intel/smm_reloc.h> |
| 16 |
#include <cpu/intel/turbo.h> |
| 17 |
#include <cpu/intel/common/common.h> |
| 18 |
#include <fsp/api.h> |
| 19 |
#include <intelblocks/cpulib.h> |
| 20 |
#include <intelblocks/mp_init.h> |
| 21 |
#include <intelblocks/msr.h> |
| 22 |
#include <intelblocks/acpi.h> |
| 23 |
#include <soc/cpu.h> |
| 24 |
#include <soc/msr.h> |
| 25 |
#include <soc/pci_devs.h> |
| 26 |
#include <soc/soc_chip.h> |
| 27 |
#include <static.h> |
| 28 |
#include <types.h> |
| 29 |
|
| 30 |
enum alderlake_model { |
| 31 |
ADL_MODEL_P_M = 0x9A, |
| 32 |
ADL_MODEL_N = 0xBE, |
| 33 |
}; |
| 34 |
|
| 35 |
bool cpu_soc_is_in_untrusted_mode(void) |
| 36 |
{ |
| 37 |
msr_t msr; |
| 38 |
|
| 39 |
msr = rdmsr(MSR_BIOS_DONE); |
| 40 |
return !!(msr.lo & ENABLE_IA_UNTRUSTED); |
| 41 |
} |
| 42 |
|
| 43 |
void cpu_soc_bios_done(void) |
| 44 |
{ |
| 45 |
msr_t msr; |
| 46 |
|
| 47 |
msr = rdmsr(MSR_BIOS_DONE); |
| 48 |
msr.lo |= ENABLE_IA_UNTRUSTED; |
| 49 |
wrmsr(MSR_BIOS_DONE, msr); |
| 50 |
} |
| 51 |
|
| 52 |
static void soc_fsp_load(void) |
| 53 |
{ |
| 54 |
fsps_load(); |
| 55 |
} |
| 56 |
|
| 57 |
static void configure_misc(void) |
| 58 |
{ |
| 59 |
msr_t msr; |
| 60 |
|
| 61 |
const config_t *conf = config_of_soc(); |
| 62 |
|
| 63 |
msr = rdmsr(IA32_MISC_ENABLE); |
| 64 |
msr.lo |= (1 << 0); |
| 65 |
msr.lo |= (1 << 3); |
| 66 |
wrmsr(IA32_MISC_ENABLE, msr); |
| 67 |
|
| 68 |
|
| 69 |
cpu_set_eist(conf->eist_enable); |
| 70 |
|
| 71 |
|
| 72 |
msr.lo = 0; |
| 73 |
msr.hi = 0; |
| 74 |
wrmsr(IA32_THERM_INTERRUPT, msr); |
| 75 |
|
| 76 |
|
| 77 |
msr.lo = 1 << 4; |
| 78 |
msr.hi = 0; |
| 79 |
wrmsr(IA32_PACKAGE_THERM_INTERRUPT, msr); |
| 80 |
|
| 81 |
|
| 82 |
msr = rdmsr(MSR_POWER_CTL); |
| 83 |
msr.lo |= (1 << 0); |
| 84 |
msr.lo |= (1 << 23); |
| 85 |
msr.lo |= (1 << 18); |
| 86 |
wrmsr(MSR_POWER_CTL, msr); |
| 87 |
} |
| 88 |
|
| 89 |
enum core_type get_soc_cpu_type(void) |
| 90 |
{ |
| 91 |
struct cpuinfo_x86 cpuinfo; |
| 92 |
|
| 93 |
if (cpu_is_hybrid_supported()) |
| 94 |
return cpu_get_cpu_type(); |
| 95 |
|
| 96 |
get_fms(&cpuinfo, cpuid_eax(1)); |
| 97 |
|
| 98 |
if (cpuinfo.x86 == 0x6 && cpuinfo.x86_model == ADL_MODEL_N) |
| 99 |
return CPUID_CORE_TYPE_INTEL_ATOM; |
| 100 |
else |
| 101 |
return CPUID_CORE_TYPE_INTEL_CORE; |
| 102 |
} |
| 103 |
|
| 104 |
bool soc_is_nominal_freq_supported(void) |
| 105 |
{ |
| 106 |
return true; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
void soc_core_init(struct device *cpu) |
| 111 |
{ |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
mca_configure(); |
| 117 |
|
| 118 |
enable_lapic_tpr(); |
| 119 |
|
| 120 |
|
| 121 |
configure_misc(); |
| 122 |
|
| 123 |
enable_pm_timer_emulation(); |
| 124 |
|
| 125 |
|
| 126 |
configure_dca_cap(); |
| 127 |
|
| 128 |
|
| 129 |
set_dev_core_type(); |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
set_energy_perf_bias(7); |
| 134 |
|
| 135 |
const config_t *conf = config_of_soc(); |
| 136 |
|
| 137 |
if (conf->enable_energy_perf_pref) |
| 138 |
if (check_energy_perf_cap()) |
| 139 |
set_energy_perf_pref(conf->energy_perf_pref_value); |
| 140 |
|
| 141 |
enable_turbo(); |
| 142 |
|
| 143 |
if (CONFIG(INTEL_TME) && is_tme_supported()) |
| 144 |
set_tme_core_activate(); |
| 145 |
} |
| 146 |
|
| 147 |
static void per_cpu_smm_trigger(void) |
| 148 |
{ |
| 149 |
|
| 150 |
smm_relocate(); |
| 151 |
} |
| 152 |
|
| 153 |
static void pre_mp_init(void) |
| 154 |
{ |
| 155 |
soc_fsp_load(); |
| 156 |
|
| 157 |
const config_t *conf = config_of_soc(); |
| 158 |
if (conf->enable_energy_perf_pref) { |
| 159 |
if (check_energy_perf_cap()) |
| 160 |
enable_energy_perf_pref(); |
| 161 |
else |
| 162 |
printk(BIOS_WARNING, "Energy Performance Preference not supported!\n"); |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
static void post_mp_init(void) |
| 167 |
{ |
| 168 |
|
| 169 |
cpu_set_max_ratio(); |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
global_smi_enable_no_pwrbtn(); |
| 178 |
} |
| 179 |
|
| 180 |
static const struct mp_ops mp_ops = { |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
.pre_mp_init = pre_mp_init, |
| 187 |
.get_cpu_count = get_cpu_count, |
| 188 |
.get_smm_info = smm_info, |
| 189 |
.get_microcode_info = get_microcode_info, |
| 190 |
.pre_mp_smm_init = smm_initialize, |
| 191 |
.per_cpu_smm_trigger = per_cpu_smm_trigger, |
| 192 |
.relocation_handler = smm_relocation_handler, |
| 193 |
.post_mp_init = post_mp_init, |
| 194 |
}; |
| 195 |
|
| 196 |
void mp_init_cpus(struct bus *cpu_bus) |
| 197 |
{ |
| 198 |
|
| 199 |
mp_init_with_smm(cpu_bus, &mp_ops); |
| 200 |
|
| 201 |
|
| 202 |
configure_tcc_thermal_target(); |
| 203 |
} |
| 204 |
|
| 205 |
enum adl_cpu_type get_adl_cpu_type(void) |
| 206 |
{ |
| 207 |
const uint16_t adl_m_mch_ids[] = { |
| 208 |
PCI_DID_INTEL_ADL_M_ID_1, |
| 209 |
PCI_DID_INTEL_ADL_M_ID_2, |
| 210 |
}; |
| 211 |
const uint16_t adl_p_mch_ids[] = { |
| 212 |
PCI_DID_INTEL_ADL_P_ID_1, |
| 213 |
PCI_DID_INTEL_ADL_P_ID_3, |
| 214 |
PCI_DID_INTEL_ADL_P_ID_4, |
| 215 |
PCI_DID_INTEL_ADL_P_ID_5, |
| 216 |
PCI_DID_INTEL_ADL_P_ID_6, |
| 217 |
PCI_DID_INTEL_ADL_P_ID_7, |
| 218 |
PCI_DID_INTEL_ADL_P_ID_8, |
| 219 |
PCI_DID_INTEL_ADL_P_ID_9, |
| 220 |
PCI_DID_INTEL_ADL_P_ID_10 |
| 221 |
}; |
| 222 |
const uint16_t adl_s_mch_ids[] = { |
| 223 |
PCI_DID_INTEL_ADL_S_ID_1, |
| 224 |
PCI_DID_INTEL_ADL_S_ID_2, |
| 225 |
PCI_DID_INTEL_ADL_S_ID_3, |
| 226 |
PCI_DID_INTEL_ADL_S_ID_4, |
| 227 |
PCI_DID_INTEL_ADL_S_ID_5, |
| 228 |
PCI_DID_INTEL_ADL_S_ID_6, |
| 229 |
PCI_DID_INTEL_ADL_S_ID_7, |
| 230 |
PCI_DID_INTEL_ADL_S_ID_8, |
| 231 |
PCI_DID_INTEL_ADL_S_ID_9, |
| 232 |
PCI_DID_INTEL_ADL_S_ID_10, |
| 233 |
PCI_DID_INTEL_ADL_S_ID_11, |
| 234 |
PCI_DID_INTEL_ADL_S_ID_12, |
| 235 |
PCI_DID_INTEL_ADL_S_ID_13, |
| 236 |
PCI_DID_INTEL_ADL_S_ID_14, |
| 237 |
PCI_DID_INTEL_ADL_S_ID_15, |
| 238 |
}; |
| 239 |
|
| 240 |
const uint16_t adl_n_mch_ids[] = { |
| 241 |
PCI_DID_INTEL_ADL_N_ID_1, |
| 242 |
PCI_DID_INTEL_ADL_N_ID_2, |
| 243 |
PCI_DID_INTEL_ADL_N_ID_3, |
| 244 |
PCI_DID_INTEL_ADL_N_ID_4, |
| 245 |
PCI_DID_INTEL_ADL_N_ID_5, |
| 246 |
PCI_DID_INTEL_ADL_N_ID_6, |
| 247 |
PCI_DID_INTEL_ADL_N_ID_7, |
| 248 |
PCI_DID_INTEL_ADL_N_ID_8, |
| 249 |
PCI_DID_INTEL_ADL_N_ID_9, |
| 250 |
}; |
| 251 |
|
| 252 |
const uint16_t asl_mch_ids[] = { |
| 253 |
PCI_DID_INTEL_ASL_ID_1, |
| 254 |
PCI_DID_INTEL_ASL_ID_2, |
| 255 |
PCI_DID_INTEL_ASL_ID_3, |
| 256 |
}; |
| 257 |
|
| 258 |
const uint16_t rpl_hx_mch_ids[] = { |
| 259 |
PCI_DID_INTEL_RPL_HX_ID_1, |
| 260 |
PCI_DID_INTEL_RPL_HX_ID_2, |
| 261 |
PCI_DID_INTEL_RPL_HX_ID_3, |
| 262 |
PCI_DID_INTEL_RPL_HX_ID_4, |
| 263 |
PCI_DID_INTEL_RPL_HX_ID_5, |
| 264 |
PCI_DID_INTEL_RPL_HX_ID_6, |
| 265 |
PCI_DID_INTEL_RPL_HX_ID_7, |
| 266 |
PCI_DID_INTEL_RPL_HX_ID_8, |
| 267 |
}; |
| 268 |
|
| 269 |
const uint16_t rpl_s_mch_ids[] = { |
| 270 |
PCI_DID_INTEL_RPL_S_ID_1, |
| 271 |
PCI_DID_INTEL_RPL_S_ID_2, |
| 272 |
PCI_DID_INTEL_RPL_S_ID_3, |
| 273 |
PCI_DID_INTEL_RPL_S_ID_4, |
| 274 |
PCI_DID_INTEL_RPL_S_ID_5 |
| 275 |
}; |
| 276 |
|
| 277 |
const uint16_t rpl_p_mch_ids[] = { |
| 278 |
PCI_DID_INTEL_RPL_P_ID_1, |
| 279 |
PCI_DID_INTEL_RPL_P_ID_2, |
| 280 |
PCI_DID_INTEL_RPL_P_ID_3, |
| 281 |
PCI_DID_INTEL_RPL_P_ID_4, |
| 282 |
PCI_DID_INTEL_RPL_P_ID_5, |
| 283 |
PCI_DID_INTEL_RPL_P_ID_6, |
| 284 |
PCI_DID_INTEL_RPL_P_ID_7, |
| 285 |
PCI_DID_INTEL_RPL_P_ID_8, |
| 286 |
}; |
| 287 |
|
| 288 |
const uint16_t mchid = pci_s_read_config16(PCI_DEV(0, PCI_SLOT(SA_DEVFN_ROOT), |
| 289 |
PCI_FUNC(SA_DEVFN_ROOT)), |
| 290 |
PCI_DEVICE_ID); |
| 291 |
|
| 292 |
for (size_t i = 0; i < ARRAY_SIZE(adl_p_mch_ids); i++) { |
| 293 |
if (adl_p_mch_ids[i] == mchid) |
| 294 |
return ADL_P; |
| 295 |
} |
| 296 |
|
| 297 |
for (size_t i = 0; i < ARRAY_SIZE(adl_m_mch_ids); i++) { |
| 298 |
if (adl_m_mch_ids[i] == mchid) |
| 299 |
return ADL_M; |
| 300 |
} |
| 301 |
|
| 302 |
for (size_t i = 0; i < ARRAY_SIZE(adl_s_mch_ids); i++) { |
| 303 |
if (adl_s_mch_ids[i] == mchid) |
| 304 |
return ADL_S; |
| 305 |
} |
| 306 |
|
| 307 |
for (size_t i = 0; i < ARRAY_SIZE(asl_mch_ids); i++) { |
| 308 |
if (asl_mch_ids[i] == mchid) |
| 309 |
return ASL; |
| 310 |
} |
| 311 |
|
| 312 |
for (size_t i = 0; i < ARRAY_SIZE(rpl_s_mch_ids); i++) { |
| 313 |
if (rpl_s_mch_ids[i] == mchid) |
| 314 |
return RPL_S; |
| 315 |
} |
| 316 |
|
| 317 |
for (size_t i = 0; i < ARRAY_SIZE(adl_n_mch_ids); i++) { |
| 318 |
if (adl_n_mch_ids[i] == mchid) |
| 319 |
return ADL_N; |
| 320 |
} |
| 321 |
|
| 322 |
for (size_t i = 0; i < ARRAY_SIZE(rpl_hx_mch_ids); i++) { |
| 323 |
if (rpl_hx_mch_ids[i] == mchid) |
| 324 |
return RPL_HX; |
| 325 |
} |
| 326 |
|
| 327 |
for (size_t i = 0; i < ARRAY_SIZE(rpl_p_mch_ids); i++) { |
| 328 |
if (rpl_p_mch_ids[i] == mchid) |
| 329 |
return RPL_P; |
| 330 |
} |
| 331 |
|
| 332 |
return ADL_UNKNOWN; |
| 333 |
} |
| 334 |
|
| 335 |
uint8_t get_supported_lpm_mask(void) |
| 336 |
{ |
| 337 |
const config_t *conf = config_of_soc(); |
| 338 |
if (!conf->s0ix_enable) |
| 339 |
return 0; |
| 340 |
|
| 341 |
enum adl_cpu_type type = get_adl_cpu_type(); |
| 342 |
switch (type) { |
| 343 |
case ADL_M: |
| 344 |
case ADL_N: |
| 345 |
case ADL_P: |
| 346 |
case ASL: |
| 347 |
case RPL_P: |
| 348 |
return LPM_S0i2_0 | LPM_S0i3_0; |
| 349 |
case ADL_S: |
| 350 |
case RPL_S: |
| 351 |
case RPL_HX: |
| 352 |
return LPM_S0i2_0 | LPM_S0i2_1; |
| 353 |
default: |
| 354 |
printk(BIOS_ERR, "Unknown ADL CPU type: %d\n", type); |
| 355 |
return 0; |
| 356 |
} |
| 357 |
} |
| 358 |
|
| 359 |
int soc_skip_ucode_update(u32 current_patch_id, u32 new_patch_id) |
| 360 |
{ |
| 361 |
if (!CONFIG(CHROMEOS)) |
| 362 |
return 0; |
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
if (CONFIG(LOCK_MANAGEMENT_ENGINE) && current_patch_id) |
| 375 |
return 1; |
| 376 |
|
| 377 |
return 0; |
| 378 |
} |