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