blob: fd80aeac1a01a4a460266525b3f3abb87f69c6d4 [file] [log] [blame]
Angel Pons3bd1e3d2020-04-05 15:47:17 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahyb0005132015-05-12 18:19:47 -07002
Lee Leahyb0005132015-05-12 18:19:47 -07003#include <bootstate.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -07004#include <commonlib/console/post_codes.h>
Lee Leahyb0005132015-05-12 18:19:47 -07005#include <console/console.h>
Michael Niewöhner48fb5732019-09-22 21:56:17 +02006#include <cpu/x86/mp.h>
Lee Leahyb0005132015-05-12 18:19:47 -07007#include <cpu/x86/smm.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -07008#include <device/mmio.h>
Subrata Banike7ceae72017-03-08 17:59:40 +05309#include <device/pci.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070010#include <device/pci_ops.h>
Pratik Prajapati1b25c8e2018-05-18 18:07:25 -070011#include <intelblocks/cpulib.h>
Subrata Banikbe3e9112022-01-28 03:12:35 +053012#include <intelblocks/cse.h>
Ravi Sarawadi1483d1f2017-09-28 17:06:01 -070013#include <intelblocks/lpc_lib.h>
Subrata Banikc51df932018-05-08 11:58:01 +053014#include <intelblocks/p2sb.h>
Subrata Banike7ceae72017-03-08 17:59:40 +053015#include <intelblocks/pcr.h>
Subrata Banik0359d9d2020-09-28 18:43:47 +053016#include <intelblocks/pmclib.h>
Michael Niewöhner5a7dc9e2019-09-17 16:03:18 +020017#include <intelblocks/tco.h>
Subrata Banikc077b222019-08-01 10:50:35 +053018#include <intelblocks/thermal.h>
Dhaval Sharma9dca83c2016-01-18 17:28:20 +053019#include <soc/me.h>
Rizwan Qureshicf73c132016-08-04 20:01:12 +053020#include <soc/p2sb.h>
Lee Leahyb0005132015-05-12 18:19:47 -070021#include <soc/pci_devs.h>
Subrata Banike7ceae72017-03-08 17:59:40 +053022#include <soc/pcr_ids.h>
Lee Leahy1d14b3e2015-05-12 18:23:27 -070023#include <soc/pm.h>
Barnali Sarkar0dddcd72016-08-02 17:49:56 +053024#include <soc/smbus.h>
Lee Leahyb0005132015-05-12 18:19:47 -070025#include <soc/systemagent.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070026#include <spi-generic.h>
Subrata Banike7ceae72017-03-08 17:59:40 +053027
Elyes HAOUASc3385072019-03-21 15:38:06 +010028#include "chip.h"
29
Subrata Banike7ceae72017-03-08 17:59:40 +053030#define PSF_BASE_ADDRESS 0xA00
31#define PCR_PSFX_T0_SHDW_PCIEN 0x1C
32#define PCR_PSFX_T0_SHDW_PCIEN_FUNDIS (1 << 8)
Archana Patni7846e342015-11-11 01:29:23 +053033
Subrata Banikbe3e9112022-01-28 03:12:35 +053034void soc_disable_heci1_using_pcr(void)
Barnali Sarkarfbf10182017-08-11 18:38:38 +053035{
Archana Patni7846e342015-11-11 01:29:23 +053036 /* unhide p2sb device */
Subrata Banikc51df932018-05-08 11:58:01 +053037 p2sb_unhide();
Archana Patni7846e342015-11-11 01:29:23 +053038
39 /* disable heci */
Subrata Banike7ceae72017-03-08 17:59:40 +053040 pcr_or32(PID_PSF1, PSF_BASE_ADDRESS + PCR_PSFX_T0_SHDW_PCIEN,
41 PCR_PSFX_T0_SHDW_PCIEN_FUNDIS);
Archana Patni7846e342015-11-11 01:29:23 +053042
Patrick Rudolph5199e822019-09-26 14:00:14 +020043 p2sb_disable_sideband_access();
Archana Patni7846e342015-11-11 01:29:23 +053044}
Lee Leahyb0005132015-05-12 18:19:47 -070045
Subrata Banikc51df932018-05-08 11:58:01 +053046static void pch_finalize_script(struct device *dev)
Lee Leahy1d14b3e2015-05-12 18:23:27 -070047{
Michael Niewöhner5a7dc9e2019-09-17 16:03:18 +020048 tco_lockdown();
49
Dhaval Sharma9dca83c2016-01-18 17:28:20 +053050 /* Display me status before we hide it */
51 intel_me_status();
52
Archana Patni6c1bf272015-12-18 23:38:21 +053053 /*
Subrata Banik771d6112017-11-29 16:17:13 +053054 * Set low maximum temp value used for dynamic thermal sensor
55 * shutdown consideration.
56 *
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.
59 */
60 pch_thermal_configuration();
61
Subrata Banika0d9ad32022-01-03 18:07:13 +000062 /* we should disable Heci1 based on the config */
63 if (CONFIG(DISABLE_HECI1_AT_PRE_BOOT))
Subrata Banikbe3e9112022-01-28 03:12:35 +053064 heci1_disable();
Patrick Rudolph5199e822019-09-26 14:00:14 +020065
66 /* Hide p2sb device as the OS must not change BAR0. */
67 p2sb_hide();
Subrata Banik112ffd72022-02-06 18:39:54 +053068
69 pmc_clear_pmcon_sts();
Lee Leahy1d14b3e2015-05-12 18:23:27 -070070}
Lee Leahyb0005132015-05-12 18:19:47 -070071
Subrata Banikc51df932018-05-08 11:58:01 +053072static void soc_lockdown(struct device *dev)
Rizwan Qureshie64f7942015-11-19 16:01:54 +053073{
Barnali Sarkar0818a2a2017-08-17 11:52:39 +053074 struct soc_intel_skylake_config *config;
Rizwan Qureshie64f7942015-11-19 16:01:54 +053075 u8 reg8;
Barnali Sarkar0818a2a2017-08-17 11:52:39 +053076
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +030077 config = config_of(dev);
Rizwan Qureshie64f7942015-11-19 16:01:54 +053078
79 /* Global SMI Lock */
80 if (config->LockDownConfigGlobalSmi == 0) {
Rizwan Qureshie64f7942015-11-19 16:01:54 +053081 reg8 = pci_read_config8(dev, GEN_PMCON_A);
82 reg8 |= SMI_LOCK;
83 pci_write_config8(dev, GEN_PMCON_A, reg8);
84 }
Michael Niewöhner48fb5732019-09-22 21:56:17 +020085
Michael Niewöhner348f2a62020-08-05 21:38:59 +020086 /*
87 * Lock chipset memory registers to protect SMM.
88 * When SkipMpInit=0, this is done by FSP.
89 */
90 if (!CONFIG(USE_INTEL_FSP_MP_INIT))
91 cpu_lt_lock_memory();
Rizwan Qureshie64f7942015-11-19 16:01:54 +053092}
93
Lee Leahy1d14b3e2015-05-12 18:23:27 -070094static void soc_finalize(void *unused)
Lee Leahyb0005132015-05-12 18:19:47 -070095{
Subrata Banikc51df932018-05-08 11:58:01 +053096 struct device *dev;
97
98 dev = PCH_DEV_PMC;
99
100 /* Check if PMC is enabled, else return */
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +0300101 if (dev == NULL)
Subrata Banikc51df932018-05-08 11:58:01 +0530102 return;
103
Lee Leahyb0005132015-05-12 18:19:47 -0700104 printk(BIOS_DEBUG, "Finalizing chipset.\n");
Rizwan Qureshie64f7942015-11-19 16:01:54 +0530105
Subrata Banikc51df932018-05-08 11:58:01 +0530106 pch_finalize_script(dev);
Lee Leahyb0005132015-05-12 18:19:47 -0700107
Subrata Banikc51df932018-05-08 11:58:01 +0530108 soc_lockdown(dev);
Kyösti Mälkkib6585482020-06-01 15:11:14 +0300109 apm_control(APM_CNT_FINALIZE);
Duncan Laurie6f0e6fa2016-02-09 09:40:39 -0800110
Lee Leahyb0005132015-05-12 18:19:47 -0700111 /* Indicate finalize step with post code */
lilacious40cb3fe2023-06-21 23:24:14 +0200112 post_code(POSTCODE_OS_BOOT);
Lee Leahyb0005132015-05-12 18:19:47 -0700113}
114
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700115BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
116BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);