blob: 4ac73b57c695f3adbcb05548860017868dabc5eb [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>
Duncan Laurief5116952018-03-26 02:24:18 -070029#include <intelblocks/xdci.h>
Brandon Breitensteinc6ec8dd2016-11-17 12:23:04 -080030#include <romstage_handoff.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053031#include <soc/acpi.h>
Patrick Georgic6a00502017-10-05 18:19:29 +020032#include <soc/intel/common/vbt.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053033#include <soc/interrupt.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020034#include <soc/iomap.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053035#include <soc/irq.h>
36#include <soc/pci_devs.h>
37#include <soc/ramstage.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020038#include <soc/systemagent.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053039#include <string.h>
40
41void soc_init_pre_device(void *chip_info)
42{
43 /* Perform silicon specific init. */
Aaron Durbin6c191d82016-11-29 21:22:42 -060044 fsp_silicon_init(romstage_handoff_is_resume());
Naresh G Solankia2d40622016-08-30 20:47:13 +053045}
46
Furquan Shaikhc2480442017-02-20 13:41:56 -080047void soc_fsp_load(void)
48{
49 fsps_load(romstage_handoff_is_resume());
50}
51
Naresh G Solankia2d40622016-08-30 20:47:13 +053052static void pci_domain_set_resources(device_t dev)
53{
54 assign_resources(dev->link_list);
55}
56
57static struct device_operations pci_domain_ops = {
58 .read_resources = &pci_domain_read_resources,
59 .set_resources = &pci_domain_set_resources,
60 .scan_bus = &pci_domain_scan_bus,
61 .ops_pci_bus = &pci_bus_default_ops,
62#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
63 .acpi_name = &soc_acpi_name,
64#endif
65};
66
67static struct device_operations cpu_bus_ops = {
68 .read_resources = DEVICE_NOOP,
69 .set_resources = DEVICE_NOOP,
70 .enable_resources = DEVICE_NOOP,
Subrata Banika4b11e5c2017-02-03 18:57:49 +053071 .init = DEVICE_NOOP,
Naresh G Solankia2d40622016-08-30 20:47:13 +053072#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
73 .acpi_fill_ssdt_generator = generate_cpu_entries,
74#endif
75};
76
77static void soc_enable(device_t dev)
78{
79 /* Set the operations if it is a special bus type */
Subrata Banik3c838c72017-12-06 18:14:01 +053080 if (dev->path.type == DEVICE_PATH_DOMAIN)
Naresh G Solankia2d40622016-08-30 20:47:13 +053081 dev->ops = &pci_domain_ops;
Subrata Banik3c838c72017-12-06 18:14:01 +053082 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
Naresh G Solankia2d40622016-08-30 20:47:13 +053083 dev->ops = &cpu_bus_ops;
Naresh G Solankia2d40622016-08-30 20:47:13 +053084}
85
86struct chip_operations soc_intel_skylake_ops = {
87 CHIP_NAME("Intel 6th Gen")
88 .enable_dev = &soc_enable,
89 .init = &soc_init_pre_device,
90};
Lee Leahyb0005132015-05-12 18:19:47 -070091
Rizwan Qureshi1222a732016-08-23 14:31:23 +053092/* UPD parameters to be initialized before SiliconInit */
Naresh G Solankia2d40622016-08-30 20:47:13 +053093void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
Rizwan Qureshi1222a732016-08-23 14:31:23 +053094{
Naresh G Solankia2d40622016-08-30 20:47:13 +053095 FSP_S_CONFIG *params = &supd->FspsConfig;
96 FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig;
97 static struct soc_intel_skylake_config *config;
98 uintptr_t vbt_data = 0;
Naresh G Solankia2d40622016-08-30 20:47:13 +053099 int i;
100
101 int is_s3_wakeup = acpi_is_wakeup_s3();
102
103 struct device *dev = SA_DEV_ROOT;
104 if (!dev || !dev->chip_info) {
105 printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
106 return;
107 }
108 config = dev->chip_info;
109
110 mainboard_silicon_init_params(params);
Gaggery Tsaida6f4ae2018-01-15 15:03:01 +0800111 /* Set PsysPmax if it is available from DT */
112 if (config->psys_pmax) {
113 /* PsysPmax is in unit of 1/8 Watt */
114 tconfig->PsysPmax = config->psys_pmax * 8;
115 printk(BIOS_DEBUG, "psys_pmax = %d\n", tconfig->PsysPmax);
116 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530117
118 /* Load VBT */
Duncan Laurie7d484102017-01-09 22:23:39 -0800119 if (is_s3_wakeup) {
120 printk(BIOS_DEBUG, "S3 resume do not pass VBT to GOP\n");
Patrick Georgic6a00502017-10-05 18:19:29 +0200121 } else if (display_init_required() && IS_ENABLED(CONFIG_RUN_FSP_GOP)) {
Duncan Laurie7d484102017-01-09 22:23:39 -0800122 /* Get VBT data */
Patrick Georgic6a00502017-10-05 18:19:29 +0200123 vbt_data = (uintptr_t)locate_vbt();
Duncan Laurie7d484102017-01-09 22:23:39 -0800124 if (vbt_data)
125 printk(BIOS_DEBUG, "Passing VBT to GOP\n");
126 else
127 printk(BIOS_DEBUG, "VBT not found!\n");
128 } else {
129 printk(BIOS_DEBUG, "Not passing VBT to GOP\n");
130 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530131 params->GraphicsConfigPtr = (u32) vbt_data;
132
133 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
134 params->PortUsb20Enable[i] =
135 config->usb2_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530136 params->Usb2OverCurrentPin[i] =
137 config->usb2_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530138 params->Usb2AfePetxiset[i] =
139 config->usb2_ports[i].pre_emp_bias;
140 params->Usb2AfeTxiset[i] =
141 config->usb2_ports[i].tx_bias;
142 params->Usb2AfePredeemp[i] =
143 config->usb2_ports[i].tx_emp_enable;
144 params->Usb2AfePehalfbit[i] =
145 config->usb2_ports[i].pre_emp_bit;
146 }
147
148 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
149 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530150 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530151 if (config->usb3_ports[i].tx_de_emp) {
152 params->Usb3HsioTxDeEmphEnable[i] = 1;
153 params->Usb3HsioTxDeEmph[i] =
154 config->usb3_ports[i].tx_de_emp;
155 }
156 if (config->usb3_ports[i].tx_downscale_amp) {
157 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
158 params->Usb3HsioTxDownscaleAmp[i] =
159 config->usb3_ports[i].tx_downscale_amp;
160 }
161 }
162
163 memcpy(params->SataPortsEnable, config->SataPortsEnable,
164 sizeof(params->SataPortsEnable));
165 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
166 sizeof(params->SataPortsDevSlp));
167 memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport,
168 sizeof(params->PcieRpClkReqSupport));
169 memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber,
170 sizeof(params->PcieRpClkReqNumber));
Rizwan Qureshi6ab4ed42017-09-05 14:18:25 +0530171 memcpy(params->PcieRpAdvancedErrorReporting,
172 config->PcieRpAdvancedErrorReporting,
173 sizeof(params->PcieRpAdvancedErrorReporting));
Rizwan Qureshi03937392017-09-16 01:54:20 +0530174 memcpy(params->PcieRpLtrEnable, config->PcieRpLtrEnable,
175 sizeof(params->PcieRpLtrEnable));
Duncan Laurie74ea48e2018-01-29 12:00:47 -0800176 memcpy(params->PcieRpHotPlug, config->PcieRpHotPlug,
177 sizeof(params->PcieRpHotPlug));
Naresh G Solankia2d40622016-08-30 20:47:13 +0530178
Divya Chellape7fb7ce2017-12-19 20:16:50 +0530179 /*
180 * PcieRpClkSrcNumber UPD is set to clock source number(0-6) for
181 * all the enabled PCIe root ports, invalid(0x1F) is set for
182 * disabled PCIe root ports.
183 */
184 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
185 if (config->PcieRpClkReqSupport[i])
186 params->PcieRpClkSrcNumber[i] =
187 config->PcieRpClkSrcNumber[i];
188 else
189 params->PcieRpClkSrcNumber[i] = 0x1F;
190 }
191
Naresh G Solankieedf6d82016-11-16 21:27:38 +0530192 /* disable Legacy PME */
193 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
194
Naresh G Solankia2d40622016-08-30 20:47:13 +0530195 memcpy(params->SerialIoDevMode, config->SerialIoDevMode,
196 sizeof(params->SerialIoDevMode));
197
198 params->PchCio2Enable = config->Cio2Enable;
Rizwan Qureshic2c8a742017-01-13 22:04:11 +0530199 params->SaImguEnable = config->SaImguEnable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530200 params->Heci3Enabled = config->Heci3Enabled;
201
202 params->LogoPtr = config->LogoPtr;
203 params->LogoSize = config->LogoSize;
204
205 params->CpuConfig.Bits.VmxEnable = config->VmxEnable;
206
207 params->PchPmWoWlanEnable = config->PchPmWoWlanEnable;
208 params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable;
209 params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
210
211 params->PchLanEnable = config->EnableLan;
Duncan Laurie14485ef2017-12-13 13:58:35 -0800212 if (config->EnableLan) {
213 params->PchLanLtrEnable = config->EnableLanLtr;
214 params->PchLanK1OffEnable = config->EnableLanK1Off;
215 params->PchLanClkReqSupported = config->LanClkReqSupported;
216 params->PchLanClkReqNumber = config->LanClkReqNumber;
217 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530218 params->SataSalpSupport = config->SataSalpSupport;
219 params->SsicPortEnable = config->SsicPortEnable;
220 params->ScsEmmcEnabled = config->ScsEmmcEnabled;
221 params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
222 params->ScsSdCardEnabled = config->ScsSdCardEnabled;
223 params->PchIshEnable = config->IshEnable;
224 params->PchHdaEnable = config->EnableAzalia;
225 params->PchHdaIoBufferOwnership = config->IoBufferOwnership;
226 params->PchHdaDspEnable = config->DspEnable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530227 params->Device4Enable = config->Device4Enable;
228 params->SataEnable = config->EnableSata;
229 params->SataMode = config->SataMode;
Matt DeVillier9e0d69b2017-10-10 14:03:36 -0500230 params->SataSpeedLimit = config->SataSpeedLimit;
Kane Chen14e0fa52017-12-27 12:11:23 +0800231 params->SataPwrOptEnable = config->SataPwrOptEnable;
Matt DeVillier9e0d69b2017-10-10 14:03:36 -0500232
Naresh G Solankia2d40622016-08-30 20:47:13 +0530233 tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530234 tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock;
Barnali Sarkarfbf10182017-08-11 18:38:38 +0530235 /*
236 * To disable HECI, the Psf needs to be left unlocked
237 * by FSP till end of post sequence. Based on the devicetree
238 * setting, we set the appropriate PsfUnlock policy in FSP,
239 * do the changes and then lock it back in coreboot during finalize.
240 */
241 tconfig->PchSbAccessUnlock = (config->HeciEnabled == 0) ? 1 : 0;
Subrata Banikc204aaa2017-08-17 15:49:58 +0530242 if (config->chipset_lockdown == CHIPSET_LOCKDOWN_COREBOOT) {
243 tconfig->PchLockDownBiosInterface = 0;
244 params->PchLockDownBiosLock = 0;
245 params->PchLockDownSpiEiss = 0;
246 /*
247 * Skip Spi Flash Lockdown from inside FSP.
248 * Making this config "0" means FSP won't set the FLOCKDN bit
249 * of SPIBAR + 0x04 (i.e., Bit 15 of BIOS_HSFSTS_CTL).
250 * So, it becomes coreboot's responsibility to set this bit
251 * before end of POST for security concerns.
252 */
253 params->SpiFlashCfgLockDown = 0;
254 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530255 params->PchSubSystemVendorId = config->PchConfigSubSystemVendorId;
256 params->PchSubSystemId = config->PchConfigSubSystemId;
257 params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride;
258 params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
259 params->PchPmDeepSxPol = config->PmConfigDeepSxPol;
Duncan Laurie25c7d932017-02-17 17:16:43 -0800260 params->PchPmSlpS0Enable = config->s0ix_enable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530261 params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert;
262 params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert;
263 params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert;
264 params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert;
265 params->PchPmLpcClockRun = config->PmConfigPciClockRun;
266 params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp;
267 params->PchPmPwrBtnOverridePeriod =
268 config->PmConfigPwrBtnOverridePeriod;
269 params->PchPmPwrCycDur = config->PmConfigPwrCycDur;
Rizwan Qureshi0da186c2017-02-23 14:43:39 +0530270
271 /* Indicate whether platform supports Voltage Margining */
272 params->PchPmSlpS0VmEnable = config->PchPmSlpS0VmEnable;
273
Naresh G Solankia2d40622016-08-30 20:47:13 +0530274 params->PchSirqEnable = config->SerialIrqConfigSirqEnable;
275 params->PchSirqMode = config->SerialIrqConfigSirqMode;
276
277 params->CpuConfig.Bits.SkipMpInit = config->FspSkipMpInit;
278
279 for (i = 0; i < ARRAY_SIZE(config->i2c); i++)
Aaron Durbined14a4e2016-11-09 17:04:15 -0600280 params->SerialIoI2cVoltage[i] = config->i2c_voltage[i];
Naresh G Solankia2d40622016-08-30 20:47:13 +0530281
282 for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++)
283 fill_vr_domain_config(params, i, &config->domain_vr_config[i]);
284
285 /* Show SPI controller if enabled in devicetree.cb */
286 dev = dev_find_slot(0, PCH_DEVFN_SPI);
287 params->ShowSpiController = dev->enabled;
288
Duncan Laurief5116952018-03-26 02:24:18 -0700289 /* Enable xDCI controller if enabled in devicetree and allowed */
290 dev = dev_find_slot(0, PCH_DEVFN_USBOTG);
291 if (!xdci_can_enable())
292 dev->enabled = 0;
293 params->XdciEnable = dev->enabled;
294
Rizwan Qureshi64670142016-11-23 15:25:19 +0530295 /*
296 * Send VR specific mailbox commands:
297 * 000b - no VR specific command sent
298 * 001b - VR mailbox command specifically for the MPS IMPV8 VR
Lee Leahyf4c4ab92017-03-16 17:08:03 -0700299 * will be sent
Rizwan Qureshi64670142016-11-23 15:25:19 +0530300 * 010b - VR specific command sent for PS4 exit issue
301 * 100b - VR specific command sent for MPS VR decay issue
302 */
303 params->SendVrMbxCmd1 = config->SendVrMbxCmd;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530304
Rizwan Qureshib3e18c72017-09-25 17:35:15 +0530305 /*
306 * Activates VR mailbox command for Intersil VR C-state issues.
307 * 0 - no mailbox command sent.
308 * 1 - VR mailbox command sent for IA/GT rails only.
309 * 2 - VR mailbox command sent for IA/GT/SA rails.
310 */
311 params->IslVrCmd = config->IslVrCmd;
312
Duncan Laurieb2aac852017-03-07 19:12:02 -0800313 /* Acoustic Noise Mitigation */
314 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
315 params->SlowSlewRateForIa = config->SlowSlewRateForIa;
316 params->SlowSlewRateForGt = config->SlowSlewRateForGt;
317 params->SlowSlewRateForSa = config->SlowSlewRateForSa;
318 params->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa;
319 params->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt;
320 params->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa;
321
Rizwan Qureshiffe58102017-02-10 15:58:24 +0530322 /* Enable PMC XRAM read */
323 tconfig->PchPmPmcReadDisable = config->PchPmPmcReadDisable;
324
Subrata Banik6b45ee42017-05-12 11:43:57 +0530325 /* Enable/Disable EIST */
326 tconfig->Eist = config->eist_enable;
327
marxwangec5a9472017-12-11 14:57:49 +0800328 /* Set TccActivationOffset */
329 tconfig->TccActivationOffset = config->tcc_offset;
330
Nico Huber2afe4dc2017-09-19 09:36:03 +0200331 /* Enable VT-d and X2APIC */
332 if (!config->ignore_vtd && soc_is_vtd_capable()) {
333 params->VtdBaseAddress[0] = GFXVT_BASE_ADDRESS;
334 params->VtdBaseAddress[1] = VTVC0_BASE_ADDRESS;
335 params->X2ApicOptOut = 0;
336 tconfig->VtdDisable = 0;
337
338 params->PchIoApicBdfValid = 1;
339 params->PchIoApicBusNumber = 250;
340 params->PchIoApicDeviceNumber = 31;
341 params->PchIoApicFunctionNumber = 0;
342 }
343
Naresh G Solankia2d40622016-08-30 20:47:13 +0530344 soc_irq_settings(params);
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530345}
Lee Leahyb0005132015-05-12 18:19:47 -0700346
Naresh G Solankia2d40622016-08-30 20:47:13 +0530347/* Mainboard GPIO Configuration */
348__attribute__((weak)) void mainboard_silicon_init_params(FSP_S_CONFIG *params)
349{
350 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
351}