Debian Codegraph @

src/soc/intel/skylake/chip.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <bootsplash.h>
4 #include <fsp/api.h>
5 #include <acpi/acpi.h>
6 #include <console/console.h>
7 #include <device/device.h>
8 #include <device/pci_ids.h>
9 #include <fsp/util.h>
10 #include <gpio.h>
11 #include <option.h>
12 #include <intelblocks/acpi.h>
13 #include <intelblocks/cfg.h>
14 #include <intelblocks/itss.h>
15 #include <intelblocks/lpc_lib.h>
16 #include <intelblocks/pcie_rp.h>
17 #include <intelblocks/power_limit.h>
18 #include <intelblocks/xdci.h>
19 #include <intelblocks/p2sb.h>
20 #include <intelblocks/systemagent.h>
21 #include <intelpch/lockdown.h>
22 #include <soc/intel/common/vbt.h>
23 #include <soc/interrupt.h>
24 #include <soc/iomap.h>
25 #include <soc/itss.h>
26 #include <soc/irq.h>
27 #include <soc/pci_devs.h>
28 #include <soc/pcie.h>
29 #include <soc/ramstage.h>
30 #include <soc/systemagent.h>
31 #include <soc/usb.h>
32 #include <static.h>
33 #include <string.h>
34 #include <types.h>
35
36 #include "chip.h"
37
38 #if CONFIG(HAVE_ACPI_TABLES)
39 const char *soc_acpi_name(const struct device *dev)
40 {
41 if (dev->path.type == DEVICE_PATH_DOMAIN)
42 return "PCI0";
43
44 if (dev->path.type == DEVICE_PATH_USB) {
45 switch (dev->path.usb.port_type) {
46 case 0:
47 /* Root Hub */
48 return "RHUB";
49 case 2:
50 /* USB2 ports */
51 switch (dev->path.usb.port_id) {
52 case 0: return "HS01";
53 case 1: return "HS02";
54 case 2: return "HS03";
55 case 3: return "HS04";
56 case 4: return "HS05";
57 case 5: return "HS06";
58 case 6: return "HS07";
59 case 7: return "HS08";
60 case 8: return "HS09";
61 case 9: return "HS10";
62 }
63 break;
64 case 3:
65 /* USB3 ports */
66 switch (dev->path.usb.port_id) {
67 case 0: return "SS01";
68 case 1: return "SS02";
69 case 2: return "SS03";
70 case 3: return "SS04";
71 case 4: return "SS05";
72 case 5: return "SS06";
73 }
74 break;
75 }
76 return NULL;
77 }
78
79 if (dev->path.type != DEVICE_PATH_PCI)
80 return NULL;
81
82 /* Match functions 0 and 1 for possible GPUs on a secondary bus */
83 if (dev->upstream && dev->upstream->secondary > 0) {
84 switch (PCI_FUNC(dev->path.pci.devfn)) {
85 case 0: return "DEV0";
86 case 1: return "DEV1";
87 }
88 return NULL;
89 }
90
91 switch (dev->path.pci.devfn) {
92 case SA_DEVFN_ROOT: return "MCHC";
93 case SA_DEVFN_PEG0: return "PEGP";
94 case SA_DEVFN_IGD: return "GFX0";
95 case PCH_DEVFN_ISH: return "ISHB";
96 case PCH_DEVFN_XHCI: return "XHCI";
97 case PCH_DEVFN_USBOTG: return "XDCI";
98 case PCH_DEVFN_THERMAL: return "THRM";
99 case PCH_DEVFN_CIO: return "ICIO";
100 case PCH_DEVFN_I2C0: return "I2C0";
101 case PCH_DEVFN_I2C1: return "I2C1";
102 case PCH_DEVFN_I2C2: return "I2C2";
103 case PCH_DEVFN_I2C3: return "I2C3";
104 case PCH_DEVFN_CSE: return "HECI";
105 case PCH_DEVFN_CSE_2: return "CSE2";
106 case PCH_DEVFN_CSE_IDER: return "CSED";
107 case PCH_DEVFN_CSE_KT: return "CSKT";
108 case PCH_DEVFN_CSE_3: return "CSE3";
109 case PCH_DEVFN_SATA: return "SATA";
110 case PCH_DEVFN_UART2: return "UAR2";
111 case PCH_DEVFN_I2C4: return "I2C4";
112 case PCH_DEVFN_I2C5: return "I2C5";
113 case PCH_DEVFN_PCIE1: return "RP01";
114 case PCH_DEVFN_PCIE2: return "RP02";
115 case PCH_DEVFN_PCIE3: return "RP03";
116 case PCH_DEVFN_PCIE4: return "RP04";
117 case PCH_DEVFN_PCIE5: return "RP05";
118 case PCH_DEVFN_PCIE6: return "RP06";
119 case PCH_DEVFN_PCIE7: return "RP07";
120 case PCH_DEVFN_PCIE8: return "RP08";
121 case PCH_DEVFN_PCIE9: return "RP09";
122 case PCH_DEVFN_PCIE10: return "RP10";
123 case PCH_DEVFN_PCIE11: return "RP11";
124 case PCH_DEVFN_PCIE12: return "RP12";
125 case PCH_DEVFN_PCIE13: return "RP13";
126 case PCH_DEVFN_PCIE14: return "RP14";
127 case PCH_DEVFN_PCIE15: return "RP15";
128 case PCH_DEVFN_PCIE16: return "RP16";
129 case PCH_DEVFN_UART0: return "UAR0";
130 case PCH_DEVFN_UART1: return "UAR1";
131 case PCH_DEVFN_GSPI0: return "SPI0";
132 case PCH_DEVFN_GSPI1: return "SPI1";
133 case PCH_DEVFN_EMMC: return "EMMC";
134 case PCH_DEVFN_SDIO: return "SDIO";
135 case PCH_DEVFN_SDCARD: return "SDXC";
136 case PCH_DEVFN_P2SB: return "P2SB";
137 case PCH_DEVFN_PMC: return "PMC_";
138 case PCH_DEVFN_HDA: return "HDAS";
139 case PCH_DEVFN_SMBUS: return "SBUS";
140 case PCH_DEVFN_SPI: return "FSPI";
141 case PCH_DEVFN_GBE: return "IGBE";
142 case PCH_DEVFN_TRACEHUB:return "THUB";
143 }
144
145 return NULL;
146 }
147 #endif
148
149 void soc_init_pre_device(void *chip_info)
150 {
151 /* Snapshot the current GPIO IRQ polarities. FSP is setting a
152 * default policy that doesn't honor boards' requirements. */
153 itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
154
155 /* Perform silicon specific init. */
156 fsp_silicon_init();
157
158 /*
159 * Keep the P2SB device visible so it and the other devices are
160 * visible in coreboot for driver support and PCI resource allocation.
161 * There is no UPD setting for this.
162 */
163 p2sb_unhide();
164
165 /* Restore GPIO IRQ polarities back to previous settings. */
166 itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
167
168 /* swap enabled PCI ports in device tree if needed */
169 pcie_rp_update_devicetree(get_pch_pcie_rp_table());
170 }
171
172 struct device_operations pci_domain_ops = {
173 .read_resources = &pci_domain_read_resources,
174 .set_resources = &pci_domain_set_resources,
175 .scan_bus = &pci_host_bridge_scan_bus,
176 #if CONFIG(HAVE_ACPI_TABLES)
177 .acpi_name = &soc_acpi_name,
178 .acpi_fill_ssdt = ssdt_set_above_4g_pci,
179 #endif
180 };
181
182 static struct device_operations cpu_bus_ops = {
183 .read_resources = noop_read_resources,
184 .set_resources = noop_set_resources,
185 #if CONFIG(HAVE_ACPI_TABLES)
186 .acpi_fill_ssdt = generate_cpu_entries,
187 #endif
188 };
189
190 static void soc_enable(struct device *dev)
191 {
192 /* Set the operations if it is a special bus type */
193 if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
194 dev->ops = &cpu_bus_ops;
195 }
196
197 struct chip_operations soc_intel_skylake_ops = {
198 .name = "Intel 6th Gen",
199 .enable_dev = &soc_enable,
200 .init = &soc_init_pre_device,
201 };
202
203 /* UPD parameters to be initialized before SiliconInit */
204 void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
205 {
206 FSP_S_CONFIG *params = &supd->FspsConfig;
207 FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig;
208 struct soc_intel_skylake_config *config;
209 uintptr_t vbt_data = (uintptr_t)vbt_get();
210 int i;
211
212 config = config_of_soc();
213
214 mainboard_silicon_init_params(params);
215
216 struct soc_power_limits_config *soc_confg;
217 config_t *confg = config_of_soc();
218 soc_confg = &confg->power_limits_config;
219 /* Set PsysPmax if it is available from DT */
220 if (soc_confg->psys_pmax) {
221 /* PsysPmax is in unit of 1/8 Watt */
222 tconfig->PsysPmax = soc_confg->psys_pmax * 8;
223 printk(BIOS_DEBUG, "psys_pmax = %d\n", tconfig->PsysPmax);
224 }
225
226 params->GraphicsConfigPtr = (u32)vbt_data;
227
228 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
229 params->PortUsb20Enable[i] =
230 config->usb2_ports[i].enable;
231 params->Usb2AfePetxiset[i] =
232 config->usb2_ports[i].pre_emp_bias;
233 params->Usb2AfeTxiset[i] =
234 config->usb2_ports[i].tx_bias;
235 params->Usb2AfePredeemp[i] =
236 config->usb2_ports[i].tx_emp_enable;
237 params->Usb2AfePehalfbit[i] =
238 config->usb2_ports[i].pre_emp_bit;
239
240 if (config->usb2_ports[i].enable)
241 params->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin;
242 else
243 params->Usb2OverCurrentPin[i] = OC_SKIP;
244 }
245
246 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
247 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
248 if (config->usb3_ports[i].enable)
249 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
250 else
251 params->Usb3OverCurrentPin[i] = OC_SKIP;
252
253 if (config->usb3_ports[i].tx_de_emp) {
254 params->Usb3HsioTxDeEmphEnable[i] = 1;
255 params->Usb3HsioTxDeEmph[i] =
256 config->usb3_ports[i].tx_de_emp;
257 }
258 if (config->usb3_ports[i].tx_downscale_amp) {
259 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
260 params->Usb3HsioTxDownscaleAmp[i] =
261 config->usb3_ports[i].tx_downscale_amp;
262 }
263 }
264
265 params->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA);
266 if (params->SataEnable) {
267 memcpy(params->SataPortsEnable, config->SataPortsEnable,
268 sizeof(params->SataPortsEnable));
269 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
270 sizeof(params->SataPortsDevSlp));
271 memcpy(params->SataPortsHotPlug, config->SataPortsHotPlug,
272 sizeof(params->SataPortsHotPlug));
273 memcpy(params->SataPortsSpinUp, config->SataPortsSpinUp,
274 sizeof(params->SataPortsSpinUp));
275
276 params->SataSalpSupport = config->SataSalpSupport;
277 params->SataMode = config->SataMode;
278 params->SataSpeedLimit = config->SataSpeedLimit;
279 /*
280 * For unknown reasons FSP skips writing some essential SATA init registers
281 * (SIR) when SataPwrOptEnable=0. This results in link errors, "unaligned
282 * write" errors and others. Enabling this option solves these problems.
283 */
284 params->SataPwrOptEnable = 1;
285 tconfig->SataTestMode = CONFIG(ENABLE_SATA_TEST_MODE);
286 }
287
288 memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport,
289 sizeof(params->PcieRpClkReqSupport));
290 memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber,
291 sizeof(params->PcieRpClkReqNumber));
292 memcpy(params->PcieRpAdvancedErrorReporting,
293 config->PcieRpAdvancedErrorReporting,
294 sizeof(params->PcieRpAdvancedErrorReporting));
295 memcpy(params->PcieRpLtrEnable, config->PcieRpLtrEnable,
296 sizeof(params->PcieRpLtrEnable));
297 memcpy(params->PcieRpHotPlug, config->PcieRpHotPlug,
298 sizeof(params->PcieRpHotPlug));
299 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
300 params->PcieRpMaxPayload[i] = config->PcieRpMaxPayload[i];
301 if (config->pcie_rp_aspm[i])
302 params->PcieRpAspm[i] = config->pcie_rp_aspm[i] - 1;
303 if (config->pcie_rp_l1substates[i])
304 params->PcieRpL1Substates[i] = config->pcie_rp_l1substates[i] - 1;
305 }
306
307 /*
308 * PcieRpClkSrcNumber UPD is set to clock source number(0-6) for
309 * all the enabled PCIe root ports, invalid(0x1F) is set for
310 * disabled PCIe root ports.
311 */
312 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
313 if (config->PcieRpClkReqSupport[i])
314 params->PcieRpClkSrcNumber[i] =
315 config->PcieRpClkSrcNumber[i];
316 else
317 params->PcieRpClkSrcNumber[i] = 0x1F;
318 }
319
320 /* disable Legacy PME */
321 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
322
323 /* Legacy 8254 timer support */
324 bool use_8254 = get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER));
325 params->Early8254ClockGatingEnable = !use_8254;
326
327 /*
328 * Legacy PM ACPI Timer (and TCO Timer)
329 * This *must* be 1 in any case to keep FSP from
330 * 1) enabling PM ACPI Timer emulation in uCode.
331 * 2) disabling the PM ACPI Timer.
332 * We handle both by ourself!
333 */
334 params->EnableTcoTimer = 1;
335
336 memcpy(params->SerialIoDevMode, config->SerialIoDevMode,
337 sizeof(params->SerialIoDevMode));
338
339 params->PchCio2Enable = is_devfn_enabled(PCH_DEVFN_CIO);
340
341 params->SaImguEnable = is_devfn_enabled(SA_DEVFN_IMGU);
342
343 tconfig->ChapDeviceEnable = is_devfn_enabled(SA_DEVFN_CHAP);
344
345 params->Heci3Enabled = is_devfn_enabled(PCH_DEVFN_CSE_3);
346
347 params->CpuConfig.Bits.VmxEnable = CONFIG(ENABLE_VMX);
348
349 params->PchPmWoWlanEnable = config->PchPmWoWlanEnable;
350 params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable;
351 params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
352
353 params->PchLanEnable = is_devfn_enabled(PCH_DEVFN_GBE);
354 if (params->PchLanEnable) {
355 params->PchLanLtrEnable = config->EnableLanLtr;
356 params->PchLanK1OffEnable = config->EnableLanK1Off;
357 params->PchLanClkReqSupported = config->LanClkReqSupported;
358 params->PchLanClkReqNumber = config->LanClkReqNumber;
359 }
360 params->SsicPortEnable = config->SsicPortEnable;
361
362 params->ScsEmmcEnabled = is_devfn_enabled(PCH_DEVFN_EMMC);
363 params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
364
365 params->ScsSdCardEnabled = is_devfn_enabled(PCH_DEVFN_SDCARD);
366
367 if (!!params->ScsEmmcHs400Enabled && !!config->EmmcHs400DllNeed) {
368 params->PchScsEmmcHs400DllDataValid =
369 !!config->EmmcHs400DllNeed;
370 params->PchScsEmmcHs400RxStrobeDll1 =
371 config->ScsEmmcHs400RxStrobeDll1;
372 params->PchScsEmmcHs400TxDataDll =
373 config->ScsEmmcHs400TxDataDll;
374 }
375
376 /* If ISH is enabled, enable ISH elements */
377 params->PchIshEnable = is_devfn_enabled(PCH_DEVFN_ISH);
378
379 params->PchHdaEnable = is_devfn_enabled(PCH_DEVFN_HDA);
380
381 params->PchHdaVcType = config->PchHdaVcType;
382 params->PchHdaIoBufferOwnership = config->IoBufferOwnership;
383 params->PchHdaDspEnable = config->DspEnable;
384
385 params->Device4Enable = is_devfn_enabled(SA_DEVFN_TS);
386 params->PchThermalDeviceEnable = is_devfn_enabled(PCH_DEVFN_THERMAL);
387
388 tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi;
389 tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock;
390 tconfig->PowerLimit4 = 0;
391 /*
392 * To disable HECI, the Psf needs to be left unlocked
393 * by FSP till end of post sequence. Based on the config
394 * setting, we set the appropriate PsfUnlock policy in FSP,
395 * do the changes and then lock it back in coreboot during finalize.
396 */
397 tconfig->PchSbAccessUnlock = CONFIG(DISABLE_HECI1_AT_PRE_BOOT);
398
399 const bool lockdown_by_fsp = get_lockdown_config() == CHIPSET_LOCKDOWN_FSP;
400 tconfig->PchLockDownBiosInterface = lockdown_by_fsp;
401 params->PchLockDownBiosLock = lockdown_by_fsp;
402 params->PchLockDownSpiEiss = lockdown_by_fsp;
403 /*
404 * Making this config "0" means FSP won't set the FLOCKDN bit
405 * of SPIBAR + 0x04 (i.e., Bit 15 of BIOS_HSFSTS_CTL).
406 * So, it becomes coreboot's responsibility to set this bit
407 * before end of POST for security concerns.
408 */
409 params->SpiFlashCfgLockDown = lockdown_by_fsp;
410
411 /* FSP should let coreboot set subsystem IDs, which are read/write-once */
412 params->DefaultSvid = 0;
413 params->PchSubSystemVendorId = 0;
414 params->DefaultSid = 0;
415 params->PchSubSystemId = 0;
416
417 params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride;
418 params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
419 params->PchPmDeepSxPol = config->PmConfigDeepSxPol;
420 config->s0ix_enable = get_uint_option("s0ix_enable", config->s0ix_enable);
421 params->PchPmSlpS0Enable = config->s0ix_enable;
422 params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert;
423 params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert;
424 params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert;
425 params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert;
426 params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp;
427 params->PchPmPwrBtnOverridePeriod =
428 config->PmConfigPwrBtnOverridePeriod;
429 params->PchPmPwrCycDur = config->PmConfigPwrCycDur;
430
431 /* Indicate whether platform supports Voltage Margining */
432 params->PchPmSlpS0VmEnable = config->PchPmSlpS0VmEnable;
433
434 params->PchSirqEnable = config->serirq_mode != SERIRQ_OFF;
435 params->PchSirqMode = config->serirq_mode == SERIRQ_CONTINUOUS;
436
437 params->CpuConfig.Bits.SkipMpInit = !CONFIG(USE_INTEL_FSP_MP_INIT);
438
439 for (i = 0; i < ARRAY_SIZE(config->i2c_voltage); i++)
440 params->SerialIoI2cVoltage[i] = config->i2c_voltage[i];
441
442 for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++)
443 fill_vr_domain_config(params, i, &config->domain_vr_config[i]);
444
445 /* Show SPI controller if enabled in devicetree.cb */
446 params->ShowSpiController = is_devfn_enabled(PCH_DEVFN_SPI);
447
448 params->XdciEnable = xdci_can_enable(PCH_DEVFN_USBOTG);
449
450 /* Enable or disable Gaussian Mixture Model in devicetree */
451 params->GmmEnable = is_devfn_enabled(SA_DEVFN_GMM);
452
453 /*
454 * Send VR specific mailbox commands:
455 * 000b - no VR specific command sent
456 * 001b - VR mailbox command specifically for the MPS IMPV8 VR
457 * will be sent
458 * 010b - VR specific command sent for PS4 exit issue
459 * 100b - VR specific command sent for MPS VR decay issue
460 */
461 params->SendVrMbxCmd1 = config->SendVrMbxCmd;
462
463 /*
464 * Activates VR mailbox command for Intersil VR C-state issues.
465 * 0 - no mailbox command sent.
466 * 1 - VR mailbox command sent for IA/GT rails only.
467 * 2 - VR mailbox command sent for IA/GT/SA rails.
468 */
469 params->IslVrCmd = config->IslVrCmd;
470
471 /* Acoustic Noise Mitigation */
472 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
473 params->SlowSlewRateForIa = config->SlowSlewRateForIa;
474 params->SlowSlewRateForGt = config->SlowSlewRateForGt;
475 params->SlowSlewRateForSa = config->SlowSlewRateForSa;
476 params->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa;
477 params->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt;
478 params->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa;
479
480 /* Enable PMC XRAM read */
481 tconfig->PchPmPmcReadDisable = config->PchPmPmcReadDisable;
482
483 /* Enable/Disable EIST */
484 tconfig->Eist = config->eist_enable;
485
486 /* Set TccActivationOffset */
487 tconfig->TccActivationOffset = config->tcc_offset;
488
489 /* Already handled in coreboot code, so tell FSP to ignore UPDs */
490 params->PchIoApicBdfValid = 0;
491
492 /* Enable VT-d and X2APIC */
493 if (soc_vtd_enabled()) {
494 params->VtdBaseAddress[0] = GFXVT_BASE_ADDRESS;
495 params->VtdBaseAddress[1] = VTVC0_BASE_ADDRESS;
496 params->X2ApicOptOut = 0;
497 tconfig->VtdDisable = 0;
498 }
499
500 params->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD);
501
502 params->PavpEnable = CONFIG(PAVP);
503
504 soc_irq_settings(params);
505 }
506
507 /* Mainboard FSP Configuration */
508 __weak void mainboard_silicon_init_params(FSP_S_CONFIG *params)
509 {
510 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
511 }
512
513 /* Handle FSP logo params */
514 void soc_load_logo_by_fsp(FSPS_UPD *supd)
515 {
516 size_t logo_size;
517 supd->FspsConfig.LogoPtr = (uint32_t)(uintptr_t)bmp_load_logo(&logo_size);
518 supd->FspsConfig.LogoSize = (uint32_t)logo_size;
519 }