blob: c4f4e50cd2b49e87850128a957b6f9b9041d268c [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
Duncan Laurie7d484102017-01-09 22:23:39 -080016#include <bootmode.h>
Rizwan Qureshi1222a732016-08-23 14:31:23 +053017#include <bootstate.h>
18#include <device/pci.h>
19#include <fsp/api.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053020#include <arch/acpi.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020021#include <device/pci_ops.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053022#include <console/console.h>
23#include <device/device.h>
Gaggery Tsai711fb812018-05-22 12:32:48 -070024#include <device/pci_ids.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053025#include <fsp/util.h>
Kyösti Mälkki32d47eb2019-09-28 00:00:30 +030026#include <intelblocks/cfg.h>
Subrata Banik46caf092018-09-28 19:54:30 +053027#include <intelblocks/itss.h>
Nico Huber44e89af2019-02-23 19:24:51 +010028#include <intelblocks/lpc_lib.h>
Subrata Banikcf32fd12018-12-19 18:02:17 +053029#include <intelblocks/mp_init.h>
Duncan Laurief5116952018-03-26 02:24:18 -070030#include <intelblocks/xdci.h>
Patrick Rudolph5199e822019-09-26 14:00:14 +020031#include <intelblocks/p2sb.h>
Subrata Banik9cd99a12018-05-28 16:12:03 +053032#include <intelpch/lockdown.h>
Brandon Breitensteinc6ec8dd2016-11-17 12:23:04 -080033#include <romstage_handoff.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053034#include <soc/acpi.h>
Patrick Georgic6a00502017-10-05 18:19:29 +020035#include <soc/intel/common/vbt.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053036#include <soc/interrupt.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020037#include <soc/iomap.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053038#include <soc/irq.h>
Subrata Banik46caf092018-09-28 19:54:30 +053039#include <soc/itss.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053040#include <soc/pci_devs.h>
41#include <soc/ramstage.h>
Nico Huber2afe4dc2017-09-19 09:36:03 +020042#include <soc/systemagent.h>
Naresh G Solankia2d40622016-08-30 20:47:13 +053043#include <string.h>
44
Elyes HAOUASc3385072019-03-21 15:38:06 +010045#include "chip.h"
46
Gaggery Tsai711fb812018-05-22 12:32:48 -070047struct pcie_entry {
48 unsigned int devfn;
49 unsigned int func_count;
50};
51
52/*
53 * According to table 2-2 in doc#546717:
54 * PCI bus[function] ID
55 * D28:[F0 - F7] 0xA110 - 0xA117
56 * D29:[F0 - F7] 0xA118 - 0xA11F
57 * D27:[F0 - F3] 0xA167 - 0xA16A
58 */
59static const struct pcie_entry pcie_table_skl_pch_h[] = {
60 {PCH_DEVFN_PCIE1, 8},
61 {PCH_DEVFN_PCIE9, 8},
62 {PCH_DEVFN_PCIE17, 4},
63};
64
65/*
66 * According to table 2-2 in doc#564464:
67 * PCI bus[function] ID
68 * D28:[F0 - F7] 0xA290 - 0xA297
69 * D29:[F0 - F7] 0xA298 - 0xA29F
70 * D27:[F0 - F7] 0xA2E7 - 0xA2EE
71 */
72static const struct pcie_entry pcie_table_kbl_pch_h[] = {
73 {PCH_DEVFN_PCIE1, 8},
74 {PCH_DEVFN_PCIE9, 8},
75 {PCH_DEVFN_PCIE17, 8},
76};
77
78/*
79 * According to table 2-2 in doc#567995/545659:
80 * PCI bus[function] ID
81 * D28:[F0 - F7] 0x9D10 - 0x9D17
82 * D29:[F0 - F3] 0x9D18 - 0x9D1B
83 */
84static const struct pcie_entry pcie_table_skl_pch_lp[] = {
85 {PCH_DEVFN_PCIE1, 8},
86 {PCH_DEVFN_PCIE9, 4},
87};
88
89/*
90 * If the PCIe root port at function 0 is disabled,
91 * the PCIe root ports might be coalesced after FSP silicon init.
92 * The below function will swap the devfn of the first enabled device
93 * in devicetree and function 0 resides a pci device
94 * so that it won't confuse coreboot.
95 */
96static void pcie_update_device_tree(const struct pcie_entry *pcie_rp_group,
97 size_t pci_groups)
98{
99 struct device *func0;
100 unsigned int devfn, devfn0;
101 int i, group;
102 unsigned int inc = PCI_DEVFN(0, 1);
103
104 for (group = 0; group < pci_groups; group++) {
105 devfn0 = pcie_rp_group[group].devfn;
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300106 func0 = pcidev_path_on_root(devfn0);
Gaggery Tsai711fb812018-05-22 12:32:48 -0700107 if (func0 == NULL)
108 continue;
109
110 /* No more functions if function 0 is disabled. */
111 if (pci_read_config32(func0, PCI_VENDOR_ID) == 0xffffffff)
112 continue;
113
114 devfn = devfn0 + inc;
115
116 /*
117 * Increase function by 1.
118 * Then find first enabled device to replace func0
119 * as that port was move to func0.
120 */
121 for (i = 1; i < pcie_rp_group[group].func_count;
122 i++, devfn += inc) {
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300123 struct device *dev = pcidev_path_on_root(devfn);
Gaggery Tsai711fb812018-05-22 12:32:48 -0700124 if (dev == NULL || !dev->enabled)
125 continue;
126
127 /*
128 * Found the first enabled device in
129 * a given dev number.
130 */
131 printk(BIOS_INFO, "PCI func %d was swapped"
132 " to func 0.\n", i);
133 func0->path.pci.devfn = dev->path.pci.devfn;
134 dev->path.pci.devfn = devfn0;
135 break;
136 }
137 }
138}
139
140static void pcie_override_devicetree_after_silicon_init(void)
141{
142 uint16_t id, id_mask;
143
144 id = pci_read_config16(PCH_DEV_PCIE1, PCI_DEVICE_ID);
145 /*
146 * We may read an ID other than func 0 after FSP-S.
147 * Strip out 4 least significant bits.
148 */
149 id_mask = id & ~0xf;
150 printk(BIOS_INFO, "Override DT after FSP-S, PCH is ");
151 if (id_mask == (PCI_DEVICE_ID_INTEL_SPT_LP_PCIE_RP1 & ~0xf)) {
152 printk(BIOS_INFO, "KBL/SKL PCH-LP SKU\n");
153 pcie_update_device_tree(&pcie_table_skl_pch_lp[0],
154 ARRAY_SIZE(pcie_table_skl_pch_lp));
155 } else if (id_mask == (PCI_DEVICE_ID_INTEL_KBP_H_PCIE_RP1 & ~0xf)) {
156 printk(BIOS_INFO, "KBL PCH-H SKU\n");
157 pcie_update_device_tree(&pcie_table_kbl_pch_h[0],
158 ARRAY_SIZE(pcie_table_kbl_pch_h));
159 } else if (id_mask == (PCI_DEVICE_ID_INTEL_SPT_H_PCIE_RP1 & ~0xf)) {
160 printk(BIOS_INFO, "SKL PCH-H SKU\n");
161 pcie_update_device_tree(&pcie_table_skl_pch_h[0],
162 ARRAY_SIZE(pcie_table_skl_pch_h));
163 } else {
164 printk(BIOS_ERR, "[BUG] PCIE Root Port id 0x%x"
165 " is not found\n", id);
166 return;
167 }
168}
169
Naresh G Solankia2d40622016-08-30 20:47:13 +0530170void soc_init_pre_device(void *chip_info)
171{
Subrata Banik46caf092018-09-28 19:54:30 +0530172 /* Snapshot the current GPIO IRQ polarities. FSP is setting a
173 * default policy that doesn't honor boards' requirements. */
174 itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
175
Naresh G Solankia2d40622016-08-30 20:47:13 +0530176 /* Perform silicon specific init. */
Aaron Durbin6c191d82016-11-29 21:22:42 -0600177 fsp_silicon_init(romstage_handoff_is_resume());
Subrata Banik46caf092018-09-28 19:54:30 +0530178
Patrick Rudolph5199e822019-09-26 14:00:14 +0200179 /*
180 * Keep the P2SB device visible so it and the other devices are
181 * visible in coreboot for driver support and PCI resource allocation.
182 * There is no UPD setting for this.
183 */
184 p2sb_unhide();
185
Subrata Banik46caf092018-09-28 19:54:30 +0530186 /* Restore GPIO IRQ polarities back to previous settings. */
187 itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
188
Gaggery Tsai711fb812018-05-22 12:32:48 -0700189 /* swap enabled PCI ports in device tree if needed */
190 pcie_override_devicetree_after_silicon_init();
Naresh G Solankia2d40622016-08-30 20:47:13 +0530191}
192
Furquan Shaikhc2480442017-02-20 13:41:56 -0800193void soc_fsp_load(void)
194{
195 fsps_load(romstage_handoff_is_resume());
196}
197
Elyes HAOUAS143fb462018-05-25 12:56:45 +0200198static void pci_domain_set_resources(struct device *dev)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530199{
200 assign_resources(dev->link_list);
201}
202
203static struct device_operations pci_domain_ops = {
204 .read_resources = &pci_domain_read_resources,
205 .set_resources = &pci_domain_set_resources,
206 .scan_bus = &pci_domain_scan_bus,
Julius Wernercd49cce2019-03-05 16:53:33 -0800207#if CONFIG(HAVE_ACPI_TABLES)
Nico Huberc37b0e32017-09-18 20:03:46 +0200208 .write_acpi_tables = &northbridge_write_acpi_tables,
209 .acpi_name = &soc_acpi_name,
Naresh G Solankia2d40622016-08-30 20:47:13 +0530210#endif
211};
212
213static struct device_operations cpu_bus_ops = {
214 .read_resources = DEVICE_NOOP,
215 .set_resources = DEVICE_NOOP,
216 .enable_resources = DEVICE_NOOP,
Subrata Banika4b11e5c2017-02-03 18:57:49 +0530217 .init = DEVICE_NOOP,
Julius Wernercd49cce2019-03-05 16:53:33 -0800218#if CONFIG(HAVE_ACPI_TABLES)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530219 .acpi_fill_ssdt_generator = generate_cpu_entries,
220#endif
221};
222
Elyes HAOUAS143fb462018-05-25 12:56:45 +0200223static void soc_enable(struct device *dev)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530224{
225 /* Set the operations if it is a special bus type */
Subrata Banik3c838c72017-12-06 18:14:01 +0530226 if (dev->path.type == DEVICE_PATH_DOMAIN)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530227 dev->ops = &pci_domain_ops;
Subrata Banik3c838c72017-12-06 18:14:01 +0530228 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530229 dev->ops = &cpu_bus_ops;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530230}
231
232struct chip_operations soc_intel_skylake_ops = {
233 CHIP_NAME("Intel 6th Gen")
234 .enable_dev = &soc_enable,
235 .init = &soc_init_pre_device,
236};
Lee Leahyb0005132015-05-12 18:19:47 -0700237
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530238/* UPD parameters to be initialized before SiliconInit */
Naresh G Solankia2d40622016-08-30 20:47:13 +0530239void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530240{
Naresh G Solankia2d40622016-08-30 20:47:13 +0530241 FSP_S_CONFIG *params = &supd->FspsConfig;
242 FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig;
Kyösti Mälkki4af4e7f2019-07-14 05:50:20 +0300243 struct soc_intel_skylake_config *config;
Kyösti Mälkki28dc7dc2019-07-12 13:10:19 +0300244 struct device *dev;
Patrick Georgid2990ff2018-05-03 18:06:15 +0200245 uintptr_t vbt_data = (uintptr_t)vbt_get();
Naresh G Solankia2d40622016-08-30 20:47:13 +0530246 int i;
247
Kyösti Mälkkid5f645c2019-09-28 00:20:27 +0300248 config = config_of_soc();
Naresh G Solankia2d40622016-08-30 20:47:13 +0530249
250 mainboard_silicon_init_params(params);
Gaggery Tsaida6f4ae2018-01-15 15:03:01 +0800251 /* Set PsysPmax if it is available from DT */
252 if (config->psys_pmax) {
253 /* PsysPmax is in unit of 1/8 Watt */
254 tconfig->PsysPmax = config->psys_pmax * 8;
255 printk(BIOS_DEBUG, "psys_pmax = %d\n", tconfig->PsysPmax);
256 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530257
Naresh G Solankia2d40622016-08-30 20:47:13 +0530258 params->GraphicsConfigPtr = (u32) vbt_data;
259
260 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
261 params->PortUsb20Enable[i] =
262 config->usb2_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530263 params->Usb2OverCurrentPin[i] =
264 config->usb2_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530265 params->Usb2AfePetxiset[i] =
266 config->usb2_ports[i].pre_emp_bias;
267 params->Usb2AfeTxiset[i] =
268 config->usb2_ports[i].tx_bias;
269 params->Usb2AfePredeemp[i] =
270 config->usb2_ports[i].tx_emp_enable;
271 params->Usb2AfePehalfbit[i] =
272 config->usb2_ports[i].pre_emp_bit;
273 }
274
275 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
276 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
Subrata Banik2c3054c2016-11-22 20:21:49 +0530277 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530278 if (config->usb3_ports[i].tx_de_emp) {
279 params->Usb3HsioTxDeEmphEnable[i] = 1;
280 params->Usb3HsioTxDeEmph[i] =
281 config->usb3_ports[i].tx_de_emp;
282 }
283 if (config->usb3_ports[i].tx_downscale_amp) {
284 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
285 params->Usb3HsioTxDownscaleAmp[i] =
286 config->usb3_ports[i].tx_downscale_amp;
287 }
288 }
289
290 memcpy(params->SataPortsEnable, config->SataPortsEnable,
291 sizeof(params->SataPortsEnable));
292 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
293 sizeof(params->SataPortsDevSlp));
Michael Niewöhnera1ef94e2019-09-01 13:53:09 +0200294 memcpy(params->SataPortsHotPlug, config->SataPortsHotPlug,
295 sizeof(params->SataPortsHotPlug));
296 memcpy(params->SataPortsSpinUp, config->SataPortsSpinUp,
297 sizeof(params->SataPortsSpinUp));
Naresh G Solankia2d40622016-08-30 20:47:13 +0530298 memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport,
299 sizeof(params->PcieRpClkReqSupport));
300 memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber,
301 sizeof(params->PcieRpClkReqNumber));
Rizwan Qureshi6ab4ed42017-09-05 14:18:25 +0530302 memcpy(params->PcieRpAdvancedErrorReporting,
303 config->PcieRpAdvancedErrorReporting,
304 sizeof(params->PcieRpAdvancedErrorReporting));
Rizwan Qureshi03937392017-09-16 01:54:20 +0530305 memcpy(params->PcieRpLtrEnable, config->PcieRpLtrEnable,
306 sizeof(params->PcieRpLtrEnable));
Duncan Laurie74ea48e2018-01-29 12:00:47 -0800307 memcpy(params->PcieRpHotPlug, config->PcieRpHotPlug,
308 sizeof(params->PcieRpHotPlug));
Naresh G Solankia2d40622016-08-30 20:47:13 +0530309
Divya Chellape7fb7ce2017-12-19 20:16:50 +0530310 /*
311 * PcieRpClkSrcNumber UPD is set to clock source number(0-6) for
312 * all the enabled PCIe root ports, invalid(0x1F) is set for
313 * disabled PCIe root ports.
314 */
315 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
316 if (config->PcieRpClkReqSupport[i])
317 params->PcieRpClkSrcNumber[i] =
318 config->PcieRpClkSrcNumber[i];
319 else
320 params->PcieRpClkSrcNumber[i] = 0x1F;
321 }
322
Naresh G Solankieedf6d82016-11-16 21:27:38 +0530323 /* disable Legacy PME */
324 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
325
Subrata Banik10a94322019-07-08 14:49:22 +0530326 /* Legacy 8254 timer support */
327 params->Early8254ClockGatingEnable = !CONFIG_USE_LEGACY_8254_TIMER;
328
Naresh G Solankia2d40622016-08-30 20:47:13 +0530329 memcpy(params->SerialIoDevMode, config->SerialIoDevMode,
330 sizeof(params->SerialIoDevMode));
331
332 params->PchCio2Enable = config->Cio2Enable;
Rizwan Qureshic2c8a742017-01-13 22:04:11 +0530333 params->SaImguEnable = config->SaImguEnable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530334 params->Heci3Enabled = config->Heci3Enabled;
335
336 params->LogoPtr = config->LogoPtr;
337 params->LogoSize = config->LogoSize;
338
Julius Wernercd49cce2019-03-05 16:53:33 -0800339 params->CpuConfig.Bits.VmxEnable = CONFIG(ENABLE_VMX);
Naresh G Solankia2d40622016-08-30 20:47:13 +0530340
341 params->PchPmWoWlanEnable = config->PchPmWoWlanEnable;
342 params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable;
343 params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
344
345 params->PchLanEnable = config->EnableLan;
Duncan Laurie14485ef2017-12-13 13:58:35 -0800346 if (config->EnableLan) {
347 params->PchLanLtrEnable = config->EnableLanLtr;
348 params->PchLanK1OffEnable = config->EnableLanK1Off;
349 params->PchLanClkReqSupported = config->LanClkReqSupported;
350 params->PchLanClkReqNumber = config->LanClkReqNumber;
351 }
Naresh G Solankia2d40622016-08-30 20:47:13 +0530352 params->SataSalpSupport = config->SataSalpSupport;
353 params->SsicPortEnable = config->SsicPortEnable;
354 params->ScsEmmcEnabled = config->ScsEmmcEnabled;
355 params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
356 params->ScsSdCardEnabled = config->ScsSdCardEnabled;
li feng21066382018-05-22 12:49:53 -0700357
Pratik Prajapatie0722472018-08-22 18:58:38 -0700358 if (!!params->ScsEmmcHs400Enabled && !!config->EmmcHs400DllNeed) {
359 params->PchScsEmmcHs400DllDataValid =
360 !!config->EmmcHs400DllNeed;
361 params->PchScsEmmcHs400RxStrobeDll1 =
362 config->ScsEmmcHs400RxStrobeDll1;
363 params->PchScsEmmcHs400TxDataDll =
364 config->ScsEmmcHs400TxDataDll;
365 }
366
li feng21066382018-05-22 12:49:53 -0700367 /* If ISH is enabled, enable ISH elements */
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300368 dev = pcidev_path_on_root(PCH_DEVFN_ISH);
Angel Ponsc54dcf42019-08-30 22:14:18 +0200369 params->PchIshEnable = dev ? dev->enabled : 0;
li feng21066382018-05-22 12:49:53 -0700370
Naresh G Solankia2d40622016-08-30 20:47:13 +0530371 params->PchHdaEnable = config->EnableAzalia;
Michael Niewöhner62385632019-09-23 14:38:41 +0200372 params->PchHdaVcType = config->PchHdaVcType;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530373 params->PchHdaIoBufferOwnership = config->IoBufferOwnership;
374 params->PchHdaDspEnable = config->DspEnable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530375 params->Device4Enable = config->Device4Enable;
376 params->SataEnable = config->EnableSata;
377 params->SataMode = config->SataMode;
Matt DeVillier9e0d69b2017-10-10 14:03:36 -0500378 params->SataSpeedLimit = config->SataSpeedLimit;
Kane Chen14e0fa52017-12-27 12:11:23 +0800379 params->SataPwrOptEnable = config->SataPwrOptEnable;
Naresh G Solanki84fbc302018-10-15 15:37:15 +0530380 params->EnableTcoTimer = !config->PmTimerDisabled;
Matt DeVillier9e0d69b2017-10-10 14:03:36 -0500381
Naresh G Solankia2d40622016-08-30 20:47:13 +0530382 tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530383 tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock;
Praveen hodagatta pranesh015b3dc2018-11-23 17:41:46 +0800384 tconfig->PowerLimit4 = config->PowerLimit4;
Michael Niewöhnera1ef94e2019-09-01 13:53:09 +0200385 tconfig->SataTestMode = config->SataTestMode;
Barnali Sarkarfbf10182017-08-11 18:38:38 +0530386 /*
387 * To disable HECI, the Psf needs to be left unlocked
388 * by FSP till end of post sequence. Based on the devicetree
389 * setting, we set the appropriate PsfUnlock policy in FSP,
390 * do the changes and then lock it back in coreboot during finalize.
391 */
392 tconfig->PchSbAccessUnlock = (config->HeciEnabled == 0) ? 1 : 0;
Subrata Banikc4986eb2018-05-09 14:55:09 +0530393 if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT) {
Subrata Banikc204aaa2017-08-17 15:49:58 +0530394 tconfig->PchLockDownBiosInterface = 0;
395 params->PchLockDownBiosLock = 0;
396 params->PchLockDownSpiEiss = 0;
397 /*
398 * Skip Spi Flash Lockdown from inside FSP.
399 * Making this config "0" means FSP won't set the FLOCKDN bit
400 * of SPIBAR + 0x04 (i.e., Bit 15 of BIOS_HSFSTS_CTL).
401 * So, it becomes coreboot's responsibility to set this bit
402 * before end of POST for security concerns.
403 */
404 params->SpiFlashCfgLockDown = 0;
405 }
Matt Delcodfffcad2018-07-23 12:44:15 -0700406 /* only replacing preexisting subsys ID defaults when non-zero */
Elyes HAOUASb58e99d2019-01-23 12:04:43 +0100407 if (CONFIG_SUBSYSTEM_VENDOR_ID != 0) {
408 params->DefaultSvid = CONFIG_SUBSYSTEM_VENDOR_ID;
409 params->PchSubSystemVendorId = CONFIG_SUBSYSTEM_VENDOR_ID;
410 }
411
412 if (CONFIG_SUBSYSTEM_DEVICE_ID != 0) {
413 params->DefaultSid = CONFIG_SUBSYSTEM_DEVICE_ID;
414 params->PchSubSystemId = CONFIG_SUBSYSTEM_DEVICE_ID;
415 }
416
Naresh G Solankia2d40622016-08-30 20:47:13 +0530417 params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride;
418 params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx;
419 params->PchPmDeepSxPol = config->PmConfigDeepSxPol;
Duncan Laurie25c7d932017-02-17 17:16:43 -0800420 params->PchPmSlpS0Enable = config->s0ix_enable;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530421 params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert;
422 params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert;
423 params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert;
424 params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert;
425 params->PchPmLpcClockRun = config->PmConfigPciClockRun;
426 params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp;
427 params->PchPmPwrBtnOverridePeriod =
428 config->PmConfigPwrBtnOverridePeriod;
429 params->PchPmPwrCycDur = config->PmConfigPwrCycDur;
Rizwan Qureshi0da186c2017-02-23 14:43:39 +0530430
431 /* Indicate whether platform supports Voltage Margining */
432 params->PchPmSlpS0VmEnable = config->PchPmSlpS0VmEnable;
433
Nico Huber44e89af2019-02-23 19:24:51 +0100434 params->PchSirqEnable = config->serirq_mode != SERIRQ_OFF;
435 params->PchSirqMode = config->serirq_mode == SERIRQ_CONTINUOUS;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530436
Subrata Banikcf32fd12018-12-19 18:02:17 +0530437 params->CpuConfig.Bits.SkipMpInit = !CONFIG_USE_INTEL_FSP_MP_INIT;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530438
Subrata Banikc4986eb2018-05-09 14:55:09 +0530439 for (i = 0; i < ARRAY_SIZE(config->i2c_voltage); i++)
Aaron Durbined14a4e2016-11-09 17:04:15 -0600440 params->SerialIoI2cVoltage[i] = config->i2c_voltage[i];
Naresh G Solankia2d40622016-08-30 20:47:13 +0530441
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 */
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300446 dev = pcidev_path_on_root(PCH_DEVFN_SPI);
Angel Ponsc54dcf42019-08-30 22:14:18 +0200447 params->ShowSpiController = dev ? dev->enabled : 0;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530448
Duncan Laurief5116952018-03-26 02:24:18 -0700449 /* Enable xDCI controller if enabled in devicetree and allowed */
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300450 dev = pcidev_path_on_root(PCH_DEVFN_USBOTG);
Angel Ponsc54dcf42019-08-30 22:14:18 +0200451 if (dev) {
452 if (!xdci_can_enable())
453 dev->enabled = 0;
454 params->XdciEnable = dev->enabled;
455 } else {
456 params->XdciEnable = 0;
457 }
Duncan Laurief5116952018-03-26 02:24:18 -0700458
Maxim Polyakov03ddd192019-08-30 18:04:02 +0300459 /* Enable or disable Gaussian Mixture Model in devicetree */
460 dev = pcidev_path_on_root(SA_DEVFN_GMM);
461 params->GmmEnable = dev ? dev->enabled : 0;
462
Rizwan Qureshi64670142016-11-23 15:25:19 +0530463 /*
464 * Send VR specific mailbox commands:
465 * 000b - no VR specific command sent
466 * 001b - VR mailbox command specifically for the MPS IMPV8 VR
Lee Leahyf4c4ab92017-03-16 17:08:03 -0700467 * will be sent
Rizwan Qureshi64670142016-11-23 15:25:19 +0530468 * 010b - VR specific command sent for PS4 exit issue
469 * 100b - VR specific command sent for MPS VR decay issue
470 */
471 params->SendVrMbxCmd1 = config->SendVrMbxCmd;
Naresh G Solankia2d40622016-08-30 20:47:13 +0530472
Rizwan Qureshib3e18c72017-09-25 17:35:15 +0530473 /*
474 * Activates VR mailbox command for Intersil VR C-state issues.
475 * 0 - no mailbox command sent.
476 * 1 - VR mailbox command sent for IA/GT rails only.
477 * 2 - VR mailbox command sent for IA/GT/SA rails.
478 */
479 params->IslVrCmd = config->IslVrCmd;
480
Duncan Laurieb2aac852017-03-07 19:12:02 -0800481 /* Acoustic Noise Mitigation */
482 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
483 params->SlowSlewRateForIa = config->SlowSlewRateForIa;
484 params->SlowSlewRateForGt = config->SlowSlewRateForGt;
485 params->SlowSlewRateForSa = config->SlowSlewRateForSa;
486 params->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa;
487 params->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt;
488 params->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa;
489
Rizwan Qureshiffe58102017-02-10 15:58:24 +0530490 /* Enable PMC XRAM read */
491 tconfig->PchPmPmcReadDisable = config->PchPmPmcReadDisable;
492
Subrata Banik6b45ee42017-05-12 11:43:57 +0530493 /* Enable/Disable EIST */
494 tconfig->Eist = config->eist_enable;
495
marxwangec5a9472017-12-11 14:57:49 +0800496 /* Set TccActivationOffset */
497 tconfig->TccActivationOffset = config->tcc_offset;
498
Nico Huber2afe4dc2017-09-19 09:36:03 +0200499 /* Enable VT-d and X2APIC */
500 if (!config->ignore_vtd && soc_is_vtd_capable()) {
501 params->VtdBaseAddress[0] = GFXVT_BASE_ADDRESS;
502 params->VtdBaseAddress[1] = VTVC0_BASE_ADDRESS;
503 params->X2ApicOptOut = 0;
504 tconfig->VtdDisable = 0;
505
506 params->PchIoApicBdfValid = 1;
Angel Ponsef879a82019-08-30 19:42:23 +0200507 params->PchIoApicBusNumber = V_P2SB_IBDF_BUS;
508 params->PchIoApicDeviceNumber = V_P2SB_IBDF_DEV;
509 params->PchIoApicFunctionNumber = V_P2SB_IBDF_FUN;
Nico Huber2afe4dc2017-09-19 09:36:03 +0200510 }
511
Naresh G Solankia2d40622016-08-30 20:47:13 +0530512 soc_irq_settings(params);
Rizwan Qureshi1222a732016-08-23 14:31:23 +0530513}
Lee Leahyb0005132015-05-12 18:19:47 -0700514
Naresh G Solankia2d40622016-08-30 20:47:13 +0530515/* Mainboard GPIO Configuration */
Aaron Durbin64031672018-04-21 14:45:32 -0600516__weak void mainboard_silicon_init_params(FSP_S_CONFIG *params)
Naresh G Solankia2d40622016-08-30 20:47:13 +0530517{
518 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
519}