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 | 2527e3f | 2023-09-05 18:51:23 +0000 | [diff] [blame] | 4 | #include <bootmode.h> |
Subrata Banik | e4f0df7 | 2023-05-15 17:22:39 +0530 | [diff] [blame] | 5 | #include <bootsplash.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 6 | #include <cbfs.h> |
| 7 | #include <console/console.h> |
| 8 | #include <cpu/intel/cpu_ids.h> |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 9 | #include <cpu/intel/microcode.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 10 | #include <device/device.h> |
| 11 | #include <device/pci.h> |
| 12 | #include <fsp/api.h> |
Subrata Banik | e88bee7 | 2022-06-27 16:51:44 +0530 | [diff] [blame] | 13 | #include <fsp/fsp_debug_event.h> |
Subrata Banik | 71a2a3d | 2023-08-03 10:26:21 +0000 | [diff] [blame] | 14 | #include <fsp/fsp_gop_blt.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 15 | #include <fsp/ppi/mp_service_ppi.h> |
| 16 | #include <fsp/util.h> |
Dinesh Gehlot | e7c1f7d | 2022-12-06 10:58:48 +0000 | [diff] [blame] | 17 | #include <option.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 18 | #include <intelblocks/cse.h> |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 19 | #include <intelblocks/irq.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 20 | #include <intelblocks/lpss.h> |
Subrata Banik | f251a6a | 2022-12-11 16:39:05 +0530 | [diff] [blame] | 21 | #include <intelblocks/mp_init.h> |
| 22 | #include <intelblocks/systemagent.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 23 | #include <intelblocks/xdci.h> |
| 24 | #include <intelpch/lockdown.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 25 | #include <security/vboot/vboot_common.h> |
John Zhao | 54a03e4 | 2022-08-03 20:07:03 -0700 | [diff] [blame] | 26 | #include <soc/cpu.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 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> |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 34 | #include <stdlib.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 35 | #include <string.h> |
Dinesh Gehlot | e7c1f7d | 2022-12-06 10:58:48 +0000 | [diff] [blame] | 36 | #include <types.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 37 | |
| 38 | /* THC assignment definition */ |
| 39 | #define THC_NONE 0 |
| 40 | #define THC_0 1 |
| 41 | #define THC_1 2 |
| 42 | |
| 43 | /* SATA DEVSLP idle timeout default values */ |
| 44 | #define DEF_DMVAL 15 |
| 45 | #define DEF_DITOVAL 625 |
| 46 | |
Kapil Porwal | fbe0442 | 2023-01-04 00:54:42 +0530 | [diff] [blame] | 47 | #define MAX_ONBOARD_PCIE_DEVICES 256 |
| 48 | |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 49 | static const struct slot_irq_constraints irq_constraints[] = { |
| 50 | { |
| 51 | .slot = PCI_DEV_SLOT_PCIE_3, |
| 52 | .fns = { |
| 53 | FIXED_INT_PIRQ(PCI_DEVFN_PCIE12, PCI_INT_A, PIRQ_A), |
| 54 | }, |
| 55 | }, |
| 56 | { |
| 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), |
| 61 | }, |
| 62 | }, |
| 63 | { |
| 64 | .slot = PCI_DEV_SLOT_DPTF, |
| 65 | .fns = { |
Jeremy Compostella | 47cb8b1 | 2023-10-26 16:02:47 -0700 | [diff] [blame] | 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), |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 69 | }, |
| 70 | }, |
| 71 | { |
| 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), |
| 77 | }, |
| 78 | }, |
| 79 | { |
| 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), |
| 85 | }, |
| 86 | }, |
| 87 | { |
| 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), |
| 94 | }, |
| 95 | }, |
| 96 | { |
| 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), |
| 101 | }, |
| 102 | }, |
| 103 | { |
| 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), |
| 108 | }, |
| 109 | }, |
| 110 | { |
| 111 | .slot = PCI_DEV_SLOT_TCSS, |
| 112 | .fns = { |
| 113 | ANY_PIRQ(PCI_DEVFN_TCSS_XHCI), |
| 114 | ANY_PIRQ(PCI_DEVFN_TCSS_XDCI), |
| 115 | }, |
| 116 | }, |
| 117 | { |
| 118 | .slot = PCI_DEV_SLOT_THC, |
| 119 | .fns = { |
| 120 | ANY_PIRQ(PCI_DEVFN_THC0), |
| 121 | ANY_PIRQ(PCI_DEVFN_THC1), |
| 122 | }, |
| 123 | }, |
| 124 | { |
| 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), |
| 130 | }, |
| 131 | }, |
| 132 | { |
| 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), |
| 138 | }, |
| 139 | }, |
| 140 | { |
| 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), |
| 147 | }, |
| 148 | }, |
| 149 | { |
| 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), |
| 158 | }, |
| 159 | }, |
| 160 | { |
| 161 | .slot = PCI_DEV_SLOT_SATA, |
| 162 | .fns = { |
| 163 | ANY_PIRQ(PCI_DEVFN_SATA), |
| 164 | }, |
| 165 | }, |
| 166 | { |
| 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), |
| 172 | }, |
| 173 | }, |
| 174 | { |
| 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), |
| 185 | }, |
| 186 | }, |
| 187 | { |
| 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), |
| 198 | }, |
| 199 | }, |
| 200 | { |
| 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), |
| 208 | }, |
| 209 | }, |
| 210 | }; |
| 211 | |
| 212 | bool is_pch_slot(unsigned int devfn) |
| 213 | { |
| 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; |
| 220 | } |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | static const SI_PCH_DEVICE_INTERRUPT_CONFIG *pci_irq_to_fsp(size_t *out_count) |
| 225 | { |
| 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; |
| 230 | |
| 231 | if (!entry) |
| 232 | return NULL; |
| 233 | |
| 234 | /* Count PCH devices */ |
| 235 | while (entry) { |
| 236 | if (is_pch_slot(entry->devfn)) |
| 237 | ++pch_total; |
| 238 | entry = entry->next; |
| 239 | } |
| 240 | |
| 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; |
| 248 | } |
| 249 | |
| 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; |
| 255 | |
| 256 | entry = entry->next; |
| 257 | } |
| 258 | |
| 259 | *out_count = cfg_count; |
| 260 | |
| 261 | return config; |
| 262 | } |
| 263 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 264 | /* |
| 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) |
| 269 | */ |
| 270 | enum fsp_end_of_post { |
| 271 | EOP_DISABLE = 0, |
| 272 | EOP_PEI = 1, |
| 273 | EOP_DXE = 2, |
| 274 | }; |
| 275 | |
| 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, |
| 283 | }; |
| 284 | |
| 285 | static const pci_devfn_t gspi_dev[] = { |
| 286 | PCI_DEVFN_GSPI0, |
| 287 | PCI_DEVFN_GSPI1, |
Angel Pons | c7c746c | 2022-07-16 12:37:38 +0200 | [diff] [blame] | 288 | PCI_DEVFN_GSPI2, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 289 | }; |
| 290 | |
| 291 | static const pci_devfn_t uart_dev[] = { |
| 292 | PCI_DEVFN_UART0, |
| 293 | PCI_DEVFN_UART1, |
| 294 | PCI_DEVFN_UART2 |
| 295 | }; |
| 296 | |
| 297 | /* |
| 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) |
| 308 | */ |
| 309 | static int get_l1_substate_control(enum L1_substates_control ctl) |
| 310 | { |
Subrata Banik | ad6c407 | 2022-12-21 11:41:33 +0530 | [diff] [blame] | 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)) |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 314 | ctl = L1_SS_L1_2; |
| 315 | return ctl - 1; |
| 316 | } |
| 317 | |
Dinesh Gehlot | 36b6b05 | 2022-12-12 08:48:14 +0000 | [diff] [blame] | 318 | /* |
Jeremy Soller | d59c799 | 2023-05-16 15:04:08 -0600 | [diff] [blame] | 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. |
Dinesh Gehlot | 36b6b05 | 2022-12-12 08:48:14 +0000 | [diff] [blame] | 323 | * get_aspm_control() ensures that the right UPD value is set in fsp_params. |
Jeremy Soller | d59c799 | 2023-05-16 15:04:08 -0600 | [diff] [blame] | 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 |
Dinesh Gehlot | 36b6b05 | 2022-12-12 08:48:14 +0000 | [diff] [blame] | 330 | */ |
| 331 | static unsigned int get_aspm_control(enum ASPM_control ctl) |
| 332 | { |
Jeremy Soller | d59c799 | 2023-05-16 15:04:08 -0600 | [diff] [blame] | 333 | if ((ctl > ASPM_AUTO) || (ctl == ASPM_DEFAULT)) |
Dinesh Gehlot | 36b6b05 | 2022-12-12 08:48:14 +0000 | [diff] [blame] | 334 | ctl = ASPM_AUTO; |
Jeremy Soller | d59c799 | 2023-05-16 15:04:08 -0600 | [diff] [blame] | 335 | return ctl - 1; |
Dinesh Gehlot | 36b6b05 | 2022-12-12 08:48:14 +0000 | [diff] [blame] | 336 | } |
| 337 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 338 | __weak void mainboard_update_soc_chip_config(struct soc_intel_meteorlake_config *config) |
| 339 | { |
| 340 | /* Override settings per board. */ |
| 341 | } |
| 342 | |
| 343 | static void fill_fsps_lpss_params(FSP_S_CONFIG *s_cfg, |
| 344 | const struct soc_intel_meteorlake_config *config) |
| 345 | { |
| 346 | int max_port, i; |
| 347 | |
| 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; |
| 352 | } |
| 353 | |
| 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; |
| 360 | } |
| 361 | |
| 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; |
| 366 | } |
| 367 | } |
| 368 | |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 369 | static void fill_fsps_microcode_params(FSP_S_CONFIG *s_cfg, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 370 | const struct soc_intel_meteorlake_config *config) |
| 371 | { |
| 372 | const struct microcode *microcode_file; |
| 373 | size_t microcode_len; |
| 374 | |
| 375 | /* Locate microcode and pass to FSP-S for 2nd microcode loading */ |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 376 | microcode_file = intel_microcode_find(); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 377 | |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 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; |
| 384 | } |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 385 | } |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 386 | } |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 387 | |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 388 | static void fill_fsps_cpu_params(FSP_S_CONFIG *s_cfg, |
| 389 | const struct soc_intel_meteorlake_config *config) |
| 390 | { |
Subrata Banik | 848c37d | 2022-12-09 13:38:26 +0530 | [diff] [blame] | 391 | /* |
| 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. |
| 397 | */ |
Elyes Haouas | 244a60e | 2023-09-09 08:51:22 +0200 | [diff] [blame] | 398 | s_cfg->CpuMpPpi = (uintptr_t)mp_fill_ppi_services_data(); |
Subrata Banik | 848c37d | 2022-12-09 13:38:26 +0530 | [diff] [blame] | 399 | |
| 400 | /* |
| 401 | * Fill `2nd microcode loading FSP UPD` if FSP is running CPU feature |
| 402 | * programming. |
| 403 | */ |
Subrata Banik | a247319 | 2023-02-22 13:03:04 +0000 | [diff] [blame] | 404 | if (CONFIG(USE_FSP_FEATURE_PROGRAM_ON_APS)) |
Subrata Banik | 10929ef | 2022-12-09 13:31:47 +0530 | [diff] [blame] | 405 | fill_fsps_microcode_params(s_cfg, config); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | |
| 409 | static void fill_fsps_igd_params(FSP_S_CONFIG *s_cfg, |
| 410 | const struct soc_intel_meteorlake_config *config) |
| 411 | { |
| 412 | /* Load VBT before devicetree-specific config. */ |
| 413 | s_cfg->GraphicsConfigPtr = (uintptr_t)vbt_get(); |
| 414 | |
| 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); |
Subrata Banik | 2527e3f | 2023-09-05 18:51:23 +0000 | [diff] [blame] | 417 | s_cfg->LidStatus = CONFIG(VBOOT_LID_SWITCH) ? get_lid_switch() : CONFIG(RUN_FSP_GOP); |
Subrata Banik | 4cc8a6c | 2022-09-07 09:48:28 -0700 | [diff] [blame] | 418 | s_cfg->PavpEnable = CONFIG(PAVP); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | static void fill_fsps_tcss_params(FSP_S_CONFIG *s_cfg, |
| 422 | const struct soc_intel_meteorlake_config *config) |
| 423 | { |
| 424 | const struct device *tcss_port_arr[] = { |
Eric Lai | 884a70b | 2023-06-16 09:26:18 +0800 | [diff] [blame] | 425 | DEV_PTR(tcss_usb3_port0), |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 426 | DEV_PTR(tcss_usb3_port1), |
| 427 | DEV_PTR(tcss_usb3_port2), |
| 428 | DEV_PTR(tcss_usb3_port3), |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 429 | }; |
| 430 | |
| 431 | s_cfg->TcssAuxOri = config->tcss_aux_ori; |
| 432 | |
| 433 | /* Explicitly clear this field to avoid using defaults */ |
| 434 | memset(s_cfg->IomTypeCPortPadCfg, 0, sizeof(s_cfg->IomTypeCPortPadCfg)); |
| 435 | |
| 436 | /* D3Hot and D3Cold for TCSS */ |
| 437 | s_cfg->D3HotEnable = !config->tcss_d3_hot_disable; |
Sean Rhodes | 2dcb2e2 | 2023-04-17 20:37:46 +0100 | [diff] [blame] | 438 | s_cfg->D3ColdEnable = CONFIG(D3COLD_SUPPORT); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 439 | s_cfg->UsbTcPortEn = 0; |
| 440 | |
| 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); |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | static void fill_fsps_chipset_lockdown_params(FSP_S_CONFIG *s_cfg, |
| 448 | const struct soc_intel_meteorlake_config *config) |
| 449 | { |
| 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; |
| 457 | |
| 458 | /* coreboot will send EOP before loading payload */ |
| 459 | s_cfg->EndOfPostMessage = EOP_DISABLE; |
| 460 | } |
| 461 | |
| 462 | static void fill_fsps_xhci_params(FSP_S_CONFIG *s_cfg, |
| 463 | const struct soc_intel_meteorlake_config *config) |
| 464 | { |
| 465 | int i, max_port; |
| 466 | |
| 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; |
| 474 | |
| 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; |
| 479 | } |
| 480 | |
| 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; |
| 488 | |
| 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; |
| 492 | } |
| 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; |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | max_port = get_max_tcss_port(); |
| 501 | for (i = 0; i < max_port; i++) { |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 502 | if (config->tcss_ports[i].enable) |
| 503 | s_cfg->CpuUsb3OverCurrentPin[i] = config->tcss_ports[i].ocpin; |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | static void fill_fsps_xdci_params(FSP_S_CONFIG *s_cfg, |
| 508 | const struct soc_intel_meteorlake_config *config) |
| 509 | { |
| 510 | s_cfg->XdciEnable = xdci_can_enable(PCI_DEVFN_USBOTG); |
| 511 | } |
| 512 | |
Subrata Banik | e88bee7 | 2022-06-27 16:51:44 +0530 | [diff] [blame] | 513 | static void fill_fsps_uart_params(FSP_S_CONFIG *s_cfg, |
| 514 | const struct soc_intel_meteorlake_config *config) |
| 515 | { |
Subrata Banik | e88bee7 | 2022-06-27 16:51:44 +0530 | [diff] [blame] | 516 | ASSERT(ARRAY_SIZE(s_cfg->SerialIoUartAutoFlow) > CONFIG_UART_FOR_CONSOLE); |
| 517 | s_cfg->SerialIoUartAutoFlow[CONFIG_UART_FOR_CONSOLE] = 0; |
| 518 | } |
| 519 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 520 | static void fill_fsps_sata_params(FSP_S_CONFIG *s_cfg, |
| 521 | const struct soc_intel_meteorlake_config *config) |
| 522 | { |
| 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)); |
| 532 | } |
| 533 | |
| 534 | /* |
| 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. |
| 539 | */ |
| 540 | s_cfg->SataPwrOptEnable = !(config->sata_pwr_optimize_disable); |
| 541 | /* |
| 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. |
| 546 | */ |
| 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]; |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | static void fill_fsps_thermal_params(FSP_S_CONFIG *s_cfg, |
| 556 | const struct soc_intel_meteorlake_config *config) |
| 557 | { |
| 558 | /* Enable TCPU for processor thermal control */ |
| 559 | s_cfg->Device4Enable = is_devfn_enabled(PCI_DEVFN_DPTF); |
| 560 | |
| 561 | /* Set TccActivationOffset */ |
| 562 | s_cfg->TccActivationOffset = config->tcc_offset; |
| 563 | } |
| 564 | |
| 565 | static void fill_fsps_lan_params(FSP_S_CONFIG *s_cfg, |
| 566 | const struct soc_intel_meteorlake_config *config) |
| 567 | { |
| 568 | /* LAN */ |
| 569 | s_cfg->PchLanEnable = is_devfn_enabled(PCI_DEVFN_GBE); |
| 570 | } |
| 571 | |
| 572 | static void fill_fsps_cnvi_params(FSP_S_CONFIG *s_cfg, |
| 573 | const struct soc_intel_meteorlake_config *config) |
| 574 | { |
| 575 | /* CNVi */ |
| 576 | s_cfg->CnviMode = is_devfn_enabled(PCI_DEVFN_CNVI_WIFI); |
Kapil Porwal | 78cc76d | 2023-04-12 10:30:48 +0530 | [diff] [blame] | 577 | s_cfg->CnviWifiCore = config->cnvi_wifi_core; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 578 | s_cfg->CnviBtCore = config->cnvi_bt_core; |
| 579 | s_cfg->CnviBtAudioOffload = config->cnvi_bt_audio_offload; |
Kapil Porwal | 4e498e1 | 2023-04-12 16:16:36 +0530 | [diff] [blame] | 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; |
| 583 | } |
| 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; |
| 587 | } |
| 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; |
| 592 | } |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | static void fill_fsps_vmd_params(FSP_S_CONFIG *s_cfg, |
| 596 | const struct soc_intel_meteorlake_config *config) |
| 597 | { |
| 598 | /* VMD */ |
| 599 | s_cfg->VmdEnable = is_devfn_enabled(PCI_DEVFN_VMD); |
| 600 | } |
| 601 | |
| 602 | static void fill_fsps_tbt_params(FSP_S_CONFIG *s_cfg, |
| 603 | const struct soc_intel_meteorlake_config *config) |
| 604 | { |
Sridhar Siricilla | cb4d464 | 2022-09-26 12:12:20 +0530 | [diff] [blame] | 605 | for (int i = 0; i < ARRAY_SIZE(s_cfg->ITbtPcieRootPortEn); i++) |
| 606 | s_cfg->ITbtPcieRootPortEn[i] = is_devfn_enabled(PCI_DEVFN_TBT(i)); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | static void fill_fsps_8254_params(FSP_S_CONFIG *s_cfg, |
| 610 | const struct soc_intel_meteorlake_config *config) |
| 611 | { |
| 612 | /* Legacy 8254 timer support */ |
Dinesh Gehlot | e7c1f7d | 2022-12-06 10:58:48 +0000 | [diff] [blame] | 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; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 616 | } |
| 617 | |
Kapil Porwal | 89ea312 | 2022-11-15 19:06:49 +0530 | [diff] [blame] | 618 | static void fill_fsps_pm_timer_params(FSP_S_CONFIG *s_cfg, |
| 619 | const struct soc_intel_meteorlake_config *config) |
| 620 | { |
| 621 | /* |
| 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! |
| 627 | */ |
| 628 | s_cfg->EnableTcoTimer = 1; |
| 629 | } |
| 630 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 631 | static void fill_fsps_pcie_params(FSP_S_CONFIG *s_cfg, |
| 632 | const struct soc_intel_meteorlake_config *config) |
| 633 | { |
| 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); |
Subrata Banik | c0f4b12 | 2022-12-06 14:03:07 +0530 | [diff] [blame] | 644 | s_cfg->PcieRpHotPlug[i] = !!(rp_cfg->flags & PCIE_RP_HOTPLUG) |
| 645 | || CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 646 | s_cfg->PcieRpClkReqDetect[i] = !!(rp_cfg->flags & PCIE_RP_CLK_REQ_DETECT); |
Dinesh Gehlot | 36b6b05 | 2022-12-12 08:48:14 +0000 | [diff] [blame] | 647 | if (rp_cfg->pcie_rp_aspm) |
| 648 | s_cfg->PcieRpAspm[i] = get_aspm_control(rp_cfg->pcie_rp_aspm); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 649 | } |
Subrata Banik | c0f4b12 | 2022-12-06 14:03:07 +0530 | [diff] [blame] | 650 | s_cfg->PcieComplianceTestMode = CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | static void fill_fsps_misc_power_params(FSP_S_CONFIG *s_cfg, |
| 654 | const struct soc_intel_meteorlake_config *config) |
| 655 | { |
Kapil Porwal | 66e44e3 | 2022-11-16 10:19:17 +0530 | [diff] [blame] | 656 | /* Skip setting D0I3 bit for all HECI devices */ |
| 657 | s_cfg->DisableD0I3SettingForHeci = 1; |
| 658 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 659 | s_cfg->Hwp = 1; |
| 660 | s_cfg->Cx = 1; |
| 661 | s_cfg->PsOnEnable = 1; |
Kapil Porwal | ae5ba37 | 2023-01-04 21:49:36 +0530 | [diff] [blame] | 662 | s_cfg->PkgCStateLimit = LIMIT_AUTO; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 663 | /* Enable the energy efficient turbo mode */ |
| 664 | s_cfg->EnergyEfficientTurbo = 1; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 665 | s_cfg->PmcLpmS0ixSubStateEnableMask = get_supported_lpm_mask(); |
Sukumar Ghorai | bab976b | 2023-07-31 03:09:40 -0700 | [diff] [blame] | 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; |
Kapil Porwal | ae5bc43 | 2023-01-04 22:03:02 +0530 | [diff] [blame] | 670 | s_cfg->PkgCStateDemotion = !config->disable_package_c_state_demotion; |
Sukumar Ghorai | b7f602a | 2023-10-04 23:37:12 -0700 | [diff] [blame] | 671 | s_cfg->PkgCStateUnDemotion = !config->disable_package_c_state_demotion; |
Subrata Banik | 794137e | 2023-02-01 17:19:50 +0530 | [diff] [blame] | 672 | s_cfg->PmcV1p05PhyExtFetControlEn = 1; |
Yong Zhi | 309d5a5 | 2023-02-14 17:25:17 -0600 | [diff] [blame] | 673 | |
| 674 | /* Enable PCH to CPU energy report feature. */ |
| 675 | s_cfg->PchPmDisableEnergyReport = !config->pch_pm_energy_report_enable; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | |
| 679 | static void fill_fsps_ufs_params(FSP_S_CONFIG *s_cfg, |
| 680 | const struct soc_intel_meteorlake_config *config) |
| 681 | { |
| 682 | s_cfg->UfsEnable[0] = is_devfn_enabled(PCI_DEVFN_UFS); |
| 683 | } |
| 684 | |
| 685 | static void fill_fsps_ai_params(FSP_S_CONFIG *s_cfg, |
| 686 | const struct soc_intel_meteorlake_config *config) |
| 687 | { |
| 688 | s_cfg->GnaEnable = is_devfn_enabled(PCI_DEVFN_GNA); |
Srinidhi N Kaushik | 9f6e25d | 2022-08-08 20:38:19 -0700 | [diff] [blame] | 689 | s_cfg->VpuEnable = is_devfn_enabled(PCI_DEVFN_VPU); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 690 | } |
| 691 | |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 692 | static void fill_fsps_irq_params(FSP_S_CONFIG *s_cfg, |
| 693 | const struct soc_intel_meteorlake_config *config) |
| 694 | { |
| 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"); |
| 697 | |
| 698 | size_t pch_count = 0; |
| 699 | const SI_PCH_DEVICE_INTERRUPT_CONFIG *upd_irqs = pci_irq_to_fsp(&pch_count); |
| 700 | |
| 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"); |
| 704 | } |
| 705 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 706 | static void arch_silicon_init_params(FSPS_ARCH_UPD *s_arch_cfg) |
| 707 | { |
zhaojohn | 9f5fea9 | 2022-09-20 08:12:47 -0700 | [diff] [blame] | 708 | /* |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 709 | * EnableMultiPhaseSiliconInit for running MultiPhaseSiInit |
| 710 | */ |
zhaojohn | 9f5fea9 | 2022-09-20 08:12:47 -0700 | [diff] [blame] | 711 | s_arch_cfg->EnableMultiPhaseSiliconInit = 1; |
Srinidhi N Kaushik | 9a69002 | 2022-07-25 22:12:34 -0700 | [diff] [blame] | 712 | |
| 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; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 718 | } |
| 719 | |
Kapil Porwal | fbe0442 | 2023-01-04 00:54:42 +0530 | [diff] [blame] | 720 | static void evaluate_ssid(const struct device *dev, uint16_t *svid, uint16_t *ssid) |
| 721 | { |
| 722 | if (!(dev && svid && ssid)) |
| 723 | return; |
| 724 | |
| 725 | *svid = CONFIG_SUBSYSTEM_VENDOR_ID ? : (dev->subsystem_vendor ? : 0x8086); |
| 726 | *ssid = CONFIG_SUBSYSTEM_DEVICE_ID ? : (dev->subsystem_device ? : 0xfffe); |
| 727 | } |
| 728 | |
| 729 | /* |
| 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. |
| 733 | */ |
| 734 | static void fill_fsps_pci_ssid_params(FSP_S_CONFIG *s_cfg, |
| 735 | const struct soc_intel_meteorlake_config *config) |
| 736 | { |
| 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; |
| 747 | }; |
| 748 | uint64_t data; |
| 749 | }; |
| 750 | struct { |
| 751 | uint16_t svid; |
| 752 | uint16_t ssid; |
| 753 | }; |
| 754 | uint32_t ignore3; |
| 755 | }; |
| 756 | |
| 757 | static struct svid_ssid_init_entry ssid_table[MAX_ONBOARD_PCIE_DEVICES]; |
| 758 | const struct device *dev; |
| 759 | int i = 0; |
| 760 | |
| 761 | for (dev = all_devices; dev; dev = dev->next) { |
| 762 | if (!(is_dev_enabled(dev) && dev->path.type == DEVICE_PATH_PCI && |
Arthur Heymans | 7fcd4d5 | 2023-08-24 15:12:19 +0200 | [diff] [blame] | 763 | dev->upstream->secondary == 0)) |
Kapil Porwal | fbe0442 | 2023-01-04 00:54:42 +0530 | [diff] [blame] | 764 | continue; |
| 765 | |
| 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++; |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | s_cfg->SiSsidTablePtr = (uintptr_t)ssid_table; |
| 778 | s_cfg->SiNumberOfSsidTableEntry = i; |
| 779 | |
| 780 | /* Ensure FSP will program the registers */ |
| 781 | s_cfg->SiSkipSsidProgramming = 0; |
| 782 | } |
| 783 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 784 | static void soc_silicon_init_params(FSP_S_CONFIG *s_cfg, |
| 785 | struct soc_intel_meteorlake_config *config) |
| 786 | { |
| 787 | /* Override settings per board if required. */ |
| 788 | mainboard_update_soc_chip_config(config); |
| 789 | |
Arthur Heymans | 4081d6c | 2022-07-29 10:45:52 +0200 | [diff] [blame] | 790 | void (*fill_fsps_params[])(FSP_S_CONFIG *s_cfg, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 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, |
Subrata Banik | e88bee7 | 2022-06-27 16:51:44 +0530 | [diff] [blame] | 799 | fill_fsps_uart_params, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 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, |
Kapil Porwal | 89ea312 | 2022-11-15 19:06:49 +0530 | [diff] [blame] | 807 | fill_fsps_pm_timer_params, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 808 | fill_fsps_pcie_params, |
| 809 | fill_fsps_misc_power_params, |
| 810 | fill_fsps_ufs_params, |
| 811 | fill_fsps_ai_params, |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 812 | fill_fsps_irq_params, |
Kapil Porwal | fbe0442 | 2023-01-04 00:54:42 +0530 | [diff] [blame] | 813 | fill_fsps_pci_ssid_params, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 814 | }; |
| 815 | |
| 816 | for (size_t i = 0; i < ARRAY_SIZE(fill_fsps_params); i++) |
| 817 | fill_fsps_params[i](s_cfg, config); |
| 818 | } |
| 819 | |
| 820 | /* UPD parameters to be initialized before SiliconInit */ |
| 821 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) |
| 822 | { |
| 823 | struct soc_intel_meteorlake_config *config; |
| 824 | FSP_S_CONFIG *s_cfg = &supd->FspsConfig; |
| 825 | FSPS_ARCH_UPD *s_arch_cfg = &supd->FspsArchUpd; |
| 826 | |
| 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); |
| 831 | } |
| 832 | |
| 833 | /* |
| 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 |
Subrata Banik | f251a6a | 2022-12-11 16:39:05 +0530 | [diff] [blame] | 839 | * 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] | 840 | */ |
Jeremy Compostella | 7eb014e | 2024-03-05 10:00:21 -0800 | [diff] [blame] | 841 | void platform_fsp_silicon_multi_phase_init_cb(uint32_t phase_index) |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 842 | { |
| 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__); |
| 848 | |
| 849 | if (CONFIG(SOC_INTEL_COMMON_BLOCK_TCSS)) { |
| 850 | const config_t *config = config_of_soc(); |
| 851 | tcss_configure(config->typec_aux_bias_pads); |
| 852 | } |
| 853 | break; |
Subrata Banik | f251a6a | 2022-12-11 16:39:05 +0530 | [diff] [blame] | 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; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 862 | default: |
| 863 | break; |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | /* Mainboard GPIO Configuration */ |
| 868 | __weak void mainboard_silicon_init_params(FSP_S_CONFIG *s_cfg) |
| 869 | { |
| 870 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 871 | } |
Subrata Banik | e4f0df7 | 2023-05-15 17:22:39 +0530 | [diff] [blame] | 872 | |
| 873 | /* Handle FSP logo params */ |
| 874 | void soc_load_logo(FSPS_UPD *supd) |
| 875 | { |
Subrata Banik | 71a2a3d | 2023-08-03 10:26:21 +0000 | [diff] [blame] | 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); |
Subrata Banik | e4f0df7 | 2023-05-15 17:22:39 +0530 | [diff] [blame] | 882 | } |