blob: 12dbab4814ff2e51a811061a6ed3ef3b544b4410 [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
Lee Leahy1d14b3e2015-05-12 18:23:27 -07005 * Copyright (C) 2015 Intel Corporation.
Lee Leahyb0005132015-05-12 18:19:47 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Lee Leahyb0005132015-05-12 18:19:47 -070015 */
16
17#include <arch/io.h>
18#include <bootstate.h>
Rizwan Qureshie64f7942015-11-19 16:01:54 +053019#include <chip.h>
Lee Leahyb0005132015-05-12 18:19:47 -070020#include <console/console.h>
21#include <console/post_codes.h>
22#include <cpu/x86/smm.h>
Subrata Banike7ceae72017-03-08 17:59:40 +053023#include <device/pci.h>
Ravi Sarawadi1483d1f2017-09-28 17:06:01 -070024#include <intelblocks/lpc_lib.h>
Subrata Banikc51df932018-05-08 11:58:01 +053025#include <intelblocks/p2sb.h>
Subrata Banike7ceae72017-03-08 17:59:40 +053026#include <intelblocks/pcr.h>
Lee Leahyb0005132015-05-12 18:19:47 -070027#include <reg_script.h>
28#include <spi-generic.h>
Dhaval Sharma9dca83c2016-01-18 17:28:20 +053029#include <soc/me.h>
Rizwan Qureshicf73c132016-08-04 20:01:12 +053030#include <soc/p2sb.h>
Lee Leahyb0005132015-05-12 18:19:47 -070031#include <soc/pci_devs.h>
Subrata Banike7ceae72017-03-08 17:59:40 +053032#include <soc/pcr_ids.h>
Lee Leahy1d14b3e2015-05-12 18:23:27 -070033#include <soc/pm.h>
Barnali Sarkar0dddcd72016-08-02 17:49:56 +053034#include <soc/smbus.h>
Lee Leahyb0005132015-05-12 18:19:47 -070035#include <soc/systemagent.h>
Subrata Banik771d6112017-11-29 16:17:13 +053036#include <soc/thermal.h>
Barnali Sarkar71464452017-03-31 18:11:49 +053037#include <stdlib.h>
Subrata Banike7ceae72017-03-08 17:59:40 +053038
Subrata Banike7ceae72017-03-08 17:59:40 +053039#define PSF_BASE_ADDRESS 0xA00
40#define PCR_PSFX_T0_SHDW_PCIEN 0x1C
41#define PCR_PSFX_T0_SHDW_PCIEN_FUNDIS (1 << 8)
Archana Patni7846e342015-11-11 01:29:23 +053042
Subrata Banik7837c202018-05-07 17:13:40 +053043static void disable_sideband_access(void)
Archana Patni7846e342015-11-11 01:29:23 +053044{
Subrata Banik7837c202018-05-07 17:13:40 +053045 p2sb_disable_sideband_access();
Barnali Sarkarfbf10182017-08-11 18:38:38 +053046
47 /* hide p2sb device */
Subrata Banikc51df932018-05-08 11:58:01 +053048 p2sb_hide();
Barnali Sarkarfbf10182017-08-11 18:38:38 +053049}
50
51static void pch_disable_heci(void)
52{
Archana Patni7846e342015-11-11 01:29:23 +053053 /* unhide p2sb device */
Subrata Banikc51df932018-05-08 11:58:01 +053054 p2sb_unhide();
Archana Patni7846e342015-11-11 01:29:23 +053055
56 /* disable heci */
Subrata Banike7ceae72017-03-08 17:59:40 +053057 pcr_or32(PID_PSF1, PSF_BASE_ADDRESS + PCR_PSFX_T0_SHDW_PCIEN,
58 PCR_PSFX_T0_SHDW_PCIEN_FUNDIS);
Archana Patni7846e342015-11-11 01:29:23 +053059
Subrata Banik7837c202018-05-07 17:13:40 +053060 disable_sideband_access();
Archana Patni7846e342015-11-11 01:29:23 +053061}
Lee Leahyb0005132015-05-12 18:19:47 -070062
Subrata Banikc51df932018-05-08 11:58:01 +053063static void pch_finalize_script(struct device *dev)
Lee Leahy1d14b3e2015-05-12 18:23:27 -070064{
Barnali Sarkar71464452017-03-31 18:11:49 +053065 uint32_t reg32;
Lee Leahy1d14b3e2015-05-12 18:23:27 -070066 uint8_t *pmcbase;
Archana Patni7846e342015-11-11 01:29:23 +053067 config_t *config;
Archana Patni6c1bf272015-12-18 23:38:21 +053068 u8 reg8;
Lee Leahyb0005132015-05-12 18:19:47 -070069
Dhaval Sharma9dca83c2016-01-18 17:28:20 +053070 /* Display me status before we hide it */
71 intel_me_status();
72
Subrata Banik639bf8a2017-08-25 12:08:59 +053073 pmcbase = pmc_mmio_regs();
Archana Patni7846e342015-11-11 01:29:23 +053074 config = dev->chip_info;
Archana Patni6c1bf272015-12-18 23:38:21 +053075
76 /*
Subrata Banik771d6112017-11-29 16:17:13 +053077 * Set low maximum temp value used for dynamic thermal sensor
78 * shutdown consideration.
79 *
80 * If Dynamic Thermal Shutdown is enabled then PMC logic shuts down the
81 * thermal sensor when CPU is in a C-state and DTS Temp <= LTT.
82 */
83 pch_thermal_configuration();
84
85 /*
Archana Patni6c1bf272015-12-18 23:38:21 +053086 * Disable ACPI PM timer based on dt policy
87 *
88 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
89 * Disabling ACPI PM timer also switches off TCO
90 */
91
92 if (config->PmTimerDisabled) {
93 reg8 = read8(pmcbase + PCH_PWRM_ACPI_TMR_CTL);
94 reg8 |= (1 << 1);
95 write8(pmcbase + PCH_PWRM_ACPI_TMR_CTL, reg8);
96 }
97
Naresh G Solankic261c4b2017-04-25 12:09:07 +053098 /* Disable XTAL shutdown qualification for low power idle. */
99 if (config->s0ix_enable) {
100 reg32 = read32(pmcbase + CIR31C);
101 reg32 |= XTALSDQDIS;
102 write32(pmcbase + CIR31C, reg32);
103 }
104
Archana Patni6c1bf272015-12-18 23:38:21 +0530105 /* we should disable Heci1 based on the devicetree policy */
Archana Patni7846e342015-11-11 01:29:23 +0530106 if (config->HeciEnabled == 0)
107 pch_disable_heci();
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700108}
Lee Leahyb0005132015-05-12 18:19:47 -0700109
Subrata Banikc51df932018-05-08 11:58:01 +0530110static void soc_lockdown(struct device *dev)
Rizwan Qureshie64f7942015-11-19 16:01:54 +0530111{
Barnali Sarkar0818a2a2017-08-17 11:52:39 +0530112 struct soc_intel_skylake_config *config;
Rizwan Qureshie64f7942015-11-19 16:01:54 +0530113 u8 reg8;
Barnali Sarkar0818a2a2017-08-17 11:52:39 +0530114
Barnali Sarkar0818a2a2017-08-17 11:52:39 +0530115 config = dev->chip_info;
Rizwan Qureshie64f7942015-11-19 16:01:54 +0530116
117 /* Global SMI Lock */
118 if (config->LockDownConfigGlobalSmi == 0) {
Rizwan Qureshie64f7942015-11-19 16:01:54 +0530119 reg8 = pci_read_config8(dev, GEN_PMCON_A);
120 reg8 |= SMI_LOCK;
121 pci_write_config8(dev, GEN_PMCON_A, reg8);
122 }
Rizwan Qureshie64f7942015-11-19 16:01:54 +0530123}
124
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700125static void soc_finalize(void *unused)
Lee Leahyb0005132015-05-12 18:19:47 -0700126{
Subrata Banikc51df932018-05-08 11:58:01 +0530127 struct device *dev;
128
129 dev = PCH_DEV_PMC;
130
131 /* Check if PMC is enabled, else return */
132 if (dev == NULL || dev->chip_info == NULL)
133 return;
134
Lee Leahyb0005132015-05-12 18:19:47 -0700135 printk(BIOS_DEBUG, "Finalizing chipset.\n");
Rizwan Qureshie64f7942015-11-19 16:01:54 +0530136
Subrata Banikc51df932018-05-08 11:58:01 +0530137 pch_finalize_script(dev);
Lee Leahyb0005132015-05-12 18:19:47 -0700138
Subrata Banikc51df932018-05-08 11:58:01 +0530139 soc_lockdown(dev);
Rizwan Qureshie64f7942015-11-19 16:01:54 +0530140
Duncan Laurie6f0e6fa2016-02-09 09:40:39 -0800141 printk(BIOS_DEBUG, "Finalizing SMM.\n");
142 outb(APM_CNT_FINALIZE, APM_CNT);
143
Lee Leahyb0005132015-05-12 18:19:47 -0700144 /* Indicate finalize step with post code */
145 post_code(POST_OS_BOOT);
146}
147
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700148BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
149BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);