blob: bc0f5a5678449f7d58275bb958687e24c17f9885 [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
Subrata Banika4b11e5c2017-02-03 18:57:49 +05304 * Copyright (C) 2016-2017 Intel Corporation.
Lee Leahyb0005132015-05-12 18:19:47 -07005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Lee Leahyb0005132015-05-12 18:19:47 -070014 */
15
Lee Leahy1d14b3e2015-05-12 18:23:27 -070016#include <chip.h>
Duncan Laurie7d484102017-01-09 22:23:39 -080017#include <bootmode.h>
Rizwan Qureshi1222a732016-08-23 14:31:23 +053018#include <bootstate.h>
19#include <device/pci.h>
20#include <fsp/api.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053021#include <arch/acpi.h>
22#include <chip.h>
23#include <bootstate.h>
24#include <console/console.h>
25#include <device/device.h>
26#include <device/pci.h>
27#include <fsp/api.h>
28#include <fsp/util.h>
Brandon Breitensteinc6ec8dd2016-11-17 12:23:04 -080029#include <romstage_handoff.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053030#include <soc/acpi.h>
Patrick Georgic6a00502017-10-05 18:19:29 +020031#include <soc/intel/common/vbt.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053032#include <soc/interrupt.h>
33#include <soc/irq.h>
34#include <soc/pci_devs.h>
35#include <soc/ramstage.h>
36#include <string.h>
37
38void soc_init_pre_device(void *chip_info)
39{
40 /* Perform silicon specific init. */
Aaron Durbin6c191d82016-11-29 21:22:42 -060041 fsp_silicon_init(romstage_handoff_is_resume());
Naresh G Solankia2d40622016-08-30 20:47:13 +053042}
43
Furquan Shaikhc2480442017-02-20 13:41:56 -080044void soc_fsp_load(void)
45{
46 fsps_load(romstage_handoff_is_resume());
47}
48
Naresh G Solankia2d40622016-08-30 20:47:13 +053049static void pci_domain_set_resources(device_t dev)
50{
51 assign_resources(dev->link_list);
52}
53
54static struct device_operations pci_domain_ops = {
55 .read_resources = &pci_domain_read_resources,
56 .set_resources = &pci_domain_set_resources,
57 .scan_bus = &pci_domain_scan_bus,
58 .ops_pci_bus = &pci_bus_default_ops,
59#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
60 .acpi_name = &soc_acpi_name,
61#endif
62};
63
64static struct device_operations cpu_bus_ops = {
65 .read_resources = DEVICE_NOOP,
66 .set_resources = DEVICE_NOOP,
67 .enable_resources = DEVICE_NOOP,
Subrata Banika4b11e5c2017-02-03 18:57:49 +053068 .init = DEVICE_NOOP,
Naresh G Solankia2d40622016-08-30 20:47:13 +053069#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
70 .acpi_fill_ssdt_generator = generate_cpu_entries,
71#endif
72};
73
74static void soc_enable(device_t dev)
75{
76 /* Set the operations if it is a special bus type */
77 if (dev->path.type == DEVICE_PATH_DOMAIN) {
78 dev->ops = &pci_domain_ops;
79 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
80 dev->ops = &cpu_bus_ops;
81 } else if (dev->path.type == DEVICE_PATH_PCI) {
82 /* Handle PCH device enable */
83 if (PCI_SLOT(dev->path.pci.devfn) > SA_DEV_SLOT_IGD &&
84 (dev->ops == NULL || dev->ops->enable == NULL)) {
85 pch_enable_dev(dev);
86 }
87 }
88}
89
90struct chip_operations soc_intel_skylake_ops = {
91 CHIP_NAME("Intel 6th Gen")
92 .enable_dev = &soc_enable,
93 .init = &soc_init_pre_device,
94};
Lee Leahyb0005132015-05-12 18:19:47 -070095
Rizwan Qureshi1222a732016-08-23 14:31:23 +053096/* UPD parameters to be initialized before SiliconInit */
Naresh G Solankia2d40622016-08-30 20:47:13 +053097void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
Rizwan Qureshi1222a732016-08-23 14:31:23 +053098{
Naresh G Solankia2d40622016-08-30 20:47:13 +053099 FSP_S_CONFIG *params = &supd->FspsConfig;
100 FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig;
101 static struct soc_intel_skylake_config *config;
102 uintptr_t vbt_data = 0;
103
104 int i;
105
106 int is_s3_wakeup = acpi_is_wakeup_s3();
107
108 struct device *dev = SA_DEV_ROOT;
109 if (!dev || !dev->chip_info) {
110 printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
111 return;
112 }
113 config = dev->chip_info;
114
115 mainboard_silicon_init_params(params);
116
117 /* Load VBT */
Duncan Laurie7d484102017-01-09 22:23:39 -0800118 if (is_s3_wakeup) {
119 printk(BIOS_DEBUG, "S3 resume do not pass VBT to GOP\n");
Patrick Georgic6a00502017-10-05 18:19:29 +0200120 } else if (display_init_required() && IS_ENABLED(CONFIG_RUN_FSP_GOP)) {
Duncan Laurie7d484102017-01-09 22:23:39 -0800121 /* Get VBT data */
Patrick Georgic6a00502017-10-05 18:19:29 +0200122 vbt_data = (uintptr_t)locate_vbt();
Duncan Laurie7d484102017-01-09 22:23:39 -0800123 if (vbt_data)
124 printk(BIOS_DEBUG, "Passing VBT to GOP\n");
125 else
126 printk(BIOS_DEBUG, "VBT not found!\n");
127 } else {
128 printk(BIOS_DEBUG, "Not passing VBT to GOP\n");
129 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530130 params->GraphicsConfigPtr = (u32) vbt_data;
131
132 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
133 params->PortUsb20Enable[i] =
134 config->usb2_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530135 params->Usb2OverCurrentPin[i] =
136 config->usb2_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530137 params->Usb2AfePetxiset[i] =
138 config->usb2_ports[i].pre_emp_bias;
139 params->Usb2AfeTxiset[i] =
140 config->usb2_ports[i].tx_bias;
141 params->Usb2AfePredeemp[i] =
142 config->usb2_ports[i].tx_emp_enable;
143 params->Usb2AfePehalfbit[i] =
144 config->usb2_ports[i].pre_emp_bit;
145 }
146
147 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
148 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530149 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530150 if (config->usb3_ports[i].tx_de_emp) {
151 params->Usb3HsioTxDeEmphEnable[i] = 1;
152 params->Usb3HsioTxDeEmph[i] =
153 config->usb3_ports[i].tx_de_emp;
154 }
155 if (config->usb3_ports[i].tx_downscale_amp) {
156 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
157 params->Usb3HsioTxDownscaleAmp[i] =
158 config->usb3_ports[i].tx_downscale_amp;
159 }
160 }
161
162 memcpy(params->SataPortsEnable, config->SataPortsEnable,
163 sizeof(params->SataPortsEnable));
164 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
165 sizeof(params->SataPortsDevSlp));
166 memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport,
167 sizeof(params->PcieRpClkReqSupport));
168 memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber,
169 sizeof(params->PcieRpClkReqNumber));
Rizwan Qureshi6ab4ed42017-09-05 14:18:25 +0530170 memcpy(params->PcieRpAdvancedErrorReporting,
171 config->PcieRpAdvancedErrorReporting,
172 sizeof(params->PcieRpAdvancedErrorReporting));
Rizwan Qureshi03937392017-09-16 01:54:20 +0530173 memcpy(params->PcieRpLtrEnable, config->PcieRpLtrEnable,
174 sizeof(params->PcieRpLtrEnable));
Naresh G Solankia2d40622016-08-30 20:47:13 +0530175
Naresh G Solankieedf6d82016-11-16 21:27:38 +0530176 /* disable Legacy PME */
177 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
178
Naresh G Solankia2d40622016-08-30 20:47:13 +0530179 memcpy(params->SerialIoDevMode, config->SerialIoDevMode,
180 sizeof(params->SerialIoDevMode));
181
182 params->PchCio2Enable = config->Cio2Enable;
Rizwan Qureshic2c8a742017-01-13 22:04:11 +0530183 params->SaImguEnable = config->SaImguEnable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530184 params->Heci3Enabled = config->Heci3Enabled;
185
186 params->LogoPtr = config->LogoPtr;
187 params->LogoSize = config->LogoSize;
188
189 params->CpuConfig.Bits.VmxEnable = config->VmxEnable;
190
191 params->PchPmWoWlanEnable = config->PchPmWoWlanEnable;
192 params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable;
193 params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
194
195 params->PchLanEnable = config->EnableLan;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530196 params->SataSalpSupport = config->SataSalpSupport;
197 params->SsicPortEnable = config->SsicPortEnable;
198 params->ScsEmmcEnabled = config->ScsEmmcEnabled;
199 params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
200 params->ScsSdCardEnabled = config->ScsSdCardEnabled;
201 params->PchIshEnable = config->IshEnable;
202 params->PchHdaEnable = config->EnableAzalia;
203 params->PchHdaIoBufferOwnership = config->IoBufferOwnership;
204 params->PchHdaDspEnable = config->DspEnable;
205 params->XdciEnable = config->XdciEnable;
206 params->Device4Enable = config->Device4Enable;
207 params->SataEnable = config->EnableSata;
208 params->SataMode = config->SataMode;
Matt DeVillier9e0d69b2017-10-10 14:03:36 -0500209 params->SataSpeedLimit = config->SataSpeedLimit;
210
Naresh G Solankia2d40622016-08-30 20:47:13 +0530211 tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530212 tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock;
Barnali Sarkarfbf10182017-08-11 18:38:38 +0530213 /*
214 * To disable HECI, the Psf needs to be left unlocked
215 * by FSP till end of post sequence. Based on the devicetree
216 * setting, we set the appropriate PsfUnlock policy in FSP,
217 * do the changes and then lock it back in coreboot during finalize.
218 */
219 tconfig->PchSbAccessUnlock = (config->HeciEnabled == 0) ? 1 : 0;
Subrata Banikc204aaa2017-08-17 15:49:58 +0530220 if (config->chipset_lockdown == CHIPSET_LOCKDOWN_COREBOOT) {
221 tconfig->PchLockDownBiosInterface = 0;
222 params->PchLockDownBiosLock = 0;
223 params->PchLockDownSpiEiss = 0;
224 /*
225 * Skip Spi Flash Lockdown from inside FSP.
226 * Making this config "0" means FSP won't set the FLOCKDN bit
227 * of SPIBAR + 0x04 (i.e., Bit 15 of BIOS_HSFSTS_CTL).
228 * So, it becomes coreboot's responsibility to set this bit
229 * before end of POST for security concerns.
230 */
231 params->SpiFlashCfgLockDown = 0;
232 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530233 params->PchSubSystemVendorId = config->PchConfigSubSystemVendorId;
234 params->PchSubSystemId = config->PchConfigSubSystemId;
235 params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride;
236 params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
237 params->PchPmDeepSxPol = config->PmConfigDeepSxPol;
Duncan Laurie25c7d932017-02-17 17:16:43 -0800238 params->PchPmSlpS0Enable = config->s0ix_enable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530239 params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert;
240 params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert;
241 params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert;
242 params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert;
243 params->PchPmLpcClockRun = config->PmConfigPciClockRun;
244 params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp;
245 params->PchPmPwrBtnOverridePeriod =
246 config->PmConfigPwrBtnOverridePeriod;
247 params->PchPmPwrCycDur = config->PmConfigPwrCycDur;
Rizwan Qureshi0da186c2017-02-23 14:43:39 +0530248
249 /* Indicate whether platform supports Voltage Margining */
250 params->PchPmSlpS0VmEnable = config->PchPmSlpS0VmEnable;
251
Naresh G Solankia2d40622016-08-30 20:47:13 +0530252 params->PchSirqEnable = config->SerialIrqConfigSirqEnable;
253 params->PchSirqMode = config->SerialIrqConfigSirqMode;
254
255 params->CpuConfig.Bits.SkipMpInit = config->FspSkipMpInit;
256
257 for (i = 0; i < ARRAY_SIZE(config->i2c); i++)
Aaron Durbined14a4e2016-11-09 17:04:15 -0600258 params->SerialIoI2cVoltage[i] = config->i2c_voltage[i];
Naresh G Solankia2d40622016-08-30 20:47:13 +0530259
260 for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++)
261 fill_vr_domain_config(params, i, &config->domain_vr_config[i]);
262
263 /* Show SPI controller if enabled in devicetree.cb */
264 dev = dev_find_slot(0, PCH_DEVFN_SPI);
265 params->ShowSpiController = dev->enabled;
266
Rizwan Qureshi64670142016-11-23 15:25:19 +0530267 /*
268 * Send VR specific mailbox commands:
269 * 000b - no VR specific command sent
270 * 001b - VR mailbox command specifically for the MPS IMPV8 VR
Lee Leahyf4c4ab92017-03-16 17:08:03 -0700271 * will be sent
Rizwan Qureshi64670142016-11-23 15:25:19 +0530272 * 010b - VR specific command sent for PS4 exit issue
273 * 100b - VR specific command sent for MPS VR decay issue
274 */
275 params->SendVrMbxCmd1 = config->SendVrMbxCmd;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530276
Rizwan Qureshib3e18c72017-09-25 17:35:15 +0530277 /*
278 * Activates VR mailbox command for Intersil VR C-state issues.
279 * 0 - no mailbox command sent.
280 * 1 - VR mailbox command sent for IA/GT rails only.
281 * 2 - VR mailbox command sent for IA/GT/SA rails.
282 */
283 params->IslVrCmd = config->IslVrCmd;
284
Duncan Laurieb2aac852017-03-07 19:12:02 -0800285 /* Acoustic Noise Mitigation */
286 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
287 params->SlowSlewRateForIa = config->SlowSlewRateForIa;
288 params->SlowSlewRateForGt = config->SlowSlewRateForGt;
289 params->SlowSlewRateForSa = config->SlowSlewRateForSa;
290 params->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa;
291 params->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt;
292 params->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa;
293
Rizwan Qureshiffe58102017-02-10 15:58:24 +0530294 /* Enable PMC XRAM read */
295 tconfig->PchPmPmcReadDisable = config->PchPmPmcReadDisable;
296
Subrata Banik6b45ee42017-05-12 11:43:57 +0530297 /* Enable/Disable EIST */
298 tconfig->Eist = config->eist_enable;
299
Naresh G Solankia2d40622016-08-30 20:47:13 +0530300 soc_irq_settings(params);
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530301}
Lee Leahyb0005132015-05-12 18:19:47 -0700302
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530303struct pci_operations soc_pci_ops = {
Naresh G Solankia2d40622016-08-30 20:47:13 +0530304 .set_subsystem = &pci_dev_set_subsystem
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530305};
Lee Leahyb0005132015-05-12 18:19:47 -0700306
Naresh G Solankia2d40622016-08-30 20:47:13 +0530307/* Mainboard GPIO Configuration */
308__attribute__((weak)) void mainboard_silicon_init_params(FSP_S_CONFIG *params)
309{
310 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
311}