1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <commonlib/console/post_codes.h>
5 #include <console/console.h>
6 #include <cpu/x86/mp.h>
7 #include <cpu/x86/smm.h>
8 #include <device/mmio.h>
9 #include <device/pci.h>
10 #include <device/pci_ops.h>
11 #include <intelblocks/cpulib.h>
12 #include <intelblocks/cse.h>
13 #include <intelblocks/lpc_lib.h>
14 #include <intelblocks/p2sb.h>
15 #include <intelblocks/pcr.h>
16 #include <intelblocks/pmclib.h>
17 #include <intelblocks/tco.h>
18 #include <intelblocks/thermal.h>
21 #include <soc/pci_devs.h>
22 #include <soc/pcr_ids.h>
24 #include <soc/smbus.h>
25 #include <soc/systemagent.h>
26 #include <spi-generic.h>
30 #define PSF_BASE_ADDRESS 0xA00
31 #define PCR_PSFX_T0_SHDW_PCIEN 0x1C
32 #define PCR_PSFX_T0_SHDW_PCIEN_FUNDIS (1 << 8)
34 void soc_disable_heci1_using_pcr(void)
36 /* unhide p2sb device */
40 pcr_or32(PID_PSF1
, PSF_BASE_ADDRESS
+ PCR_PSFX_T0_SHDW_PCIEN
,
41 PCR_PSFX_T0_SHDW_PCIEN_FUNDIS
);
43 p2sb_disable_sideband_access();
46 static void pch_finalize_script(struct device
*dev
)
50 /* Display me status before we hide it */
54 * Set low maximum temp value used for dynamic thermal sensor
55 * shutdown consideration.
57 * If Dynamic Thermal Shutdown is enabled then PMC logic shuts down the
58 * thermal sensor when CPU is in a C-state and DTS Temp <= LTT.
60 pch_thermal_configuration();
62 /* we should disable Heci1 based on the config */
63 if (CONFIG(DISABLE_HECI1_AT_PRE_BOOT
))
66 /* Hide p2sb device as the OS must not change BAR0. */
69 pmc_clear_pmcon_sts();
72 static void soc_lockdown(struct device
*dev
)
74 struct soc_intel_skylake_config
*config
;
77 config
= config_of(dev
);
80 if (config
->LockDownConfigGlobalSmi
== 0) {
81 reg8
= pci_read_config8(dev
, GEN_PMCON_A
);
83 pci_write_config8(dev
, GEN_PMCON_A
, reg8
);
87 * Lock chipset memory registers to protect SMM.
88 * When SkipMpInit=0, this is done by FSP.
90 if (!CONFIG(USE_INTEL_FSP_MP_INIT
))
94 static void soc_finalize(void *unused
)
100 /* Check if PMC is enabled, else return */
104 printk(BIOS_DEBUG
, "Finalizing chipset.\n");
106 pch_finalize_script(dev
);
109 apm_control(APM_CNT_FINALIZE
);
111 /* Indicate finalize step with post code */
112 post_code(POSTCODE_OS_BOOT
);
115 BOOT_STATE_INIT_ENTRY(BS_OS_RESUME
, BS_ON_ENTRY
, soc_finalize
, NULL
);
116 BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD
, BS_ON_EXIT
, soc_finalize
, NULL
);