soc/intel/pantherlake: Remove soc_info.[hc] interface
[coreboot2.git] / src / soc / intel / pantherlake / cpu.c
blob1b81856afcc1bf1094213e99899eee7f343f6508
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <assert.h>
4 #include <console/console.h>
5 #include <cpu/cpu.h>
6 #include <cpu/intel/common/common.h>
7 #include <cpu/intel/microcode.h>
8 #include <cpu/intel/smm_reloc.h>
9 #include <cpu/intel/turbo.h>
10 #include <cpu/x86/lapic.h>
11 #include <cpu/x86/mp.h>
12 #include <cpu/x86/msr.h>
13 #include <device/pci.h>
14 #include <fsp/api.h>
15 #include <intelblocks/acpi.h>
16 #include <intelblocks/cpulib.h>
17 #include <intelblocks/mp_init.h>
18 #include <intelblocks/msr.h>
19 #include <soc/cpu.h>
20 #include <soc/msr.h>
21 #include <soc/pci_devs.h>
22 #include <soc/soc_chip.h>
24 bool cpu_soc_is_in_untrusted_mode(void)
26 msr_t msr;
28 msr = rdmsr(MSR_BIOS_DONE);
29 return !!(msr.lo & ENABLE_IA_UNTRUSTED);
32 void cpu_soc_bios_done(void)
34 msr_t msr;
36 msr = rdmsr(MSR_BIOS_DONE);
37 msr.lo |= ENABLE_IA_UNTRUSTED;
38 wrmsr(MSR_BIOS_DONE, msr);
41 uint8_t get_supported_lpm_mask(void)
43 return LPM_S0i2_0 | LPM_S0i2_1 | LPM_S0i2_2;
46 static void soc_fsp_load(void)
48 fsps_load();
51 static void configure_misc(void)
53 msr_t msr;
55 const struct soc_intel_pantherlake_config *conf = config_of_soc();
57 msr = rdmsr(IA32_MISC_ENABLE);
58 msr.lo |= FAST_STRINGS_ENABLE_BIT;
59 msr.lo |= TM1_TM2_EMTTM_ENABLE_BIT;
60 wrmsr(IA32_MISC_ENABLE, msr);
62 /* Set EIST status */
63 cpu_set_eist(conf->eist_enable);
65 /* Disable Thermal interrupts */
66 msr.lo = 0;
67 msr.hi = 0;
68 wrmsr(IA32_THERM_INTERRUPT, msr);
70 /* Enable package critical interrupt only */
71 msr.lo = CRITICAL_TEMP_INTERRUPT_ENABLE;
72 msr.hi = 0;
73 wrmsr(IA32_PACKAGE_THERM_INTERRUPT, msr);
75 /* Enable PROCHOT and Power Performance Platform Override */
76 msr = rdmsr(MSR_POWER_CTL);
77 msr.lo |= ENABLE_BIDIR_PROCHOT;
78 msr.lo |= VR_THERM_ALERT_DISABLE_LOCK;
79 msr.lo |= PWR_PERF_PLATFORM_OVR;
80 wrmsr(MSR_POWER_CTL, msr);
83 enum core_type get_soc_cpu_type(void)
85 if (cpu_is_hybrid_supported())
86 return cpu_get_cpu_type();
88 return CPUID_CORE_TYPE_INTEL_CORE;
91 bool soc_is_nominal_freq_supported(void)
93 return true;
96 static void enable_x2apic(void)
98 if (!CONFIG(X2APIC_LATE_WORKAROUND))
99 return;
101 enable_lapic_mode(true);
104 /* All CPUs including BSP will run the following function. */
105 void soc_core_init(struct device *cpu)
107 /* Clear out pending MCEs */
108 mca_configure();
110 enable_x2apic();
112 enable_lapic_tpr();
114 /* Configure Enhanced SpeedStep and Thermal Sensors */
115 configure_misc();
117 enable_pm_timer_emulation();
119 /* Enable Direct Cache Access */
120 configure_dca_cap();
122 /* Set energy policy */
123 set_energy_perf_bias(ENERGY_POLICY_NORMAL);
125 const struct soc_intel_pantherlake_config *conf = config_of_soc();
126 /* Set energy-performance preference */
127 if (conf != NULL && conf->enable_energy_perf_pref) {
128 if (check_energy_perf_cap())
129 set_energy_perf_pref(conf->energy_perf_pref_value);
132 /* Enable Turbo */
133 enable_turbo();
135 /* Set core type in struct cpu_info */
136 set_dev_core_type();
138 if (CONFIG(INTEL_TME) && is_tme_supported())
139 set_tme_core_activate();
141 /* TODO: Add support for DROP_CPU_FEATURE_PROGRAM_IN_FSP */
144 static void per_cpu_smm_trigger(void)
146 /* Relocate the SMM handler. */
147 smm_relocate();
150 static void pre_mp_init(void)
152 soc_fsp_load();
154 const struct soc_intel_pantherlake_config *conf = config_of_soc();
155 if (conf == NULL) {
156 printk(BIOS_ERR, "Configuration could not be retrieved.\n");
157 return;
159 if (conf->enable_energy_perf_pref) {
160 if (check_energy_perf_cap())
161 enable_energy_perf_pref();
162 else
163 printk(BIOS_WARNING, "Energy Performance Preference not supported!\n");
167 static void post_mp_init(void)
169 /* Set Max Ratio */
170 cpu_set_max_ratio();
173 * 1. Now that all APs have been relocated as well as the BSP let SMIs
174 * start flowing.
175 * 2. Skip enabling power button SMI and enable it after BS_CHIPS_INIT
176 * to avoid shutdown hang due to lack of init on certain IP in FSP-S.
178 global_smi_enable_no_pwrbtn();
181 static const struct mp_ops mp_ops = {
183 * Skip Pre MP init MTRR programming as MTRRs are mirrored from BSP,
184 * that are set prior to ramstage.
185 * Real MTRRs programming are being done after resource allocation.
187 .pre_mp_init = pre_mp_init,
188 .get_cpu_count = get_cpu_count,
189 .get_smm_info = smm_info,
190 .get_microcode_info = get_microcode_info,
191 .pre_mp_smm_init = smm_initialize,
192 .per_cpu_smm_trigger = per_cpu_smm_trigger,
193 .relocation_handler = smm_relocation_handler,
194 .post_mp_init = post_mp_init,
197 void mp_init_cpus(struct bus *cpu_bus)
199 if (mp_init_with_smm(cpu_bus, &mp_ops))
200 printk(BIOS_ERR, "MP initialization failure.\n");
202 /* Thermal throttle activation offset */
203 configure_tcc_thermal_target();
206 int soc_skip_ucode_update(u32 current_patch_id, u32 new_patch_id)
208 if (!CONFIG(CHROMEOS))
209 return 0;
211 * Locked RO Descriptor Implications:
213 * - A locked descriptor signals the RO binary is fixed; the FIT will load the
214 * RO's microcode during system reset.
215 * - Attempts to load newer microcode from the RW CBFS will cause a boot-time
216 * delay (~60ms, core-dependent), as the microcode must be reloaded on BSP+APs.
217 * - The kernel can load microcode updates without impacting AP FW boot time.
218 * - Skipping RW CBFS microcode loading is low-risk when the RO is locked,
219 * prioritizing fast boot times.
221 if (CONFIG(LOCK_MANAGEMENT_ENGINE) && current_patch_id)
222 return 1;
224 return 0;