blob: 6423cf4120883c1998e8ada71ad2bc7b36ac40cd [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
Wim Vervoornd1371502019-12-17 14:10:16 +01003#include <cbmem.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>
Kyösti Mälkki32d47eb2019-09-28 00:00:30 +030010#include <intelblocks/cfg.h>
Subrata Banik46caf092018-09-28 19:54:30 +053011#include <intelblocks/itss.h>
Nico Huber44e89af2019-02-23 19:24:51 +010012#include <intelblocks/lpc_lib.h>
Subrata Banikcf32fd12018-12-19 18:02:17 +053013#include <intelblocks/mp_init.h>
Nico Huberad91b182019-10-12 15:16:33 +020014#include <intelblocks/pcie_rp.h>
Sumeet R Pawnikar97c54642020-05-10 01:24:11 +053015#include <intelblocks/power_limit.h>
Duncan Laurief5116952018-03-26 02:24:18 -070016#include <intelblocks/xdci.h>
Patrick Rudolph5199e822019-09-26 14:00:14 +020017#include <intelblocks/p2sb.h>
Subrata Banik9cd99a12018-05-28 16:12:03 +053018#include <intelpch/lockdown.h>
Brandon Breitensteinc6ec8dd2016-11-17 12:23:04 -080019#include <romstage_handoff.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053020#include <soc/acpi.h>
Patrick Georgic6a00502017-10-05 18:19:29 +020021#include <soc/intel/common/vbt.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053022#include <soc/interrupt.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020023#include <soc/iomap.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053024#include <soc/irq.h>
Subrata Banik46caf092018-09-28 19:54:30 +053025#include <soc/itss.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053026#include <soc/pci_devs.h>
27#include <soc/ramstage.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020028#include <soc/systemagent.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053029#include <string.h>
30
Elyes HAOUASc3385072019-03-21 15:38:06 +010031#include "chip.h"
32
Nico Huberad91b182019-10-12 15:16:33 +020033static const struct pcie_rp_group pch_lp_rp_groups[] = {
34 { .slot = PCH_DEV_SLOT_PCIE, .count = 8 },
35 { .slot = PCH_DEV_SLOT_PCIE_1, .count = 4 },
36 { 0 }
Gaggery Tsai711fb812018-05-22 12:32:48 -070037};
38
Nico Huberad91b182019-10-12 15:16:33 +020039static const struct pcie_rp_group pch_h_rp_groups[] = {
40 { .slot = PCH_DEV_SLOT_PCIE, .count = 8 },
41 { .slot = PCH_DEV_SLOT_PCIE_1, .count = 8 },
42 /* Sunrise Point PCH-H actually only has 4 ports in the
43 third group. But that would require a runtime check
44 and probing 4 non-existent ports shouldn't hurt. */
45 { .slot = PCH_DEV_SLOT_PCIE_2, .count = 8 },
46 { 0 }
Gaggery Tsai711fb812018-05-22 12:32:48 -070047};
48
Naresh G Solankia2d40622016-08-30 20:47:13 +053049void soc_init_pre_device(void *chip_info)
50{
Subrata Banik46caf092018-09-28 19:54:30 +053051 /* Snapshot the current GPIO IRQ polarities. FSP is setting a
52 * default policy that doesn't honor boards' requirements. */
53 itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
54
Naresh G Solankia2d40622016-08-30 20:47:13 +053055 /* Perform silicon specific init. */
Aaron Durbin6c191d82016-11-29 21:22:42 -060056 fsp_silicon_init(romstage_handoff_is_resume());
Subrata Banik46caf092018-09-28 19:54:30 +053057
Patrick Rudolph5199e822019-09-26 14:00:14 +020058 /*
59 * Keep the P2SB device visible so it and the other devices are
60 * visible in coreboot for driver support and PCI resource allocation.
61 * There is no UPD setting for this.
62 */
63 p2sb_unhide();
64
Subrata Banik46caf092018-09-28 19:54:30 +053065 /* Restore GPIO IRQ polarities back to previous settings. */
66 itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
67
Gaggery Tsai711fb812018-05-22 12:32:48 -070068 /* swap enabled PCI ports in device tree if needed */
Nico Huberad91b182019-10-12 15:16:33 +020069 if (CONFIG(SKYLAKE_SOC_PCH_H))
70 pcie_rp_update_devicetree(pch_h_rp_groups);
71 else
72 pcie_rp_update_devicetree(pch_lp_rp_groups);
Naresh G Solankia2d40622016-08-30 20:47:13 +053073}
74
Furquan Shaikhc2480442017-02-20 13:41:56 -080075void soc_fsp_load(void)
76{
77 fsps_load(romstage_handoff_is_resume());
78}
79
Naresh G Solankia2d40622016-08-30 20:47:13 +053080static struct device_operations pci_domain_ops = {
81 .read_resources = &pci_domain_read_resources,
82 .set_resources = &pci_domain_set_resources,
83 .scan_bus = &pci_domain_scan_bus,
Julius Wernercd49cce2019-03-05 16:53:33 -080084#if CONFIG(HAVE_ACPI_TABLES)
Nico Huberc37b0e32017-09-18 20:03:46 +020085 .write_acpi_tables = &northbridge_write_acpi_tables,
86 .acpi_name = &soc_acpi_name,
Naresh G Solankia2d40622016-08-30 20:47:13 +053087#endif
88};
89
90static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020091 .read_resources = noop_read_resources,
92 .set_resources = noop_set_resources,
Julius Wernercd49cce2019-03-05 16:53:33 -080093#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +020094 .acpi_fill_ssdt = generate_cpu_entries,
Naresh G Solankia2d40622016-08-30 20:47:13 +053095#endif
96};
97
Elyes HAOUAS143fb462018-05-25 12:56:45 +020098static void soc_enable(struct device *dev)
Naresh G Solankia2d40622016-08-30 20:47:13 +053099{
100 /* Set the operations if it is a special bus type */
Subrata Banik3c838c72017-12-06 18:14:01 +0530101 if (dev->path.type == DEVICE_PATH_DOMAIN)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530102 dev->ops = &pci_domain_ops;
Subrata Banik3c838c72017-12-06 18:14:01 +0530103 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530104 dev->ops = &cpu_bus_ops;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530105}
106
107struct chip_operations soc_intel_skylake_ops = {
108 CHIP_NAME("Intel 6th Gen")
109 .enable_dev = &soc_enable,
110 .init = &soc_init_pre_device,
111};
Lee Leahyb0005132015-05-12 18:19:47 -0700112
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530113/* UPD parameters to be initialized before SiliconInit */
Naresh G Solankia2d40622016-08-30 20:47:13 +0530114void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530115{
Naresh G Solankia2d40622016-08-30 20:47:13 +0530116 FSP_S_CONFIG *params = &supd->FspsConfig;
117 FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig;
Kyösti Mälkki4af4e7f2019-07-14 05:50:20 +0300118 struct soc_intel_skylake_config *config;
Kyösti Mälkki28dc7dc2019-07-12 13:10:19 +0300119 struct device *dev;
Patrick Georgid2990ff2018-05-03 18:06:15 +0200120 uintptr_t vbt_data = (uintptr_t)vbt_get();
Naresh G Solankia2d40622016-08-30 20:47:13 +0530121 int i;
122
Kyösti Mälkkid5f645c2019-09-28 00:20:27 +0300123 config = config_of_soc();
Naresh G Solankia2d40622016-08-30 20:47:13 +0530124
125 mainboard_silicon_init_params(params);
Sumeet R Pawnikar97c54642020-05-10 01:24:11 +0530126
127 struct soc_power_limits_config *soc_confg;
128 config_t *confg = config_of_soc();
129 soc_confg = &confg->power_limits_config;
Gaggery Tsaida6f4ae2018-01-15 15:03:01 +0800130 /* Set PsysPmax if it is available from DT */
Sumeet R Pawnikar97c54642020-05-10 01:24:11 +0530131 if (soc_confg->psys_pmax) {
Gaggery Tsaida6f4ae2018-01-15 15:03:01 +0800132 /* PsysPmax is in unit of 1/8 Watt */
Sumeet R Pawnikar97c54642020-05-10 01:24:11 +0530133 tconfig->PsysPmax = soc_confg->psys_pmax * 8;
Gaggery Tsaida6f4ae2018-01-15 15:03:01 +0800134 printk(BIOS_DEBUG, "psys_pmax = %d\n", tconfig->PsysPmax);
135 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530136
Naresh G Solankia2d40622016-08-30 20:47:13 +0530137 params->GraphicsConfigPtr = (u32) vbt_data;
138
139 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
140 params->PortUsb20Enable[i] =
141 config->usb2_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530142 params->Usb2OverCurrentPin[i] =
143 config->usb2_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530144 params->Usb2AfePetxiset[i] =
145 config->usb2_ports[i].pre_emp_bias;
146 params->Usb2AfeTxiset[i] =
147 config->usb2_ports[i].tx_bias;
148 params->Usb2AfePredeemp[i] =
149 config->usb2_ports[i].tx_emp_enable;
150 params->Usb2AfePehalfbit[i] =
151 config->usb2_ports[i].pre_emp_bit;
152 }
153
154 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
155 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530156 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530157 if (config->usb3_ports[i].tx_de_emp) {
158 params->Usb3HsioTxDeEmphEnable[i] = 1;
159 params->Usb3HsioTxDeEmph[i] =
160 config->usb3_ports[i].tx_de_emp;
161 }
162 if (config->usb3_ports[i].tx_downscale_amp) {
163 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
164 params->Usb3HsioTxDownscaleAmp[i] =
165 config->usb3_ports[i].tx_downscale_amp;
166 }
167 }
168
Felix Singer0901d032020-07-29 19:57:25 +0200169 dev = pcidev_path_on_root(PCH_DEVFN_SATA);
170 params->SataEnable = dev ? dev->enabled : 0;
171 if (params->SataEnable) {
Felix Singer4e58ce12020-07-25 04:39:52 +0200172 memcpy(params->SataPortsEnable, config->SataPortsEnable,
173 sizeof(params->SataPortsEnable));
174 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
175 sizeof(params->SataPortsDevSlp));
176 memcpy(params->SataPortsHotPlug, config->SataPortsHotPlug,
177 sizeof(params->SataPortsHotPlug));
178 memcpy(params->SataPortsSpinUp, config->SataPortsSpinUp,
179 sizeof(params->SataPortsSpinUp));
180
181 params->SataSalpSupport = config->SataSalpSupport;
182 params->SataMode = config->SataMode;
183 params->SataSpeedLimit = config->SataSpeedLimit;
184 /*
185 * For unknown reasons FSP skips writing some essential SATA init registers
186 * (SIR) when SataPwrOptEnable=0. This results in link errors, "unaligned
187 * write" errors and others. Enabling this option solves these problems.
188 */
189 params->SataPwrOptEnable = 1;
190 tconfig->SataTestMode = config->SataTestMode;
191 }
192
Naresh G Solankia2d40622016-08-30 20:47:13 +0530193 memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport,
194 sizeof(params->PcieRpClkReqSupport));
195 memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber,
196 sizeof(params->PcieRpClkReqNumber));
Rizwan Qureshi6ab4ed42017-09-05 14:18:25 +0530197 memcpy(params->PcieRpAdvancedErrorReporting,
198 config->PcieRpAdvancedErrorReporting,
199 sizeof(params->PcieRpAdvancedErrorReporting));
Rizwan Qureshi03937392017-09-16 01:54:20 +0530200 memcpy(params->PcieRpLtrEnable, config->PcieRpLtrEnable,
201 sizeof(params->PcieRpLtrEnable));
Duncan Laurie74ea48e2018-01-29 12:00:47 -0800202 memcpy(params->PcieRpHotPlug, config->PcieRpHotPlug,
203 sizeof(params->PcieRpHotPlug));
Wim Vervoorn5819eab2020-05-07 13:16:32 +0200204 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
Wim Vervoornd6b682c2020-05-07 12:41:13 +0200205 params->PcieRpMaxPayload[i] = config->PcieRpMaxPayload[i];
Wim Vervoorn5819eab2020-05-07 13:16:32 +0200206 if (config->PcieRpAspm[i])
207 params->PcieRpAspm[i] = config->PcieRpAspm[i] - 1;
208 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530209
Divya Chellape7fb7ce2017-12-19 20:16:50 +0530210 /*
211 * PcieRpClkSrcNumber UPD is set to clock source number(0-6) for
212 * all the enabled PCIe root ports, invalid(0x1F) is set for
213 * disabled PCIe root ports.
214 */
215 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
216 if (config->PcieRpClkReqSupport[i])
217 params->PcieRpClkSrcNumber[i] =
218 config->PcieRpClkSrcNumber[i];
219 else
220 params->PcieRpClkSrcNumber[i] = 0x1F;
221 }
222
Naresh G Solankieedf6d82016-11-16 21:27:38 +0530223 /* disable Legacy PME */
224 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
225
Subrata Banik10a94322019-07-08 14:49:22 +0530226 /* Legacy 8254 timer support */
Martin Rothc25c1eb2020-07-24 12:26:21 -0600227 params->Early8254ClockGatingEnable = !CONFIG(USE_LEGACY_8254_TIMER);
Subrata Banik10a94322019-07-08 14:49:22 +0530228
Naresh G Solankia2d40622016-08-30 20:47:13 +0530229 memcpy(params->SerialIoDevMode, config->SerialIoDevMode,
230 sizeof(params->SerialIoDevMode));
231
232 params->PchCio2Enable = config->Cio2Enable;
Rizwan Qureshic2c8a742017-01-13 22:04:11 +0530233 params->SaImguEnable = config->SaImguEnable;
Felix Singer91dfb922020-07-25 14:01:52 +0200234
235 dev = pcidev_path_on_root(PCH_DEVFN_CSE_3);
236 params->Heci3Enabled = dev ? dev->enabled : 0;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530237
238 params->LogoPtr = config->LogoPtr;
239 params->LogoSize = config->LogoSize;
240
Julius Wernercd49cce2019-03-05 16:53:33 -0800241 params->CpuConfig.Bits.VmxEnable = CONFIG(ENABLE_VMX);
Naresh G Solankia2d40622016-08-30 20:47:13 +0530242
243 params->PchPmWoWlanEnable = config->PchPmWoWlanEnable;
244 params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable;
245 params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
246
Felix Singer57c81432020-07-25 07:50:51 +0200247 dev = pcidev_path_on_root(PCH_DEVFN_GBE);
248 params->PchLanEnable = dev ? dev->enabled : 0;
249 if (params->PchLanEnable) {
Duncan Laurie14485ef2017-12-13 13:58:35 -0800250 params->PchLanLtrEnable = config->EnableLanLtr;
251 params->PchLanK1OffEnable = config->EnableLanK1Off;
252 params->PchLanClkReqSupported = config->LanClkReqSupported;
253 params->PchLanClkReqNumber = config->LanClkReqNumber;
254 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530255 params->SsicPortEnable = config->SsicPortEnable;
Felix Singeraff69be2020-07-25 13:37:17 +0200256
257 dev = pcidev_path_on_root(PCH_DEVFN_EMMC);
258 params->ScsEmmcEnabled = dev ? dev->enabled : 0;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530259 params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
260 params->ScsSdCardEnabled = config->ScsSdCardEnabled;
li feng21066382018-05-22 12:49:53 -0700261
Pratik Prajapatie0722472018-08-22 18:58:38 -0700262 if (!!params->ScsEmmcHs400Enabled && !!config->EmmcHs400DllNeed) {
263 params->PchScsEmmcHs400DllDataValid =
264 !!config->EmmcHs400DllNeed;
265 params->PchScsEmmcHs400RxStrobeDll1 =
266 config->ScsEmmcHs400RxStrobeDll1;
267 params->PchScsEmmcHs400TxDataDll =
268 config->ScsEmmcHs400TxDataDll;
269 }
270
li feng21066382018-05-22 12:49:53 -0700271 /* If ISH is enabled, enable ISH elements */
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300272 dev = pcidev_path_on_root(PCH_DEVFN_ISH);
Angel Ponsc54dcf42019-08-30 22:14:18 +0200273 params->PchIshEnable = dev ? dev->enabled : 0;
li feng21066382018-05-22 12:49:53 -0700274
Felix Singer048d9b52020-07-25 14:31:58 +0200275 dev = pcidev_path_on_root(PCH_DEVFN_HDA);
276 params->PchHdaEnable = dev ? dev->enabled : 0;
277
Michael Niewöhner62385632019-09-23 14:38:41 +0200278 params->PchHdaVcType = config->PchHdaVcType;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530279 params->PchHdaIoBufferOwnership = config->IoBufferOwnership;
280 params->PchHdaDspEnable = config->DspEnable;
Felix Singer9c1c0092020-07-29 20:48:08 +0200281
282 dev = pcidev_path_on_root(SA_DEVFN_TS);
283 params->Device4Enable = dev && dev->enabled;
Naresh G Solanki84fbc302018-10-15 15:37:15 +0530284 params->EnableTcoTimer = !config->PmTimerDisabled;
Matt DeVillier9e0d69b2017-10-10 14:03:36 -0500285
Michael Niewöhner13dee2a2020-04-30 00:44:04 +0200286
Naresh G Solankia2d40622016-08-30 20:47:13 +0530287 tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530288 tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock;
Praveen hodagatta pranesh015b3dc2018-11-23 17:41:46 +0800289 tconfig->PowerLimit4 = config->PowerLimit4;
Barnali Sarkarfbf10182017-08-11 18:38:38 +0530290 /*
291 * To disable HECI, the Psf needs to be left unlocked
292 * by FSP till end of post sequence. Based on the devicetree
293 * setting, we set the appropriate PsfUnlock policy in FSP,
294 * do the changes and then lock it back in coreboot during finalize.
295 */
296 tconfig->PchSbAccessUnlock = (config->HeciEnabled == 0) ? 1 : 0;
Subrata Banikc4986eb2018-05-09 14:55:09 +0530297 if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT) {
Subrata Banikc204aaa2017-08-17 15:49:58 +0530298 tconfig->PchLockDownBiosInterface = 0;
299 params->PchLockDownBiosLock = 0;
300 params->PchLockDownSpiEiss = 0;
301 /*
302 * Skip Spi Flash Lockdown from inside FSP.
303 * Making this config "0" means FSP won't set the FLOCKDN bit
304 * of SPIBAR + 0x04 (i.e., Bit 15 of BIOS_HSFSTS_CTL).
305 * So, it becomes coreboot's responsibility to set this bit
306 * before end of POST for security concerns.
307 */
308 params->SpiFlashCfgLockDown = 0;
309 }
Matt Delcodfffcad2018-07-23 12:44:15 -0700310 /* only replacing preexisting subsys ID defaults when non-zero */
Elyes HAOUASb58e99d2019-01-23 12:04:43 +0100311 if (CONFIG_SUBSYSTEM_VENDOR_ID != 0) {
312 params->DefaultSvid = CONFIG_SUBSYSTEM_VENDOR_ID;
313 params->PchSubSystemVendorId = CONFIG_SUBSYSTEM_VENDOR_ID;
314 }
315
316 if (CONFIG_SUBSYSTEM_DEVICE_ID != 0) {
317 params->DefaultSid = CONFIG_SUBSYSTEM_DEVICE_ID;
318 params->PchSubSystemId = CONFIG_SUBSYSTEM_DEVICE_ID;
319 }
320
Naresh G Solankia2d40622016-08-30 20:47:13 +0530321 params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride;
322 params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
323 params->PchPmDeepSxPol = config->PmConfigDeepSxPol;
Duncan Laurie25c7d932017-02-17 17:16:43 -0800324 params->PchPmSlpS0Enable = config->s0ix_enable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530325 params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert;
326 params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert;
327 params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert;
328 params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert;
329 params->PchPmLpcClockRun = config->PmConfigPciClockRun;
330 params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp;
331 params->PchPmPwrBtnOverridePeriod =
332 config->PmConfigPwrBtnOverridePeriod;
333 params->PchPmPwrCycDur = config->PmConfigPwrCycDur;
Rizwan Qureshi0da186c2017-02-23 14:43:39 +0530334
335 /* Indicate whether platform supports Voltage Margining */
336 params->PchPmSlpS0VmEnable = config->PchPmSlpS0VmEnable;
337
Nico Huber44e89af2019-02-23 19:24:51 +0100338 params->PchSirqEnable = config->serirq_mode != SERIRQ_OFF;
339 params->PchSirqMode = config->serirq_mode == SERIRQ_CONTINUOUS;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530340
Martin Rothc25c1eb2020-07-24 12:26:21 -0600341 params->CpuConfig.Bits.SkipMpInit = !CONFIG(USE_INTEL_FSP_MP_INIT);
Naresh G Solankia2d40622016-08-30 20:47:13 +0530342
Subrata Banikc4986eb2018-05-09 14:55:09 +0530343 for (i = 0; i < ARRAY_SIZE(config->i2c_voltage); i++)
Aaron Durbined14a4e2016-11-09 17:04:15 -0600344 params->SerialIoI2cVoltage[i] = config->i2c_voltage[i];
Naresh G Solankia2d40622016-08-30 20:47:13 +0530345
346 for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++)
347 fill_vr_domain_config(params, i, &config->domain_vr_config[i]);
348
349 /* Show SPI controller if enabled in devicetree.cb */
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300350 dev = pcidev_path_on_root(PCH_DEVFN_SPI);
Angel Ponsc54dcf42019-08-30 22:14:18 +0200351 params->ShowSpiController = dev ? dev->enabled : 0;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530352
Duncan Laurief5116952018-03-26 02:24:18 -0700353 /* Enable xDCI controller if enabled in devicetree and allowed */
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300354 dev = pcidev_path_on_root(PCH_DEVFN_USBOTG);
Angel Ponsc54dcf42019-08-30 22:14:18 +0200355 if (dev) {
356 if (!xdci_can_enable())
357 dev->enabled = 0;
358 params->XdciEnable = dev->enabled;
359 } else {
360 params->XdciEnable = 0;
361 }
Duncan Laurief5116952018-03-26 02:24:18 -0700362
Maxim Polyakov03ddd192019-08-30 18:04:02 +0300363 /* Enable or disable Gaussian Mixture Model in devicetree */
364 dev = pcidev_path_on_root(SA_DEVFN_GMM);
365 params->GmmEnable = dev ? dev->enabled : 0;
366
Rizwan Qureshi64670142016-11-23 15:25:19 +0530367 /*
368 * Send VR specific mailbox commands:
369 * 000b - no VR specific command sent
370 * 001b - VR mailbox command specifically for the MPS IMPV8 VR
Lee Leahyf4c4ab92017-03-16 17:08:03 -0700371 * will be sent
Rizwan Qureshi64670142016-11-23 15:25:19 +0530372 * 010b - VR specific command sent for PS4 exit issue
373 * 100b - VR specific command sent for MPS VR decay issue
374 */
375 params->SendVrMbxCmd1 = config->SendVrMbxCmd;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530376
Rizwan Qureshib3e18c72017-09-25 17:35:15 +0530377 /*
378 * Activates VR mailbox command for Intersil VR C-state issues.
379 * 0 - no mailbox command sent.
380 * 1 - VR mailbox command sent for IA/GT rails only.
381 * 2 - VR mailbox command sent for IA/GT/SA rails.
382 */
383 params->IslVrCmd = config->IslVrCmd;
384
Duncan Laurieb2aac852017-03-07 19:12:02 -0800385 /* Acoustic Noise Mitigation */
386 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
387 params->SlowSlewRateForIa = config->SlowSlewRateForIa;
388 params->SlowSlewRateForGt = config->SlowSlewRateForGt;
389 params->SlowSlewRateForSa = config->SlowSlewRateForSa;
390 params->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa;
391 params->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt;
392 params->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa;
393
Rizwan Qureshiffe58102017-02-10 15:58:24 +0530394 /* Enable PMC XRAM read */
395 tconfig->PchPmPmcReadDisable = config->PchPmPmcReadDisable;
396
Subrata Banik6b45ee42017-05-12 11:43:57 +0530397 /* Enable/Disable EIST */
398 tconfig->Eist = config->eist_enable;
399
marxwangec5a9472017-12-11 14:57:49 +0800400 /* Set TccActivationOffset */
401 tconfig->TccActivationOffset = config->tcc_offset;
402
Angel Pons4ff63d32019-08-30 20:05:33 +0200403 /* Already handled in coreboot code, so tell FSP to ignore UPDs */
404 params->PchIoApicBdfValid = 0;
405
Nico Huber2afe4dc2017-09-19 09:36:03 +0200406 /* Enable VT-d and X2APIC */
407 if (!config->ignore_vtd && soc_is_vtd_capable()) {
408 params->VtdBaseAddress[0] = GFXVT_BASE_ADDRESS;
409 params->VtdBaseAddress[1] = VTVC0_BASE_ADDRESS;
410 params->X2ApicOptOut = 0;
411 tconfig->VtdDisable = 0;
Nico Huber2afe4dc2017-09-19 09:36:03 +0200412 }
413
Michael Niewöhnerd60089b2019-10-26 10:44:33 +0200414 dev = pcidev_path_on_root(SA_DEVFN_IGD);
415 if (CONFIG(RUN_FSP_GOP) && dev && dev->enabled)
416 params->PeiGraphicsPeimInit = 1;
417 else
418 params->PeiGraphicsPeimInit = 0;
419
Naresh G Solankia2d40622016-08-30 20:47:13 +0530420 soc_irq_settings(params);
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530421}
Lee Leahyb0005132015-05-12 18:19:47 -0700422
Naresh G Solankia2d40622016-08-30 20:47:13 +0530423/* Mainboard GPIO Configuration */
Aaron Durbin64031672018-04-21 14:45:32 -0600424__weak void mainboard_silicon_init_params(FSP_S_CONFIG *params)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530425{
426 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
427}
Wim Vervoornd1371502019-12-17 14:10:16 +0100428
429/* Handle FSP logo params */
430const struct cbmem_entry *soc_load_logo(FSPS_UPD *supd)
431{
432 return fsp_load_logo(&supd->FspsConfig.LogoPtr, &supd->FspsConfig.LogoSize);
433}