1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/pci.h>
4 #include <cpu/x86/mp.h>
5 #include <cpu/x86/msr.h>
6 #include <cpu/intel/smm_reloc.h>
7 #include <cpu/intel/turbo.h>
8 #include <cpu/intel/common/common.h>
10 #include <intelblocks/cpulib.h>
11 #include <intelblocks/mp_init.h>
12 #include <intelblocks/msr.h>
15 #include <soc/pci_devs.h>
16 #include <soc/soc_chip.h>
19 bool cpu_soc_is_in_untrusted_mode(void)
23 msr
= rdmsr(MSR_BIOS_DONE
);
24 return !!(msr
.lo
& ENABLE_IA_UNTRUSTED
);
27 void cpu_soc_bios_done(void)
31 msr
= rdmsr(MSR_BIOS_DONE
);
32 msr
.lo
|= ENABLE_IA_UNTRUSTED
;
33 wrmsr(MSR_BIOS_DONE
, msr
);
36 static void soc_fsp_load(void)
41 static void configure_misc(void)
45 config_t
*conf
= config_of_soc();
47 msr
= rdmsr(IA32_MISC_ENABLE
);
48 msr
.lo
|= (1 << 0); /* Fast String enable */
49 msr
.lo
|= (1 << 3); /* TM1/TM2/EMTTM enable */
50 wrmsr(IA32_MISC_ENABLE
, msr
);
53 cpu_set_eist(conf
->eist_enable
);
55 /* Disable Thermal interrupts */
58 wrmsr(IA32_THERM_INTERRUPT
, msr
);
60 /* Enable package critical interrupt only */
63 wrmsr(IA32_PACKAGE_THERM_INTERRUPT
, msr
);
66 msr
= rdmsr(MSR_POWER_CTL
);
67 msr
.lo
|= (1 << 0); /* Enable Bi-directional PROCHOT as an input */
68 msr
.lo
|= (1 << 23); /* Lock it */
69 wrmsr(MSR_POWER_CTL
, msr
);
72 /* All CPUs including BSP will run the following function. */
73 void soc_core_init(struct device
*cpu
)
75 /* Clear out pending MCEs */
76 /* TODO(adurbin): This should only be done on a cold boot. Also, some
77 * of these banks are core vs package scope. For now every CPU clears
83 /* Configure Enhanced SpeedStep and Thermal Sensors */
86 enable_pm_timer_emulation();
88 /* Enable Direct Cache Access */
91 /* Set energy policy */
92 set_energy_perf_bias(ENERGY_POLICY_NORMAL
);
98 static void per_cpu_smm_trigger(void)
100 /* Relocate the SMM handler. */
104 static void post_mp_init(void)
110 * 1. Now that all APs have been relocated as well as the BSP let SMIs
112 * 2. Skip enabling power button SMI and enable it after BS_CHIPS_INIT
113 * to avoid shutdown hang due to lack of init on certain IP in FSP-S.
115 global_smi_enable_no_pwrbtn();
118 static const struct mp_ops mp_ops
= {
120 * Skip Pre MP init MTRR programming as MTRRs are mirrored from BSP,
121 * that are set prior to ramstage.
122 * Real MTRRs programming are being done after resource allocation.
124 .pre_mp_init
= soc_fsp_load
,
125 .get_cpu_count
= get_cpu_count
,
126 .get_smm_info
= smm_info
,
127 .get_microcode_info
= get_microcode_info
,
128 .pre_mp_smm_init
= smm_initialize
,
129 .per_cpu_smm_trigger
= per_cpu_smm_trigger
,
130 .relocation_handler
= smm_relocation_handler
,
131 .post_mp_init
= post_mp_init
,
134 void mp_init_cpus(struct bus
*cpu_bus
)
136 /* TODO: Handle mp_init_with_smm failure? */
137 mp_init_with_smm(cpu_bus
, &mp_ops
);
139 /* Thermal throttle activation offset */
140 configure_tcc_thermal_target();