soc/intel/xeon_sp/spr: Drop microcode constraints
[coreboot2.git] / src / soc / intel / meteorlake / fsp_params.c
bloba02d4b99c67945a4b64921428aec73420ca96f0e
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <assert.h>
4 #include <bootmode.h>
5 #include <bootsplash.h>
6 #include <cbfs.h>
7 #include <console/console.h>
8 #include <cpu/intel/cpu_ids.h>
9 #include <cpu/intel/microcode.h>
10 #include <device/device.h>
11 #include <device/pci.h>
12 #include <fsp/api.h>
13 #include <fsp/fsp_debug_event.h>
14 #include <fsp/fsp_gop_blt.h>
15 #include <fsp/ppi/mp_service_ppi.h>
16 #include <fsp/util.h>
17 #include <option.h>
18 #include <intelblocks/cse.h>
19 #include <intelblocks/irq.h>
20 #include <intelblocks/lpss.h>
21 #include <intelblocks/mp_init.h>
22 #include <intelblocks/systemagent.h>
23 #include <intelblocks/xdci.h>
24 #include <intelpch/lockdown.h>
25 #include <security/vboot/vboot_common.h>
26 #include <soc/cpu.h>
27 #include <soc/gpio_soc_defs.h>
28 #include <soc/intel/common/vbt.h>
29 #include <soc/pci_devs.h>
30 #include <soc/pcie.h>
31 #include <soc/ramstage.h>
32 #include <soc/soc_chip.h>
33 #include <soc/soc_info.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <types.h>
38 /* THC assignment definition */
39 #define THC_NONE 0
40 #define THC_0 1
41 #define THC_1 2
43 /* SATA DEVSLP idle timeout default values */
44 #define DEF_DMVAL 15
45 #define DEF_DITOVAL 625
47 #define MAX_ONBOARD_PCIE_DEVICES 256
49 static const struct slot_irq_constraints irq_constraints[] = {
51 .slot = PCI_DEV_SLOT_PCIE_3,
52 .fns = {
53 FIXED_INT_PIRQ(PCI_DEVFN_PCIE12, PCI_INT_A, PIRQ_A),
57 .slot = PCI_DEV_SLOT_IGD,
58 .fns = {
59 /* INTERRUPT_PIN is RO/0x01 */
60 FIXED_INT_ANY_PIRQ(PCI_DEV_SLOT_IGD, PCI_INT_A),
64 .slot = PCI_DEV_SLOT_DPTF,
65 .fns = {
66 /* Dynamic Tuning Technology (DTT) device IRQ is not
67 programmable and is INT_A/PIRQ_A (IRQ 16) */
68 FIXED_INT_PIRQ(PCI_DEVFN_DPTF, PCI_INT_A, PIRQ_A),
72 .slot = PCI_DEV_SLOT_IPU,
73 .fns = {
74 /* INTERRUPT_PIN is RO/0x01, and INTERRUPT_LINE is RW,
75 but S0ix fails when not set to 16 (b/193434192) */
76 FIXED_INT_PIRQ(PCI_DEVFN_IPU, PCI_INT_A, PIRQ_A),
80 .slot = PCI_DEV_SLOT_PCIE_2,
81 .fns = {
82 FIXED_INT_PIRQ(PCI_DEVFN_PCIE9, PCI_INT_A, PIRQ_A),
83 FIXED_INT_PIRQ(PCI_DEVFN_PCIE10, PCI_INT_B, PIRQ_B),
84 FIXED_INT_PIRQ(PCI_DEVFN_PCIE11, PCI_INT_C, PIRQ_C),
88 .slot = PCI_DEV_SLOT_TBT,
89 .fns = {
90 ANY_PIRQ(PCI_DEVFN_TBT0),
91 ANY_PIRQ(PCI_DEVFN_TBT1),
92 ANY_PIRQ(PCI_DEVFN_TBT2),
93 ANY_PIRQ(PCI_DEVFN_TBT3),
97 .slot = PCI_DEV_SLOT_GNA,
98 .fns = {
99 /* INTERRUPT_PIN is RO/0x01 */
100 FIXED_INT_ANY_PIRQ(PCI_DEVFN_GNA, PCI_INT_A),
104 .slot = PCI_DEV_SLOT_VPU,
105 .fns = {
106 /* INTERRUPT_PIN is RO/0x01 */
107 FIXED_INT_ANY_PIRQ(PCI_DEVFN_VPU, PCI_INT_A),
111 .slot = PCI_DEV_SLOT_TCSS,
112 .fns = {
113 ANY_PIRQ(PCI_DEVFN_TCSS_XHCI),
114 ANY_PIRQ(PCI_DEVFN_TCSS_XDCI),
118 .slot = PCI_DEV_SLOT_THC,
119 .fns = {
120 ANY_PIRQ(PCI_DEVFN_THC0),
121 ANY_PIRQ(PCI_DEVFN_THC1),
125 .slot = PCI_DEV_SLOT_ISH,
126 .fns = {
127 DIRECT_IRQ(PCI_DEVFN_ISH),
128 DIRECT_IRQ(PCI_DEVFN_GSPI2),
129 ANY_PIRQ(PCI_DEVFN_UFS),
133 .slot = PCI_DEV_SLOT_XHCI,
134 .fns = {
135 ANY_PIRQ(PCI_DEVFN_XHCI),
136 DIRECT_IRQ(PCI_DEVFN_USBOTG),
137 ANY_PIRQ(PCI_DEVFN_CNVI_WIFI),
141 .slot = PCI_DEV_SLOT_SIO0,
142 .fns = {
143 DIRECT_IRQ(PCI_DEVFN_I2C0),
144 DIRECT_IRQ(PCI_DEVFN_I2C1),
145 DIRECT_IRQ(PCI_DEVFN_I2C2),
146 DIRECT_IRQ(PCI_DEVFN_I2C3),
150 .slot = PCI_DEV_SLOT_CSE,
151 .fns = {
152 ANY_PIRQ(PCI_DEVFN_CSE),
153 ANY_PIRQ(PCI_DEVFN_CSE_2),
154 ANY_PIRQ(PCI_DEVFN_CSE_IDER),
155 ANY_PIRQ(PCI_DEVFN_CSE_KT),
156 ANY_PIRQ(PCI_DEVFN_CSE_3),
157 ANY_PIRQ(PCI_DEVFN_CSE_4),
161 .slot = PCI_DEV_SLOT_SATA,
162 .fns = {
163 ANY_PIRQ(PCI_DEVFN_SATA),
167 .slot = PCI_DEV_SLOT_SIO1,
168 .fns = {
169 DIRECT_IRQ(PCI_DEVFN_I2C4),
170 DIRECT_IRQ(PCI_DEVFN_I2C5),
171 DIRECT_IRQ(PCI_DEVFN_UART2),
175 .slot = PCI_DEV_SLOT_PCIE_1,
176 .fns = {
177 FIXED_INT_PIRQ(PCI_DEVFN_PCIE1, PCI_INT_A, PIRQ_A),
178 FIXED_INT_PIRQ(PCI_DEVFN_PCIE2, PCI_INT_B, PIRQ_B),
179 FIXED_INT_PIRQ(PCI_DEVFN_PCIE3, PCI_INT_C, PIRQ_C),
180 FIXED_INT_PIRQ(PCI_DEVFN_PCIE4, PCI_INT_D, PIRQ_D),
181 FIXED_INT_PIRQ(PCI_DEVFN_PCIE5, PCI_INT_A, PIRQ_A),
182 FIXED_INT_PIRQ(PCI_DEVFN_PCIE6, PCI_INT_B, PIRQ_B),
183 FIXED_INT_PIRQ(PCI_DEVFN_PCIE7, PCI_INT_C, PIRQ_C),
184 FIXED_INT_PIRQ(PCI_DEVFN_PCIE8, PCI_INT_D, PIRQ_D),
188 .slot = PCI_DEV_SLOT_SIO2,
189 .fns = {
190 /* UART0 shares an interrupt line with TSN0, so must use
191 a PIRQ */
192 FIXED_INT_ANY_PIRQ(PCI_DEVFN_UART0, PCI_INT_A),
193 /* UART1 shares an interrupt line with TSN1, so must use
194 a PIRQ */
195 FIXED_INT_ANY_PIRQ(PCI_DEVFN_UART1, PCI_INT_B),
196 DIRECT_IRQ(PCI_DEVFN_GSPI0),
197 DIRECT_IRQ(PCI_DEVFN_GSPI1),
201 .slot = PCI_DEV_SLOT_ESPI,
202 .fns = {
203 ANY_PIRQ(PCI_DEVFN_HDA),
204 ANY_PIRQ(PCI_DEVFN_SMBUS),
205 ANY_PIRQ(PCI_DEVFN_GBE),
206 /* INTERRUPT_PIN is RO/0x01 */
207 FIXED_INT_ANY_PIRQ(PCI_DEVFN_NPK, PCI_INT_A),
212 bool is_pch_slot(unsigned int devfn)
214 if (PCI_SLOT(devfn) >= MIN_PCH_SLOT)
215 return true;
216 const struct pcie_rp_group *group;
217 for (group = get_pcie_rp_table(); group->count; ++group) {
218 if (PCI_SLOT(devfn) == group->slot)
219 return true;
221 return false;
224 static const SI_PCH_DEVICE_INTERRUPT_CONFIG *pci_irq_to_fsp(size_t *out_count)
226 const struct pci_irq_entry *entry = get_cached_pci_irqs();
227 SI_PCH_DEVICE_INTERRUPT_CONFIG *config;
228 size_t pch_total = 0;
229 size_t cfg_count = 0;
231 if (!entry)
232 return NULL;
234 /* Count PCH devices */
235 while (entry) {
236 if (is_pch_slot(entry->devfn))
237 ++pch_total;
238 entry = entry->next;
241 /* Convert PCH device entries to FSP format */
242 config = calloc(pch_total, sizeof(*config));
243 entry = get_cached_pci_irqs();
244 while (entry) {
245 if (!is_pch_slot(entry->devfn)) {
246 entry = entry->next;
247 continue;
250 config[cfg_count].Device = PCI_SLOT(entry->devfn);
251 config[cfg_count].Function = PCI_FUNC(entry->devfn);
252 config[cfg_count].IntX = (SI_PCH_INT_PIN)entry->pin;
253 config[cfg_count].Irq = entry->irq;
254 ++cfg_count;
256 entry = entry->next;
259 *out_count = cfg_count;
261 return config;
265 * ME End of Post configuration
266 * 0 - Disable EOP.
267 * 1 - Send in PEI (Applicable for FSP in API mode)
268 * 2 - Send in DXE (Not applicable for FSP in API mode)
270 enum fsp_end_of_post {
271 EOP_DISABLE = 0,
272 EOP_PEI = 1,
273 EOP_DXE = 2,
276 static const pci_devfn_t i2c_dev[] = {
277 PCI_DEVFN_I2C0,
278 PCI_DEVFN_I2C1,
279 PCI_DEVFN_I2C2,
280 PCI_DEVFN_I2C3,
281 PCI_DEVFN_I2C4,
282 PCI_DEVFN_I2C5,
285 static const pci_devfn_t gspi_dev[] = {
286 PCI_DEVFN_GSPI0,
287 PCI_DEVFN_GSPI1,
288 PCI_DEVFN_GSPI2,
291 static const pci_devfn_t uart_dev[] = {
292 PCI_DEVFN_UART0,
293 PCI_DEVFN_UART1,
294 PCI_DEVFN_UART2
298 * Chip config parameter PcieRpL1Substates uses (UPD value + 1)
299 * because UPD value of 0 for PcieRpL1Substates means disabled for FSP.
300 * In order to ensure that mainboard setting does not disable L1 substates
301 * incorrectly, chip config parameter values are offset by 1 with 0 meaning
302 * use FSP UPD default. get_l1_substate_control() ensures that the right UPD
303 * value is set in fsp_params.
304 * 0: Use FSP UPD default
305 * 1: Disable L1 substates
306 * 2: Use L1.1
307 * 3: Use L1.2 (FSP UPD default)
309 static int get_l1_substate_control(enum L1_substates_control ctl)
311 if (CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE))
312 ctl = L1_SS_DISABLED;
313 else if ((ctl > L1_SS_L1_2) || (ctl == L1_SS_FSP_DEFAULT))
314 ctl = L1_SS_L1_2;
315 return ctl - 1;
319 * Chip config parameter pcie_rp_aspm uses (UPD value + 1) because
320 * a UPD value of 0 for pcie_rp_aspm means disabled. In order to ensure
321 * that the mainboard setting does not disable ASPM incorrectly, chip
322 * config parameter values are offset by 1 with 0 meaning use FSP UPD default.
323 * get_aspm_control() ensures that the right UPD value is set in fsp_params.
324 * 0: Use FSP UPD default
325 * 1: Disable ASPM
326 * 2: L0s only
327 * 3: L1 only
328 * 4: L0s and L1
329 * 5: Auto configuration
331 static unsigned int get_aspm_control(enum ASPM_control ctl)
333 if ((ctl > ASPM_AUTO) || (ctl == ASPM_DEFAULT))
334 ctl = ASPM_AUTO;
335 return ctl - 1;
338 __weak void mainboard_update_soc_chip_config(struct soc_intel_meteorlake_config *config)
340 /* Override settings per board. */
343 static void fill_fsps_lpss_params(FSP_S_CONFIG *s_cfg,
344 const struct soc_intel_meteorlake_config *config)
346 int max_port, i;
348 max_port = get_max_i2c_port();
349 for (i = 0; i < max_port; i++) {
350 s_cfg->SerialIoI2cMode[i] = is_devfn_enabled(i2c_dev[i]) ?
351 config->serial_io_i2c_mode[i] : 0;
354 max_port = get_max_gspi_port();
355 for (i = 0; i < max_port; i++) {
356 s_cfg->SerialIoSpiCsMode[i] = config->serial_io_gspi_cs_mode[i];
357 s_cfg->SerialIoSpiCsState[i] = config->serial_io_gspi_cs_state[i];
358 s_cfg->SerialIoSpiMode[i] = is_devfn_enabled(gspi_dev[i]) ?
359 config->serial_io_gspi_mode[i] : 0;
362 max_port = get_max_uart_port();
363 for (i = 0; i < max_port; i++) {
364 s_cfg->SerialIoUartMode[i] = is_devfn_enabled(uart_dev[i]) ?
365 config->serial_io_uart_mode[i] : 0;
369 static void fill_fsps_microcode_params(FSP_S_CONFIG *s_cfg,
370 const struct soc_intel_meteorlake_config *config)
372 const struct microcode *microcode_file;
373 size_t microcode_len;
375 /* Locate microcode and pass to FSP-S for 2nd microcode loading */
376 microcode_file = intel_microcode_find();
378 if (microcode_file != NULL) {
379 microcode_len = get_microcode_size(microcode_file);
380 if (microcode_len != 0) {
381 /* Update CPU Microcode patch base address/size */
382 s_cfg->MicrocodeRegionBase = (uint32_t)(uintptr_t)microcode_file;
383 s_cfg->MicrocodeRegionSize = (uint32_t)microcode_len;
388 static void fill_fsps_cpu_params(FSP_S_CONFIG *s_cfg,
389 const struct soc_intel_meteorlake_config *config)
392 * FIXME: FSP assumes ownership of the APs (Application Processors)
393 * upon passing `NULL` pointer to the CpuMpPpi FSP-S UPD.
394 * Hence, pass a valid pointer to the CpuMpPpi UPD unconditionally.
395 * This would avoid APs from getting hijacked by FSP while coreboot
396 * decides to set SkipMpInit UPD.
398 s_cfg->CpuMpPpi = (uintptr_t)mp_fill_ppi_services_data();
401 * Fill `2nd microcode loading FSP UPD` if FSP is running CPU feature
402 * programming.
404 if (CONFIG(USE_FSP_FEATURE_PROGRAM_ON_APS))
405 fill_fsps_microcode_params(s_cfg, config);
409 static void fill_fsps_igd_params(FSP_S_CONFIG *s_cfg,
410 const struct soc_intel_meteorlake_config *config)
412 /* Load VBT before devicetree-specific config. */
413 s_cfg->GraphicsConfigPtr = (uintptr_t)vbt_get();
415 /* Check if IGD is present and fill Graphics init param accordingly */
416 s_cfg->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(PCI_DEVFN_IGD);
417 s_cfg->LidStatus = CONFIG(VBOOT_LID_SWITCH) ? get_lid_switch() : CONFIG(RUN_FSP_GOP);
418 s_cfg->PavpEnable = CONFIG(PAVP);
421 static void fill_fsps_tcss_params(FSP_S_CONFIG *s_cfg,
422 const struct soc_intel_meteorlake_config *config)
424 const struct device *tcss_port_arr[] = {
425 DEV_PTR(tcss_usb3_port0),
426 DEV_PTR(tcss_usb3_port1),
427 DEV_PTR(tcss_usb3_port2),
428 DEV_PTR(tcss_usb3_port3),
431 s_cfg->TcssAuxOri = config->tcss_aux_ori;
433 /* Explicitly clear this field to avoid using defaults */
434 memset(s_cfg->IomTypeCPortPadCfg, 0, sizeof(s_cfg->IomTypeCPortPadCfg));
436 /* D3Hot and D3Cold for TCSS */
437 s_cfg->D3HotEnable = !config->tcss_d3_hot_disable;
438 s_cfg->D3ColdEnable = CONFIG(D3COLD_SUPPORT);
439 s_cfg->UsbTcPortEn = 0;
441 for (int i = 0; i < MAX_TYPE_C_PORTS; i++) {
442 if (is_dev_enabled(tcss_port_arr[i]))
443 s_cfg->UsbTcPortEn |= BIT(i);
447 static void fill_fsps_chipset_lockdown_params(FSP_S_CONFIG *s_cfg,
448 const struct soc_intel_meteorlake_config *config)
450 /* Chipset Lockdown */
451 const bool lockdown_by_fsp = get_lockdown_config() == CHIPSET_LOCKDOWN_FSP;
452 s_cfg->PchLockDownGlobalSmi = lockdown_by_fsp;
453 s_cfg->PchLockDownBiosInterface = lockdown_by_fsp;
454 s_cfg->PchUnlockGpioPads = !lockdown_by_fsp;
455 s_cfg->RtcMemoryLock = lockdown_by_fsp;
456 s_cfg->SkipPamLock = !lockdown_by_fsp;
458 /* coreboot will send EOP before loading payload */
459 s_cfg->EndOfPostMessage = EOP_DISABLE;
462 static void fill_fsps_xhci_params(FSP_S_CONFIG *s_cfg,
463 const struct soc_intel_meteorlake_config *config)
465 int i, max_port;
467 max_port = get_max_usb20_port();
468 for (i = 0; i < max_port; i++) {
469 s_cfg->PortUsb20Enable[i] = config->usb2_ports[i].enable;
470 s_cfg->Usb2PhyPetxiset[i] = config->usb2_ports[i].pre_emp_bias;
471 s_cfg->Usb2PhyTxiset[i] = config->usb2_ports[i].tx_bias;
472 s_cfg->Usb2PhyPredeemp[i] = config->usb2_ports[i].tx_emp_enable;
473 s_cfg->Usb2PhyPehalfbit[i] = config->usb2_ports[i].pre_emp_bit;
475 if (config->usb2_ports[i].enable)
476 s_cfg->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin;
477 else
478 s_cfg->Usb2OverCurrentPin[i] = OC_SKIP;
481 max_port = get_max_usb30_port();
482 for (i = 0; i < max_port; i++) {
483 s_cfg->PortUsb30Enable[i] = config->usb3_ports[i].enable;
484 if (config->usb3_ports[i].enable)
485 s_cfg->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
486 else
487 s_cfg->Usb3OverCurrentPin[i] = OC_SKIP;
489 if (config->usb3_ports[i].tx_de_emp) {
490 s_cfg->Usb3HsioTxDeEmphEnable[i] = 1;
491 s_cfg->Usb3HsioTxDeEmph[i] = config->usb3_ports[i].tx_de_emp;
493 if (config->usb3_ports[i].tx_downscale_amp) {
494 s_cfg->Usb3HsioTxDownscaleAmpEnable[i] = 1;
495 s_cfg->Usb3HsioTxDownscaleAmp[i] =
496 config->usb3_ports[i].tx_downscale_amp;
500 max_port = get_max_tcss_port();
501 for (i = 0; i < max_port; i++) {
502 if (config->tcss_ports[i].enable)
503 s_cfg->CpuUsb3OverCurrentPin[i] = config->tcss_ports[i].ocpin;
507 static void fill_fsps_xdci_params(FSP_S_CONFIG *s_cfg,
508 const struct soc_intel_meteorlake_config *config)
510 s_cfg->XdciEnable = xdci_can_enable(PCI_DEVFN_USBOTG);
513 static void fill_fsps_uart_params(FSP_S_CONFIG *s_cfg,
514 const struct soc_intel_meteorlake_config *config)
516 ASSERT(ARRAY_SIZE(s_cfg->SerialIoUartAutoFlow) > CONFIG_UART_FOR_CONSOLE);
517 s_cfg->SerialIoUartAutoFlow[CONFIG_UART_FOR_CONSOLE] = 0;
520 static void fill_fsps_sata_params(FSP_S_CONFIG *s_cfg,
521 const struct soc_intel_meteorlake_config *config)
523 /* SATA */
524 s_cfg->SataEnable = is_devfn_enabled(PCI_DEVFN_SATA);
525 if (s_cfg->SataEnable) {
526 s_cfg->SataMode = config->sata_mode;
527 s_cfg->SataSalpSupport = config->sata_salp_support;
528 memcpy(s_cfg->SataPortsEnable, config->sata_ports_enable,
529 sizeof(s_cfg->SataPortsEnable));
530 memcpy(s_cfg->SataPortsDevSlp, config->sata_ports_dev_slp,
531 sizeof(s_cfg->SataPortsDevSlp));
535 * Power Optimizer for SATA.
536 * SataPwrOptimizeDisable is default to 0.
537 * Boards not needing the optimizers explicitly disables them by setting
538 * these disable variables to 1 in devicetree overrides.
540 s_cfg->SataPwrOptEnable = !(config->sata_pwr_optimize_disable);
542 * Enable DEVSLP Idle Timeout settings DmVal and DitoVal.
543 * SataPortsDmVal is the DITO multiplier. Default is 15.
544 * SataPortsDitoVal is the DEVSLP Idle Timeout (DITO), Default is 625ms.
545 * The default values can be changed from devicetree.
547 for (size_t i = 0; i < ARRAY_SIZE(config->sata_ports_enable_dito_config); i++) {
548 if (config->sata_ports_enable_dito_config[i]) {
549 s_cfg->SataPortsDmVal[i] = config->sata_ports_dm_val[i];
550 s_cfg->SataPortsDitoVal[i] = config->sata_ports_dito_val[i];
555 static void fill_fsps_thermal_params(FSP_S_CONFIG *s_cfg,
556 const struct soc_intel_meteorlake_config *config)
558 /* Enable TCPU for processor thermal control */
559 s_cfg->Device4Enable = is_devfn_enabled(PCI_DEVFN_DPTF);
561 /* Set TccActivationOffset */
562 s_cfg->TccActivationOffset = config->tcc_offset;
565 static void fill_fsps_lan_params(FSP_S_CONFIG *s_cfg,
566 const struct soc_intel_meteorlake_config *config)
568 /* LAN */
569 s_cfg->PchLanEnable = is_devfn_enabled(PCI_DEVFN_GBE);
572 static void fill_fsps_cnvi_params(FSP_S_CONFIG *s_cfg,
573 const struct soc_intel_meteorlake_config *config)
575 /* CNVi */
576 s_cfg->CnviMode = is_devfn_enabled(PCI_DEVFN_CNVI_WIFI);
577 s_cfg->CnviWifiCore = config->cnvi_wifi_core;
578 s_cfg->CnviBtCore = config->cnvi_bt_core;
579 s_cfg->CnviBtAudioOffload = config->cnvi_bt_audio_offload;
580 if (!s_cfg->CnviMode && s_cfg->CnviWifiCore) {
581 printk(BIOS_ERR, "CNVi WiFi is enabled without CNVi being enabled\n");
582 s_cfg->CnviWifiCore = 0;
584 if (!s_cfg->CnviBtCore && s_cfg->CnviBtAudioOffload) {
585 printk(BIOS_ERR, "BT offload is enabled without CNVi BT being enabled\n");
586 s_cfg->CnviBtAudioOffload = 0;
588 if (!s_cfg->CnviMode && s_cfg->CnviBtCore) {
589 printk(BIOS_ERR, "CNVi BT is enabled without CNVi being enabled\n");
590 s_cfg->CnviBtCore = 0;
591 s_cfg->CnviBtAudioOffload = 0;
595 static void fill_fsps_vmd_params(FSP_S_CONFIG *s_cfg,
596 const struct soc_intel_meteorlake_config *config)
598 /* VMD */
599 s_cfg->VmdEnable = is_devfn_enabled(PCI_DEVFN_VMD);
602 static void fill_fsps_tbt_params(FSP_S_CONFIG *s_cfg,
603 const struct soc_intel_meteorlake_config *config)
605 for (int i = 0; i < ARRAY_SIZE(s_cfg->ITbtPcieRootPortEn); i++)
606 s_cfg->ITbtPcieRootPortEn[i] = is_devfn_enabled(PCI_DEVFN_TBT(i));
609 static void fill_fsps_8254_params(FSP_S_CONFIG *s_cfg,
610 const struct soc_intel_meteorlake_config *config)
612 /* Legacy 8254 timer support */
613 bool use_8254 = get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER));
614 s_cfg->Enable8254ClockGating = !use_8254;
615 s_cfg->Enable8254ClockGatingOnS3 = !use_8254;
618 static void fill_fsps_pm_timer_params(FSP_S_CONFIG *s_cfg,
619 const struct soc_intel_meteorlake_config *config)
622 * Legacy PM ACPI Timer (and TCO Timer)
623 * This *must* be 1 in any case to keep FSP from
624 * 1) enabling PM ACPI Timer emulation in uCode.
625 * 2) disabling the PM ACPI Timer.
626 * We handle both by ourself!
628 s_cfg->EnableTcoTimer = 1;
631 static void fill_fsps_pcie_params(FSP_S_CONFIG *s_cfg,
632 const struct soc_intel_meteorlake_config *config)
634 int max_port = get_max_pcie_port();
635 uint32_t enable_mask = pcie_rp_enable_mask(get_pcie_rp_table());
636 for (int i = 0; i < max_port; i++) {
637 if (!(enable_mask & BIT(i)))
638 continue;
639 const struct pcie_rp_config *rp_cfg = &config->pcie_rp[i];
640 s_cfg->PcieRpL1Substates[i] =
641 get_l1_substate_control(rp_cfg->PcieRpL1Substates);
642 s_cfg->PcieRpLtrEnable[i] = !!(rp_cfg->flags & PCIE_RP_LTR);
643 s_cfg->PcieRpAdvancedErrorReporting[i] = !!(rp_cfg->flags & PCIE_RP_AER);
644 s_cfg->PcieRpHotPlug[i] = !!(rp_cfg->flags & PCIE_RP_HOTPLUG)
645 || CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE);
646 s_cfg->PcieRpClkReqDetect[i] = !!(rp_cfg->flags & PCIE_RP_CLK_REQ_DETECT);
647 if (rp_cfg->pcie_rp_aspm)
648 s_cfg->PcieRpAspm[i] = get_aspm_control(rp_cfg->pcie_rp_aspm);
650 s_cfg->PcieComplianceTestMode = CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE);
653 static void fill_fsps_misc_power_params(FSP_S_CONFIG *s_cfg,
654 const struct soc_intel_meteorlake_config *config)
656 /* Skip setting D0I3 bit for all HECI devices */
657 s_cfg->DisableD0I3SettingForHeci = 1;
659 s_cfg->Hwp = 1;
660 s_cfg->Cx = 1;
661 s_cfg->PsOnEnable = 1;
662 s_cfg->PkgCStateLimit = LIMIT_AUTO;
663 /* Enable the energy efficient turbo mode */
664 s_cfg->EnergyEfficientTurbo = 1;
665 s_cfg->PmcLpmS0ixSubStateEnableMask = get_supported_lpm_mask();
666 /* Un-Demotion from Demoted C1 need to be disable when
667 * C1 auto demotion is disabled */
668 s_cfg->C1StateUnDemotion = !config->disable_c1_state_auto_demotion;
669 s_cfg->C1StateAutoDemotion = !config->disable_c1_state_auto_demotion;
670 s_cfg->PkgCStateDemotion = !config->disable_package_c_state_demotion;
671 s_cfg->PkgCStateUnDemotion = !config->disable_package_c_state_demotion;
672 s_cfg->PmcV1p05PhyExtFetControlEn = 1;
674 /* Enable PCH to CPU energy report feature. */
675 s_cfg->PchPmDisableEnergyReport = !config->pch_pm_energy_report_enable;
679 static void fill_fsps_ufs_params(FSP_S_CONFIG *s_cfg,
680 const struct soc_intel_meteorlake_config *config)
682 s_cfg->UfsEnable[0] = is_devfn_enabled(PCI_DEVFN_UFS);
685 static void fill_fsps_ai_params(FSP_S_CONFIG *s_cfg,
686 const struct soc_intel_meteorlake_config *config)
688 s_cfg->GnaEnable = is_devfn_enabled(PCI_DEVFN_GNA);
689 s_cfg->VpuEnable = is_devfn_enabled(PCI_DEVFN_VPU);
692 static void fill_fsps_irq_params(FSP_S_CONFIG *s_cfg,
693 const struct soc_intel_meteorlake_config *config)
695 if (!assign_pci_irqs(irq_constraints, ARRAY_SIZE(irq_constraints)))
696 die("ERROR: Unable to assign PCI IRQs, and no _PRT table available\n");
698 size_t pch_count = 0;
699 const SI_PCH_DEVICE_INTERRUPT_CONFIG *upd_irqs = pci_irq_to_fsp(&pch_count);
701 s_cfg->DevIntConfigPtr = (UINT32)((uintptr_t)upd_irqs);
702 s_cfg->NumOfDevIntConfig = pch_count;
703 printk(BIOS_INFO, "IRQ: Using dynamically assigned PCI IO-APIC IRQs\n");
706 static void arch_silicon_init_params(FSPS_ARCH_UPD *s_arch_cfg)
709 * EnableMultiPhaseSiliconInit for running MultiPhaseSiInit
711 s_arch_cfg->EnableMultiPhaseSiliconInit = 1;
713 /* Assign FspEventHandler arch Upd to use coreboot debug event handler */
714 if (CONFIG(FSP_USES_CB_DEBUG_EVENT_HANDLER) && CONFIG(CONSOLE_SERIAL) &&
715 CONFIG(FSP_ENABLE_SERIAL_DEBUG))
716 s_arch_cfg->FspEventHandler = (FSP_EVENT_HANDLER)
717 fsp_debug_event_handler;
720 static void evaluate_ssid(const struct device *dev, uint16_t *svid, uint16_t *ssid)
722 if (!(dev && svid && ssid))
723 return;
725 *svid = CONFIG_SUBSYSTEM_VENDOR_ID ? : (dev->subsystem_vendor ? : 0x8086);
726 *ssid = CONFIG_SUBSYSTEM_DEVICE_ID ? : (dev->subsystem_device ? : 0xfffe);
730 * Programming SSID before FSP-S is important because SSID registers of a few PCIE
731 * devices (e.g. IPU, Crashlog, XHCI, TCSS_XHCI etc.) are locked after FSP-S hence
732 * provide a custom SSID (same as DID by default) value via UPD.
734 static void fill_fsps_pci_ssid_params(FSP_S_CONFIG *s_cfg,
735 const struct soc_intel_meteorlake_config *config)
737 struct svid_ssid_init_entry {
738 union {
739 struct {
740 uint64_t reg:12;
741 uint64_t function:3;
742 uint64_t device:5;
743 uint64_t bus:8;
744 uint64_t ignore1:4;
745 uint64_t segment:16;
746 uint64_t ignore2:16;
748 uint64_t data;
750 struct {
751 uint16_t svid;
752 uint16_t ssid;
754 uint32_t ignore3;
757 static struct svid_ssid_init_entry ssid_table[MAX_ONBOARD_PCIE_DEVICES];
758 const struct device *dev;
759 int i = 0;
761 for (dev = all_devices; dev; dev = dev->next) {
762 if (!(is_dev_enabled(dev) && dev->path.type == DEVICE_PATH_PCI &&
763 dev->upstream->secondary == 0))
764 continue;
766 if (dev->path.pci.devfn == PCI_DEVFN_ROOT) {
767 evaluate_ssid(dev, &s_cfg->SiCustomizedSvid, &s_cfg->SiCustomizedSsid);
768 } else {
769 ssid_table[i].reg = PCI_SUBSYSTEM_VENDOR_ID;
770 ssid_table[i].device = PCI_SLOT(dev->path.pci.devfn);
771 ssid_table[i].function = PCI_FUNC(dev->path.pci.devfn);
772 evaluate_ssid(dev, &ssid_table[i].svid, &ssid_table[i].ssid);
773 i++;
777 s_cfg->SiSsidTablePtr = (uintptr_t)ssid_table;
778 s_cfg->SiNumberOfSsidTableEntry = i;
780 /* Ensure FSP will program the registers */
781 s_cfg->SiSkipSsidProgramming = 0;
784 static void soc_silicon_init_params(FSP_S_CONFIG *s_cfg,
785 struct soc_intel_meteorlake_config *config)
787 /* Override settings per board if required. */
788 mainboard_update_soc_chip_config(config);
790 void (*fill_fsps_params[])(FSP_S_CONFIG *s_cfg,
791 const struct soc_intel_meteorlake_config *config) = {
792 fill_fsps_lpss_params,
793 fill_fsps_cpu_params,
794 fill_fsps_igd_params,
795 fill_fsps_tcss_params,
796 fill_fsps_chipset_lockdown_params,
797 fill_fsps_xhci_params,
798 fill_fsps_xdci_params,
799 fill_fsps_uart_params,
800 fill_fsps_sata_params,
801 fill_fsps_thermal_params,
802 fill_fsps_lan_params,
803 fill_fsps_cnvi_params,
804 fill_fsps_vmd_params,
805 fill_fsps_tbt_params,
806 fill_fsps_8254_params,
807 fill_fsps_pm_timer_params,
808 fill_fsps_pcie_params,
809 fill_fsps_misc_power_params,
810 fill_fsps_ufs_params,
811 fill_fsps_ai_params,
812 fill_fsps_irq_params,
813 fill_fsps_pci_ssid_params,
816 for (size_t i = 0; i < ARRAY_SIZE(fill_fsps_params); i++)
817 fill_fsps_params[i](s_cfg, config);
820 /* UPD parameters to be initialized before SiliconInit */
821 void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
823 struct soc_intel_meteorlake_config *config;
824 FSP_S_CONFIG *s_cfg = &supd->FspsConfig;
825 FSPS_ARCH_UPD *s_arch_cfg = &supd->FspsArchUpd;
827 config = config_of_soc();
828 arch_silicon_init_params(s_arch_cfg);
829 soc_silicon_init_params(s_cfg, config);
830 mainboard_silicon_init_params(s_cfg);
834 * Callbacks for SoC/Mainboard specific overrides for FspMultiPhaseSiInit
835 * This platform supports below MultiPhaseSIInit Phase(s):
836 * Phase | FSP return point | Purpose
837 * ------- + ------------------------------------------------ + -------------------------------
838 * 1 | After TCSS initialization completed | for TCSS specific init
839 * 2 | Before BIOS Reset CPL is set by FSP-S | for CPU specific init
841 void platform_fsp_silicon_multi_phase_init_cb(uint32_t phase_index)
843 switch (phase_index) {
844 case 1:
845 /* TCSS specific initialization here */
846 printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n",
847 __FILE__, __func__);
849 if (CONFIG(SOC_INTEL_COMMON_BLOCK_TCSS)) {
850 const config_t *config = config_of_soc();
851 tcss_configure(config->typec_aux_bias_pads);
853 break;
854 case 2:
855 /* CPU specific initialization here */
856 printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n",
857 __FILE__, __func__);
858 before_post_cpus_init();
859 /* Enable BIOS Reset CPL */
860 enable_bios_reset_cpl();
861 break;
862 default:
863 break;
867 /* Mainboard GPIO Configuration */
868 __weak void mainboard_silicon_init_params(FSP_S_CONFIG *s_cfg)
870 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
873 /* Handle FSP logo params */
874 void soc_load_logo(FSPS_UPD *supd)
876 fsp_convert_bmp_to_gop_blt(&supd->FspsConfig.LogoPtr,
877 &supd->FspsConfig.LogoSize,
878 &supd->FspsConfig.BltBufferAddress,
879 &supd->FspsConfig.BltBufferSize,
880 &supd->FspsConfig.LogoPixelHeight,
881 &supd->FspsConfig.LogoPixelWidth);