Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <assert.h> |
Subrata Banik | e4f0df7 | 2023-05-15 17:22:39 +0530 | [diff] [blame] | 4 | #include <bootsplash.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 5 | #include <cbfs.h> |
| 6 | #include <console/console.h> |
| 7 | #include <cpu/intel/cpu_ids.h> |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 8 | #include <cpu/intel/microcode.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 9 | #include <device/device.h> |
| 10 | #include <device/pci.h> |
| 11 | #include <fsp/api.h> |
Subrata Banik | e88bee7 | 2022-06-27 16:51:44 +0530 | [diff] [blame] | 12 | #include <fsp/fsp_debug_event.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 13 | #include <fsp/ppi/mp_service_ppi.h> |
| 14 | #include <fsp/util.h> |
Dinesh Gehlot | e7c1f7d | 2022-12-06 10:58:48 +0000 | [diff] [blame] | 15 | #include <option.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 16 | #include <intelblocks/cse.h> |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 17 | #include <intelblocks/irq.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 18 | #include <intelblocks/lpss.h> |
Subrata Banik | f251a6a | 2022-12-11 16:39:05 +0530 | [diff] [blame] | 19 | #include <intelblocks/mp_init.h> |
| 20 | #include <intelblocks/systemagent.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 21 | #include <intelblocks/xdci.h> |
| 22 | #include <intelpch/lockdown.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 23 | #include <security/vboot/vboot_common.h> |
John Zhao | 54a03e4 | 2022-08-03 20:07:03 -0700 | [diff] [blame] | 24 | #include <soc/cpu.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 25 | #include <soc/gpio_soc_defs.h> |
| 26 | #include <soc/intel/common/vbt.h> |
| 27 | #include <soc/pci_devs.h> |
| 28 | #include <soc/pcie.h> |
| 29 | #include <soc/ramstage.h> |
| 30 | #include <soc/soc_chip.h> |
| 31 | #include <soc/soc_info.h> |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 32 | #include <stdlib.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 33 | #include <string.h> |
Dinesh Gehlot | e7c1f7d | 2022-12-06 10:58:48 +0000 | [diff] [blame] | 34 | #include <types.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 35 | |
| 36 | /* THC assignment definition */ |
| 37 | #define THC_NONE 0 |
| 38 | #define THC_0 1 |
| 39 | #define THC_1 2 |
| 40 | |
| 41 | /* SATA DEVSLP idle timeout default values */ |
| 42 | #define DEF_DMVAL 15 |
| 43 | #define DEF_DITOVAL 625 |
| 44 | |
Kapil Porwal | fbe0442 | 2023-01-04 00:54:42 +0530 | [diff] [blame] | 45 | #define MAX_ONBOARD_PCIE_DEVICES 256 |
| 46 | |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 47 | static const struct slot_irq_constraints irq_constraints[] = { |
| 48 | { |
| 49 | .slot = PCI_DEV_SLOT_PCIE_3, |
| 50 | .fns = { |
| 51 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE12, PCI_INT_A, PIRQ_A), |
| 52 | }, |
| 53 | }, |
| 54 | { |
| 55 | .slot = PCI_DEV_SLOT_IGD, |
| 56 | .fns = { |
| 57 | /* INTERRUPT_PIN is RO/0x01 */ |
| 58 | FIXED_INT_ANY_PIRQ(PCI_DEV_SLOT_IGD, PCI_INT_A), |
| 59 | }, |
| 60 | }, |
| 61 | { |
| 62 | .slot = PCI_DEV_SLOT_DPTF, |
| 63 | .fns = { |
| 64 | ANY_PIRQ(PCI_DEVFN_DPTF), |
| 65 | }, |
| 66 | }, |
| 67 | { |
| 68 | .slot = PCI_DEV_SLOT_IPU, |
| 69 | .fns = { |
| 70 | /* INTERRUPT_PIN is RO/0x01, and INTERRUPT_LINE is RW, |
| 71 | but S0ix fails when not set to 16 (b/193434192) */ |
| 72 | FIXED_INT_PIRQ(PCI_DEVFN_IPU, PCI_INT_A, PIRQ_A), |
| 73 | }, |
| 74 | }, |
| 75 | { |
| 76 | .slot = PCI_DEV_SLOT_PCIE_2, |
| 77 | .fns = { |
| 78 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE9, PCI_INT_A, PIRQ_A), |
| 79 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE10, PCI_INT_B, PIRQ_B), |
| 80 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE11, PCI_INT_C, PIRQ_C), |
| 81 | }, |
| 82 | }, |
| 83 | { |
| 84 | .slot = PCI_DEV_SLOT_TBT, |
| 85 | .fns = { |
| 86 | ANY_PIRQ(PCI_DEVFN_TBT0), |
| 87 | ANY_PIRQ(PCI_DEVFN_TBT1), |
| 88 | ANY_PIRQ(PCI_DEVFN_TBT2), |
| 89 | ANY_PIRQ(PCI_DEVFN_TBT3), |
| 90 | }, |
| 91 | }, |
| 92 | { |
| 93 | .slot = PCI_DEV_SLOT_GNA, |
| 94 | .fns = { |
| 95 | /* INTERRUPT_PIN is RO/0x01 */ |
| 96 | FIXED_INT_ANY_PIRQ(PCI_DEVFN_GNA, PCI_INT_A), |
| 97 | }, |
| 98 | }, |
| 99 | { |
| 100 | .slot = PCI_DEV_SLOT_VPU, |
| 101 | .fns = { |
| 102 | /* INTERRUPT_PIN is RO/0x01 */ |
| 103 | FIXED_INT_ANY_PIRQ(PCI_DEVFN_VPU, PCI_INT_A), |
| 104 | }, |
| 105 | }, |
| 106 | { |
| 107 | .slot = PCI_DEV_SLOT_TCSS, |
| 108 | .fns = { |
| 109 | ANY_PIRQ(PCI_DEVFN_TCSS_XHCI), |
| 110 | ANY_PIRQ(PCI_DEVFN_TCSS_XDCI), |
| 111 | }, |
| 112 | }, |
| 113 | { |
| 114 | .slot = PCI_DEV_SLOT_THC, |
| 115 | .fns = { |
| 116 | ANY_PIRQ(PCI_DEVFN_THC0), |
| 117 | ANY_PIRQ(PCI_DEVFN_THC1), |
| 118 | }, |
| 119 | }, |
| 120 | { |
| 121 | .slot = PCI_DEV_SLOT_ISH, |
| 122 | .fns = { |
| 123 | DIRECT_IRQ(PCI_DEVFN_ISH), |
| 124 | DIRECT_IRQ(PCI_DEVFN_GSPI2), |
| 125 | ANY_PIRQ(PCI_DEVFN_UFS), |
| 126 | }, |
| 127 | }, |
| 128 | { |
| 129 | .slot = PCI_DEV_SLOT_XHCI, |
| 130 | .fns = { |
| 131 | ANY_PIRQ(PCI_DEVFN_XHCI), |
| 132 | DIRECT_IRQ(PCI_DEVFN_USBOTG), |
| 133 | ANY_PIRQ(PCI_DEVFN_CNVI_WIFI), |
| 134 | }, |
| 135 | }, |
| 136 | { |
| 137 | .slot = PCI_DEV_SLOT_SIO0, |
| 138 | .fns = { |
| 139 | DIRECT_IRQ(PCI_DEVFN_I2C0), |
| 140 | DIRECT_IRQ(PCI_DEVFN_I2C1), |
| 141 | DIRECT_IRQ(PCI_DEVFN_I2C2), |
| 142 | DIRECT_IRQ(PCI_DEVFN_I2C3), |
| 143 | }, |
| 144 | }, |
| 145 | { |
| 146 | .slot = PCI_DEV_SLOT_CSE, |
| 147 | .fns = { |
| 148 | ANY_PIRQ(PCI_DEVFN_CSE), |
| 149 | ANY_PIRQ(PCI_DEVFN_CSE_2), |
| 150 | ANY_PIRQ(PCI_DEVFN_CSE_IDER), |
| 151 | ANY_PIRQ(PCI_DEVFN_CSE_KT), |
| 152 | ANY_PIRQ(PCI_DEVFN_CSE_3), |
| 153 | ANY_PIRQ(PCI_DEVFN_CSE_4), |
| 154 | }, |
| 155 | }, |
| 156 | { |
| 157 | .slot = PCI_DEV_SLOT_SATA, |
| 158 | .fns = { |
| 159 | ANY_PIRQ(PCI_DEVFN_SATA), |
| 160 | }, |
| 161 | }, |
| 162 | { |
| 163 | .slot = PCI_DEV_SLOT_SIO1, |
| 164 | .fns = { |
| 165 | DIRECT_IRQ(PCI_DEVFN_I2C4), |
| 166 | DIRECT_IRQ(PCI_DEVFN_I2C5), |
| 167 | DIRECT_IRQ(PCI_DEVFN_UART2), |
| 168 | }, |
| 169 | }, |
| 170 | { |
| 171 | .slot = PCI_DEV_SLOT_PCIE_1, |
| 172 | .fns = { |
| 173 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE1, PCI_INT_A, PIRQ_A), |
| 174 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE2, PCI_INT_B, PIRQ_B), |
| 175 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE3, PCI_INT_C, PIRQ_C), |
| 176 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE4, PCI_INT_D, PIRQ_D), |
| 177 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE5, PCI_INT_A, PIRQ_A), |
| 178 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE6, PCI_INT_B, PIRQ_B), |
| 179 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE7, PCI_INT_C, PIRQ_C), |
| 180 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE8, PCI_INT_D, PIRQ_D), |
| 181 | }, |
| 182 | }, |
| 183 | { |
| 184 | .slot = PCI_DEV_SLOT_SIO2, |
| 185 | .fns = { |
| 186 | /* UART0 shares an interrupt line with TSN0, so must use |
| 187 | a PIRQ */ |
| 188 | FIXED_INT_ANY_PIRQ(PCI_DEVFN_UART0, PCI_INT_A), |
| 189 | /* UART1 shares an interrupt line with TSN1, so must use |
| 190 | a PIRQ */ |
| 191 | FIXED_INT_ANY_PIRQ(PCI_DEVFN_UART1, PCI_INT_B), |
| 192 | DIRECT_IRQ(PCI_DEVFN_GSPI0), |
| 193 | DIRECT_IRQ(PCI_DEVFN_GSPI1), |
| 194 | }, |
| 195 | }, |
| 196 | { |
| 197 | .slot = PCI_DEV_SLOT_ESPI, |
| 198 | .fns = { |
| 199 | ANY_PIRQ(PCI_DEVFN_HDA), |
| 200 | ANY_PIRQ(PCI_DEVFN_SMBUS), |
| 201 | ANY_PIRQ(PCI_DEVFN_GBE), |
| 202 | /* INTERRUPT_PIN is RO/0x01 */ |
| 203 | FIXED_INT_ANY_PIRQ(PCI_DEVFN_NPK, PCI_INT_A), |
| 204 | }, |
| 205 | }, |
| 206 | }; |
| 207 | |
| 208 | bool is_pch_slot(unsigned int devfn) |
| 209 | { |
| 210 | if (PCI_SLOT(devfn) >= MIN_PCH_SLOT) |
| 211 | return true; |
| 212 | const struct pcie_rp_group *group; |
| 213 | for (group = get_pcie_rp_table(); group->count; ++group) { |
| 214 | if (PCI_SLOT(devfn) == group->slot) |
| 215 | return true; |
| 216 | } |
| 217 | return false; |
| 218 | } |
| 219 | |
| 220 | static const SI_PCH_DEVICE_INTERRUPT_CONFIG *pci_irq_to_fsp(size_t *out_count) |
| 221 | { |
| 222 | const struct pci_irq_entry *entry = get_cached_pci_irqs(); |
| 223 | SI_PCH_DEVICE_INTERRUPT_CONFIG *config; |
| 224 | size_t pch_total = 0; |
| 225 | size_t cfg_count = 0; |
| 226 | |
| 227 | if (!entry) |
| 228 | return NULL; |
| 229 | |
| 230 | /* Count PCH devices */ |
| 231 | while (entry) { |
| 232 | if (is_pch_slot(entry->devfn)) |
| 233 | ++pch_total; |
| 234 | entry = entry->next; |
| 235 | } |
| 236 | |
| 237 | /* Convert PCH device entries to FSP format */ |
| 238 | config = calloc(pch_total, sizeof(*config)); |
| 239 | entry = get_cached_pci_irqs(); |
| 240 | while (entry) { |
| 241 | if (!is_pch_slot(entry->devfn)) { |
| 242 | entry = entry->next; |
| 243 | continue; |
| 244 | } |
| 245 | |
| 246 | config[cfg_count].Device = PCI_SLOT(entry->devfn); |
| 247 | config[cfg_count].Function = PCI_FUNC(entry->devfn); |
| 248 | config[cfg_count].IntX = (SI_PCH_INT_PIN)entry->pin; |
| 249 | config[cfg_count].Irq = entry->irq; |
| 250 | ++cfg_count; |
| 251 | |
| 252 | entry = entry->next; |
| 253 | } |
| 254 | |
| 255 | *out_count = cfg_count; |
| 256 | |
| 257 | return config; |
| 258 | } |
| 259 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 260 | /* |
| 261 | * ME End of Post configuration |
| 262 | * 0 - Disable EOP. |
| 263 | * 1 - Send in PEI (Applicable for FSP in API mode) |
| 264 | * 2 - Send in DXE (Not applicable for FSP in API mode) |
| 265 | */ |
| 266 | enum fsp_end_of_post { |
| 267 | EOP_DISABLE = 0, |
| 268 | EOP_PEI = 1, |
| 269 | EOP_DXE = 2, |
| 270 | }; |
| 271 | |
| 272 | static const pci_devfn_t i2c_dev[] = { |
| 273 | PCI_DEVFN_I2C0, |
| 274 | PCI_DEVFN_I2C1, |
| 275 | PCI_DEVFN_I2C2, |
| 276 | PCI_DEVFN_I2C3, |
| 277 | PCI_DEVFN_I2C4, |
| 278 | PCI_DEVFN_I2C5, |
| 279 | }; |
| 280 | |
| 281 | static const pci_devfn_t gspi_dev[] = { |
| 282 | PCI_DEVFN_GSPI0, |
| 283 | PCI_DEVFN_GSPI1, |
Angel Pons | c7c746c | 2022-07-16 12:37:38 +0200 | [diff] [blame] | 284 | PCI_DEVFN_GSPI2, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 285 | }; |
| 286 | |
| 287 | static const pci_devfn_t uart_dev[] = { |
| 288 | PCI_DEVFN_UART0, |
| 289 | PCI_DEVFN_UART1, |
| 290 | PCI_DEVFN_UART2 |
| 291 | }; |
| 292 | |
| 293 | /* |
| 294 | * Chip config parameter PcieRpL1Substates uses (UPD value + 1) |
| 295 | * because UPD value of 0 for PcieRpL1Substates means disabled for FSP. |
| 296 | * In order to ensure that mainboard setting does not disable L1 substates |
| 297 | * incorrectly, chip config parameter values are offset by 1 with 0 meaning |
| 298 | * use FSP UPD default. get_l1_substate_control() ensures that the right UPD |
| 299 | * value is set in fsp_params. |
| 300 | * 0: Use FSP UPD default |
| 301 | * 1: Disable L1 substates |
| 302 | * 2: Use L1.1 |
| 303 | * 3: Use L1.2 (FSP UPD default) |
| 304 | */ |
| 305 | static int get_l1_substate_control(enum L1_substates_control ctl) |
| 306 | { |
Subrata Banik | ad6c407 | 2022-12-21 11:41:33 +0530 | [diff] [blame] | 307 | if (CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE)) |
| 308 | ctl = L1_SS_DISABLED; |
| 309 | else if ((ctl > L1_SS_L1_2) || (ctl == L1_SS_FSP_DEFAULT)) |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 310 | ctl = L1_SS_L1_2; |
| 311 | return ctl - 1; |
| 312 | } |
| 313 | |
Dinesh Gehlot | 36b6b05 | 2022-12-12 08:48:14 +0000 | [diff] [blame] | 314 | /* |
| 315 | * get_aspm_control() ensures that the right UPD value is set in fsp_params. |
| 316 | * 0: Disable ASPM |
| 317 | * 1: L0s only |
| 318 | * 2: L1 only |
| 319 | * 3: L0s and L1 |
| 320 | * 4: Auto configuration |
| 321 | */ |
| 322 | static unsigned int get_aspm_control(enum ASPM_control ctl) |
| 323 | { |
| 324 | if (ctl > ASPM_AUTO) |
| 325 | ctl = ASPM_AUTO; |
| 326 | return ctl; |
| 327 | } |
| 328 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 329 | __weak void mainboard_update_soc_chip_config(struct soc_intel_meteorlake_config *config) |
| 330 | { |
| 331 | /* Override settings per board. */ |
| 332 | } |
| 333 | |
| 334 | static void fill_fsps_lpss_params(FSP_S_CONFIG *s_cfg, |
| 335 | const struct soc_intel_meteorlake_config *config) |
| 336 | { |
| 337 | int max_port, i; |
| 338 | |
| 339 | max_port = get_max_i2c_port(); |
| 340 | for (i = 0; i < max_port; i++) { |
| 341 | s_cfg->SerialIoI2cMode[i] = is_devfn_enabled(i2c_dev[i]) ? |
| 342 | config->serial_io_i2c_mode[i] : 0; |
| 343 | } |
| 344 | |
| 345 | max_port = get_max_gspi_port(); |
| 346 | for (i = 0; i < max_port; i++) { |
| 347 | s_cfg->SerialIoSpiCsMode[i] = config->serial_io_gspi_cs_mode[i]; |
| 348 | s_cfg->SerialIoSpiCsState[i] = config->serial_io_gspi_cs_state[i]; |
| 349 | s_cfg->SerialIoSpiMode[i] = is_devfn_enabled(gspi_dev[i]) ? |
| 350 | config->serial_io_gspi_mode[i] : 0; |
| 351 | } |
| 352 | |
| 353 | max_port = get_max_uart_port(); |
| 354 | for (i = 0; i < max_port; i++) { |
| 355 | s_cfg->SerialIoUartMode[i] = is_devfn_enabled(uart_dev[i]) ? |
| 356 | config->serial_io_uart_mode[i] : 0; |
| 357 | } |
| 358 | } |
| 359 | |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 360 | static void fill_fsps_microcode_params(FSP_S_CONFIG *s_cfg, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 361 | const struct soc_intel_meteorlake_config *config) |
| 362 | { |
| 363 | const struct microcode *microcode_file; |
| 364 | size_t microcode_len; |
| 365 | |
| 366 | /* Locate microcode and pass to FSP-S for 2nd microcode loading */ |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 367 | microcode_file = intel_microcode_find(); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 368 | |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 369 | if (microcode_file != NULL) { |
| 370 | microcode_len = get_microcode_size(microcode_file); |
| 371 | if (microcode_len != 0) { |
| 372 | /* Update CPU Microcode patch base address/size */ |
| 373 | s_cfg->MicrocodeRegionBase = (uint32_t)(uintptr_t)microcode_file; |
| 374 | s_cfg->MicrocodeRegionSize = (uint32_t)microcode_len; |
| 375 | } |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 376 | } |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 377 | } |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 378 | |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 379 | static void fill_fsps_cpu_params(FSP_S_CONFIG *s_cfg, |
| 380 | const struct soc_intel_meteorlake_config *config) |
| 381 | { |
Subrata Banik | 848c37d | 2022-12-09 13:38:26 +0530 | [diff] [blame] | 382 | /* |
| 383 | * FIXME: FSP assumes ownership of the APs (Application Processors) |
| 384 | * upon passing `NULL` pointer to the CpuMpPpi FSP-S UPD. |
| 385 | * Hence, pass a valid pointer to the CpuMpPpi UPD unconditionally. |
| 386 | * This would avoid APs from getting hijacked by FSP while coreboot |
| 387 | * decides to set SkipMpInit UPD. |
| 388 | */ |
| 389 | s_cfg->CpuMpPpi = (uintptr_t) mp_fill_ppi_services_data(); |
| 390 | |
| 391 | /* |
| 392 | * Fill `2nd microcode loading FSP UPD` if FSP is running CPU feature |
| 393 | * programming. |
| 394 | */ |
Subrata Banik | a247319 | 2023-02-22 13:03:04 +0000 | [diff] [blame] | 395 | if (CONFIG(USE_FSP_FEATURE_PROGRAM_ON_APS)) |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 396 | fill_fsps_microcode_params(s_cfg, config); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | |
| 400 | static void fill_fsps_igd_params(FSP_S_CONFIG *s_cfg, |
| 401 | const struct soc_intel_meteorlake_config *config) |
| 402 | { |
| 403 | /* Load VBT before devicetree-specific config. */ |
| 404 | s_cfg->GraphicsConfigPtr = (uintptr_t)vbt_get(); |
| 405 | |
| 406 | /* Check if IGD is present and fill Graphics init param accordingly */ |
| 407 | s_cfg->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(PCI_DEVFN_IGD); |
| 408 | s_cfg->LidStatus = CONFIG(RUN_FSP_GOP); |
Subrata Banik | 4cc8a6c | 2022-09-07 09:48:28 -0700 | [diff] [blame] | 409 | s_cfg->PavpEnable = CONFIG(PAVP); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | static void fill_fsps_tcss_params(FSP_S_CONFIG *s_cfg, |
| 413 | const struct soc_intel_meteorlake_config *config) |
| 414 | { |
| 415 | const struct device *tcss_port_arr[] = { |
Eric Lai | 884a70b | 2023-06-16 09:26:18 +0800 | [diff] [blame] | 416 | DEV_PTR(tcss_usb3_port0), |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 417 | DEV_PTR(tcss_usb3_port1), |
| 418 | DEV_PTR(tcss_usb3_port2), |
| 419 | DEV_PTR(tcss_usb3_port3), |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 420 | }; |
| 421 | |
| 422 | s_cfg->TcssAuxOri = config->tcss_aux_ori; |
| 423 | |
| 424 | /* Explicitly clear this field to avoid using defaults */ |
| 425 | memset(s_cfg->IomTypeCPortPadCfg, 0, sizeof(s_cfg->IomTypeCPortPadCfg)); |
| 426 | |
| 427 | /* D3Hot and D3Cold for TCSS */ |
| 428 | s_cfg->D3HotEnable = !config->tcss_d3_hot_disable; |
Sean Rhodes | 2dcb2e2 | 2023-04-17 20:37:46 +0100 | [diff] [blame] | 429 | s_cfg->D3ColdEnable = CONFIG(D3COLD_SUPPORT); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 430 | s_cfg->UsbTcPortEn = 0; |
| 431 | |
| 432 | for (int i = 0; i < MAX_TYPE_C_PORTS; i++) { |
| 433 | if (is_dev_enabled(tcss_port_arr[i])) |
| 434 | s_cfg->UsbTcPortEn |= BIT(i); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | static void fill_fsps_chipset_lockdown_params(FSP_S_CONFIG *s_cfg, |
| 439 | const struct soc_intel_meteorlake_config *config) |
| 440 | { |
| 441 | /* Chipset Lockdown */ |
| 442 | const bool lockdown_by_fsp = get_lockdown_config() == CHIPSET_LOCKDOWN_FSP; |
| 443 | s_cfg->PchLockDownGlobalSmi = lockdown_by_fsp; |
| 444 | s_cfg->PchLockDownBiosInterface = lockdown_by_fsp; |
| 445 | s_cfg->PchUnlockGpioPads = !lockdown_by_fsp; |
| 446 | s_cfg->RtcMemoryLock = lockdown_by_fsp; |
| 447 | s_cfg->SkipPamLock = !lockdown_by_fsp; |
| 448 | |
| 449 | /* coreboot will send EOP before loading payload */ |
| 450 | s_cfg->EndOfPostMessage = EOP_DISABLE; |
| 451 | } |
| 452 | |
| 453 | static void fill_fsps_xhci_params(FSP_S_CONFIG *s_cfg, |
| 454 | const struct soc_intel_meteorlake_config *config) |
| 455 | { |
| 456 | int i, max_port; |
| 457 | |
| 458 | max_port = get_max_usb20_port(); |
| 459 | for (i = 0; i < max_port; i++) { |
| 460 | s_cfg->PortUsb20Enable[i] = config->usb2_ports[i].enable; |
| 461 | s_cfg->Usb2PhyPetxiset[i] = config->usb2_ports[i].pre_emp_bias; |
| 462 | s_cfg->Usb2PhyTxiset[i] = config->usb2_ports[i].tx_bias; |
| 463 | s_cfg->Usb2PhyPredeemp[i] = config->usb2_ports[i].tx_emp_enable; |
| 464 | s_cfg->Usb2PhyPehalfbit[i] = config->usb2_ports[i].pre_emp_bit; |
| 465 | |
| 466 | if (config->usb2_ports[i].enable) |
| 467 | s_cfg->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin; |
| 468 | else |
| 469 | s_cfg->Usb2OverCurrentPin[i] = OC_SKIP; |
| 470 | } |
| 471 | |
| 472 | max_port = get_max_usb30_port(); |
| 473 | for (i = 0; i < max_port; i++) { |
| 474 | s_cfg->PortUsb30Enable[i] = config->usb3_ports[i].enable; |
| 475 | if (config->usb3_ports[i].enable) |
| 476 | s_cfg->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin; |
| 477 | else |
| 478 | s_cfg->Usb3OverCurrentPin[i] = OC_SKIP; |
| 479 | |
| 480 | if (config->usb3_ports[i].tx_de_emp) { |
| 481 | s_cfg->Usb3HsioTxDeEmphEnable[i] = 1; |
| 482 | s_cfg->Usb3HsioTxDeEmph[i] = config->usb3_ports[i].tx_de_emp; |
| 483 | } |
| 484 | if (config->usb3_ports[i].tx_downscale_amp) { |
| 485 | s_cfg->Usb3HsioTxDownscaleAmpEnable[i] = 1; |
| 486 | s_cfg->Usb3HsioTxDownscaleAmp[i] = |
| 487 | config->usb3_ports[i].tx_downscale_amp; |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | max_port = get_max_tcss_port(); |
| 492 | for (i = 0; i < max_port; i++) { |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 493 | if (config->tcss_ports[i].enable) |
| 494 | s_cfg->CpuUsb3OverCurrentPin[i] = config->tcss_ports[i].ocpin; |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | static void fill_fsps_xdci_params(FSP_S_CONFIG *s_cfg, |
| 499 | const struct soc_intel_meteorlake_config *config) |
| 500 | { |
| 501 | s_cfg->XdciEnable = xdci_can_enable(PCI_DEVFN_USBOTG); |
| 502 | } |
| 503 | |
Subrata Banik | e88bee7 | 2022-06-27 16:51:44 +0530 | [diff] [blame] | 504 | static void fill_fsps_uart_params(FSP_S_CONFIG *s_cfg, |
| 505 | const struct soc_intel_meteorlake_config *config) |
| 506 | { |
Subrata Banik | e88bee7 | 2022-06-27 16:51:44 +0530 | [diff] [blame] | 507 | ASSERT(ARRAY_SIZE(s_cfg->SerialIoUartAutoFlow) > CONFIG_UART_FOR_CONSOLE); |
| 508 | s_cfg->SerialIoUartAutoFlow[CONFIG_UART_FOR_CONSOLE] = 0; |
| 509 | } |
| 510 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 511 | static void fill_fsps_sata_params(FSP_S_CONFIG *s_cfg, |
| 512 | const struct soc_intel_meteorlake_config *config) |
| 513 | { |
| 514 | /* SATA */ |
| 515 | s_cfg->SataEnable = is_devfn_enabled(PCI_DEVFN_SATA); |
| 516 | if (s_cfg->SataEnable) { |
| 517 | s_cfg->SataMode = config->sata_mode; |
| 518 | s_cfg->SataSalpSupport = config->sata_salp_support; |
| 519 | memcpy(s_cfg->SataPortsEnable, config->sata_ports_enable, |
| 520 | sizeof(s_cfg->SataPortsEnable)); |
| 521 | memcpy(s_cfg->SataPortsDevSlp, config->sata_ports_dev_slp, |
| 522 | sizeof(s_cfg->SataPortsDevSlp)); |
| 523 | } |
| 524 | |
| 525 | /* |
| 526 | * Power Optimizer for SATA. |
| 527 | * SataPwrOptimizeDisable is default to 0. |
| 528 | * Boards not needing the optimizers explicitly disables them by setting |
| 529 | * these disable variables to 1 in devicetree overrides. |
| 530 | */ |
| 531 | s_cfg->SataPwrOptEnable = !(config->sata_pwr_optimize_disable); |
| 532 | /* |
| 533 | * Enable DEVSLP Idle Timeout settings DmVal and DitoVal. |
| 534 | * SataPortsDmVal is the DITO multiplier. Default is 15. |
| 535 | * SataPortsDitoVal is the DEVSLP Idle Timeout (DITO), Default is 625ms. |
| 536 | * The default values can be changed from devicetree. |
| 537 | */ |
| 538 | for (size_t i = 0; i < ARRAY_SIZE(config->sata_ports_enable_dito_config); i++) { |
| 539 | if (config->sata_ports_enable_dito_config[i]) { |
| 540 | s_cfg->SataPortsDmVal[i] = config->sata_ports_dm_val[i]; |
| 541 | s_cfg->SataPortsDitoVal[i] = config->sata_ports_dito_val[i]; |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | static void fill_fsps_thermal_params(FSP_S_CONFIG *s_cfg, |
| 547 | const struct soc_intel_meteorlake_config *config) |
| 548 | { |
| 549 | /* Enable TCPU for processor thermal control */ |
| 550 | s_cfg->Device4Enable = is_devfn_enabled(PCI_DEVFN_DPTF); |
| 551 | |
| 552 | /* Set TccActivationOffset */ |
| 553 | s_cfg->TccActivationOffset = config->tcc_offset; |
| 554 | } |
| 555 | |
| 556 | static void fill_fsps_lan_params(FSP_S_CONFIG *s_cfg, |
| 557 | const struct soc_intel_meteorlake_config *config) |
| 558 | { |
| 559 | /* LAN */ |
| 560 | s_cfg->PchLanEnable = is_devfn_enabled(PCI_DEVFN_GBE); |
| 561 | } |
| 562 | |
| 563 | static void fill_fsps_cnvi_params(FSP_S_CONFIG *s_cfg, |
| 564 | const struct soc_intel_meteorlake_config *config) |
| 565 | { |
| 566 | /* CNVi */ |
| 567 | s_cfg->CnviMode = is_devfn_enabled(PCI_DEVFN_CNVI_WIFI); |
Kapil Porwal | 78cc76d | 2023-04-12 10:30:48 +0530 | [diff] [blame] | 568 | s_cfg->CnviWifiCore = config->cnvi_wifi_core; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 569 | s_cfg->CnviBtCore = config->cnvi_bt_core; |
| 570 | s_cfg->CnviBtAudioOffload = config->cnvi_bt_audio_offload; |
Kapil Porwal | 4e498e1 | 2023-04-12 16:16:36 +0530 | [diff] [blame] | 571 | if (!s_cfg->CnviMode && s_cfg->CnviWifiCore) { |
| 572 | printk(BIOS_ERR, "CNVi WiFi is enabled without CNVi being enabled\n"); |
| 573 | s_cfg->CnviWifiCore = 0; |
| 574 | } |
| 575 | if (!s_cfg->CnviBtCore && s_cfg->CnviBtAudioOffload) { |
| 576 | printk(BIOS_ERR, "BT offload is enabled without CNVi BT being enabled\n"); |
| 577 | s_cfg->CnviBtAudioOffload = 0; |
| 578 | } |
| 579 | if (!s_cfg->CnviMode && s_cfg->CnviBtCore) { |
| 580 | printk(BIOS_ERR, "CNVi BT is enabled without CNVi being enabled\n"); |
| 581 | s_cfg->CnviBtCore = 0; |
| 582 | s_cfg->CnviBtAudioOffload = 0; |
| 583 | } |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | static void fill_fsps_vmd_params(FSP_S_CONFIG *s_cfg, |
| 587 | const struct soc_intel_meteorlake_config *config) |
| 588 | { |
| 589 | /* VMD */ |
| 590 | s_cfg->VmdEnable = is_devfn_enabled(PCI_DEVFN_VMD); |
| 591 | } |
| 592 | |
| 593 | static void fill_fsps_tbt_params(FSP_S_CONFIG *s_cfg, |
| 594 | const struct soc_intel_meteorlake_config *config) |
| 595 | { |
Sridhar Siricilla | cb4d464 | 2022-09-26 12:12:20 +0530 | [diff] [blame] | 596 | for (int i = 0; i < ARRAY_SIZE(s_cfg->ITbtPcieRootPortEn); i++) |
| 597 | s_cfg->ITbtPcieRootPortEn[i] = is_devfn_enabled(PCI_DEVFN_TBT(i)); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | static void fill_fsps_8254_params(FSP_S_CONFIG *s_cfg, |
| 601 | const struct soc_intel_meteorlake_config *config) |
| 602 | { |
| 603 | /* Legacy 8254 timer support */ |
Dinesh Gehlot | e7c1f7d | 2022-12-06 10:58:48 +0000 | [diff] [blame] | 604 | bool use_8254 = get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER)); |
| 605 | s_cfg->Enable8254ClockGating = !use_8254; |
| 606 | s_cfg->Enable8254ClockGatingOnS3 = !use_8254; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 607 | } |
| 608 | |
Kapil Porwal | 89ea312 | 2022-11-15 19:06:49 +0530 | [diff] [blame] | 609 | static void fill_fsps_pm_timer_params(FSP_S_CONFIG *s_cfg, |
| 610 | const struct soc_intel_meteorlake_config *config) |
| 611 | { |
| 612 | /* |
| 613 | * Legacy PM ACPI Timer (and TCO Timer) |
| 614 | * This *must* be 1 in any case to keep FSP from |
| 615 | * 1) enabling PM ACPI Timer emulation in uCode. |
| 616 | * 2) disabling the PM ACPI Timer. |
| 617 | * We handle both by ourself! |
| 618 | */ |
| 619 | s_cfg->EnableTcoTimer = 1; |
| 620 | } |
| 621 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 622 | static void fill_fsps_pcie_params(FSP_S_CONFIG *s_cfg, |
| 623 | const struct soc_intel_meteorlake_config *config) |
| 624 | { |
| 625 | int max_port = get_max_pcie_port(); |
| 626 | uint32_t enable_mask = pcie_rp_enable_mask(get_pcie_rp_table()); |
| 627 | for (int i = 0; i < max_port; i++) { |
| 628 | if (!(enable_mask & BIT(i))) |
| 629 | continue; |
| 630 | const struct pcie_rp_config *rp_cfg = &config->pcie_rp[i]; |
| 631 | s_cfg->PcieRpL1Substates[i] = |
| 632 | get_l1_substate_control(rp_cfg->PcieRpL1Substates); |
| 633 | s_cfg->PcieRpLtrEnable[i] = !!(rp_cfg->flags & PCIE_RP_LTR); |
| 634 | s_cfg->PcieRpAdvancedErrorReporting[i] = !!(rp_cfg->flags & PCIE_RP_AER); |
Subrata Banik | c0f4b12 | 2022-12-06 14:03:07 +0530 | [diff] [blame] | 635 | s_cfg->PcieRpHotPlug[i] = !!(rp_cfg->flags & PCIE_RP_HOTPLUG) |
| 636 | || CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 637 | s_cfg->PcieRpClkReqDetect[i] = !!(rp_cfg->flags & PCIE_RP_CLK_REQ_DETECT); |
Dinesh Gehlot | 36b6b05 | 2022-12-12 08:48:14 +0000 | [diff] [blame] | 638 | if (rp_cfg->pcie_rp_aspm) |
| 639 | s_cfg->PcieRpAspm[i] = get_aspm_control(rp_cfg->pcie_rp_aspm); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 640 | } |
Subrata Banik | c0f4b12 | 2022-12-06 14:03:07 +0530 | [diff] [blame] | 641 | s_cfg->PcieComplianceTestMode = CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | static void fill_fsps_misc_power_params(FSP_S_CONFIG *s_cfg, |
| 645 | const struct soc_intel_meteorlake_config *config) |
| 646 | { |
Kapil Porwal | 66e44e3 | 2022-11-16 10:19:17 +0530 | [diff] [blame] | 647 | /* Skip setting D0I3 bit for all HECI devices */ |
| 648 | s_cfg->DisableD0I3SettingForHeci = 1; |
| 649 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 650 | s_cfg->Hwp = 1; |
| 651 | s_cfg->Cx = 1; |
| 652 | s_cfg->PsOnEnable = 1; |
Kapil Porwal | ae5ba37 | 2023-01-04 21:49:36 +0530 | [diff] [blame] | 653 | s_cfg->PkgCStateLimit = LIMIT_AUTO; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 654 | /* Enable the energy efficient turbo mode */ |
| 655 | s_cfg->EnergyEfficientTurbo = 1; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 656 | s_cfg->PmcLpmS0ixSubStateEnableMask = get_supported_lpm_mask(); |
Sukumar Ghorai | bab976b | 2023-07-31 03:09:40 -0700 | [diff] [blame^] | 657 | /* Un-Demotion from Demoted C1 need to be disable when |
| 658 | * C1 auto demotion is disabled */ |
| 659 | s_cfg->C1StateUnDemotion = !config->disable_c1_state_auto_demotion; |
| 660 | s_cfg->C1StateAutoDemotion = !config->disable_c1_state_auto_demotion; |
Kapil Porwal | ae5bc43 | 2023-01-04 22:03:02 +0530 | [diff] [blame] | 661 | s_cfg->PkgCStateDemotion = !config->disable_package_c_state_demotion; |
Subrata Banik | 794137e | 2023-02-01 17:19:50 +0530 | [diff] [blame] | 662 | s_cfg->PmcV1p05PhyExtFetControlEn = 1; |
Yong Zhi | 309d5a5 | 2023-02-14 17:25:17 -0600 | [diff] [blame] | 663 | |
| 664 | /* Enable PCH to CPU energy report feature. */ |
| 665 | s_cfg->PchPmDisableEnergyReport = !config->pch_pm_energy_report_enable; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | |
| 669 | static void fill_fsps_ufs_params(FSP_S_CONFIG *s_cfg, |
| 670 | const struct soc_intel_meteorlake_config *config) |
| 671 | { |
| 672 | s_cfg->UfsEnable[0] = is_devfn_enabled(PCI_DEVFN_UFS); |
| 673 | } |
| 674 | |
| 675 | static void fill_fsps_ai_params(FSP_S_CONFIG *s_cfg, |
| 676 | const struct soc_intel_meteorlake_config *config) |
| 677 | { |
| 678 | s_cfg->GnaEnable = is_devfn_enabled(PCI_DEVFN_GNA); |
Srinidhi N Kaushik | 9f6e25d | 2022-08-08 20:38:19 -0700 | [diff] [blame] | 679 | s_cfg->VpuEnable = is_devfn_enabled(PCI_DEVFN_VPU); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 680 | } |
| 681 | |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 682 | static void fill_fsps_irq_params(FSP_S_CONFIG *s_cfg, |
| 683 | const struct soc_intel_meteorlake_config *config) |
| 684 | { |
| 685 | if (!assign_pci_irqs(irq_constraints, ARRAY_SIZE(irq_constraints))) |
| 686 | die("ERROR: Unable to assign PCI IRQs, and no _PRT table available\n"); |
| 687 | |
| 688 | size_t pch_count = 0; |
| 689 | const SI_PCH_DEVICE_INTERRUPT_CONFIG *upd_irqs = pci_irq_to_fsp(&pch_count); |
| 690 | |
| 691 | s_cfg->DevIntConfigPtr = (UINT32)((uintptr_t)upd_irqs); |
| 692 | s_cfg->NumOfDevIntConfig = pch_count; |
| 693 | printk(BIOS_INFO, "IRQ: Using dynamically assigned PCI IO-APIC IRQs\n"); |
| 694 | } |
| 695 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 696 | static void arch_silicon_init_params(FSPS_ARCH_UPD *s_arch_cfg) |
| 697 | { |
zhaojohn | 9f5fea9 | 2022-09-20 08:12:47 -0700 | [diff] [blame] | 698 | /* |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 699 | * EnableMultiPhaseSiliconInit for running MultiPhaseSiInit |
| 700 | */ |
zhaojohn | 9f5fea9 | 2022-09-20 08:12:47 -0700 | [diff] [blame] | 701 | s_arch_cfg->EnableMultiPhaseSiliconInit = 1; |
Srinidhi N Kaushik | 9a69002 | 2022-07-25 22:12:34 -0700 | [diff] [blame] | 702 | |
| 703 | /* Assign FspEventHandler arch Upd to use coreboot debug event handler */ |
| 704 | if (CONFIG(FSP_USES_CB_DEBUG_EVENT_HANDLER) && CONFIG(CONSOLE_SERIAL) && |
| 705 | CONFIG(FSP_ENABLE_SERIAL_DEBUG)) |
| 706 | s_arch_cfg->FspEventHandler = (FSP_EVENT_HANDLER) |
| 707 | fsp_debug_event_handler; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 708 | } |
| 709 | |
Kapil Porwal | fbe0442 | 2023-01-04 00:54:42 +0530 | [diff] [blame] | 710 | static void evaluate_ssid(const struct device *dev, uint16_t *svid, uint16_t *ssid) |
| 711 | { |
| 712 | if (!(dev && svid && ssid)) |
| 713 | return; |
| 714 | |
| 715 | *svid = CONFIG_SUBSYSTEM_VENDOR_ID ? : (dev->subsystem_vendor ? : 0x8086); |
| 716 | *ssid = CONFIG_SUBSYSTEM_DEVICE_ID ? : (dev->subsystem_device ? : 0xfffe); |
| 717 | } |
| 718 | |
| 719 | /* |
| 720 | * Programming SSID before FSP-S is important because SSID registers of a few PCIE |
| 721 | * devices (e.g. IPU, Crashlog, XHCI, TCSS_XHCI etc.) are locked after FSP-S hence |
| 722 | * provide a custom SSID (same as DID by default) value via UPD. |
| 723 | */ |
| 724 | static void fill_fsps_pci_ssid_params(FSP_S_CONFIG *s_cfg, |
| 725 | const struct soc_intel_meteorlake_config *config) |
| 726 | { |
| 727 | struct svid_ssid_init_entry { |
| 728 | union { |
| 729 | struct { |
| 730 | uint64_t reg:12; |
| 731 | uint64_t function:3; |
| 732 | uint64_t device:5; |
| 733 | uint64_t bus:8; |
| 734 | uint64_t ignore1:4; |
| 735 | uint64_t segment:16; |
| 736 | uint64_t ignore2:16; |
| 737 | }; |
| 738 | uint64_t data; |
| 739 | }; |
| 740 | struct { |
| 741 | uint16_t svid; |
| 742 | uint16_t ssid; |
| 743 | }; |
| 744 | uint32_t ignore3; |
| 745 | }; |
| 746 | |
| 747 | static struct svid_ssid_init_entry ssid_table[MAX_ONBOARD_PCIE_DEVICES]; |
| 748 | const struct device *dev; |
| 749 | int i = 0; |
| 750 | |
| 751 | for (dev = all_devices; dev; dev = dev->next) { |
| 752 | if (!(is_dev_enabled(dev) && dev->path.type == DEVICE_PATH_PCI && |
| 753 | dev->bus->secondary == 0)) |
| 754 | continue; |
| 755 | |
| 756 | if (dev->path.pci.devfn == PCI_DEVFN_ROOT) { |
| 757 | evaluate_ssid(dev, &s_cfg->SiCustomizedSvid, &s_cfg->SiCustomizedSsid); |
| 758 | } else { |
| 759 | ssid_table[i].reg = PCI_SUBSYSTEM_VENDOR_ID; |
| 760 | ssid_table[i].device = PCI_SLOT(dev->path.pci.devfn); |
| 761 | ssid_table[i].function = PCI_FUNC(dev->path.pci.devfn); |
| 762 | evaluate_ssid(dev, &ssid_table[i].svid, &ssid_table[i].ssid); |
| 763 | i++; |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | s_cfg->SiSsidTablePtr = (uintptr_t)ssid_table; |
| 768 | s_cfg->SiNumberOfSsidTableEntry = i; |
| 769 | |
| 770 | /* Ensure FSP will program the registers */ |
| 771 | s_cfg->SiSkipSsidProgramming = 0; |
| 772 | } |
| 773 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 774 | static void soc_silicon_init_params(FSP_S_CONFIG *s_cfg, |
| 775 | struct soc_intel_meteorlake_config *config) |
| 776 | { |
| 777 | /* Override settings per board if required. */ |
| 778 | mainboard_update_soc_chip_config(config); |
| 779 | |
Arthur Heymans | 4081d6c | 2022-07-29 10:45:52 +0200 | [diff] [blame] | 780 | void (*fill_fsps_params[])(FSP_S_CONFIG *s_cfg, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 781 | const struct soc_intel_meteorlake_config *config) = { |
| 782 | fill_fsps_lpss_params, |
| 783 | fill_fsps_cpu_params, |
| 784 | fill_fsps_igd_params, |
| 785 | fill_fsps_tcss_params, |
| 786 | fill_fsps_chipset_lockdown_params, |
| 787 | fill_fsps_xhci_params, |
| 788 | fill_fsps_xdci_params, |
Subrata Banik | e88bee7 | 2022-06-27 16:51:44 +0530 | [diff] [blame] | 789 | fill_fsps_uart_params, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 790 | fill_fsps_sata_params, |
| 791 | fill_fsps_thermal_params, |
| 792 | fill_fsps_lan_params, |
| 793 | fill_fsps_cnvi_params, |
| 794 | fill_fsps_vmd_params, |
| 795 | fill_fsps_tbt_params, |
| 796 | fill_fsps_8254_params, |
Kapil Porwal | 89ea312 | 2022-11-15 19:06:49 +0530 | [diff] [blame] | 797 | fill_fsps_pm_timer_params, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 798 | fill_fsps_pcie_params, |
| 799 | fill_fsps_misc_power_params, |
| 800 | fill_fsps_ufs_params, |
| 801 | fill_fsps_ai_params, |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 802 | fill_fsps_irq_params, |
Kapil Porwal | fbe0442 | 2023-01-04 00:54:42 +0530 | [diff] [blame] | 803 | fill_fsps_pci_ssid_params, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 804 | }; |
| 805 | |
| 806 | for (size_t i = 0; i < ARRAY_SIZE(fill_fsps_params); i++) |
| 807 | fill_fsps_params[i](s_cfg, config); |
| 808 | } |
| 809 | |
| 810 | /* UPD parameters to be initialized before SiliconInit */ |
| 811 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) |
| 812 | { |
| 813 | struct soc_intel_meteorlake_config *config; |
| 814 | FSP_S_CONFIG *s_cfg = &supd->FspsConfig; |
| 815 | FSPS_ARCH_UPD *s_arch_cfg = &supd->FspsArchUpd; |
| 816 | |
| 817 | config = config_of_soc(); |
| 818 | arch_silicon_init_params(s_arch_cfg); |
| 819 | soc_silicon_init_params(s_cfg, config); |
| 820 | mainboard_silicon_init_params(s_cfg); |
| 821 | } |
| 822 | |
| 823 | /* |
| 824 | * Callbacks for SoC/Mainboard specific overrides for FspMultiPhaseSiInit |
| 825 | * This platform supports below MultiPhaseSIInit Phase(s): |
| 826 | * Phase | FSP return point | Purpose |
| 827 | * ------- + ------------------------------------------------ + ------------------------------- |
| 828 | * 1 | After TCSS initialization completed | for TCSS specific init |
Subrata Banik | f251a6a | 2022-12-11 16:39:05 +0530 | [diff] [blame] | 829 | * 2 | Before BIOS Reset CPL is set by FSP-S | for CPU specific init |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 830 | */ |
| 831 | void platform_fsp_multi_phase_init_cb(uint32_t phase_index) |
| 832 | { |
| 833 | switch (phase_index) { |
| 834 | case 1: |
| 835 | /* TCSS specific initialization here */ |
| 836 | printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n", |
| 837 | __FILE__, __func__); |
| 838 | |
| 839 | if (CONFIG(SOC_INTEL_COMMON_BLOCK_TCSS)) { |
| 840 | const config_t *config = config_of_soc(); |
| 841 | tcss_configure(config->typec_aux_bias_pads); |
| 842 | } |
| 843 | break; |
Subrata Banik | f251a6a | 2022-12-11 16:39:05 +0530 | [diff] [blame] | 844 | case 2: |
| 845 | /* CPU specific initialization here */ |
| 846 | printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n", |
| 847 | __FILE__, __func__); |
| 848 | before_post_cpus_init(); |
| 849 | /* Enable BIOS Reset CPL */ |
| 850 | enable_bios_reset_cpl(); |
| 851 | break; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 852 | default: |
| 853 | break; |
| 854 | } |
| 855 | } |
| 856 | |
| 857 | /* Mainboard GPIO Configuration */ |
| 858 | __weak void mainboard_silicon_init_params(FSP_S_CONFIG *s_cfg) |
| 859 | { |
| 860 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 861 | } |
Subrata Banik | e4f0df7 | 2023-05-15 17:22:39 +0530 | [diff] [blame] | 862 | |
| 863 | /* Handle FSP logo params */ |
| 864 | void soc_load_logo(FSPS_UPD *supd) |
| 865 | { |
| 866 | bmp_load_logo(&supd->FspsConfig.LogoPtr, &supd->FspsConfig.LogoSize); |
| 867 | } |