blob: f471edb96023d4fce276e40c669d438ff89cd924 [file] [log] [blame]
Angel Pons3bd1e3d2020-04-05 15:47:17 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahyb0005132015-05-12 18:19:47 -07002
Kyösti Mälkki4949a3d2021-01-09 20:38:43 +02003#include <bootsplash.h>
Rizwan Qureshi1222a732016-08-23 14:31:23 +05304#include <fsp/api.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -07005#include <acpi/acpi.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +05306#include <console/console.h>
7#include <device/device.h>
Gaggery Tsai711fb812018-05-22 12:32:48 -07008#include <device/pci_ids.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +05309#include <fsp/util.h>
Michael Niewöhner8913b782020-12-11 22:13:44 +010010#include <gpio.h>
Sean Rhodesbc35bed2021-07-13 13:36:28 +010011#include <option.h>
Michael Niewöhnerf6611a22020-08-03 16:53:41 +020012#include <intelblocks/acpi.h>
Kyösti Mälkki32d47eb2019-09-28 00:00:30 +030013#include <intelblocks/cfg.h>
Subrata Banik46caf092018-09-28 19:54:30 +053014#include <intelblocks/itss.h>
Nico Huber44e89af2019-02-23 19:24:51 +010015#include <intelblocks/lpc_lib.h>
Nico Huberad91b182019-10-12 15:16:33 +020016#include <intelblocks/pcie_rp.h>
Sumeet R Pawnikar97c54642020-05-10 01:24:11 +053017#include <intelblocks/power_limit.h>
Duncan Laurief5116952018-03-26 02:24:18 -070018#include <intelblocks/xdci.h>
Patrick Rudolph5199e822019-09-26 14:00:14 +020019#include <intelblocks/p2sb.h>
Arthur Heymans08769c62022-05-09 14:33:15 +020020#include <intelblocks/systemagent.h>
Subrata Banik9cd99a12018-05-28 16:12:03 +053021#include <intelpch/lockdown.h>
Patrick Georgic6a00502017-10-05 18:19:29 +020022#include <soc/intel/common/vbt.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053023#include <soc/interrupt.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020024#include <soc/iomap.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053025#include <soc/irq.h>
Subrata Banik46caf092018-09-28 19:54:30 +053026#include <soc/itss.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053027#include <soc/pci_devs.h>
28#include <soc/ramstage.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020029#include <soc/systemagent.h>
Michael Niewöhner84fde762020-11-25 16:36:18 +010030#include <soc/usb.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053031#include <string.h>
Sean Rhodesbc35bed2021-07-13 13:36:28 +010032#include <types.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053033
Elyes HAOUASc3385072019-03-21 15:38:06 +010034#include "chip.h"
35
Nico Huberad91b182019-10-12 15:16:33 +020036static const struct pcie_rp_group pch_lp_rp_groups[] = {
MAULIK V VAGHELAd9c5b142022-02-14 22:04:03 +053037 { .slot = PCH_DEV_SLOT_PCIE, .count = 8, .lcap_port_base = 1 },
38 { .slot = PCH_DEV_SLOT_PCIE_1, .count = 4, .lcap_port_base = 1 },
Nico Huberad91b182019-10-12 15:16:33 +020039 { 0 }
Gaggery Tsai711fb812018-05-22 12:32:48 -070040};
41
Nico Huberad91b182019-10-12 15:16:33 +020042static const struct pcie_rp_group pch_h_rp_groups[] = {
MAULIK V VAGHELAd9c5b142022-02-14 22:04:03 +053043 { .slot = PCH_DEV_SLOT_PCIE, .count = 8, .lcap_port_base = 1 },
44 { .slot = PCH_DEV_SLOT_PCIE_1, .count = 8, .lcap_port_base = 1 },
Nico Huberad91b182019-10-12 15:16:33 +020045 /* Sunrise Point PCH-H actually only has 4 ports in the
46 third group. But that would require a runtime check
47 and probing 4 non-existent ports shouldn't hurt. */
MAULIK V VAGHELAd9c5b142022-02-14 22:04:03 +053048 { .slot = PCH_DEV_SLOT_PCIE_2, .count = 8, .lcap_port_base = 1 },
Nico Huberad91b182019-10-12 15:16:33 +020049 { 0 }
Gaggery Tsai711fb812018-05-22 12:32:48 -070050};
51
Angel Pons6edbaa22021-02-19 19:49:38 +010052#if CONFIG(HAVE_ACPI_TABLES)
53const char *soc_acpi_name(const struct device *dev)
54{
55 if (dev->path.type == DEVICE_PATH_DOMAIN)
56 return "PCI0";
57
58 if (dev->path.type == DEVICE_PATH_USB) {
59 switch (dev->path.usb.port_type) {
60 case 0:
61 /* Root Hub */
62 return "RHUB";
63 case 2:
64 /* USB2 ports */
65 switch (dev->path.usb.port_id) {
66 case 0: return "HS01";
67 case 1: return "HS02";
68 case 2: return "HS03";
69 case 3: return "HS04";
70 case 4: return "HS05";
71 case 5: return "HS06";
72 case 6: return "HS07";
73 case 7: return "HS08";
74 case 8: return "HS09";
75 case 9: return "HS10";
76 }
77 break;
78 case 3:
79 /* USB3 ports */
80 switch (dev->path.usb.port_id) {
81 case 0: return "SS01";
82 case 1: return "SS02";
83 case 2: return "SS03";
84 case 3: return "SS04";
85 case 4: return "SS05";
86 case 5: return "SS06";
87 }
88 break;
89 }
90 return NULL;
91 }
92
93 if (dev->path.type != DEVICE_PATH_PCI)
94 return NULL;
95
96 /* Match functions 0 and 1 for possible GPUs on a secondary bus */
97 if (dev->bus && dev->bus->secondary > 0) {
98 switch (PCI_FUNC(dev->path.pci.devfn)) {
99 case 0: return "DEV0";
100 case 1: return "DEV1";
101 }
102 return NULL;
103 }
104
105 switch (dev->path.pci.devfn) {
106 case SA_DEVFN_ROOT: return "MCHC";
107 case SA_DEVFN_PEG0: return "PEGP";
108 case SA_DEVFN_IGD: return "GFX0";
109 case PCH_DEVFN_ISH: return "ISHB";
110 case PCH_DEVFN_XHCI: return "XHCI";
111 case PCH_DEVFN_USBOTG: return "XDCI";
112 case PCH_DEVFN_THERMAL: return "THRM";
113 case PCH_DEVFN_CIO: return "ICIO";
114 case PCH_DEVFN_I2C0: return "I2C0";
115 case PCH_DEVFN_I2C1: return "I2C1";
116 case PCH_DEVFN_I2C2: return "I2C2";
117 case PCH_DEVFN_I2C3: return "I2C3";
118 case PCH_DEVFN_CSE: return "CSE1";
119 case PCH_DEVFN_CSE_2: return "CSE2";
120 case PCH_DEVFN_CSE_IDER: return "CSED";
121 case PCH_DEVFN_CSE_KT: return "CSKT";
122 case PCH_DEVFN_CSE_3: return "CSE3";
123 case PCH_DEVFN_SATA: return "SATA";
124 case PCH_DEVFN_UART2: return "UAR2";
125 case PCH_DEVFN_I2C4: return "I2C4";
126 case PCH_DEVFN_I2C5: return "I2C5";
127 case PCH_DEVFN_PCIE1: return "RP01";
128 case PCH_DEVFN_PCIE2: return "RP02";
129 case PCH_DEVFN_PCIE3: return "RP03";
130 case PCH_DEVFN_PCIE4: return "RP04";
131 case PCH_DEVFN_PCIE5: return "RP05";
132 case PCH_DEVFN_PCIE6: return "RP06";
133 case PCH_DEVFN_PCIE7: return "RP07";
134 case PCH_DEVFN_PCIE8: return "RP08";
135 case PCH_DEVFN_PCIE9: return "RP09";
136 case PCH_DEVFN_PCIE10: return "RP10";
137 case PCH_DEVFN_PCIE11: return "RP11";
138 case PCH_DEVFN_PCIE12: return "RP12";
139 case PCH_DEVFN_PCIE13: return "RP13";
140 case PCH_DEVFN_PCIE14: return "RP14";
141 case PCH_DEVFN_PCIE15: return "RP15";
142 case PCH_DEVFN_PCIE16: return "RP16";
143 case PCH_DEVFN_UART0: return "UAR0";
144 case PCH_DEVFN_UART1: return "UAR1";
145 case PCH_DEVFN_GSPI0: return "SPI0";
146 case PCH_DEVFN_GSPI1: return "SPI1";
147 case PCH_DEVFN_EMMC: return "EMMC";
148 case PCH_DEVFN_SDIO: return "SDIO";
149 case PCH_DEVFN_SDCARD: return "SDXC";
150 case PCH_DEVFN_P2SB: return "P2SB";
151 case PCH_DEVFN_PMC: return "PMC_";
152 case PCH_DEVFN_HDA: return "HDAS";
153 case PCH_DEVFN_SMBUS: return "SBUS";
154 case PCH_DEVFN_SPI: return "FSPI";
155 case PCH_DEVFN_GBE: return "IGBE";
156 case PCH_DEVFN_TRACEHUB:return "THUB";
157 }
158
159 return NULL;
160}
161#endif
162
Naresh G Solankia2d40622016-08-30 20:47:13 +0530163void soc_init_pre_device(void *chip_info)
164{
Subrata Banik46caf092018-09-28 19:54:30 +0530165 /* Snapshot the current GPIO IRQ polarities. FSP is setting a
166 * default policy that doesn't honor boards' requirements. */
167 itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
168
Naresh G Solankia2d40622016-08-30 20:47:13 +0530169 /* Perform silicon specific init. */
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +0200170 fsp_silicon_init();
Subrata Banik46caf092018-09-28 19:54:30 +0530171
Patrick Rudolph5199e822019-09-26 14:00:14 +0200172 /*
173 * Keep the P2SB device visible so it and the other devices are
174 * visible in coreboot for driver support and PCI resource allocation.
175 * There is no UPD setting for this.
176 */
177 p2sb_unhide();
178
Subrata Banik46caf092018-09-28 19:54:30 +0530179 /* Restore GPIO IRQ polarities back to previous settings. */
180 itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
181
Gaggery Tsai711fb812018-05-22 12:32:48 -0700182 /* swap enabled PCI ports in device tree if needed */
Nico Huberad91b182019-10-12 15:16:33 +0200183 if (CONFIG(SKYLAKE_SOC_PCH_H))
184 pcie_rp_update_devicetree(pch_h_rp_groups);
185 else
186 pcie_rp_update_devicetree(pch_lp_rp_groups);
Naresh G Solankia2d40622016-08-30 20:47:13 +0530187}
188
Nico Huber57686192022-08-06 19:11:55 +0200189struct device_operations pci_domain_ops = {
Naresh G Solankia2d40622016-08-30 20:47:13 +0530190 .read_resources = &pci_domain_read_resources,
191 .set_resources = &pci_domain_set_resources,
Arthur Heymans0b0113f2023-08-31 17:09:28 +0200192 .scan_bus = &pci_host_bridge_scan_bus,
Julius Wernercd49cce2019-03-05 16:53:33 -0800193#if CONFIG(HAVE_ACPI_TABLES)
Arthur Heymans08769c62022-05-09 14:33:15 +0200194 .acpi_name = &soc_acpi_name,
195 .acpi_fill_ssdt = ssdt_set_above_4g_pci,
Naresh G Solankia2d40622016-08-30 20:47:13 +0530196#endif
197};
198
199static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +0200200 .read_resources = noop_read_resources,
201 .set_resources = noop_set_resources,
Julius Wernercd49cce2019-03-05 16:53:33 -0800202#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +0200203 .acpi_fill_ssdt = generate_cpu_entries,
Naresh G Solankia2d40622016-08-30 20:47:13 +0530204#endif
205};
206
Elyes HAOUAS143fb462018-05-25 12:56:45 +0200207static void soc_enable(struct device *dev)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530208{
209 /* Set the operations if it is a special bus type */
Nico Huber57686192022-08-06 19:11:55 +0200210 if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530211 dev->ops = &cpu_bus_ops;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530212}
213
214struct chip_operations soc_intel_skylake_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +0900215 .name = "Intel 6th Gen",
Naresh G Solankia2d40622016-08-30 20:47:13 +0530216 .enable_dev = &soc_enable,
217 .init = &soc_init_pre_device,
218};
Lee Leahyb0005132015-05-12 18:19:47 -0700219
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530220/* UPD parameters to be initialized before SiliconInit */
Naresh G Solankia2d40622016-08-30 20:47:13 +0530221void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530222{
Naresh G Solankia2d40622016-08-30 20:47:13 +0530223 FSP_S_CONFIG *params = &supd->FspsConfig;
224 FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig;
Kyösti Mälkki4af4e7f2019-07-14 05:50:20 +0300225 struct soc_intel_skylake_config *config;
Patrick Georgid2990ff2018-05-03 18:06:15 +0200226 uintptr_t vbt_data = (uintptr_t)vbt_get();
Naresh G Solankia2d40622016-08-30 20:47:13 +0530227 int i;
228
Kyösti Mälkkid5f645c2019-09-28 00:20:27 +0300229 config = config_of_soc();
Naresh G Solankia2d40622016-08-30 20:47:13 +0530230
231 mainboard_silicon_init_params(params);
Sumeet R Pawnikar97c54642020-05-10 01:24:11 +0530232
233 struct soc_power_limits_config *soc_confg;
234 config_t *confg = config_of_soc();
235 soc_confg = &confg->power_limits_config;
Gaggery Tsaida6f4ae2018-01-15 15:03:01 +0800236 /* Set PsysPmax if it is available from DT */
Sumeet R Pawnikar97c54642020-05-10 01:24:11 +0530237 if (soc_confg->psys_pmax) {
Gaggery Tsaida6f4ae2018-01-15 15:03:01 +0800238 /* PsysPmax is in unit of 1/8 Watt */
Sumeet R Pawnikar97c54642020-05-10 01:24:11 +0530239 tconfig->PsysPmax = soc_confg->psys_pmax * 8;
Gaggery Tsaida6f4ae2018-01-15 15:03:01 +0800240 printk(BIOS_DEBUG, "psys_pmax = %d\n", tconfig->PsysPmax);
241 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530242
Elyes Haouas9018dee2022-11-18 15:07:33 +0100243 params->GraphicsConfigPtr = (u32)vbt_data;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530244
245 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
246 params->PortUsb20Enable[i] =
247 config->usb2_ports[i].enable;
248 params->Usb2AfePetxiset[i] =
249 config->usb2_ports[i].pre_emp_bias;
250 params->Usb2AfeTxiset[i] =
251 config->usb2_ports[i].tx_bias;
252 params->Usb2AfePredeemp[i] =
253 config->usb2_ports[i].tx_emp_enable;
254 params->Usb2AfePehalfbit[i] =
255 config->usb2_ports[i].pre_emp_bit;
Michael Niewöhner056d5522020-09-04 15:40:35 +0200256
257 if (config->usb2_ports[i].enable)
258 params->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin;
259 else
Michael Niewöhner84fde762020-11-25 16:36:18 +0100260 params->Usb2OverCurrentPin[i] = OC_SKIP;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530261 }
262
263 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
264 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
Michael Niewöhner84fde762020-11-25 16:36:18 +0100265 if (config->usb3_ports[i].enable)
Michael Niewöhner056d5522020-09-04 15:40:35 +0200266 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
Michael Niewöhner84fde762020-11-25 16:36:18 +0100267 else
268 params->Usb3OverCurrentPin[i] = OC_SKIP;
269
Naresh G Solankia2d40622016-08-30 20:47:13 +0530270 if (config->usb3_ports[i].tx_de_emp) {
271 params->Usb3HsioTxDeEmphEnable[i] = 1;
272 params->Usb3HsioTxDeEmph[i] =
273 config->usb3_ports[i].tx_de_emp;
274 }
275 if (config->usb3_ports[i].tx_downscale_amp) {
276 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
277 params->Usb3HsioTxDownscaleAmp[i] =
278 config->usb3_ports[i].tx_downscale_amp;
279 }
280 }
281
Angel Pons7ff3f312021-06-23 12:13:57 +0200282 params->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA);
Felix Singer0901d032020-07-29 19:57:25 +0200283 if (params->SataEnable) {
Felix Singer4e58ce12020-07-25 04:39:52 +0200284 memcpy(params->SataPortsEnable, config->SataPortsEnable,
285 sizeof(params->SataPortsEnable));
286 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
287 sizeof(params->SataPortsDevSlp));
288 memcpy(params->SataPortsHotPlug, config->SataPortsHotPlug,
289 sizeof(params->SataPortsHotPlug));
290 memcpy(params->SataPortsSpinUp, config->SataPortsSpinUp,
291 sizeof(params->SataPortsSpinUp));
292
293 params->SataSalpSupport = config->SataSalpSupport;
294 params->SataMode = config->SataMode;
295 params->SataSpeedLimit = config->SataSpeedLimit;
296 /*
297 * For unknown reasons FSP skips writing some essential SATA init registers
298 * (SIR) when SataPwrOptEnable=0. This results in link errors, "unaligned
299 * write" errors and others. Enabling this option solves these problems.
300 */
301 params->SataPwrOptEnable = 1;
Angel Pons8f3e1192021-04-04 16:20:54 +0200302 tconfig->SataTestMode = CONFIG(ENABLE_SATA_TEST_MODE);
Felix Singer4e58ce12020-07-25 04:39:52 +0200303 }
304
Naresh G Solankia2d40622016-08-30 20:47:13 +0530305 memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport,
306 sizeof(params->PcieRpClkReqSupport));
307 memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber,
308 sizeof(params->PcieRpClkReqNumber));
Rizwan Qureshi6ab4ed42017-09-05 14:18:25 +0530309 memcpy(params->PcieRpAdvancedErrorReporting,
310 config->PcieRpAdvancedErrorReporting,
311 sizeof(params->PcieRpAdvancedErrorReporting));
Rizwan Qureshi03937392017-09-16 01:54:20 +0530312 memcpy(params->PcieRpLtrEnable, config->PcieRpLtrEnable,
313 sizeof(params->PcieRpLtrEnable));
Duncan Laurie74ea48e2018-01-29 12:00:47 -0800314 memcpy(params->PcieRpHotPlug, config->PcieRpHotPlug,
315 sizeof(params->PcieRpHotPlug));
Wim Vervoorn5819eab2020-05-07 13:16:32 +0200316 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
Wim Vervoornd6b682c2020-05-07 12:41:13 +0200317 params->PcieRpMaxPayload[i] = config->PcieRpMaxPayload[i];
Benjamin Doronb53858b2020-10-12 04:19:42 +0000318 if (config->pcie_rp_aspm[i])
319 params->PcieRpAspm[i] = config->pcie_rp_aspm[i] - 1;
Benjamin Doronadcb8702020-03-14 01:53:25 +0000320 if (config->pcie_rp_l1substates[i])
321 params->PcieRpL1Substates[i] = config->pcie_rp_l1substates[i] - 1;
Wim Vervoorn5819eab2020-05-07 13:16:32 +0200322 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530323
Divya Chellape7fb7ce2017-12-19 20:16:50 +0530324 /*
325 * PcieRpClkSrcNumber UPD is set to clock source number(0-6) for
326 * all the enabled PCIe root ports, invalid(0x1F) is set for
327 * disabled PCIe root ports.
328 */
329 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
330 if (config->PcieRpClkReqSupport[i])
331 params->PcieRpClkSrcNumber[i] =
332 config->PcieRpClkSrcNumber[i];
333 else
334 params->PcieRpClkSrcNumber[i] = 0x1F;
335 }
336
Naresh G Solankieedf6d82016-11-16 21:27:38 +0530337 /* disable Legacy PME */
338 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
339
Subrata Banik10a94322019-07-08 14:49:22 +0530340 /* Legacy 8254 timer support */
Sean Rhodesbc35bed2021-07-13 13:36:28 +0100341 bool use_8254 = get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER));
342 params->Early8254ClockGatingEnable = !use_8254;
Subrata Banik10a94322019-07-08 14:49:22 +0530343
Michael Niewöhner0e905802021-09-25 00:10:30 +0200344 /*
345 * Legacy PM ACPI Timer (and TCO Timer)
346 * This *must* be 1 in any case to keep FSP from
347 * 1) enabling PM ACPI Timer emulation in uCode.
348 * 2) disabling the PM ACPI Timer.
349 * We handle both by ourself!
350 */
351 params->EnableTcoTimer = 1;
Michael Niewöhnera1843d82020-10-02 18:28:22 +0200352
Naresh G Solankia2d40622016-08-30 20:47:13 +0530353 memcpy(params->SerialIoDevMode, config->SerialIoDevMode,
354 sizeof(params->SerialIoDevMode));
355
Angel Pons7ff3f312021-06-23 12:13:57 +0200356 params->PchCio2Enable = is_devfn_enabled(PCH_DEVFN_CIO);
Felix Singer4d5c4e02020-07-29 22:28:37 +0200357
Angel Pons7ff3f312021-06-23 12:13:57 +0200358 params->SaImguEnable = is_devfn_enabled(SA_DEVFN_IMGU);
Felix Singer91dfb922020-07-25 14:01:52 +0200359
Angel Pons7ff3f312021-06-23 12:13:57 +0200360 tconfig->ChapDeviceEnable = is_devfn_enabled(SA_DEVFN_CHAP);
Benjamin Dorond0701c92020-12-07 22:56:47 +0000361
Angel Pons7ff3f312021-06-23 12:13:57 +0200362 params->Heci3Enabled = is_devfn_enabled(PCH_DEVFN_CSE_3);
Naresh G Solankia2d40622016-08-30 20:47:13 +0530363
Julius Wernercd49cce2019-03-05 16:53:33 -0800364 params->CpuConfig.Bits.VmxEnable = CONFIG(ENABLE_VMX);
Naresh G Solankia2d40622016-08-30 20:47:13 +0530365
366 params->PchPmWoWlanEnable = config->PchPmWoWlanEnable;
367 params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable;
368 params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
369
Angel Pons7ff3f312021-06-23 12:13:57 +0200370 params->PchLanEnable = is_devfn_enabled(PCH_DEVFN_GBE);
Felix Singer57c81432020-07-25 07:50:51 +0200371 if (params->PchLanEnable) {
Duncan Laurie14485ef2017-12-13 13:58:35 -0800372 params->PchLanLtrEnable = config->EnableLanLtr;
373 params->PchLanK1OffEnable = config->EnableLanK1Off;
374 params->PchLanClkReqSupported = config->LanClkReqSupported;
375 params->PchLanClkReqNumber = config->LanClkReqNumber;
376 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530377 params->SsicPortEnable = config->SsicPortEnable;
Felix Singeraff69be2020-07-25 13:37:17 +0200378
Angel Pons7ff3f312021-06-23 12:13:57 +0200379 params->ScsEmmcEnabled = is_devfn_enabled(PCH_DEVFN_EMMC);
Naresh G Solankia2d40622016-08-30 20:47:13 +0530380 params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
Felix Singer52919522020-07-29 21:44:36 +0200381
Angel Pons7ff3f312021-06-23 12:13:57 +0200382 params->ScsSdCardEnabled = is_devfn_enabled(PCH_DEVFN_SDCARD);
li feng21066382018-05-22 12:49:53 -0700383
Pratik Prajapatie0722472018-08-22 18:58:38 -0700384 if (!!params->ScsEmmcHs400Enabled && !!config->EmmcHs400DllNeed) {
385 params->PchScsEmmcHs400DllDataValid =
386 !!config->EmmcHs400DllNeed;
387 params->PchScsEmmcHs400RxStrobeDll1 =
388 config->ScsEmmcHs400RxStrobeDll1;
389 params->PchScsEmmcHs400TxDataDll =
390 config->ScsEmmcHs400TxDataDll;
391 }
392
li feng21066382018-05-22 12:49:53 -0700393 /* If ISH is enabled, enable ISH elements */
Angel Pons7ff3f312021-06-23 12:13:57 +0200394 params->PchIshEnable = is_devfn_enabled(PCH_DEVFN_ISH);
li feng21066382018-05-22 12:49:53 -0700395
Angel Pons7ff3f312021-06-23 12:13:57 +0200396 params->PchHdaEnable = is_devfn_enabled(PCH_DEVFN_HDA);
Felix Singer048d9b52020-07-25 14:31:58 +0200397
Michael Niewöhner62385632019-09-23 14:38:41 +0200398 params->PchHdaVcType = config->PchHdaVcType;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530399 params->PchHdaIoBufferOwnership = config->IoBufferOwnership;
400 params->PchHdaDspEnable = config->DspEnable;
Felix Singer9c1c0092020-07-29 20:48:08 +0200401
Angel Pons7ff3f312021-06-23 12:13:57 +0200402 params->Device4Enable = is_devfn_enabled(SA_DEVFN_TS);
403 params->PchThermalDeviceEnable = is_devfn_enabled(PCH_DEVFN_THERMAL);
Matt DeVillier9e0d69b2017-10-10 14:03:36 -0500404
Naresh G Solankia2d40622016-08-30 20:47:13 +0530405 tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530406 tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock;
Angel Pons950cdbc2020-12-11 17:00:42 +0100407 tconfig->PowerLimit4 = 0;
Barnali Sarkarfbf10182017-08-11 18:38:38 +0530408 /*
409 * To disable HECI, the Psf needs to be left unlocked
Subrata Banika0d9ad32022-01-03 18:07:13 +0000410 * by FSP till end of post sequence. Based on the config
Barnali Sarkarfbf10182017-08-11 18:38:38 +0530411 * setting, we set the appropriate PsfUnlock policy in FSP,
412 * do the changes and then lock it back in coreboot during finalize.
413 */
Subrata Banika0d9ad32022-01-03 18:07:13 +0000414 tconfig->PchSbAccessUnlock = CONFIG(DISABLE_HECI1_AT_PRE_BOOT);
Felix Singer5385b4d2021-05-03 02:25:08 +0200415
416 const bool lockdown_by_fsp = get_lockdown_config() == CHIPSET_LOCKDOWN_FSP;
417 tconfig->PchLockDownBiosInterface = lockdown_by_fsp;
418 params->PchLockDownBiosLock = lockdown_by_fsp;
419 params->PchLockDownSpiEiss = lockdown_by_fsp;
420 /*
421 * Making this config "0" means FSP won't set the FLOCKDN bit
422 * of SPIBAR + 0x04 (i.e., Bit 15 of BIOS_HSFSTS_CTL).
423 * So, it becomes coreboot's responsibility to set this bit
424 * before end of POST for security concerns.
425 */
426 params->SpiFlashCfgLockDown = lockdown_by_fsp;
427
Benjamin Dorondc667982020-10-16 18:07:13 +0000428 /* FSP should let coreboot set subsystem IDs, which are read/write-once */
429 params->DefaultSvid = 0;
430 params->PchSubSystemVendorId = 0;
431 params->DefaultSid = 0;
432 params->PchSubSystemId = 0;
Elyes HAOUASb58e99d2019-01-23 12:04:43 +0100433
Naresh G Solankia2d40622016-08-30 20:47:13 +0530434 params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride;
435 params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
436 params->PchPmDeepSxPol = config->PmConfigDeepSxPol;
Duncan Laurie25c7d932017-02-17 17:16:43 -0800437 params->PchPmSlpS0Enable = config->s0ix_enable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530438 params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert;
439 params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert;
440 params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert;
441 params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530442 params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp;
443 params->PchPmPwrBtnOverridePeriod =
444 config->PmConfigPwrBtnOverridePeriod;
445 params->PchPmPwrCycDur = config->PmConfigPwrCycDur;
Rizwan Qureshi0da186c2017-02-23 14:43:39 +0530446
447 /* Indicate whether platform supports Voltage Margining */
448 params->PchPmSlpS0VmEnable = config->PchPmSlpS0VmEnable;
449
Nico Huber44e89af2019-02-23 19:24:51 +0100450 params->PchSirqEnable = config->serirq_mode != SERIRQ_OFF;
451 params->PchSirqMode = config->serirq_mode == SERIRQ_CONTINUOUS;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530452
Martin Rothc25c1eb2020-07-24 12:26:21 -0600453 params->CpuConfig.Bits.SkipMpInit = !CONFIG(USE_INTEL_FSP_MP_INIT);
Naresh G Solankia2d40622016-08-30 20:47:13 +0530454
Subrata Banikc4986eb2018-05-09 14:55:09 +0530455 for (i = 0; i < ARRAY_SIZE(config->i2c_voltage); i++)
Aaron Durbined14a4e2016-11-09 17:04:15 -0600456 params->SerialIoI2cVoltage[i] = config->i2c_voltage[i];
Naresh G Solankia2d40622016-08-30 20:47:13 +0530457
458 for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++)
459 fill_vr_domain_config(params, i, &config->domain_vr_config[i]);
460
461 /* Show SPI controller if enabled in devicetree.cb */
Angel Pons7ff3f312021-06-23 12:13:57 +0200462 params->ShowSpiController = is_devfn_enabled(PCH_DEVFN_SPI);
Naresh G Solankia2d40622016-08-30 20:47:13 +0530463
Angel Ponsc7cfe0b2021-06-23 12:39:22 +0200464 params->XdciEnable = xdci_can_enable(PCH_DEVFN_USBOTG);
Duncan Laurief5116952018-03-26 02:24:18 -0700465
Maxim Polyakov03ddd192019-08-30 18:04:02 +0300466 /* Enable or disable Gaussian Mixture Model in devicetree */
Angel Pons7ff3f312021-06-23 12:13:57 +0200467 params->GmmEnable = is_devfn_enabled(SA_DEVFN_GMM);
Maxim Polyakov03ddd192019-08-30 18:04:02 +0300468
Rizwan Qureshi64670142016-11-23 15:25:19 +0530469 /*
470 * Send VR specific mailbox commands:
471 * 000b - no VR specific command sent
472 * 001b - VR mailbox command specifically for the MPS IMPV8 VR
Lee Leahyf4c4ab92017-03-16 17:08:03 -0700473 * will be sent
Rizwan Qureshi64670142016-11-23 15:25:19 +0530474 * 010b - VR specific command sent for PS4 exit issue
475 * 100b - VR specific command sent for MPS VR decay issue
476 */
477 params->SendVrMbxCmd1 = config->SendVrMbxCmd;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530478
Rizwan Qureshib3e18c72017-09-25 17:35:15 +0530479 /*
480 * Activates VR mailbox command for Intersil VR C-state issues.
481 * 0 - no mailbox command sent.
482 * 1 - VR mailbox command sent for IA/GT rails only.
483 * 2 - VR mailbox command sent for IA/GT/SA rails.
484 */
485 params->IslVrCmd = config->IslVrCmd;
486
Duncan Laurieb2aac852017-03-07 19:12:02 -0800487 /* Acoustic Noise Mitigation */
488 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
489 params->SlowSlewRateForIa = config->SlowSlewRateForIa;
490 params->SlowSlewRateForGt = config->SlowSlewRateForGt;
491 params->SlowSlewRateForSa = config->SlowSlewRateForSa;
492 params->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa;
493 params->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt;
494 params->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa;
495
Rizwan Qureshiffe58102017-02-10 15:58:24 +0530496 /* Enable PMC XRAM read */
497 tconfig->PchPmPmcReadDisable = config->PchPmPmcReadDisable;
498
Subrata Banik6b45ee42017-05-12 11:43:57 +0530499 /* Enable/Disable EIST */
500 tconfig->Eist = config->eist_enable;
501
marxwangec5a9472017-12-11 14:57:49 +0800502 /* Set TccActivationOffset */
503 tconfig->TccActivationOffset = config->tcc_offset;
504
Angel Pons4ff63d32019-08-30 20:05:33 +0200505 /* Already handled in coreboot code, so tell FSP to ignore UPDs */
506 params->PchIoApicBdfValid = 0;
507
Nico Huber2afe4dc2017-09-19 09:36:03 +0200508 /* Enable VT-d and X2APIC */
Sean Rhodes66c80622021-07-13 07:23:22 +0100509 if (soc_vtd_enabled()) {
Nico Huber2afe4dc2017-09-19 09:36:03 +0200510 params->VtdBaseAddress[0] = GFXVT_BASE_ADDRESS;
511 params->VtdBaseAddress[1] = VTVC0_BASE_ADDRESS;
512 params->X2ApicOptOut = 0;
513 tconfig->VtdDisable = 0;
Nico Huber2afe4dc2017-09-19 09:36:03 +0200514 }
515
Angel Pons7ff3f312021-06-23 12:13:57 +0200516 params->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD);
Michael Niewöhnerd60089b2019-10-26 10:44:33 +0200517
Benjamin Doronbbb81232020-06-28 02:43:53 +0000518 params->PavpEnable = CONFIG(PAVP);
519
Naresh G Solankia2d40622016-08-30 20:47:13 +0530520 soc_irq_settings(params);
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530521}
Lee Leahyb0005132015-05-12 18:19:47 -0700522
Felix Singer3616e9c2020-11-25 20:10:49 +0000523/* Mainboard FSP Configuration */
Aaron Durbin64031672018-04-21 14:45:32 -0600524__weak void mainboard_silicon_init_params(FSP_S_CONFIG *params)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530525{
526 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
527}
Wim Vervoornd1371502019-12-17 14:10:16 +0100528
529/* Handle FSP logo params */
Kyösti Mälkki4949a3d2021-01-09 20:38:43 +0200530void soc_load_logo(FSPS_UPD *supd)
Wim Vervoornd1371502019-12-17 14:10:16 +0100531{
Kyösti Mälkki4949a3d2021-01-09 20:38:43 +0200532 bmp_load_logo(&supd->FspsConfig.LogoPtr, &supd->FspsConfig.LogoSize);
Wim Vervoornd1371502019-12-17 14:10:16 +0100533}