blob: 1cf3d2fee8901b23245dffca6d6c1ee072d50204 [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>
5#include <device/device.h>
Shreesh Chhabbifbad99f2021-01-20 09:07:25 -08006#include <arch/pci_io_cfg.h>
Subrata Banikaec07162021-07-16 11:26:30 +05307#include <cpu/intel/cpu_ids.h>
Shreesh Chhabbifbad99f2021-01-20 09:07:25 -08008#include <device/pci_ops.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -08009#include <device/pci.h>
Shreesh Chhabbifbad99f2021-01-20 09:07:25 -080010#include <device/pci_ids.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053011#include <fsp/api.h>
Wonkyu Kim82e0a812020-04-13 13:26:05 -070012#include <fsp/ppi/mp_service_ppi.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080013#include <fsp/util.h>
Sean Rhodesbc35bed2021-07-13 13:36:28 +010014#include <option.h>
Jamie Ryu02a1b332020-06-11 01:57:13 -070015#include <intelblocks/cse.h>
Tim Wawrzynczaked042a92021-02-04 17:07:14 -070016#include <intelblocks/irq.h>
Aamir Bohra86da00d2019-12-06 19:57:36 +053017#include <intelblocks/lpss.h>
Jamie Ryu5b7daa22020-08-18 18:54:49 -070018#include <intelblocks/pmclib.h>
Tim Wawrzynczakeb6ebc02021-03-22 16:39:57 -060019#include <intelblocks/tcss.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080020#include <intelblocks/xdci.h>
Wonkyu Kim3ba64ca2020-03-20 12:17:14 -070021#include <intelpch/lockdown.h>
Jamie Ryu02a1b332020-06-11 01:57:13 -070022#include <security/vboot/vboot_common.h>
Jeremy Soller21d7c472021-08-12 10:49:58 -060023#include <soc/gpio.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080024#include <soc/intel/common/vbt.h>
Tim Wawrzynczak90f9cbb2021-07-19 16:07:42 -060025#include <soc/lpm.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080026#include <soc/pci_devs.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053027#include <soc/ramstage.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080028#include <soc/soc_chip.h>
Tim Wawrzynczak59a621a2021-03-22 10:43:42 -060029#include <soc/tcss.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080030#include <string.h>
Sean Rhodesbc35bed2021-07-13 13:36:28 +010031#include <types.h>
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080032
Wonkyu Kim4cabf782020-05-20 13:09:39 -070033/* THC assignment definition */
34#define THC_NONE 0
35#define THC_0 1
36#define THC_1 2
37
Shaunak Saha1a8949c2020-06-08 18:59:47 -070038/* SATA DEVSLP idle timeout default values */
39#define DEF_DMVAL 15
40#define DEF_DITOVAL 625
41
Wonkyu Kim84b48822020-03-09 13:34:38 -070042/*
Nick Vaccaro202b1892021-02-22 14:26:13 -080043 * ME End of Post configuration
44 * 0 - Disable EOP.
45 * 1 - Send in PEI (Applicable for FSP in API mode)
46 * 2 - Send in DXE (Not applicable for FSP in API mode)
47 */
48enum {
Tim Wawrzynczak25d24522021-06-17 12:44:06 -060049 EOP_DISABLE = 0,
50 EOP_PEI = 1,
51 EOP_DXE = 2,
52};
Nick Vaccaro202b1892021-02-22 14:26:13 -080053
54/*
Wonkyu Kim84b48822020-03-09 13:34:38 -070055 * Chip config parameter PcieRpL1Substates uses (UPD value + 1)
56 * because UPD value of 0 for PcieRpL1Substates means disabled for FSP.
57 * In order to ensure that mainboard setting does not disable L1 substates
58 * incorrectly, chip config parameter values are offset by 1 with 0 meaning
59 * use FSP UPD default. get_l1_substate_control() ensures that the right UPD
60 * value is set in fsp_params.
61 * 0: Use FSP UPD default
62 * 1: Disable L1 substates
63 * 2: Use L1.1
64 * 3: Use L1.2 (FSP UPD default)
65 */
66static int get_l1_substate_control(enum L1_substates_control ctl)
67{
68 if ((ctl > L1_SS_L1_2) || (ctl == L1_SS_FSP_DEFAULT))
69 ctl = L1_SS_L1_2;
70 return ctl - 1;
71}
72
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -080073static void parse_devicetree(FSP_S_CONFIG *params)
74{
75 const struct soc_intel_tigerlake_config *config;
76 config = config_of_soc();
77
78 for (int i = 0; i < CONFIG_SOC_INTEL_I2C_DEV_MAX; i++)
79 params->SerialIoI2cMode[i] = config->SerialIoI2cMode[i];
80
81 for (int i = 0; i < CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX; i++) {
82 params->SerialIoSpiMode[i] = config->SerialIoGSpiMode[i];
83 params->SerialIoSpiCsMode[i] = config->SerialIoGSpiCsMode[i];
84 params->SerialIoSpiCsState[i] = config->SerialIoGSpiCsState[i];
85 }
86
87 for (int i = 0; i < CONFIG_SOC_INTEL_UART_DEV_MAX; i++)
88 params->SerialIoUartMode[i] = config->SerialIoUartMode[i];
89}
Subrata Banik91e89c52019-11-01 18:30:01 +053090
Tim Wawrzynczaked042a92021-02-04 17:07:14 -070091/*
92 * The FSP expects a certain list of PCI devices to be in the DevIntConfig table,
93 * regardless of whether or not they are used by the mainboard.
94 */
95static const struct slot_irq_constraints irq_constraints[] = {
96 {
97 .slot = SA_DEV_SLOT_IGD,
98 .fns = {
99 ANY_PIRQ(SA_DEVFN_IGD),
100 },
101 },
102 {
103 .slot = SA_DEV_SLOT_DPTF,
104 .fns = {
105 ANY_PIRQ(SA_DEVFN_DPTF),
106 },
107 },
108 {
109 .slot = SA_DEV_SLOT_IPU,
110 .fns = {
111 ANY_PIRQ(SA_DEVFN_IPU),
112 },
113 },
114 {
115 .slot = SA_DEV_SLOT_CPU_PCIE,
116 .fns = {
117 ANY_PIRQ(SA_DEVFN_CPU_PCIE),
118 },
119 },
120 {
121 .slot = SA_DEV_SLOT_TBT,
122 .fns = {
123 FIXED_INT_ANY_PIRQ(SA_DEVFN_TBT0, PCI_INT_A),
124 FIXED_INT_ANY_PIRQ(SA_DEVFN_TBT1, PCI_INT_B),
125 FIXED_INT_ANY_PIRQ(SA_DEVFN_TBT2, PCI_INT_C),
126 FIXED_INT_ANY_PIRQ(SA_DEVFN_TBT3, PCI_INT_D),
127 },
128 },
129 {
130 .slot = SA_DEV_SLOT_TCSS,
131 .fns = {
132 ANY_PIRQ(SA_DEVFN_TCSS_XHCI),
133 ANY_PIRQ(SA_DEVFN_TCSS_DMA0),
134 ANY_PIRQ(SA_DEVFN_TCSS_DMA1),
135 },
136 },
137 {
138 .slot = PCH_DEV_SLOT_SIO0,
139 .fns = {
140 ANY_PIRQ(PCH_DEVFN_THC0),
141 ANY_PIRQ(PCH_DEVFN_THC1),
142 },
143 },
144 {
145 .slot = PCH_DEV_SLOT_SIO1,
146 .fns = {
147 DIRECT_IRQ(PCH_DEVFN_UART3),
148 },
149 },
150 {
151 .slot = PCH_DEV_SLOT_ISH,
152 .fns = {
153 DIRECT_IRQ(PCH_DEVFN_ISH),
154 DIRECT_IRQ(PCH_DEVFN_GSPI2),
155 },
156 },
157 {
158 .slot = PCH_DEV_SLOT_SIO2,
159 .fns = {
160 DIRECT_IRQ(PCH_DEVFN_GSPI3),
161 },
162 },
163 {
164 .slot = PCH_DEV_SLOT_XHCI,
165 .fns = {
166 ANY_PIRQ(PCH_DEVFN_XHCI),
Sean Rhodese8b6b072021-10-14 20:55:41 +0100167 FIXED_INT_ANY_PIRQ(PCH_DEVFN_CNVI_WIFI, PCI_INT_A),
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700168 },
169 },
170 {
171 .slot = PCH_DEV_SLOT_SIO3,
172 .fns = {
173 DIRECT_IRQ(PCH_DEVFN_I2C0),
174 DIRECT_IRQ(PCH_DEVFN_I2C1),
175 DIRECT_IRQ(PCH_DEVFN_I2C2),
176 DIRECT_IRQ(PCH_DEVFN_I2C3),
177 },
178 },
179 {
180 .slot = PCH_DEV_SLOT_CSE,
181 .fns = {
182 ANY_PIRQ(PCH_DEVFN_CSE),
183 ANY_PIRQ(PCH_DEVFN_CSE_2),
184 ANY_PIRQ(PCH_DEVFN_CSE_IDER),
185 ANY_PIRQ(PCH_DEVFN_CSE_KT),
186 ANY_PIRQ(PCH_DEVFN_CSE_3),
187 ANY_PIRQ(PCH_DEVFN_CSE_4),
188 },
189 },
190 {
191 .slot = PCH_DEV_SLOT_SATA,
192 .fns = {
193 ANY_PIRQ(PCH_DEVFN_SATA),
194 },
195 },
196 {
197 .slot = PCH_DEV_SLOT_SIO4,
198 .fns = {
199 DIRECT_IRQ(PCH_DEVFN_I2C4),
200 DIRECT_IRQ(PCH_DEVFN_I2C5),
201 DIRECT_IRQ(PCH_DEVFN_UART2),
202 },
203 },
204 {
205 .slot = PCH_DEV_SLOT_PCIE,
206 .fns = {
207 FIXED_INT_PIRQ(PCH_DEVFN_PCIE1, PCI_INT_A, PIRQ_A),
208 FIXED_INT_PIRQ(PCH_DEVFN_PCIE2, PCI_INT_B, PIRQ_B),
209 FIXED_INT_PIRQ(PCH_DEVFN_PCIE3, PCI_INT_C, PIRQ_C),
210 FIXED_INT_PIRQ(PCH_DEVFN_PCIE4, PCI_INT_D, PIRQ_D),
211 FIXED_INT_PIRQ(PCH_DEVFN_PCIE5, PCI_INT_A, PIRQ_A),
212 FIXED_INT_PIRQ(PCH_DEVFN_PCIE6, PCI_INT_B, PIRQ_B),
213 FIXED_INT_PIRQ(PCH_DEVFN_PCIE7, PCI_INT_C, PIRQ_C),
214 FIXED_INT_PIRQ(PCH_DEVFN_PCIE8, PCI_INT_D, PIRQ_D),
215 },
216 },
217 {
218 .slot = PCH_DEV_SLOT_PCIE_1,
219 .fns = {
220 FIXED_INT_PIRQ(PCH_DEVFN_PCIE9, PCI_INT_A, PIRQ_A),
221 FIXED_INT_PIRQ(PCH_DEVFN_PCIE10, PCI_INT_B, PIRQ_B),
222 FIXED_INT_PIRQ(PCH_DEVFN_PCIE11, PCI_INT_C, PIRQ_C),
223 FIXED_INT_PIRQ(PCH_DEVFN_PCIE12, PCI_INT_D, PIRQ_D),
224 },
225 },
226 {
227 .slot = PCH_DEV_SLOT_SIO5,
228 .fns = {
229 FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART0, PCI_INT_A),
230 FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART1, PCI_INT_B),
231 DIRECT_IRQ(PCH_DEVFN_GSPI0),
232 DIRECT_IRQ(PCH_DEVFN_GSPI1),
233 },
234 },
235 {
236 .slot = PCH_DEV_SLOT_ESPI,
237 .fns = {
238 ANY_PIRQ(PCH_DEVFN_HDA),
239 ANY_PIRQ(PCH_DEVFN_SMBUS),
240 ANY_PIRQ(PCH_DEVFN_GBE),
241 FIXED_INT_ANY_PIRQ(PCH_DEVFN_TRACEHUB, PCI_INT_A),
242 },
243 },
244};
245
Jes Klinke476ca3a2020-08-28 13:44:21 -0700246__weak void mainboard_update_soc_chip_config(struct soc_intel_tigerlake_config *config)
247{
248 /* Override settings per board. */
249}
250
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700251static const SI_PCH_DEVICE_INTERRUPT_CONFIG *pci_irq_to_fsp(size_t *out_count)
252{
253 const struct pci_irq_entry *entry = get_cached_pci_irqs();
254 SI_PCH_DEVICE_INTERRUPT_CONFIG *config;
255 size_t pch_total = 0;
256 size_t cfg_count = 0;
257
258 if (!entry)
259 return NULL;
260
261 /* Count PCH devices */
262 while (entry) {
263 if (PCI_SLOT(entry->devfn) >= MIN_PCH_SLOT)
264 ++pch_total;
265 entry = entry->next;
266 }
267
268 /* Convert PCH device entries to FSP format */
269 config = calloc(pch_total, sizeof(*config));
270 entry = get_cached_pci_irqs();
271 while (entry) {
272 if (PCI_SLOT(entry->devfn) < MIN_PCH_SLOT) {
273 entry = entry->next;
274 continue;
275 }
276
277 config[cfg_count].Device = PCI_SLOT(entry->devfn);
278 config[cfg_count].Function = PCI_FUNC(entry->devfn);
279 config[cfg_count].IntX = (SI_PCH_INT_PIN)entry->pin;
280 config[cfg_count].Irq = entry->irq;
281 ++cfg_count;
282
283 entry = entry->next;
284 }
285
286 *out_count = cfg_count;
287
288 return config;
289}
290
Subrata Banik91e89c52019-11-01 18:30:01 +0530291/* UPD parameters to be initialized before SiliconInit */
292void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
293{
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800294 int i;
John Zhaobd615d62020-07-27 13:22:11 -0700295 uint32_t cpu_id;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800296 FSP_S_CONFIG *params = &supd->FspsConfig;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800297 struct device *dev;
298 struct soc_intel_tigerlake_config *config;
299 config = config_of_soc();
Jes Klinke476ca3a2020-08-28 13:44:21 -0700300 mainboard_update_soc_chip_config(config);
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800301
302 /* Parse device tree and enable/disable Serial I/O devices */
303 parse_devicetree(params);
304
305 /* Load VBT before devicetree-specific config. */
306 params->GraphicsConfigPtr = (uintptr_t)vbt_get();
307
Wonkyu Kim82e0a812020-04-13 13:26:05 -0700308 /* Check if IGD is present and fill Graphics init param accordingly */
Subrata Banik49a21092021-06-09 03:58:25 +0530309 params->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD);
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800310
Wonkyu Kim82e0a812020-04-13 13:26:05 -0700311 /* Use coreboot MP PPI services if Kconfig is enabled */
Subrata Banik6362de32020-07-30 11:31:55 +0530312 if (CONFIG(USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI))
Wonkyu Kim82e0a812020-04-13 13:26:05 -0700313 params->CpuMpPpi = (uintptr_t) mp_fill_ppi_services_data();
Wonkyu Kim82e0a812020-04-13 13:26:05 -0700314
John Zhao8aac8812020-05-16 13:06:25 -0700315 /* D3Hot and D3Cold for TCSS */
John Zhaobd615d62020-07-27 13:22:11 -0700316 params->D3HotEnable = !config->TcssD3HotDisable;
317 cpu_id = cpu_get_cpuid();
318 if (cpu_id == CPUID_TIGERLAKE_A0)
319 params->D3ColdEnable = 0;
320 else
321 params->D3ColdEnable = !config->TcssD3ColdDisable;
John Zhao8aac8812020-05-16 13:06:25 -0700322
Brandon Breitensteinbf50c312020-12-21 14:55:38 -0800323 params->UsbTcPortEn = config->UsbTcPortEn;
Brandon Breitensteinfc932372020-03-11 14:07:23 -0700324 params->TcssAuxOri = config->TcssAuxOri;
Tim Wawrzynczak59a621a2021-03-22 10:43:42 -0600325
326 /* Explicitly clear this field to avoid using defaults */
327 memset(params->IomTypeCPortPadCfg, 0, sizeof(params->IomTypeCPortPadCfg));
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800328
Tim Wawrzynczaked042a92021-02-04 17:07:14 -0700329
330 /* Assign PCI IRQs */
331 if (!assign_pci_irqs(irq_constraints, ARRAY_SIZE(irq_constraints)))
332 die("ERROR: Unable to assign PCI IRQs, and no ACPI _PRT table is defined\n");
333
334 size_t pch_count = 0;
335 const SI_PCH_DEVICE_INTERRUPT_CONFIG *upd_irqs = pci_irq_to_fsp(&pch_count);
336 params->DevIntConfigPtr = (UINT32)((uintptr_t)upd_irqs);
337 params->NumOfDevIntConfig = pch_count;
338 printk(BIOS_INFO, "IRQ: Using dynamically assigned PCI IO-APIC IRQs\n");
339
John Zhao92a3a302020-06-03 13:06:24 -0700340 /*
341 * Set FSPS UPD ITbtConnectTopologyTimeoutInMs with value 0. FSP will
342 * evaluate this UPD value and skip sending command. There will be no
343 * delay for command completion.
344 */
345 params->ITbtConnectTopologyTimeoutInMs = 0;
346
Srinidhi N Kaushik44509d82021-01-08 10:01:25 -0800347 /* Disable TcColdOnUsbConnect */
348 params->DisableTccoldOnUsbConnected = 1;
349
Wonkyu Kim3ba64ca2020-03-20 12:17:14 -0700350 /* Chipset Lockdown */
Felix Singer673e6d12021-05-03 02:28:16 +0200351 const bool lockdown_by_fsp = get_lockdown_config() == CHIPSET_LOCKDOWN_FSP;
352 params->PchLockDownGlobalSmi = lockdown_by_fsp;
353 params->PchLockDownBiosInterface = lockdown_by_fsp;
354 params->PchUnlockGpioPads = !lockdown_by_fsp;
355 params->RtcMemoryLock = lockdown_by_fsp;
Tim Wawrzynczak58966082021-08-25 09:32:19 -0600356 params->SkipPamLock = !lockdown_by_fsp;
Wonkyu Kim3ba64ca2020-03-20 12:17:14 -0700357
Tim Wawrzynczak25d24522021-06-17 12:44:06 -0600358 /* coreboot will send EOP before loading payload */
359 params->EndOfPostMessage = EOP_DISABLE;
Nick Vaccaro202b1892021-02-22 14:26:13 -0800360
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800361 /* USB */
362 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
363 params->PortUsb20Enable[i] = config->usb2_ports[i].enable;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800364 params->Usb2PhyPetxiset[i] = config->usb2_ports[i].pre_emp_bias;
365 params->Usb2PhyTxiset[i] = config->usb2_ports[i].tx_bias;
366 params->Usb2PhyPredeemp[i] = config->usb2_ports[i].tx_emp_enable;
367 params->Usb2PhyPehalfbit[i] = config->usb2_ports[i].pre_emp_bit;
Michael Niewöhner056d5522020-09-04 15:40:35 +0200368
369 if (config->usb2_ports[i].enable)
370 params->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin;
371 else
372 params->Usb2OverCurrentPin[i] = 0xff;
John Zhao4ead6b332021-01-01 14:19:36 -0800373
374 if (config->usb2_ports[i].type_c)
375 params->PortResetMessageEnable[i] = 1;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800376 }
377
378 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
379 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
Michael Niewöhner056d5522020-09-04 15:40:35 +0200380 if (config->usb3_ports[i].enable) {
381 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
382 } else {
383 params->Usb3OverCurrentPin[i] = 0xff;
384 }
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800385 if (config->usb3_ports[i].tx_de_emp) {
386 params->Usb3HsioTxDeEmphEnable[i] = 1;
387 params->Usb3HsioTxDeEmph[i] = config->usb3_ports[i].tx_de_emp;
388 }
389 if (config->usb3_ports[i].tx_downscale_amp) {
390 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
391 params->Usb3HsioTxDownscaleAmp[i] =
392 config->usb3_ports[i].tx_downscale_amp;
393 }
394 }
395
Wonkyu Kim84b48822020-03-09 13:34:38 -0700396 /* RP Configs */
Wonkyu Kim59431172020-04-07 20:45:28 -0700397 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) {
Wonkyu Kim84b48822020-03-09 13:34:38 -0700398 params->PcieRpL1Substates[i] =
399 get_l1_substate_control(config->PcieRpL1Substates[i]);
Wonkyu Kim59431172020-04-07 20:45:28 -0700400 params->PcieRpLtrEnable[i] = config->PcieRpLtrEnable[i];
401 params->PcieRpAdvancedErrorReporting[i] =
402 config->PcieRpAdvancedErrorReporting[i];
Wonkyu Kimc66c1532020-05-27 13:34:04 -0700403 params->PcieRpHotPlug[i] = config->PcieRpHotPlug[i];
Duncan Laurie17e905ac2020-10-27 17:57:13 -0700404 params->PciePtm[i] = config->PciePtm[i];
Michael Niewöhner45b60802022-01-08 20:47:11 +0100405 params->PcieRpSlotImplemented[i] = config->PcieRpSlotImplemented[i];
Wonkyu Kim59431172020-04-07 20:45:28 -0700406 }
Meera Ravindranath0d6cc222020-04-29 12:19:33 +0530407
408 /* Enable ClkReqDetect for enabled port */
409 memcpy(params->PcieRpClkReqDetect, config->PcieRpClkReqDetect,
410 sizeof(config->PcieRpClkReqDetect));
411
Nick Vaccaro4b3e06e2021-05-11 16:39:32 -0700412 for (i = 0; i < ARRAY_SIZE(config->tcss_ports); i++) {
413 if (config->tcss_ports[i].enable)
414 params->CpuUsb3OverCurrentPin[i] =
415 config->tcss_ports[i].ocpin;
416 }
417
Angel Ponsc7cfe0b2021-06-23 12:39:22 +0200418 params->XdciEnable = xdci_can_enable(PCH_DEVFN_USBOTG);
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800419
420 /* PCH UART selection for FSP Debug */
421 params->SerialIoDebugUartNumber = CONFIG_UART_FOR_CONSOLE;
Srinidhi N Kaushik4af0adb2020-02-29 00:32:23 -0800422 ASSERT(ARRAY_SIZE(params->SerialIoUartAutoFlow) > CONFIG_UART_FOR_CONSOLE);
423 params->SerialIoUartAutoFlow[CONFIG_UART_FOR_CONSOLE] = 0;
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800424
Wonkyu Kim815d96a2020-01-21 21:51:19 -0800425 /* SATA */
Subrata Banik49a21092021-06-09 03:58:25 +0530426 params->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA);
Felix Singer5c107042020-07-26 09:22:42 +0200427 if (params->SataEnable) {
Wonkyu Kim815d96a2020-01-21 21:51:19 -0800428 params->SataMode = config->SataMode;
429 params->SataSalpSupport = config->SataSalpSupport;
430 memcpy(params->SataPortsEnable, config->SataPortsEnable,
431 sizeof(params->SataPortsEnable));
432 memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp,
433 sizeof(params->SataPortsDevSlp));
434 }
435
Jes Klinke6fd87ff2020-08-10 13:30:40 -0700436 /* S0iX: Selectively enable individual sub-states,
437 * by default all are enabled.
438 *
439 * LPM0-s0i2.0, LPM1-s0i2.1, LPM2-s0i2.2, LPM3-s0i3.0,
440 * LPM4-s0i3.1, LPM5-s0i3.2, LPM6-s0i3.3, LPM7-s0i3.4
441 */
Tim Wawrzynczak90f9cbb2021-07-19 16:07:42 -0600442 params->PmcLpmS0ixSubStateEnableMask = get_supported_lpm_mask(config);
Jes Klinke6fd87ff2020-08-10 13:30:40 -0700443
Shaunak Saha32b8a512020-03-31 22:56:13 -0700444 /*
445 * Power Optimizer for DMI and SATA.
446 * DmiPwrOptimizeDisable and SataPwrOptimizeDisable is default to 0.
447 * Boards not needing the optimizers explicitly disables them by setting
448 * these disable variables to 1 in devicetree overrides.
449 */
450 params->PchPwrOptEnable = !(config->DmiPwrOptimizeDisable);
451 params->SataPwrOptEnable = !(config->SataPwrOptimizeDisable);
452
Shaunak Saha1a8949c2020-06-08 18:59:47 -0700453 /*
454 * Enable DEVSLP Idle Timeout settings DmVal and DitoVal.
455 * SataPortsDmVal is the DITO multiplier. Default is 15.
456 * SataPortsDitoVal is the DEVSLP Idle Timeout (DITO), Default is 625ms.
457 * The default values can be changed from devicetree.
458 */
459 for (i = 0; i < ARRAY_SIZE(config->SataPortsEnableDitoConfig); i++) {
460 if (config->SataPortsEnableDitoConfig[i]) {
461 if (config->SataPortsDmVal[i])
462 params->SataPortsDmVal[i] = config->SataPortsDmVal[i];
463 else
464 params->SataPortsDmVal[i] = DEF_DMVAL;
465
466 if (config->SataPortsDitoVal[i])
467 params->SataPortsDitoVal[i] = config->SataPortsDitoVal[i];
468 else
469 params->SataPortsDitoVal[i] = DEF_DITOVAL;
470 }
471 }
472
Shaunak Saha0d0f43f2020-09-02 15:37:00 -0700473 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
Shaunak Saha82d51232021-02-17 23:26:43 -0800474 params->FastPkgCRampDisable[0] = config->FastPkgCRampDisable;
475 params->SlowSlewRate[0] = config->SlowSlewRate;
Shaunak Saha0d0f43f2020-09-02 15:37:00 -0700476
Sumeet R Pawnikar7d6bc602020-05-08 19:22:07 +0530477 /* Enable TCPU for processor thermal control */
Felix Singer2aa1ff42021-12-05 03:13:37 +0100478 params->Device4Enable = is_devfn_enabled(SA_DEVFN_DPTF);
Sumeet R Pawnikar7d6bc602020-05-08 19:22:07 +0530479
Sumeet R Pawnikar6caa4762020-06-18 16:50:58 +0530480 /* Set TccActivationOffset */
481 params->TccActivationOffset = config->tcc_offset;
482
Wonkyu Kimb3fa6a02020-02-27 15:54:56 -0800483 /* LAN */
Subrata Banik49a21092021-06-09 03:58:25 +0530484 params->PchLanEnable = is_devfn_enabled(PCH_DEVFN_GBE);
Wonkyu Kimb3fa6a02020-02-27 15:54:56 -0800485
Srinidhi N Kaushik84888532020-03-05 00:54:02 -0800486 /* CNVi */
Subrata Banik49a21092021-06-09 03:58:25 +0530487 params->CnviMode = is_devfn_enabled(PCH_DEVFN_CNVI_WIFI);
Cliff Huangb34be4d2021-02-04 15:37:24 -0800488 params->CnviBtCore = config->CnviBtCore;
John Zhaoc16fc8a2020-09-21 13:10:11 -0700489 params->CnviBtAudioOffload = config->CnviBtAudioOffload;
Cliff Huangb34be4d2021-02-04 15:37:24 -0800490 /* Assert if CNVi BT is enabled without CNVi being enabled. */
491 assert(params->CnviMode || !params->CnviBtCore);
492 /* Assert if CNVi BT offload is enabled without CNVi BT being enabled. */
493 assert(params->CnviBtCore || !params->CnviBtAudioOffload);
John Zhaoc16fc8a2020-09-21 13:10:11 -0700494
Wonkyu Kim165efa12020-05-05 09:10:13 -0700495 /* VMD */
Subrata Banik49a21092021-06-09 03:58:25 +0530496 params->VmdEnable = is_devfn_enabled(SA_DEVFN_VMD);
Wonkyu Kim165efa12020-05-05 09:10:13 -0700497
Wonkyu Kim4cabf782020-05-20 13:09:39 -0700498 /* THC */
Subrata Banik49a21092021-06-09 03:58:25 +0530499 params->ThcPort0Assignment = is_devfn_enabled(PCH_DEVFN_THC0) ? THC_0 : THC_NONE;
500 params->ThcPort1Assignment = is_devfn_enabled(PCH_DEVFN_THC1) ? THC_1 : THC_NONE;
Wonkyu Kim4cabf782020-05-20 13:09:39 -0700501
Subrata Banik1bfd56cb2020-02-24 15:14:22 +0530502 /* Legacy 8254 timer support */
Sean Rhodesbc35bed2021-07-13 13:36:28 +0100503 bool use_8254 = get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER));
504 params->Enable8254ClockGating = !use_8254;
505 params->Enable8254ClockGatingOnS3 = !use_8254;
Subrata Banik1bfd56cb2020-02-24 15:14:22 +0530506
Michael Niewöhner0e905802021-09-25 00:10:30 +0200507 /*
508 * Legacy PM ACPI Timer (and TCO Timer)
509 * This *must* be 1 in any case to keep FSP from
510 * 1) enabling PM ACPI Timer emulation in uCode.
511 * 2) disabling the PM ACPI Timer.
512 * We handle both by ourself!
513 */
514 params->EnableTcoTimer = 1;
515
Wonkyu Kim2b4ded02020-03-03 01:43:45 -0800516 /* Enable Hybrid storage auto detection */
Jamie Ryu02a1b332020-06-11 01:57:13 -0700517 if (CONFIG(SOC_INTEL_CSE_LITE_SKU) && cse_is_hfs3_fw_sku_lite()
518 && vboot_recovery_mode_enabled() && !cse_is_hfs1_com_normal()) {
519 /*
520 * CSE Lite SKU does not support hybrid storage dynamic configuration
521 * in CSE RO boot, and FSP does not allow to send the strap override
522 * HECI commands if CSE is not in normal mode; hence, hybrid storage
523 * mode is disabled on CSE RO boot in recovery boot mode.
524 */
525 printk(BIOS_INFO, "cse_lite: CSE RO boot. HybridStorageMode disabled\n");
526 params->HybridStorageMode = 0;
527 } else {
528 params->HybridStorageMode = config->HybridStorageMode;
529 }
Wonkyu Kim2b4ded02020-03-03 01:43:45 -0800530
Brandon Breitenstein11637452020-02-06 14:20:57 -0800531 /* USB4/TBT */
532 for (i = 0; i < ARRAY_SIZE(params->ITbtPcieRootPortEn); i++) {
533 dev = pcidev_on_root(SA_DEV_SLOT_TBT, i);
Felix Singerf424c8b2021-12-10 23:23:42 +0100534 params->ITbtPcieRootPortEn[i] = is_dev_enabled(dev);
Brandon Breitenstein11637452020-02-06 14:20:57 -0800535 }
536
Venkata Krishna Nimmagaddae18f7192020-05-15 00:13:40 -0700537 /* PCH FIVR settings override */
538 if (config->ext_fivr_settings.configure_ext_fivr) {
539 params->PchFivrExtV1p05RailEnabledStates =
540 config->ext_fivr_settings.v1p05_enable_bitmap;
541
542 params->PchFivrExtV1p05RailSupportedVoltageStates =
543 config->ext_fivr_settings.v1p05_supported_voltage_bitmap;
544
545 params->PchFivrExtVnnRailEnabledStates =
546 config->ext_fivr_settings.vnn_enable_bitmap;
547
548 params->PchFivrExtVnnRailSupportedVoltageStates =
549 config->ext_fivr_settings.vnn_supported_voltage_bitmap;
550
551 /* convert mV to number of 2.5 mV increments */
552 params->PchFivrExtVnnRailSxVoltage =
553 (config->ext_fivr_settings.vnn_sx_voltage_mv * 10) / 25;
554
555 params->PchFivrExtV1p05RailIccMaximum =
556 config->ext_fivr_settings.v1p05_icc_max_ma;
557
558 }
559
Jamie Ryu5b7daa22020-08-18 18:54:49 -0700560 /* Apply minimum assertion width settings if non-zero */
561 if (config->PchPmSlpS3MinAssert)
562 params->PchPmSlpS3MinAssert = config->PchPmSlpS3MinAssert;
563 if (config->PchPmSlpS4MinAssert)
564 params->PchPmSlpS4MinAssert = config->PchPmSlpS4MinAssert;
565 if (config->PchPmSlpSusMinAssert)
566 params->PchPmSlpSusMinAssert = config->PchPmSlpSusMinAssert;
567 if (config->PchPmSlpAMinAssert)
568 params->PchPmSlpAMinAssert = config->PchPmSlpAMinAssert;
569
570 /* Set Power Cycle Duration */
571 if (config->PchPmPwrCycDur)
572 params->PchPmPwrCycDur = get_pm_pwr_cyc_dur(config->PchPmSlpS4MinAssert,
573 config->PchPmSlpS3MinAssert, config->PchPmSlpAMinAssert,
574 config->PchPmPwrCycDur);
575
Subrata Banik298b3592021-09-14 12:38:08 +0530576 /* Override EnableMultiPhaseSiliconInit prior calling MultiPhaseSiInit */
577 params->EnableMultiPhaseSiliconInit = fsp_is_multi_phase_init_enabled();
Ravi Sarawadid83e24d2020-10-14 16:30:38 -0700578
579 /* Disable C1 C-state Demotion */
580 params->C1StateAutoDemotion = 0;
581
Derek Huang80561872021-03-15 12:11:19 +0800582 /* USB2 Phy Sus power gating setting override */
583 params->PmcUsb2PhySusPgEnable = !config->usb2_phy_sus_pg_disable;
584
Tim Crawfordf3c4f292021-08-07 00:30:15 -0600585 /*
586 * Prevent FSP from programming write-once subsystem IDs by providing
587 * a custom SSID table. Must have at least one entry for the FSP to
588 * use the table.
589 */
590 struct svid_ssid_init_entry {
591 union {
592 struct {
593 uint64_t reg:12; /* Register offset */
594 uint64_t function:3;
595 uint64_t device:5;
596 uint64_t bus:8;
597 uint64_t :4;
598 uint64_t segment:16;
599 uint64_t :16;
600 };
601 uint64_t segbusdevfuncregister;
602 };
603 struct {
604 uint16_t svid;
605 uint16_t ssid;
606 };
607 uint32_t reserved;
608 };
609
610 /*
611 * The xHCI and HDA devices have RW/L rather than RW/O registers for
612 * subsystem IDs and so must be written before FspSiliconInit locks
613 * them with their default values.
614 */
615 const pci_devfn_t devfn_table[] = { PCH_DEVFN_XHCI, PCH_DEVFN_HDA };
616 static struct svid_ssid_init_entry ssid_table[ARRAY_SIZE(devfn_table)];
617
618 for (i = 0; i < ARRAY_SIZE(devfn_table); i++) {
619 ssid_table[i].reg = PCI_SUBSYSTEM_VENDOR_ID;
620 ssid_table[i].device = PCI_SLOT(devfn_table[i]);
621 ssid_table[i].function = PCI_FUNC(devfn_table[i]);
622 dev = pcidev_path_on_root(devfn_table[i]);
623 if (dev) {
624 ssid_table[i].svid = dev->subsystem_vendor;
625 ssid_table[i].ssid = dev->subsystem_device;
626 }
627 }
628
629 params->SiSsidTablePtr = (uintptr_t)ssid_table;
630 params->SiNumberOfSsidTableEntry = ARRAY_SIZE(ssid_table);
631
632 /*
633 * Replace the default SVID:SSID value with the values specified in
634 * the devicetree for the root device.
635 */
636 dev = pcidev_path_on_root(SA_DEVFN_ROOT);
637 params->SiCustomizedSvid = dev->subsystem_vendor;
638 params->SiCustomizedSsid = dev->subsystem_device;
639
640 /* Ensure FSP will program the registers */
641 params->SiSkipSsidProgramming = 0;
642
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800643 mainboard_silicon_init_params(params);
644}
645
Subrata Banikb622d4b2020-05-26 18:33:22 +0530646/*
647 * Callbacks for SoC/Mainboard specific overrides for FspMultiPhaseSiInit
648 * This platform supports below MultiPhaseSIInit Phase(s):
649 * Phase | FSP return point | Purpose
650 * ------- + ------------------------------------------------ + -------------------------------
651 * 1 | After TCSS initialization completed | for TCSS specific init
652 */
653void platform_fsp_multi_phase_init_cb(uint32_t phase_index)
654{
655 switch (phase_index) {
656 case 1:
657 /* TCSS specific initialization here */
Brandon Breitenstein99b38a92019-12-19 23:12:58 -0800658 printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n",
659 __FILE__, __func__);
Tim Wawrzynczakeb6ebc02021-03-22 16:39:57 -0600660
Tim Wawrzynczak59a621a2021-03-22 10:43:42 -0600661 if (CONFIG(SOC_INTEL_COMMON_BLOCK_TCSS)) {
662 const config_t *config = config_of_soc();
663 tcss_configure(config->typec_aux_bias_pads);
664 }
Subrata Banikb622d4b2020-05-26 18:33:22 +0530665 break;
666 default:
667 break;
668 }
669}
670
Srinidhi N Kaushikd801b1f2019-12-27 13:28:01 -0800671/* Mainboard GPIO Configuration */
672__weak void mainboard_silicon_init_params(FSP_S_CONFIG *params)
673{
674 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
Subrata Banik91e89c52019-11-01 18:30:01 +0530675}