blob: 309392c461ff9bbb01e180d7882d9a9790facf6a [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>
Aaron Durbin64031672018-04-21 14:45:32 -060023#include <compiler.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053024#include <bootstate.h>
25#include <console/console.h>
26#include <device/device.h>
27#include <device/pci.h>
28#include <fsp/api.h>
29#include <fsp/util.h>
Duncan Laurief5116952018-03-26 02:24:18 -070030#include <intelblocks/xdci.h>
Brandon Breitensteinc6ec8dd2016-11-17 12:23:04 -080031#include <romstage_handoff.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053032#include <soc/acpi.h>
Patrick Georgic6a00502017-10-05 18:19:29 +020033#include <soc/intel/common/vbt.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053034#include <soc/interrupt.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020035#include <soc/iomap.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053036#include <soc/irq.h>
37#include <soc/pci_devs.h>
38#include <soc/ramstage.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020039#include <soc/systemagent.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053040#include <string.h>
41
42void soc_init_pre_device(void *chip_info)
43{
44 /* Perform silicon specific init. */
Aaron Durbin6c191d82016-11-29 21:22:42 -060045 fsp_silicon_init(romstage_handoff_is_resume());
Naresh G Solankia2d40622016-08-30 20:47:13 +053046}
47
Furquan Shaikhc2480442017-02-20 13:41:56 -080048void soc_fsp_load(void)
49{
50 fsps_load(romstage_handoff_is_resume());
51}
52
Naresh G Solankia2d40622016-08-30 20:47:13 +053053static void pci_domain_set_resources(device_t dev)
54{
55 assign_resources(dev->link_list);
56}
57
58static struct device_operations pci_domain_ops = {
59 .read_resources = &pci_domain_read_resources,
60 .set_resources = &pci_domain_set_resources,
61 .scan_bus = &pci_domain_scan_bus,
62 .ops_pci_bus = &pci_bus_default_ops,
63#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
Nico Huberc37b0e32017-09-18 20:03:46 +020064 .write_acpi_tables = &northbridge_write_acpi_tables,
65 .acpi_name = &soc_acpi_name,
Naresh G Solankia2d40622016-08-30 20:47:13 +053066#endif
67};
68
69static struct device_operations cpu_bus_ops = {
70 .read_resources = DEVICE_NOOP,
71 .set_resources = DEVICE_NOOP,
72 .enable_resources = DEVICE_NOOP,
Subrata Banika4b11e5c2017-02-03 18:57:49 +053073 .init = DEVICE_NOOP,
Naresh G Solankia2d40622016-08-30 20:47:13 +053074#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
75 .acpi_fill_ssdt_generator = generate_cpu_entries,
76#endif
77};
78
79static void soc_enable(device_t dev)
80{
81 /* Set the operations if it is a special bus type */
Subrata Banik3c838c72017-12-06 18:14:01 +053082 if (dev->path.type == DEVICE_PATH_DOMAIN)
Naresh G Solankia2d40622016-08-30 20:47:13 +053083 dev->ops = &pci_domain_ops;
Subrata Banik3c838c72017-12-06 18:14:01 +053084 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
Naresh G Solankia2d40622016-08-30 20:47:13 +053085 dev->ops = &cpu_bus_ops;
Naresh G Solankia2d40622016-08-30 20:47:13 +053086}
87
88struct chip_operations soc_intel_skylake_ops = {
89 CHIP_NAME("Intel 6th Gen")
90 .enable_dev = &soc_enable,
91 .init = &soc_init_pre_device,
92};
Lee Leahyb0005132015-05-12 18:19:47 -070093
Rizwan Qureshi1222a732016-08-23 14:31:23 +053094/* UPD parameters to be initialized before SiliconInit */
Naresh G Solankia2d40622016-08-30 20:47:13 +053095void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
Rizwan Qureshi1222a732016-08-23 14:31:23 +053096{
Naresh G Solankia2d40622016-08-30 20:47:13 +053097 FSP_S_CONFIG *params = &supd->FspsConfig;
98 FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig;
99 static struct soc_intel_skylake_config *config;
Patrick Georgid2990ff2018-05-03 18:06:15 +0200100 uintptr_t vbt_data = (uintptr_t)vbt_get();
Naresh G Solankia2d40622016-08-30 20:47:13 +0530101 int i;
102
Naresh G Solankia2d40622016-08-30 20:47:13 +0530103 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
Naresh G Solankia2d40622016-08-30 20:47:13 +0530118 params->GraphicsConfigPtr = (u32) vbt_data;
119
120 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
121 params->PortUsb20Enable[i] =
122 config->usb2_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530123 params->Usb2OverCurrentPin[i] =
124 config->usb2_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530125 params->Usb2AfePetxiset[i] =
126 config->usb2_ports[i].pre_emp_bias;
127 params->Usb2AfeTxiset[i] =
128 config->usb2_ports[i].tx_bias;
129 params->Usb2AfePredeemp[i] =
130 config->usb2_ports[i].tx_emp_enable;
131 params->Usb2AfePehalfbit[i] =
132 config->usb2_ports[i].pre_emp_bit;
133 }
134
135 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
136 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530137 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530138 if (config->usb3_ports[i].tx_de_emp) {
139 params->Usb3HsioTxDeEmphEnable[i] = 1;
140 params->Usb3HsioTxDeEmph[i] =
141 config->usb3_ports[i].tx_de_emp;
142 }
143 if (config->usb3_ports[i].tx_downscale_amp) {
144 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
145 params->Usb3HsioTxDownscaleAmp[i] =
146 config->usb3_ports[i].tx_downscale_amp;
147 }
148 }
149
150 memcpy(params->SataPortsEnable, config->SataPortsEnable,
151 sizeof(params->SataPortsEnable));
152 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
153 sizeof(params->SataPortsDevSlp));
154 memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport,
155 sizeof(params->PcieRpClkReqSupport));
156 memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber,
157 sizeof(params->PcieRpClkReqNumber));
Rizwan Qureshi6ab4ed42017-09-05 14:18:25 +0530158 memcpy(params->PcieRpAdvancedErrorReporting,
159 config->PcieRpAdvancedErrorReporting,
160 sizeof(params->PcieRpAdvancedErrorReporting));
Rizwan Qureshi03937392017-09-16 01:54:20 +0530161 memcpy(params->PcieRpLtrEnable, config->PcieRpLtrEnable,
162 sizeof(params->PcieRpLtrEnable));
Duncan Laurie74ea48e2018-01-29 12:00:47 -0800163 memcpy(params->PcieRpHotPlug, config->PcieRpHotPlug,
164 sizeof(params->PcieRpHotPlug));
Naresh G Solankia2d40622016-08-30 20:47:13 +0530165
Divya Chellape7fb7ce2017-12-19 20:16:50 +0530166 /*
167 * PcieRpClkSrcNumber UPD is set to clock source number(0-6) for
168 * all the enabled PCIe root ports, invalid(0x1F) is set for
169 * disabled PCIe root ports.
170 */
171 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
172 if (config->PcieRpClkReqSupport[i])
173 params->PcieRpClkSrcNumber[i] =
174 config->PcieRpClkSrcNumber[i];
175 else
176 params->PcieRpClkSrcNumber[i] = 0x1F;
177 }
178
Naresh G Solankieedf6d82016-11-16 21:27:38 +0530179 /* disable Legacy PME */
180 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
181
Naresh G Solankia2d40622016-08-30 20:47:13 +0530182 memcpy(params->SerialIoDevMode, config->SerialIoDevMode,
183 sizeof(params->SerialIoDevMode));
184
185 params->PchCio2Enable = config->Cio2Enable;
Rizwan Qureshic2c8a742017-01-13 22:04:11 +0530186 params->SaImguEnable = config->SaImguEnable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530187 params->Heci3Enabled = config->Heci3Enabled;
188
189 params->LogoPtr = config->LogoPtr;
190 params->LogoSize = config->LogoSize;
191
192 params->CpuConfig.Bits.VmxEnable = config->VmxEnable;
193
194 params->PchPmWoWlanEnable = config->PchPmWoWlanEnable;
195 params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable;
196 params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
197
198 params->PchLanEnable = config->EnableLan;
Duncan Laurie14485ef2017-12-13 13:58:35 -0800199 if (config->EnableLan) {
200 params->PchLanLtrEnable = config->EnableLanLtr;
201 params->PchLanK1OffEnable = config->EnableLanK1Off;
202 params->PchLanClkReqSupported = config->LanClkReqSupported;
203 params->PchLanClkReqNumber = config->LanClkReqNumber;
204 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530205 params->SataSalpSupport = config->SataSalpSupport;
206 params->SsicPortEnable = config->SsicPortEnable;
207 params->ScsEmmcEnabled = config->ScsEmmcEnabled;
208 params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
209 params->ScsSdCardEnabled = config->ScsSdCardEnabled;
210 params->PchIshEnable = config->IshEnable;
211 params->PchHdaEnable = config->EnableAzalia;
212 params->PchHdaIoBufferOwnership = config->IoBufferOwnership;
213 params->PchHdaDspEnable = config->DspEnable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530214 params->Device4Enable = config->Device4Enable;
215 params->SataEnable = config->EnableSata;
216 params->SataMode = config->SataMode;
Matt DeVillier9e0d69b2017-10-10 14:03:36 -0500217 params->SataSpeedLimit = config->SataSpeedLimit;
Kane Chen14e0fa52017-12-27 12:11:23 +0800218 params->SataPwrOptEnable = config->SataPwrOptEnable;
Matt DeVillier9e0d69b2017-10-10 14:03:36 -0500219
Naresh G Solankia2d40622016-08-30 20:47:13 +0530220 tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530221 tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock;
Barnali Sarkarfbf10182017-08-11 18:38:38 +0530222 /*
223 * To disable HECI, the Psf needs to be left unlocked
224 * by FSP till end of post sequence. Based on the devicetree
225 * setting, we set the appropriate PsfUnlock policy in FSP,
226 * do the changes and then lock it back in coreboot during finalize.
227 */
228 tconfig->PchSbAccessUnlock = (config->HeciEnabled == 0) ? 1 : 0;
Subrata Banikc204aaa2017-08-17 15:49:58 +0530229 if (config->chipset_lockdown == CHIPSET_LOCKDOWN_COREBOOT) {
230 tconfig->PchLockDownBiosInterface = 0;
231 params->PchLockDownBiosLock = 0;
232 params->PchLockDownSpiEiss = 0;
233 /*
234 * Skip Spi Flash Lockdown from inside FSP.
235 * Making this config "0" means FSP won't set the FLOCKDN bit
236 * of SPIBAR + 0x04 (i.e., Bit 15 of BIOS_HSFSTS_CTL).
237 * So, it becomes coreboot's responsibility to set this bit
238 * before end of POST for security concerns.
239 */
240 params->SpiFlashCfgLockDown = 0;
241 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530242 params->PchSubSystemVendorId = config->PchConfigSubSystemVendorId;
243 params->PchSubSystemId = config->PchConfigSubSystemId;
244 params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride;
245 params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
246 params->PchPmDeepSxPol = config->PmConfigDeepSxPol;
Duncan Laurie25c7d932017-02-17 17:16:43 -0800247 params->PchPmSlpS0Enable = config->s0ix_enable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530248 params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert;
249 params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert;
250 params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert;
251 params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert;
252 params->PchPmLpcClockRun = config->PmConfigPciClockRun;
253 params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp;
254 params->PchPmPwrBtnOverridePeriod =
255 config->PmConfigPwrBtnOverridePeriod;
256 params->PchPmPwrCycDur = config->PmConfigPwrCycDur;
Rizwan Qureshi0da186c2017-02-23 14:43:39 +0530257
258 /* Indicate whether platform supports Voltage Margining */
259 params->PchPmSlpS0VmEnable = config->PchPmSlpS0VmEnable;
260
Naresh G Solankia2d40622016-08-30 20:47:13 +0530261 params->PchSirqEnable = config->SerialIrqConfigSirqEnable;
262 params->PchSirqMode = config->SerialIrqConfigSirqMode;
263
264 params->CpuConfig.Bits.SkipMpInit = config->FspSkipMpInit;
265
266 for (i = 0; i < ARRAY_SIZE(config->i2c); i++)
Aaron Durbined14a4e2016-11-09 17:04:15 -0600267 params->SerialIoI2cVoltage[i] = config->i2c_voltage[i];
Naresh G Solankia2d40622016-08-30 20:47:13 +0530268
269 for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++)
270 fill_vr_domain_config(params, i, &config->domain_vr_config[i]);
271
272 /* Show SPI controller if enabled in devicetree.cb */
273 dev = dev_find_slot(0, PCH_DEVFN_SPI);
274 params->ShowSpiController = dev->enabled;
275
Duncan Laurief5116952018-03-26 02:24:18 -0700276 /* Enable xDCI controller if enabled in devicetree and allowed */
277 dev = dev_find_slot(0, PCH_DEVFN_USBOTG);
278 if (!xdci_can_enable())
279 dev->enabled = 0;
280 params->XdciEnable = dev->enabled;
281
Rizwan Qureshi64670142016-11-23 15:25:19 +0530282 /*
283 * Send VR specific mailbox commands:
284 * 000b - no VR specific command sent
285 * 001b - VR mailbox command specifically for the MPS IMPV8 VR
Lee Leahyf4c4ab92017-03-16 17:08:03 -0700286 * will be sent
Rizwan Qureshi64670142016-11-23 15:25:19 +0530287 * 010b - VR specific command sent for PS4 exit issue
288 * 100b - VR specific command sent for MPS VR decay issue
289 */
290 params->SendVrMbxCmd1 = config->SendVrMbxCmd;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530291
Rizwan Qureshib3e18c72017-09-25 17:35:15 +0530292 /*
293 * Activates VR mailbox command for Intersil VR C-state issues.
294 * 0 - no mailbox command sent.
295 * 1 - VR mailbox command sent for IA/GT rails only.
296 * 2 - VR mailbox command sent for IA/GT/SA rails.
297 */
298 params->IslVrCmd = config->IslVrCmd;
299
Duncan Laurieb2aac852017-03-07 19:12:02 -0800300 /* Acoustic Noise Mitigation */
301 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
302 params->SlowSlewRateForIa = config->SlowSlewRateForIa;
303 params->SlowSlewRateForGt = config->SlowSlewRateForGt;
304 params->SlowSlewRateForSa = config->SlowSlewRateForSa;
305 params->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa;
306 params->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt;
307 params->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa;
308
Rizwan Qureshiffe58102017-02-10 15:58:24 +0530309 /* Enable PMC XRAM read */
310 tconfig->PchPmPmcReadDisable = config->PchPmPmcReadDisable;
311
Subrata Banik6b45ee42017-05-12 11:43:57 +0530312 /* Enable/Disable EIST */
313 tconfig->Eist = config->eist_enable;
314
marxwangec5a9472017-12-11 14:57:49 +0800315 /* Set TccActivationOffset */
316 tconfig->TccActivationOffset = config->tcc_offset;
317
Nico Huber2afe4dc2017-09-19 09:36:03 +0200318 /* Enable VT-d and X2APIC */
319 if (!config->ignore_vtd && soc_is_vtd_capable()) {
320 params->VtdBaseAddress[0] = GFXVT_BASE_ADDRESS;
321 params->VtdBaseAddress[1] = VTVC0_BASE_ADDRESS;
322 params->X2ApicOptOut = 0;
323 tconfig->VtdDisable = 0;
324
325 params->PchIoApicBdfValid = 1;
326 params->PchIoApicBusNumber = 250;
327 params->PchIoApicDeviceNumber = 31;
328 params->PchIoApicFunctionNumber = 0;
329 }
330
Naresh G Solankia2d40622016-08-30 20:47:13 +0530331 soc_irq_settings(params);
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530332}
Lee Leahyb0005132015-05-12 18:19:47 -0700333
Naresh G Solankia2d40622016-08-30 20:47:13 +0530334/* Mainboard GPIO Configuration */
Aaron Durbin64031672018-04-21 14:45:32 -0600335__weak void mainboard_silicon_init_params(FSP_S_CONFIG *params)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530336{
337 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
338}