blob: d5472dd91bbbabca1a077fde6a1128b4bcd7f025 [file] [log] [blame]
Angel Pons16f6aa82020-04-05 15:47:21 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Subrata Banik91e89c52019-11-01 18:30:01 +05302
Srinidhi N Kaushik4af0adb2020-02-29 00:32:23 -08003#include <assert.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -08004#include <console/console.h>
Subrata Banikaec07162021-07-16 11:26:30 +05305#include <cpu/intel/cpu_ids.h>
Dinesh Gehlot3e866812023-01-17 05:57:56 +00006#include <device/device.h>
Shreesh Chhabbifbad99f2021-01-20 09:07:25 -08007#include <device/pci_ops.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -08008#include <device/pci.h>
Shreesh Chhabbifbad99f2021-01-20 09:07:25 -08009#include <device/pci_ids.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053010#include <fsp/api.h>
Wonkyu Kim82e0a812020-04-13 13:26:05 -070011#include <fsp/ppi/mp_service_ppi.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080012#include <fsp/util.h>
Dinesh Gehlot3e866812023-01-17 05:57:56 +000013#include <gpio.h>
Jamie Ryu02a1b332020-06-11 01:57:13 -070014#include <intelblocks/cse.h>
Tim Wawrzynczaked042a92021-02-04 17:07:14 -070015#include <intelblocks/irq.h>
Aamir Bohra86da00d2019-12-06 19:57:36 +053016#include <intelblocks/lpss.h>
Jamie Ryu5b7daa22020-08-18 18:54:49 -070017#include <intelblocks/pmclib.h>
Tim Wawrzynczakeb6ebc02021-03-22 16:39:57 -060018#include <intelblocks/tcss.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080019#include <intelblocks/xdci.h>
Wonkyu Kim3ba64ca2020-03-20 12:17:14 -070020#include <intelpch/lockdown.h>
Dinesh Gehlot3e866812023-01-17 05:57:56 +000021#include <option.h>
Jamie Ryu02a1b332020-06-11 01:57:13 -070022#include <security/vboot/vboot_common.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080023#include <soc/intel/common/vbt.h>
Tim Wawrzynczak90f9cbb2021-07-19 16:07:42 -060024#include <soc/lpm.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080025#include <soc/pci_devs.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053026#include <soc/ramstage.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080027#include <soc/soc_chip.h>
Tim Wawrzynczak59a621a2021-03-22 10:43:42 -060028#include <soc/tcss.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080029#include <string.h>
Sean Rhodesbc35bed2021-07-13 13:36:28 +010030#include <types.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080031
Wonkyu Kim4cabf782020-05-20 13:09:39 -070032/* THC assignment definition */
33#define THC_NONE 0
34#define THC_0 1
35#define THC_1 2
36
Shaunak Saha1a8949c2020-06-08 18:59:47 -070037/* SATA DEVSLP idle timeout default values */
38#define DEF_DMVAL 15
39#define DEF_DITOVAL 625
40
Wonkyu Kim84b48822020-03-09 13:34:38 -070041/*
Nick Vaccaro202b1892021-02-22 14:26:13 -080042 * ME End of Post configuration
43 * 0 - Disable EOP.
44 * 1 - Send in PEI (Applicable for FSP in API mode)
45 * 2 - Send in DXE (Not applicable for FSP in API mode)
46 */
47enum {
Tim Wawrzynczak25d24522021-06-17 12:44:06 -060048 EOP_DISABLE = 0,
49 EOP_PEI = 1,
50 EOP_DXE = 2,
51};
Nick Vaccaro202b1892021-02-22 14:26:13 -080052
53/*
Wonkyu Kim84b48822020-03-09 13:34:38 -070054 * Chip config parameter PcieRpL1Substates uses (UPD value + 1)
55 * because UPD value of 0 for PcieRpL1Substates means disabled for FSP.
56 * In order to ensure that mainboard setting does not disable L1 substates
57 * incorrectly, chip config parameter values are offset by 1 with 0 meaning
58 * use FSP UPD default. get_l1_substate_control() ensures that the right UPD
59 * value is set in fsp_params.
60 * 0: Use FSP UPD default
61 * 1: Disable L1 substates
62 * 2: Use L1.1
63 * 3: Use L1.2 (FSP UPD default)
64 */
65static int get_l1_substate_control(enum L1_substates_control ctl)
66{
67 if ((ctl > L1_SS_L1_2) || (ctl == L1_SS_FSP_DEFAULT))
68 ctl = L1_SS_L1_2;
69 return ctl - 1;
70}
71
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080072static void parse_devicetree(FSP_S_CONFIG *params)
73{
74 const struct soc_intel_tigerlake_config *config;
75 config = config_of_soc();
76
77 for (int i = 0; i < CONFIG_SOC_INTEL_I2C_DEV_MAX; i++)
78 params->SerialIoI2cMode[i] = config->SerialIoI2cMode[i];
79
80 for (int i = 0; i < CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX; i++) {
81 params->SerialIoSpiMode[i] = config->SerialIoGSpiMode[i];
82 params->SerialIoSpiCsMode[i] = config->SerialIoGSpiCsMode[i];
83 params->SerialIoSpiCsState[i] = config->SerialIoGSpiCsState[i];
84 }
85
86 for (int i = 0; i < CONFIG_SOC_INTEL_UART_DEV_MAX; i++)
87 params->SerialIoUartMode[i] = config->SerialIoUartMode[i];
88}
Subrata Banik91e89c52019-11-01 18:30:01 +053089
Tim Wawrzynczaked042a92021-02-04 17:07:14 -070090/*
91 * The FSP expects a certain list of PCI devices to be in the DevIntConfig table,
92 * regardless of whether or not they are used by the mainboard.
93 */
94static const struct slot_irq_constraints irq_constraints[] = {
95 {
Tim Crawford59609782022-05-25 12:36:47 -060096 .slot = SA_DEV_SLOT_PEG,
97 .fns = {
98 FIXED_INT_PIRQ(SA_DEVFN_PEG1, PCI_INT_A, PIRQ_A),
99 FIXED_INT_PIRQ(SA_DEVFN_PEG2, PCI_INT_B, PIRQ_B),
100 FIXED_INT_PIRQ(SA_DEVFN_PEG3, PCI_INT_C, PIRQ_C),
101 },
102 },
103 {
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700104 .slot = SA_DEV_SLOT_IGD,
105 .fns = {
106 ANY_PIRQ(SA_DEVFN_IGD),
107 },
108 },
109 {
110 .slot = SA_DEV_SLOT_DPTF,
111 .fns = {
112 ANY_PIRQ(SA_DEVFN_DPTF),
113 },
114 },
115 {
116 .slot = SA_DEV_SLOT_IPU,
117 .fns = {
118 ANY_PIRQ(SA_DEVFN_IPU),
119 },
120 },
121 {
122 .slot = SA_DEV_SLOT_CPU_PCIE,
123 .fns = {
Frans Hendriks82f0a682022-08-17 09:59:29 +0200124 FIXED_INT_PIRQ(SA_DEVFN_CPU_PCIE, PCI_INT_D, PIRQ_D),
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700125 },
126 },
127 {
128 .slot = SA_DEV_SLOT_TBT,
129 .fns = {
130 FIXED_INT_ANY_PIRQ(SA_DEVFN_TBT0, PCI_INT_A),
131 FIXED_INT_ANY_PIRQ(SA_DEVFN_TBT1, PCI_INT_B),
132 FIXED_INT_ANY_PIRQ(SA_DEVFN_TBT2, PCI_INT_C),
133 FIXED_INT_ANY_PIRQ(SA_DEVFN_TBT3, PCI_INT_D),
134 },
135 },
136 {
137 .slot = SA_DEV_SLOT_TCSS,
138 .fns = {
139 ANY_PIRQ(SA_DEVFN_TCSS_XHCI),
140 ANY_PIRQ(SA_DEVFN_TCSS_DMA0),
141 ANY_PIRQ(SA_DEVFN_TCSS_DMA1),
142 },
143 },
144 {
145 .slot = PCH_DEV_SLOT_SIO0,
146 .fns = {
Frans Hendriksf4040e62022-08-03 09:57:32 +0200147 ANY_PIRQ(PCH_DEVFN_CT),
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700148 ANY_PIRQ(PCH_DEVFN_THC0),
149 ANY_PIRQ(PCH_DEVFN_THC1),
150 },
151 },
152 {
153 .slot = PCH_DEV_SLOT_SIO1,
154 .fns = {
155 DIRECT_IRQ(PCH_DEVFN_UART3),
156 },
157 },
158 {
159 .slot = PCH_DEV_SLOT_ISH,
160 .fns = {
161 DIRECT_IRQ(PCH_DEVFN_ISH),
162 DIRECT_IRQ(PCH_DEVFN_GSPI2),
163 },
164 },
165 {
166 .slot = PCH_DEV_SLOT_SIO2,
167 .fns = {
168 DIRECT_IRQ(PCH_DEVFN_GSPI3),
169 },
170 },
171 {
172 .slot = PCH_DEV_SLOT_XHCI,
173 .fns = {
174 ANY_PIRQ(PCH_DEVFN_XHCI),
Frans Hendriksf4040e62022-08-03 09:57:32 +0200175 DIRECT_IRQ(PCH_DEVFN_USBOTG),
Sean Rhodese8b6b072021-10-14 20:55:41 +0100176 FIXED_INT_ANY_PIRQ(PCH_DEVFN_CNVI_WIFI, PCI_INT_A),
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700177 },
178 },
179 {
180 .slot = PCH_DEV_SLOT_SIO3,
181 .fns = {
182 DIRECT_IRQ(PCH_DEVFN_I2C0),
183 DIRECT_IRQ(PCH_DEVFN_I2C1),
184 DIRECT_IRQ(PCH_DEVFN_I2C2),
185 DIRECT_IRQ(PCH_DEVFN_I2C3),
186 },
187 },
188 {
189 .slot = PCH_DEV_SLOT_CSE,
190 .fns = {
191 ANY_PIRQ(PCH_DEVFN_CSE),
192 ANY_PIRQ(PCH_DEVFN_CSE_2),
193 ANY_PIRQ(PCH_DEVFN_CSE_IDER),
194 ANY_PIRQ(PCH_DEVFN_CSE_KT),
195 ANY_PIRQ(PCH_DEVFN_CSE_3),
196 ANY_PIRQ(PCH_DEVFN_CSE_4),
197 },
198 },
199 {
200 .slot = PCH_DEV_SLOT_SATA,
201 .fns = {
202 ANY_PIRQ(PCH_DEVFN_SATA),
203 },
204 },
205 {
206 .slot = PCH_DEV_SLOT_SIO4,
207 .fns = {
208 DIRECT_IRQ(PCH_DEVFN_I2C4),
209 DIRECT_IRQ(PCH_DEVFN_I2C5),
210 DIRECT_IRQ(PCH_DEVFN_UART2),
211 },
212 },
213 {
214 .slot = PCH_DEV_SLOT_PCIE,
215 .fns = {
216 FIXED_INT_PIRQ(PCH_DEVFN_PCIE1, PCI_INT_A, PIRQ_A),
217 FIXED_INT_PIRQ(PCH_DEVFN_PCIE2, PCI_INT_B, PIRQ_B),
218 FIXED_INT_PIRQ(PCH_DEVFN_PCIE3, PCI_INT_C, PIRQ_C),
219 FIXED_INT_PIRQ(PCH_DEVFN_PCIE4, PCI_INT_D, PIRQ_D),
220 FIXED_INT_PIRQ(PCH_DEVFN_PCIE5, PCI_INT_A, PIRQ_A),
221 FIXED_INT_PIRQ(PCH_DEVFN_PCIE6, PCI_INT_B, PIRQ_B),
222 FIXED_INT_PIRQ(PCH_DEVFN_PCIE7, PCI_INT_C, PIRQ_C),
223 FIXED_INT_PIRQ(PCH_DEVFN_PCIE8, PCI_INT_D, PIRQ_D),
224 },
225 },
226 {
227 .slot = PCH_DEV_SLOT_PCIE_1,
228 .fns = {
229 FIXED_INT_PIRQ(PCH_DEVFN_PCIE9, PCI_INT_A, PIRQ_A),
230 FIXED_INT_PIRQ(PCH_DEVFN_PCIE10, PCI_INT_B, PIRQ_B),
231 FIXED_INT_PIRQ(PCH_DEVFN_PCIE11, PCI_INT_C, PIRQ_C),
232 FIXED_INT_PIRQ(PCH_DEVFN_PCIE12, PCI_INT_D, PIRQ_D),
233 },
234 },
235 {
236 .slot = PCH_DEV_SLOT_SIO5,
237 .fns = {
238 FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART0, PCI_INT_A),
239 FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART1, PCI_INT_B),
240 DIRECT_IRQ(PCH_DEVFN_GSPI0),
241 DIRECT_IRQ(PCH_DEVFN_GSPI1),
242 },
243 },
244 {
245 .slot = PCH_DEV_SLOT_ESPI,
246 .fns = {
247 ANY_PIRQ(PCH_DEVFN_HDA),
248 ANY_PIRQ(PCH_DEVFN_SMBUS),
249 ANY_PIRQ(PCH_DEVFN_GBE),
250 FIXED_INT_ANY_PIRQ(PCH_DEVFN_TRACEHUB, PCI_INT_A),
251 },
252 },
253};
254
Jes Klinke476ca3a2020-08-28 13:44:21 -0700255__weak void mainboard_update_soc_chip_config(struct soc_intel_tigerlake_config *config)
256{
257 /* Override settings per board. */
258}
259
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700260static const SI_PCH_DEVICE_INTERRUPT_CONFIG *pci_irq_to_fsp(size_t *out_count)
261{
262 const struct pci_irq_entry *entry = get_cached_pci_irqs();
263 SI_PCH_DEVICE_INTERRUPT_CONFIG *config;
264 size_t pch_total = 0;
265 size_t cfg_count = 0;
266
267 if (!entry)
268 return NULL;
269
270 /* Count PCH devices */
271 while (entry) {
Kapil Porwal9395cf92022-12-22 23:08:26 +0530272 if (is_pch_slot(entry->devfn))
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700273 ++pch_total;
274 entry = entry->next;
275 }
276
277 /* Convert PCH device entries to FSP format */
278 config = calloc(pch_total, sizeof(*config));
279 entry = get_cached_pci_irqs();
280 while (entry) {
Kapil Porwal9395cf92022-12-22 23:08:26 +0530281 if (!is_pch_slot(entry->devfn)) {
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700282 entry = entry->next;
283 continue;
284 }
285
286 config[cfg_count].Device = PCI_SLOT(entry->devfn);
287 config[cfg_count].Function = PCI_FUNC(entry->devfn);
288 config[cfg_count].IntX = (SI_PCH_INT_PIN)entry->pin;
289 config[cfg_count].Irq = entry->irq;
290 ++cfg_count;
291
292 entry = entry->next;
293 }
294
295 *out_count = cfg_count;
296
297 return config;
298}
299
Subrata Banik91e89c52019-11-01 18:30:01 +0530300/* UPD parameters to be initialized before SiliconInit */
301void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
302{
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800303 int i;
John Zhaobd615d62020-07-27 13:22:11 -0700304 uint32_t cpu_id;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800305 FSP_S_CONFIG *params = &supd->FspsConfig;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800306 struct device *dev;
307 struct soc_intel_tigerlake_config *config;
308 config = config_of_soc();
Jes Klinke476ca3a2020-08-28 13:44:21 -0700309 mainboard_update_soc_chip_config(config);
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800310
311 /* Parse device tree and enable/disable Serial I/O devices */
312 parse_devicetree(params);
313
314 /* Load VBT before devicetree-specific config. */
315 params->GraphicsConfigPtr = (uintptr_t)vbt_get();
316
Wonkyu Kim82e0a812020-04-13 13:26:05 -0700317 /* Check if IGD is present and fill Graphics init param accordingly */
Subrata Banik49a21092021-06-09 03:58:25 +0530318 params->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD);
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800319
Wonkyu Kim82e0a812020-04-13 13:26:05 -0700320 /* Use coreboot MP PPI services if Kconfig is enabled */
Subrata Banik6362de32020-07-30 11:31:55 +0530321 if (CONFIG(USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI))
Elyes Haouas9018dee2022-11-18 15:07:33 +0100322 params->CpuMpPpi = (uintptr_t)mp_fill_ppi_services_data();
Wonkyu Kim82e0a812020-04-13 13:26:05 -0700323
John Zhao8aac8812020-05-16 13:06:25 -0700324 /* D3Hot and D3Cold for TCSS */
John Zhaobd615d62020-07-27 13:22:11 -0700325 params->D3HotEnable = !config->TcssD3HotDisable;
326 cpu_id = cpu_get_cpuid();
327 if (cpu_id == CPUID_TIGERLAKE_A0)
328 params->D3ColdEnable = 0;
329 else
Sean Rhodes2980e312023-04-17 20:28:01 +0100330 params->D3ColdEnable = CONFIG(D3COLD_SUPPORT);
John Zhao8aac8812020-05-16 13:06:25 -0700331
Brandon Breitensteinbf50c312020-12-21 14:55:38 -0800332 params->UsbTcPortEn = config->UsbTcPortEn;
Brandon Breitensteinfc932372020-03-11 14:07:23 -0700333 params->TcssAuxOri = config->TcssAuxOri;
Tim Wawrzynczak59a621a2021-03-22 10:43:42 -0600334
335 /* Explicitly clear this field to avoid using defaults */
336 memset(params->IomTypeCPortPadCfg, 0, sizeof(params->IomTypeCPortPadCfg));
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800337
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700338
339 /* Assign PCI IRQs */
340 if (!assign_pci_irqs(irq_constraints, ARRAY_SIZE(irq_constraints)))
341 die("ERROR: Unable to assign PCI IRQs, and no ACPI _PRT table is defined\n");
342
343 size_t pch_count = 0;
344 const SI_PCH_DEVICE_INTERRUPT_CONFIG *upd_irqs = pci_irq_to_fsp(&pch_count);
345 params->DevIntConfigPtr = (UINT32)((uintptr_t)upd_irqs);
346 params->NumOfDevIntConfig = pch_count;
347 printk(BIOS_INFO, "IRQ: Using dynamically assigned PCI IO-APIC IRQs\n");
348
John Zhao92a3a302020-06-03 13:06:24 -0700349 /*
350 * Set FSPS UPD ITbtConnectTopologyTimeoutInMs with value 0. FSP will
351 * evaluate this UPD value and skip sending command. There will be no
352 * delay for command completion.
353 */
354 params->ITbtConnectTopologyTimeoutInMs = 0;
355
Srinidhi N Kaushik44509d82021-01-08 10:01:25 -0800356 /* Disable TcColdOnUsbConnect */
357 params->DisableTccoldOnUsbConnected = 1;
358
Wonkyu Kim3ba64ca2020-03-20 12:17:14 -0700359 /* Chipset Lockdown */
Felix Singer673e6d12021-05-03 02:28:16 +0200360 const bool lockdown_by_fsp = get_lockdown_config() == CHIPSET_LOCKDOWN_FSP;
361 params->PchLockDownGlobalSmi = lockdown_by_fsp;
362 params->PchLockDownBiosInterface = lockdown_by_fsp;
363 params->PchUnlockGpioPads = !lockdown_by_fsp;
364 params->RtcMemoryLock = lockdown_by_fsp;
Tim Wawrzynczak58966082021-08-25 09:32:19 -0600365 params->SkipPamLock = !lockdown_by_fsp;
Wonkyu Kim3ba64ca2020-03-20 12:17:14 -0700366
Tim Wawrzynczak25d24522021-06-17 12:44:06 -0600367 /* coreboot will send EOP before loading payload */
368 params->EndOfPostMessage = EOP_DISABLE;
Nick Vaccaro202b1892021-02-22 14:26:13 -0800369
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800370 /* USB */
371 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
372 params->PortUsb20Enable[i] = config->usb2_ports[i].enable;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800373 params->Usb2PhyPetxiset[i] = config->usb2_ports[i].pre_emp_bias;
374 params->Usb2PhyTxiset[i] = config->usb2_ports[i].tx_bias;
375 params->Usb2PhyPredeemp[i] = config->usb2_ports[i].tx_emp_enable;
376 params->Usb2PhyPehalfbit[i] = config->usb2_ports[i].pre_emp_bit;
Michael Niewöhner056d5522020-09-04 15:40:35 +0200377
378 if (config->usb2_ports[i].enable)
379 params->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin;
380 else
381 params->Usb2OverCurrentPin[i] = 0xff;
John Zhao4ead6b332021-01-01 14:19:36 -0800382
383 if (config->usb2_ports[i].type_c)
384 params->PortResetMessageEnable[i] = 1;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800385 }
386
387 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
388 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
Michael Niewöhner056d5522020-09-04 15:40:35 +0200389 if (config->usb3_ports[i].enable) {
390 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
391 } else {
392 params->Usb3OverCurrentPin[i] = 0xff;
393 }
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800394 if (config->usb3_ports[i].tx_de_emp) {
395 params->Usb3HsioTxDeEmphEnable[i] = 1;
396 params->Usb3HsioTxDeEmph[i] = config->usb3_ports[i].tx_de_emp;
397 }
398 if (config->usb3_ports[i].tx_downscale_amp) {
399 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
400 params->Usb3HsioTxDownscaleAmp[i] =
401 config->usb3_ports[i].tx_downscale_amp;
402 }
403 }
404
Wonkyu Kim84b48822020-03-09 13:34:38 -0700405 /* RP Configs */
Wonkyu Kim59431172020-04-07 20:45:28 -0700406 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
Wonkyu Kim84b48822020-03-09 13:34:38 -0700407 params->PcieRpL1Substates[i] =
408 get_l1_substate_control(config->PcieRpL1Substates[i]);
Wonkyu Kim59431172020-04-07 20:45:28 -0700409 params->PcieRpLtrEnable[i] = config->PcieRpLtrEnable[i];
410 params->PcieRpAdvancedErrorReporting[i] =
411 config->PcieRpAdvancedErrorReporting[i];
Wonkyu Kimc66c1532020-05-27 13:34:04 -0700412 params->PcieRpHotPlug[i] = config->PcieRpHotPlug[i];
Duncan Laurie17e905ac2020-10-27 17:57:13 -0700413 params->PciePtm[i] = config->PciePtm[i];
Michael Niewöhner45b60802022-01-08 20:47:11 +0100414 params->PcieRpSlotImplemented[i] = config->PcieRpSlotImplemented[i];
Wonkyu Kim59431172020-04-07 20:45:28 -0700415 }
Meera Ravindranath0d6cc222020-04-29 12:19:33 +0530416
417 /* Enable ClkReqDetect for enabled port */
418 memcpy(params->PcieRpClkReqDetect, config->PcieRpClkReqDetect,
419 sizeof(config->PcieRpClkReqDetect));
420
Nick Vaccaro4b3e06e2021-05-11 16:39:32 -0700421 for (i = 0; i < ARRAY_SIZE(config->tcss_ports); i++) {
422 if (config->tcss_ports[i].enable)
423 params->CpuUsb3OverCurrentPin[i] =
424 config->tcss_ports[i].ocpin;
425 }
426
Angel Ponsc7cfe0b2021-06-23 12:39:22 +0200427 params->XdciEnable = xdci_can_enable(PCH_DEVFN_USBOTG);
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800428
429 /* PCH UART selection for FSP Debug */
430 params->SerialIoDebugUartNumber = CONFIG_UART_FOR_CONSOLE;
Srinidhi N Kaushik4af0adb2020-02-29 00:32:23 -0800431 ASSERT(ARRAY_SIZE(params->SerialIoUartAutoFlow) > CONFIG_UART_FOR_CONSOLE);
432 params->SerialIoUartAutoFlow[CONFIG_UART_FOR_CONSOLE] = 0;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800433
Wonkyu Kim815d96a2020-01-21 21:51:19 -0800434 /* SATA */
Subrata Banik49a21092021-06-09 03:58:25 +0530435 params->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA);
Felix Singer5c107042020-07-26 09:22:42 +0200436 if (params->SataEnable) {
Wonkyu Kim815d96a2020-01-21 21:51:19 -0800437 params->SataMode = config->SataMode;
438 params->SataSalpSupport = config->SataSalpSupport;
439 memcpy(params->SataPortsEnable, config->SataPortsEnable,
440 sizeof(params->SataPortsEnable));
441 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
442 sizeof(params->SataPortsDevSlp));
443 }
444
Jes Klinke6fd87ff2020-08-10 13:30:40 -0700445 /* S0iX: Selectively enable individual sub-states,
446 * by default all are enabled.
447 *
448 * LPM0-s0i2.0, LPM1-s0i2.1, LPM2-s0i2.2, LPM3-s0i3.0,
449 * LPM4-s0i3.1, LPM5-s0i3.2, LPM6-s0i3.3, LPM7-s0i3.4
450 */
Tim Wawrzynczak90f9cbb2021-07-19 16:07:42 -0600451 params->PmcLpmS0ixSubStateEnableMask = get_supported_lpm_mask(config);
Jes Klinke6fd87ff2020-08-10 13:30:40 -0700452
Shaunak Saha32b8a512020-03-31 22:56:13 -0700453 /*
454 * Power Optimizer for DMI and SATA.
455 * DmiPwrOptimizeDisable and SataPwrOptimizeDisable is default to 0.
456 * Boards not needing the optimizers explicitly disables them by setting
457 * these disable variables to 1 in devicetree overrides.
458 */
459 params->PchPwrOptEnable = !(config->DmiPwrOptimizeDisable);
460 params->SataPwrOptEnable = !(config->SataPwrOptimizeDisable);
461
Shaunak Saha1a8949c2020-06-08 18:59:47 -0700462 /*
463 * Enable DEVSLP Idle Timeout settings DmVal and DitoVal.
464 * SataPortsDmVal is the DITO multiplier. Default is 15.
465 * SataPortsDitoVal is the DEVSLP Idle Timeout (DITO), Default is 625ms.
466 * The default values can be changed from devicetree.
467 */
468 for (i = 0; i < ARRAY_SIZE(config->SataPortsEnableDitoConfig); i++) {
469 if (config->SataPortsEnableDitoConfig[i]) {
470 if (config->SataPortsDmVal[i])
471 params->SataPortsDmVal[i] = config->SataPortsDmVal[i];
472 else
473 params->SataPortsDmVal[i] = DEF_DMVAL;
474
475 if (config->SataPortsDitoVal[i])
476 params->SataPortsDitoVal[i] = config->SataPortsDitoVal[i];
477 else
478 params->SataPortsDitoVal[i] = DEF_DITOVAL;
479 }
480 }
481
Shaunak Saha0d0f43f2020-09-02 15:37:00 -0700482 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
Shaunak Saha82d51232021-02-17 23:26:43 -0800483 params->FastPkgCRampDisable[0] = config->FastPkgCRampDisable;
484 params->SlowSlewRate[0] = config->SlowSlewRate;
Shaunak Saha0d0f43f2020-09-02 15:37:00 -0700485
Sumeet R Pawnikar7d6bc602020-05-08 19:22:07 +0530486 /* Enable TCPU for processor thermal control */
Felix Singer2aa1ff42021-12-05 03:13:37 +0100487 params->Device4Enable = is_devfn_enabled(SA_DEVFN_DPTF);
Sumeet R Pawnikar7d6bc602020-05-08 19:22:07 +0530488
Sumeet R Pawnikar6caa4762020-06-18 16:50:58 +0530489 /* Set TccActivationOffset */
490 params->TccActivationOffset = config->tcc_offset;
491
Wonkyu Kimb3fa6a02020-02-27 15:54:56 -0800492 /* LAN */
Subrata Banik49a21092021-06-09 03:58:25 +0530493 params->PchLanEnable = is_devfn_enabled(PCH_DEVFN_GBE);
Wonkyu Kimb3fa6a02020-02-27 15:54:56 -0800494
Srinidhi N Kaushik84888532020-03-05 00:54:02 -0800495 /* CNVi */
Subrata Banik49a21092021-06-09 03:58:25 +0530496 params->CnviMode = is_devfn_enabled(PCH_DEVFN_CNVI_WIFI);
Cliff Huangb34be4d2021-02-04 15:37:24 -0800497 params->CnviBtCore = config->CnviBtCore;
John Zhaoc16fc8a2020-09-21 13:10:11 -0700498 params->CnviBtAudioOffload = config->CnviBtAudioOffload;
Cliff Huangb34be4d2021-02-04 15:37:24 -0800499 /* Assert if CNVi BT is enabled without CNVi being enabled. */
500 assert(params->CnviMode || !params->CnviBtCore);
501 /* Assert if CNVi BT offload is enabled without CNVi BT being enabled. */
502 assert(params->CnviBtCore || !params->CnviBtAudioOffload);
John Zhaoc16fc8a2020-09-21 13:10:11 -0700503
Wonkyu Kim165efa12020-05-05 09:10:13 -0700504 /* VMD */
Subrata Banik49a21092021-06-09 03:58:25 +0530505 params->VmdEnable = is_devfn_enabled(SA_DEVFN_VMD);
Wonkyu Kim165efa12020-05-05 09:10:13 -0700506
Wonkyu Kim4cabf782020-05-20 13:09:39 -0700507 /* THC */
Subrata Banik49a21092021-06-09 03:58:25 +0530508 params->ThcPort0Assignment = is_devfn_enabled(PCH_DEVFN_THC0) ? THC_0 : THC_NONE;
509 params->ThcPort1Assignment = is_devfn_enabled(PCH_DEVFN_THC1) ? THC_1 : THC_NONE;
Wonkyu Kim4cabf782020-05-20 13:09:39 -0700510
Subrata Banik1bfd56cb2020-02-24 15:14:22 +0530511 /* Legacy 8254 timer support */
Sean Rhodesbc35bed2021-07-13 13:36:28 +0100512 bool use_8254 = get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER));
513 params->Enable8254ClockGating = !use_8254;
514 params->Enable8254ClockGatingOnS3 = !use_8254;
Subrata Banik1bfd56cb2020-02-24 15:14:22 +0530515
Michael Niewöhner0e905802021-09-25 00:10:30 +0200516 /*
517 * Legacy PM ACPI Timer (and TCO Timer)
518 * This *must* be 1 in any case to keep FSP from
519 * 1) enabling PM ACPI Timer emulation in uCode.
520 * 2) disabling the PM ACPI Timer.
521 * We handle both by ourself!
522 */
523 params->EnableTcoTimer = 1;
524
Wonkyu Kim2b4ded02020-03-03 01:43:45 -0800525 /* Enable Hybrid storage auto detection */
Jamie Ryu02a1b332020-06-11 01:57:13 -0700526 if (CONFIG(SOC_INTEL_CSE_LITE_SKU) && cse_is_hfs3_fw_sku_lite()
527 && vboot_recovery_mode_enabled() && !cse_is_hfs1_com_normal()) {
528 /*
529 * CSE Lite SKU does not support hybrid storage dynamic configuration
530 * in CSE RO boot, and FSP does not allow to send the strap override
531 * HECI commands if CSE is not in normal mode; hence, hybrid storage
532 * mode is disabled on CSE RO boot in recovery boot mode.
533 */
534 printk(BIOS_INFO, "cse_lite: CSE RO boot. HybridStorageMode disabled\n");
535 params->HybridStorageMode = 0;
536 } else {
537 params->HybridStorageMode = config->HybridStorageMode;
538 }
Wonkyu Kim2b4ded02020-03-03 01:43:45 -0800539
Brandon Breitenstein11637452020-02-06 14:20:57 -0800540 /* USB4/TBT */
541 for (i = 0; i < ARRAY_SIZE(params->ITbtPcieRootPortEn); i++) {
542 dev = pcidev_on_root(SA_DEV_SLOT_TBT, i);
Felix Singerf424c8b2021-12-10 23:23:42 +0100543 params->ITbtPcieRootPortEn[i] = is_dev_enabled(dev);
Brandon Breitenstein11637452020-02-06 14:20:57 -0800544 }
545
Venkata Krishna Nimmagaddae18f7192020-05-15 00:13:40 -0700546 /* PCH FIVR settings override */
547 if (config->ext_fivr_settings.configure_ext_fivr) {
548 params->PchFivrExtV1p05RailEnabledStates =
549 config->ext_fivr_settings.v1p05_enable_bitmap;
550
551 params->PchFivrExtV1p05RailSupportedVoltageStates =
552 config->ext_fivr_settings.v1p05_supported_voltage_bitmap;
553
554 params->PchFivrExtVnnRailEnabledStates =
555 config->ext_fivr_settings.vnn_enable_bitmap;
556
557 params->PchFivrExtVnnRailSupportedVoltageStates =
558 config->ext_fivr_settings.vnn_supported_voltage_bitmap;
559
560 /* convert mV to number of 2.5 mV increments */
561 params->PchFivrExtVnnRailSxVoltage =
562 (config->ext_fivr_settings.vnn_sx_voltage_mv * 10) / 25;
563
564 params->PchFivrExtV1p05RailIccMaximum =
565 config->ext_fivr_settings.v1p05_icc_max_ma;
Venkata Krishna Nimmagaddae18f7192020-05-15 00:13:40 -0700566 }
567
Jamie Ryu5b7daa22020-08-18 18:54:49 -0700568 /* Apply minimum assertion width settings if non-zero */
569 if (config->PchPmSlpS3MinAssert)
570 params->PchPmSlpS3MinAssert = config->PchPmSlpS3MinAssert;
571 if (config->PchPmSlpS4MinAssert)
572 params->PchPmSlpS4MinAssert = config->PchPmSlpS4MinAssert;
573 if (config->PchPmSlpSusMinAssert)
574 params->PchPmSlpSusMinAssert = config->PchPmSlpSusMinAssert;
575 if (config->PchPmSlpAMinAssert)
576 params->PchPmSlpAMinAssert = config->PchPmSlpAMinAssert;
577
578 /* Set Power Cycle Duration */
579 if (config->PchPmPwrCycDur)
580 params->PchPmPwrCycDur = get_pm_pwr_cyc_dur(config->PchPmSlpS4MinAssert,
581 config->PchPmSlpS3MinAssert, config->PchPmSlpAMinAssert,
582 config->PchPmPwrCycDur);
583
Subrata Banik298b3592021-09-14 12:38:08 +0530584 /* Override EnableMultiPhaseSiliconInit prior calling MultiPhaseSiInit */
585 params->EnableMultiPhaseSiliconInit = fsp_is_multi_phase_init_enabled();
Ravi Sarawadid83e24d2020-10-14 16:30:38 -0700586
587 /* Disable C1 C-state Demotion */
588 params->C1StateAutoDemotion = 0;
589
Derek Huang80561872021-03-15 12:11:19 +0800590 /* USB2 Phy Sus power gating setting override */
591 params->PmcUsb2PhySusPgEnable = !config->usb2_phy_sus_pg_disable;
592
Tim Crawfordf3c4f292021-08-07 00:30:15 -0600593 /*
594 * Prevent FSP from programming write-once subsystem IDs by providing
595 * a custom SSID table. Must have at least one entry for the FSP to
596 * use the table.
597 */
598 struct svid_ssid_init_entry {
599 union {
600 struct {
601 uint64_t reg:12; /* Register offset */
602 uint64_t function:3;
603 uint64_t device:5;
604 uint64_t bus:8;
605 uint64_t :4;
606 uint64_t segment:16;
607 uint64_t :16;
608 };
609 uint64_t segbusdevfuncregister;
610 };
611 struct {
612 uint16_t svid;
613 uint16_t ssid;
614 };
615 uint32_t reserved;
616 };
617
618 /*
619 * The xHCI and HDA devices have RW/L rather than RW/O registers for
620 * subsystem IDs and so must be written before FspSiliconInit locks
621 * them with their default values.
622 */
623 const pci_devfn_t devfn_table[] = { PCH_DEVFN_XHCI, PCH_DEVFN_HDA };
624 static struct svid_ssid_init_entry ssid_table[ARRAY_SIZE(devfn_table)];
625
626 for (i = 0; i < ARRAY_SIZE(devfn_table); i++) {
627 ssid_table[i].reg = PCI_SUBSYSTEM_VENDOR_ID;
628 ssid_table[i].device = PCI_SLOT(devfn_table[i]);
629 ssid_table[i].function = PCI_FUNC(devfn_table[i]);
630 dev = pcidev_path_on_root(devfn_table[i]);
631 if (dev) {
632 ssid_table[i].svid = dev->subsystem_vendor;
633 ssid_table[i].ssid = dev->subsystem_device;
634 }
635 }
636
637 params->SiSsidTablePtr = (uintptr_t)ssid_table;
638 params->SiNumberOfSsidTableEntry = ARRAY_SIZE(ssid_table);
639
640 /*
641 * Replace the default SVID:SSID value with the values specified in
642 * the devicetree for the root device.
643 */
644 dev = pcidev_path_on_root(SA_DEVFN_ROOT);
645 params->SiCustomizedSvid = dev->subsystem_vendor;
646 params->SiCustomizedSsid = dev->subsystem_device;
647
648 /* Ensure FSP will program the registers */
649 params->SiSkipSsidProgramming = 0;
650
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800651 mainboard_silicon_init_params(params);
652}
653
Subrata Banikb622d4b2020-05-26 18:33:22 +0530654/*
655 * Callbacks for SoC/Mainboard specific overrides for FspMultiPhaseSiInit
656 * This platform supports below MultiPhaseSIInit Phase(s):
657 * Phase | FSP return point | Purpose
658 * ------- + ------------------------------------------------ + -------------------------------
659 * 1 | After TCSS initialization completed | for TCSS specific init
660 */
Jeremy Compostella7eb014e2024-03-05 10:00:21 -0800661void platform_fsp_silicon_multi_phase_init_cb(uint32_t phase_index)
Subrata Banikb622d4b2020-05-26 18:33:22 +0530662{
663 switch (phase_index) {
664 case 1:
665 /* TCSS specific initialization here */
Brandon Breitenstein99b38a92019-12-19 23:12:58 -0800666 printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n",
667 __FILE__, __func__);
Tim Wawrzynczakeb6ebc02021-03-22 16:39:57 -0600668
Tim Wawrzynczak59a621a2021-03-22 10:43:42 -0600669 if (CONFIG(SOC_INTEL_COMMON_BLOCK_TCSS)) {
670 const config_t *config = config_of_soc();
671 tcss_configure(config->typec_aux_bias_pads);
672 }
Subrata Banikb622d4b2020-05-26 18:33:22 +0530673 break;
674 default:
675 break;
676 }
677}
678
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800679/* Mainboard GPIO Configuration */
680__weak void mainboard_silicon_init_params(FSP_S_CONFIG *params)
681{
682 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
Subrata Banik91e89c52019-11-01 18:30:01 +0530683}