| 1 |
|
| 2 |
|
| 3 |
#include <cpu/intel/smm_reloc.h> |
| 4 |
#include <cpu/intel/turbo.h> |
| 5 |
#include <cpu/intel/common/common.h> |
| 6 |
#include <cpu/x86/mp.h> |
| 7 |
#include <cpu/x86/msr.h> |
| 8 |
#include <device/pci.h> |
| 9 |
#include <fsp/api.h> |
| 10 |
#include <intelblocks/cpulib.h> |
| 11 |
#include <intelblocks/mp_init.h> |
| 12 |
#include <intelblocks/msr.h> |
| 13 |
#include <soc/cpu.h> |
| 14 |
#include <soc/msr.h> |
| 15 |
#include <soc/pci_devs.h> |
| 16 |
#include <soc/soc_chip.h> |
| 17 |
#include <static.h> |
| 18 |
#include <types.h> |
| 19 |
|
| 20 |
bool cpu_soc_is_in_untrusted_mode(void) |
| 21 |
{ |
| 22 |
msr_t msr; |
| 23 |
|
| 24 |
msr = rdmsr(MSR_BIOS_DONE); |
| 25 |
return !!(msr.lo & ENABLE_IA_UNTRUSTED); |
| 26 |
} |
| 27 |
|
| 28 |
void cpu_soc_bios_done(void) |
| 29 |
{ |
| 30 |
msr_t msr; |
| 31 |
|
| 32 |
msr = rdmsr(MSR_BIOS_DONE); |
| 33 |
msr.lo |= ENABLE_IA_UNTRUSTED; |
| 34 |
wrmsr(MSR_BIOS_DONE, msr); |
| 35 |
} |
| 36 |
|
| 37 |
static void soc_fsp_load(void) |
| 38 |
{ |
| 39 |
fsps_load(); |
| 40 |
} |
| 41 |
|
| 42 |
static void configure_misc(void) |
| 43 |
{ |
| 44 |
msr_t msr; |
| 45 |
|
| 46 |
config_t *conf = config_of_soc(); |
| 47 |
|
| 48 |
msr = rdmsr(IA32_MISC_ENABLE); |
| 49 |
msr.lo |= (1 << 0); |
| 50 |
msr.lo |= (1 << 3); |
| 51 |
wrmsr(IA32_MISC_ENABLE, msr); |
| 52 |
|
| 53 |
|
| 54 |
cpu_set_eist(conf->eist_enable); |
| 55 |
|
| 56 |
|
| 57 |
msr.lo = 0; |
| 58 |
msr.hi = 0; |
| 59 |
wrmsr(IA32_THERM_INTERRUPT, msr); |
| 60 |
|
| 61 |
|
| 62 |
msr.lo = 1 << 4; |
| 63 |
msr.hi = 0; |
| 64 |
wrmsr(IA32_PACKAGE_THERM_INTERRUPT, msr); |
| 65 |
|
| 66 |
|
| 67 |
msr = rdmsr(MSR_POWER_CTL); |
| 68 |
msr.lo |= (1 << 0); |
| 69 |
msr.lo |= (1 << 23); |
| 70 |
wrmsr(MSR_POWER_CTL, msr); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
if (conf->L1_prefetcher_disable) { |
| 75 |
msr = rdmsr(MSR_PREFETCH_CTL); |
| 76 |
msr.lo |= PREFETCH_L1_DISABLE; |
| 77 |
wrmsr(MSR_PREFETCH_CTL, msr); |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
void soc_core_init(struct device *cpu) |
| 83 |
{ |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
mca_configure(); |
| 89 |
|
| 90 |
enable_lapic_tpr(); |
| 91 |
|
| 92 |
|
| 93 |
configure_misc(); |
| 94 |
|
| 95 |
enable_pm_timer_emulation(); |
| 96 |
|
| 97 |
|
| 98 |
configure_dca_cap(); |
| 99 |
|
| 100 |
|
| 101 |
set_energy_perf_bias(ENERGY_POLICY_NORMAL); |
| 102 |
|
| 103 |
|
| 104 |
enable_turbo(); |
| 105 |
} |
| 106 |
|
| 107 |
static void per_cpu_smm_trigger(void) |
| 108 |
{ |
| 109 |
|
| 110 |
smm_relocate(); |
| 111 |
} |
| 112 |
|
| 113 |
static void post_mp_init(void) |
| 114 |
{ |
| 115 |
|
| 116 |
cpu_set_max_ratio(); |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
global_smi_enable(); |
| 123 |
} |
| 124 |
|
| 125 |
static const struct mp_ops mp_ops = { |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
.pre_mp_init = soc_fsp_load, |
| 132 |
.get_cpu_count = get_cpu_count, |
| 133 |
.get_smm_info = smm_info, |
| 134 |
.get_microcode_info = get_microcode_info, |
| 135 |
.pre_mp_smm_init = smm_initialize, |
| 136 |
.per_cpu_smm_trigger = per_cpu_smm_trigger, |
| 137 |
.relocation_handler = smm_relocation_handler, |
| 138 |
.post_mp_init = post_mp_init, |
| 139 |
}; |
| 140 |
|
| 141 |
void mp_init_cpus(struct bus *cpu_bus) |
| 142 |
{ |
| 143 |
|
| 144 |
mp_init_with_smm(cpu_bus, &mp_ops); |
| 145 |
|
| 146 |
|
| 147 |
configure_tcc_thermal_target(); |
| 148 |
} |