| 1 |
|
| 2 |
|
| 3 |
#include <bootstate.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <console/debug.h> |
| 6 |
#include <cpu/x86/mp.h> |
| 7 |
#include <cpu/x86/smm.h> |
| 8 |
#include <device/pci.h> |
| 9 |
#include <intelpch/lockdown.h> |
| 10 |
#include <soc/msr.h> |
| 11 |
#include <soc/pci_devs.h> |
| 12 |
#include <soc/pm.h> |
| 13 |
#include <soc/util.h> |
| 14 |
#include <soc/soc_util.h> |
| 15 |
#include <smp/spinlock.h> |
| 16 |
|
| 17 |
#include "chip.h" |
| 18 |
|
| 19 |
DECLARE_SPIN_LOCK(msr_ppin_lock); |
| 20 |
|
| 21 |
static void lock_msr_ppin_ctl(void *unused) |
| 22 |
{ |
| 23 |
msr_t msr; |
| 24 |
|
| 25 |
msr = rdmsr(MSR_PLATFORM_INFO); |
| 26 |
if ((msr.lo & MSR_PPIN_CAP) == 0) |
| 27 |
return; |
| 28 |
|
| 29 |
spin_lock(&msr_ppin_lock); |
| 30 |
|
| 31 |
msr = rdmsr(MSR_PPIN_CTL); |
| 32 |
if (msr.lo & MSR_PPIN_CTL_LOCK) { |
| 33 |
spin_unlock(&msr_ppin_lock); |
| 34 |
return; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
msr.lo &= ~MSR_PPIN_CTL_ENABLE; |
| 39 |
msr.lo |= MSR_PPIN_CTL_LOCK; |
| 40 |
wrmsr(MSR_PPIN_CTL, msr); |
| 41 |
|
| 42 |
spin_unlock(&msr_ppin_lock); |
| 43 |
} |
| 44 |
|
| 45 |
static void soc_finalize(void *unused) |
| 46 |
{ |
| 47 |
printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
if (!CONFIG(USE_PM_ACPI_TIMER)) |
| 60 |
setbits8(pmc_mmio_regs() + PCH_PWRM_ACPI_TMR_CTL, ACPI_TIM_DIS); |
| 61 |
|
| 62 |
apm_control(APM_CNT_FINALIZE); |
| 63 |
|
| 64 |
if (CONFIG_MAX_SOCKET > 1) { |
| 65 |
|
| 66 |
if (mp_run_on_all_cpus(&lock_msr_ppin_ctl, NULL) != CB_SUCCESS) |
| 67 |
printk(BIOS_ERR, "Lock PPIN CTL MSR failed\n"); |
| 68 |
} else { |
| 69 |
lock_msr_ppin_ctl(NULL); |
| 70 |
} |
| 71 |
|
| 72 |
post_code(POSTCODE_OS_BOOT); |
| 73 |
} |
| 74 |
|
| 75 |
static void bios_done_finalize(void *unused) |
| 76 |
{ |
| 77 |
if (!CONFIG(SOC_INTEL_HAS_BIOS_DONE_MSR)) |
| 78 |
return; |
| 79 |
|
| 80 |
printk(BIOS_DEBUG, "Setting BIOS_DONE\n"); |
| 81 |
|
| 82 |
if (mp_run_on_all_cpus(&bios_done_msr, NULL) != CB_SUCCESS) |
| 83 |
printk(BIOS_ERR, "Fail to set BIOS_DONE MSR\n"); |
| 84 |
} |
| 85 |
|
| 86 |
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_ENTRY, soc_finalize, NULL); |
| 87 |
|
| 88 |
|
| 89 |
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, bios_done_finalize, NULL); |