Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <assert.h> |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 4 | #include <cbfs.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
| 7 | #include <device/pci.h> |
| 8 | #include <fsp/api.h> |
| 9 | #include <fsp/ppi/mp_service_ppi.h> |
| 10 | #include <fsp/util.h> |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 11 | #include <intelblocks/irq.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 12 | #include <intelblocks/lpss.h> |
| 13 | #include <intelblocks/xdci.h> |
| 14 | #include <intelpch/lockdown.h> |
Deepti Deshatty | 8e7facf | 2021-05-12 17:45:37 +0530 | [diff] [blame] | 15 | #include <intelblocks/tcss.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 16 | #include <soc/gpio_soc_defs.h> |
| 17 | #include <soc/intel/common/vbt.h> |
| 18 | #include <soc/pci_devs.h> |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 19 | #include <soc/pcie.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 20 | #include <soc/ramstage.h> |
| 21 | #include <soc/soc_chip.h> |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 22 | #include <stdlib.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 23 | #include <string.h> |
| 24 | |
| 25 | /* THC assignment definition */ |
| 26 | #define THC_NONE 0 |
| 27 | #define THC_0 1 |
| 28 | #define THC_1 2 |
| 29 | |
| 30 | /* SATA DEVSLP idle timeout default values */ |
| 31 | #define DEF_DMVAL 15 |
| 32 | #define DEF_DITOVAL 625 |
| 33 | |
Tim Wawrzynczak | c0e82e7 | 2021-06-17 12:42:35 -0600 | [diff] [blame] | 34 | /* |
| 35 | * ME End of Post configuration |
| 36 | * 0 - Disable EOP. |
| 37 | * 1 - Send in PEI (Applicable for FSP in API mode) |
| 38 | * 2 - Send in DXE (Not applicable for FSP in API mode) |
| 39 | */ |
| 40 | enum fsp_end_of_post { |
| 41 | EOP_DISABLE = 0, |
| 42 | EOP_PEI = 1, |
| 43 | EOP_DXE = 2, |
| 44 | }; |
| 45 | |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 46 | static const struct slot_irq_constraints irq_constraints[] = { |
| 47 | { |
| 48 | .slot = SA_DEV_SLOT_IGD, |
| 49 | .fns = { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 50 | /* INTERRUPT_PIN is RO/0x01 */ |
| 51 | FIXED_INT_ANY_PIRQ(SA_DEVFN_IGD, PCI_INT_A), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 52 | }, |
| 53 | }, |
| 54 | { |
| 55 | .slot = SA_DEV_SLOT_DPTF, |
| 56 | .fns = { |
| 57 | ANY_PIRQ(SA_DEVFN_DPTF), |
| 58 | }, |
| 59 | }, |
| 60 | { |
| 61 | .slot = SA_DEV_SLOT_IPU, |
| 62 | .fns = { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 63 | /* INTERRUPT_PIN is RO/0x01, and INTERRUPT_LINE is RW, |
| 64 | but S0ix fails when not set to 16 (b/193434192) */ |
| 65 | FIXED_INT_PIRQ(SA_DEVFN_IPU, PCI_INT_A, PIRQ_A), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 66 | }, |
| 67 | }, |
| 68 | { |
| 69 | .slot = SA_DEV_SLOT_CPU_6, |
| 70 | .fns = { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 71 | FIXED_INT_PIRQ(SA_DEVFN_CPU_PCIE6_0, PCI_INT_A, PIRQ_A), |
| 72 | FIXED_INT_PIRQ(SA_DEVFN_CPU_PCIE6_2, PCI_INT_C, PIRQ_C), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 73 | }, |
| 74 | }, |
| 75 | { |
| 76 | .slot = SA_DEV_SLOT_TBT, |
| 77 | .fns = { |
| 78 | ANY_PIRQ(SA_DEVFN_TBT0), |
| 79 | ANY_PIRQ(SA_DEVFN_TBT1), |
| 80 | ANY_PIRQ(SA_DEVFN_TBT2), |
| 81 | ANY_PIRQ(SA_DEVFN_TBT3), |
| 82 | }, |
| 83 | }, |
| 84 | { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 85 | .slot = SA_DEV_SLOT_GNA, |
| 86 | .fns = { |
| 87 | /* INTERRUPT_PIN is RO/0x01 */ |
| 88 | FIXED_INT_ANY_PIRQ(SA_DEVFN_GNA, PCI_INT_A), |
| 89 | }, |
| 90 | }, |
| 91 | { |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 92 | .slot = SA_DEV_SLOT_TCSS, |
| 93 | .fns = { |
| 94 | ANY_PIRQ(SA_DEVFN_TCSS_XHCI), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 95 | ANY_PIRQ(SA_DEVFN_TCSS_XDCI), |
| 96 | }, |
| 97 | }, |
| 98 | { |
| 99 | .slot = PCH_DEV_SLOT_SIO0, |
| 100 | .fns = { |
| 101 | DIRECT_IRQ(PCH_DEVFN_I2C6), |
| 102 | DIRECT_IRQ(PCH_DEVFN_I2C7), |
| 103 | ANY_PIRQ(PCH_DEVFN_THC0), |
| 104 | ANY_PIRQ(PCH_DEVFN_THC1), |
| 105 | }, |
| 106 | }, |
| 107 | { |
| 108 | .slot = PCH_DEV_SLOT_SIO6, |
| 109 | .fns = { |
| 110 | DIRECT_IRQ(PCH_DEVFN_UART3), |
| 111 | DIRECT_IRQ(PCH_DEVFN_UART4), |
| 112 | DIRECT_IRQ(PCH_DEVFN_UART5), |
| 113 | DIRECT_IRQ(PCH_DEVFN_UART6), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 114 | }, |
| 115 | }, |
| 116 | { |
| 117 | .slot = PCH_DEV_SLOT_ISH, |
| 118 | .fns = { |
| 119 | DIRECT_IRQ(PCH_DEVFN_ISH), |
| 120 | DIRECT_IRQ(PCH_DEVFN_GSPI2), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 121 | ANY_PIRQ(PCH_DEVFN_UFS), |
| 122 | }, |
| 123 | }, |
| 124 | { |
| 125 | .slot = PCH_DEV_SLOT_SIO2, |
| 126 | .fns = { |
| 127 | DIRECT_IRQ(PCH_DEVFN_GSPI3), |
| 128 | DIRECT_IRQ(PCH_DEVFN_GSPI4), |
| 129 | DIRECT_IRQ(PCH_DEVFN_GSPI5), |
| 130 | DIRECT_IRQ(PCH_DEVFN_GSPI6), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 131 | }, |
| 132 | }, |
| 133 | { |
| 134 | .slot = PCH_DEV_SLOT_XHCI, |
| 135 | .fns = { |
| 136 | ANY_PIRQ(PCH_DEVFN_XHCI), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 137 | DIRECT_IRQ(PCH_DEVFN_USBOTG), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 138 | ANY_PIRQ(PCH_DEVFN_CNVI_WIFI), |
| 139 | }, |
| 140 | }, |
| 141 | { |
| 142 | .slot = PCH_DEV_SLOT_SIO3, |
| 143 | .fns = { |
| 144 | DIRECT_IRQ(PCH_DEVFN_I2C0), |
| 145 | DIRECT_IRQ(PCH_DEVFN_I2C1), |
| 146 | DIRECT_IRQ(PCH_DEVFN_I2C2), |
| 147 | DIRECT_IRQ(PCH_DEVFN_I2C3), |
| 148 | }, |
| 149 | }, |
| 150 | { |
| 151 | .slot = PCH_DEV_SLOT_CSE, |
| 152 | .fns = { |
| 153 | ANY_PIRQ(PCH_DEVFN_CSE), |
| 154 | ANY_PIRQ(PCH_DEVFN_CSE_2), |
| 155 | ANY_PIRQ(PCH_DEVFN_CSE_IDER), |
| 156 | ANY_PIRQ(PCH_DEVFN_CSE_KT), |
| 157 | ANY_PIRQ(PCH_DEVFN_CSE_3), |
| 158 | ANY_PIRQ(PCH_DEVFN_CSE_4), |
| 159 | }, |
| 160 | }, |
| 161 | { |
| 162 | .slot = PCH_DEV_SLOT_SATA, |
| 163 | .fns = { |
| 164 | ANY_PIRQ(PCH_DEVFN_SATA), |
| 165 | }, |
| 166 | }, |
| 167 | { |
| 168 | .slot = PCH_DEV_SLOT_SIO4, |
| 169 | .fns = { |
| 170 | DIRECT_IRQ(PCH_DEVFN_I2C4), |
| 171 | DIRECT_IRQ(PCH_DEVFN_I2C5), |
| 172 | DIRECT_IRQ(PCH_DEVFN_UART2), |
| 173 | }, |
| 174 | }, |
| 175 | { |
| 176 | .slot = PCH_DEV_SLOT_PCIE, |
| 177 | .fns = { |
| 178 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE1, PCI_INT_A, PIRQ_A), |
| 179 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE2, PCI_INT_B, PIRQ_B), |
| 180 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE3, PCI_INT_C, PIRQ_C), |
| 181 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE4, PCI_INT_D, PIRQ_D), |
| 182 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE5, PCI_INT_A, PIRQ_A), |
| 183 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE6, PCI_INT_B, PIRQ_B), |
| 184 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE7, PCI_INT_C, PIRQ_C), |
| 185 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE8, PCI_INT_D, PIRQ_D), |
| 186 | }, |
| 187 | }, |
| 188 | { |
| 189 | .slot = PCH_DEV_SLOT_PCIE_1, |
| 190 | .fns = { |
| 191 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE9, PCI_INT_A, PIRQ_A), |
| 192 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE10, PCI_INT_B, PIRQ_B), |
| 193 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE11, PCI_INT_C, PIRQ_C), |
| 194 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE12, PCI_INT_D, PIRQ_D), |
| 195 | }, |
| 196 | }, |
| 197 | { |
| 198 | .slot = PCH_DEV_SLOT_SIO5, |
| 199 | .fns = { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 200 | /* UART0 shares an interrupt line with TSN0, so must use |
| 201 | a PIRQ */ |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 202 | FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART0, PCI_INT_A), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 203 | /* UART1 shares an interrupt line with TSN1, so must use |
| 204 | a PIRQ */ |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 205 | FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART1, PCI_INT_B), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 206 | DIRECT_IRQ(PCH_DEVFN_GSPI0), |
| 207 | DIRECT_IRQ(PCH_DEVFN_GSPI1), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 208 | }, |
| 209 | }, |
| 210 | { |
| 211 | .slot = PCH_DEV_SLOT_ESPI, |
| 212 | .fns = { |
| 213 | ANY_PIRQ(PCH_DEVFN_HDA), |
| 214 | ANY_PIRQ(PCH_DEVFN_SMBUS), |
| 215 | ANY_PIRQ(PCH_DEVFN_GBE), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 216 | /* INTERRUPT_PIN is RO/0x01 */ |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 217 | FIXED_INT_ANY_PIRQ(PCH_DEVFN_TRACEHUB, PCI_INT_A), |
| 218 | }, |
| 219 | }, |
| 220 | }; |
| 221 | |
| 222 | static const SI_PCH_DEVICE_INTERRUPT_CONFIG *pci_irq_to_fsp(size_t *out_count) |
| 223 | { |
| 224 | const struct pci_irq_entry *entry = get_cached_pci_irqs(); |
| 225 | SI_PCH_DEVICE_INTERRUPT_CONFIG *config; |
| 226 | size_t pch_total = 0; |
| 227 | size_t cfg_count = 0; |
| 228 | |
| 229 | if (!entry) |
| 230 | return NULL; |
| 231 | |
| 232 | /* Count PCH devices */ |
| 233 | while (entry) { |
| 234 | if (PCI_SLOT(entry->devfn) >= MIN_PCH_SLOT) |
| 235 | ++pch_total; |
| 236 | entry = entry->next; |
| 237 | } |
| 238 | |
| 239 | /* Convert PCH device entries to FSP format */ |
| 240 | config = calloc(pch_total, sizeof(*config)); |
| 241 | entry = get_cached_pci_irqs(); |
| 242 | while (entry) { |
| 243 | if (PCI_SLOT(entry->devfn) < MIN_PCH_SLOT) { |
| 244 | entry = entry->next; |
| 245 | continue; |
| 246 | } |
| 247 | |
| 248 | config[cfg_count].Device = PCI_SLOT(entry->devfn); |
| 249 | config[cfg_count].Function = PCI_FUNC(entry->devfn); |
| 250 | config[cfg_count].IntX = (SI_PCH_INT_PIN)entry->pin; |
| 251 | config[cfg_count].Irq = entry->irq; |
| 252 | ++cfg_count; |
| 253 | |
| 254 | entry = entry->next; |
| 255 | } |
| 256 | |
| 257 | *out_count = cfg_count; |
| 258 | |
| 259 | return config; |
| 260 | } |
| 261 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 262 | /* |
| 263 | * Chip config parameter PcieRpL1Substates uses (UPD value + 1) |
| 264 | * because UPD value of 0 for PcieRpL1Substates means disabled for FSP. |
| 265 | * In order to ensure that mainboard setting does not disable L1 substates |
| 266 | * incorrectly, chip config parameter values are offset by 1 with 0 meaning |
| 267 | * use FSP UPD default. get_l1_substate_control() ensures that the right UPD |
| 268 | * value is set in fsp_params. |
| 269 | * 0: Use FSP UPD default |
| 270 | * 1: Disable L1 substates |
| 271 | * 2: Use L1.1 |
| 272 | * 3: Use L1.2 (FSP UPD default) |
| 273 | */ |
| 274 | static int get_l1_substate_control(enum L1_substates_control ctl) |
| 275 | { |
| 276 | if ((ctl > L1_SS_L1_2) || (ctl == L1_SS_FSP_DEFAULT)) |
| 277 | ctl = L1_SS_L1_2; |
| 278 | return ctl - 1; |
| 279 | } |
| 280 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 281 | __weak void mainboard_update_soc_chip_config(struct soc_intel_alderlake_config *config) |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 282 | { |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 283 | /* Override settings per board. */ |
| 284 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 285 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 286 | static void fill_fsps_lpss_params(FSP_S_CONFIG *s_cfg, |
| 287 | const struct soc_intel_alderlake_config *config) |
| 288 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 289 | for (int i = 0; i < CONFIG_SOC_INTEL_I2C_DEV_MAX; i++) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 290 | s_cfg->SerialIoI2cMode[i] = config->SerialIoI2cMode[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 291 | |
| 292 | for (int i = 0; i < CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX; i++) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 293 | s_cfg->SerialIoSpiMode[i] = config->SerialIoGSpiMode[i]; |
| 294 | s_cfg->SerialIoSpiCsMode[i] = config->SerialIoGSpiCsMode[i]; |
| 295 | s_cfg->SerialIoSpiCsState[i] = config->SerialIoGSpiCsState[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | for (int i = 0; i < CONFIG_SOC_INTEL_UART_DEV_MAX; i++) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 299 | s_cfg->SerialIoUartMode[i] = config->SerialIoUartMode[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 300 | } |
| 301 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 302 | static void fill_fsps_cpu_params(FSP_S_CONFIG *s_cfg, |
| 303 | const struct soc_intel_alderlake_config *config) |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 304 | { |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 305 | const struct microcode *microcode_file; |
| 306 | size_t microcode_len; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 307 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 308 | /* Locate microcode and pass to FSP-S for 2nd microcode loading */ |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 309 | microcode_file = cbfs_map("cpu_microcode_blob.bin", µcode_len); |
| 310 | |
| 311 | if ((microcode_file != NULL) && (microcode_len != 0)) { |
| 312 | /* Update CPU Microcode patch base address/size */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 313 | s_cfg->MicrocodeRegionBase = (uint32_t)microcode_file; |
| 314 | s_cfg->MicrocodeRegionSize = (uint32_t)microcode_len; |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 315 | } |
| 316 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 317 | /* Use coreboot MP PPI services if Kconfig is enabled */ |
| 318 | if (CONFIG(USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI)) |
| 319 | s_cfg->CpuMpPpi = (uintptr_t) mp_fill_ppi_services_data(); |
| 320 | } |
| 321 | |
| 322 | static void fill_fsps_igd_params(FSP_S_CONFIG *s_cfg, |
| 323 | const struct soc_intel_alderlake_config *config) |
| 324 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 325 | /* Load VBT before devicetree-specific config. */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 326 | s_cfg->GraphicsConfigPtr = (uintptr_t)vbt_get(); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 327 | |
| 328 | /* Check if IGD is present and fill Graphics init param accordingly */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 329 | s_cfg->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD); |
| 330 | s_cfg->LidStatus = CONFIG(RUN_FSP_GOP); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 331 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 332 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 333 | static void fill_fsps_tcss_params(FSP_S_CONFIG *s_cfg, |
| 334 | const struct soc_intel_alderlake_config *config) |
| 335 | { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 336 | s_cfg->TcssAuxOri = config->TcssAuxOri; |
Deepti Deshatty | 8e7facf | 2021-05-12 17:45:37 +0530 | [diff] [blame] | 337 | |
| 338 | /* Explicitly clear this field to avoid using defaults */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 339 | memset(s_cfg->IomTypeCPortPadCfg, 0, sizeof(s_cfg->IomTypeCPortPadCfg)); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 340 | |
| 341 | /* |
| 342 | * Set FSPS UPD ITbtConnectTopologyTimeoutInMs with value 0. FSP will |
| 343 | * evaluate this UPD value and skip sending command. There will be no |
| 344 | * delay for command completion. |
| 345 | */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 346 | s_cfg->ITbtConnectTopologyTimeoutInMs = 0; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 347 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 348 | /* D3Hot and D3Cold for TCSS */ |
| 349 | s_cfg->D3HotEnable = !config->TcssD3HotDisable; |
| 350 | s_cfg->D3ColdEnable = !config->TcssD3ColdDisable; |
Bernardo Perez Priego | 421ce56 | 2021-06-09 09:40:31 -0700 | [diff] [blame] | 351 | |
| 352 | s_cfg->UsbTcPortEn = 0; |
| 353 | for (int i = 0; i < MAX_TYPE_C_PORTS; i++) { |
| 354 | /* TCSS xHCI --> Root Hub --> Type-C Port */ |
| 355 | const struct device_path port_path[] = { |
| 356 | {.type = DEVICE_PATH_PCI, .pci.devfn = SA_DEVFN_TCSS_XHCI}, |
| 357 | {.type = DEVICE_PATH_USB, .usb.port_type = 0, .usb.port_id = 0}, |
| 358 | {.type = DEVICE_PATH_USB, .usb.port_type = 3, .usb.port_id = i} }; |
| 359 | const struct device *port = find_dev_nested_path(pci_root_bus(), port_path, |
| 360 | ARRAY_SIZE(port_path)); |
| 361 | |
| 362 | if (is_dev_enabled(port)) |
| 363 | s_cfg->UsbTcPortEn |= BIT(i); |
| 364 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | static void fill_fsps_chipset_lockdown_params(FSP_S_CONFIG *s_cfg, |
| 368 | const struct soc_intel_alderlake_config *config) |
| 369 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 370 | /* Chipset Lockdown */ |
| 371 | if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 372 | s_cfg->PchLockDownGlobalSmi = 0; |
| 373 | s_cfg->PchLockDownBiosInterface = 0; |
| 374 | s_cfg->PchUnlockGpioPads = 1; |
| 375 | s_cfg->RtcMemoryLock = 0; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 376 | } else { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 377 | s_cfg->PchLockDownGlobalSmi = 1; |
| 378 | s_cfg->PchLockDownBiosInterface = 1; |
| 379 | s_cfg->PchUnlockGpioPads = 0; |
| 380 | s_cfg->RtcMemoryLock = 1; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 381 | } |
Tim Wawrzynczak | c0e82e7 | 2021-06-17 12:42:35 -0600 | [diff] [blame] | 382 | |
| 383 | /* coreboot will send EOP before loading payload */ |
| 384 | s_cfg->EndOfPostMessage = EOP_DISABLE; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 385 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 386 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 387 | static void fill_fsps_xhci_params(FSP_S_CONFIG *s_cfg, |
| 388 | const struct soc_intel_alderlake_config *config) |
| 389 | { |
| 390 | int i; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 391 | /* USB */ |
| 392 | for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 393 | s_cfg->PortUsb20Enable[i] = config->usb2_ports[i].enable; |
| 394 | s_cfg->Usb2PhyPetxiset[i] = config->usb2_ports[i].pre_emp_bias; |
| 395 | s_cfg->Usb2PhyTxiset[i] = config->usb2_ports[i].tx_bias; |
| 396 | s_cfg->Usb2PhyPredeemp[i] = config->usb2_ports[i].tx_emp_enable; |
| 397 | s_cfg->Usb2PhyPehalfbit[i] = config->usb2_ports[i].pre_emp_bit; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 398 | |
| 399 | if (config->usb2_ports[i].enable) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 400 | s_cfg->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 401 | else |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 402 | s_cfg->Usb2OverCurrentPin[i] = OC_SKIP; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 406 | s_cfg->PortUsb30Enable[i] = config->usb3_ports[i].enable; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 407 | if (config->usb3_ports[i].enable) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 408 | s_cfg->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 409 | else |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 410 | s_cfg->Usb3OverCurrentPin[i] = OC_SKIP; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 411 | |
| 412 | if (config->usb3_ports[i].tx_de_emp) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 413 | s_cfg->Usb3HsioTxDeEmphEnable[i] = 1; |
| 414 | s_cfg->Usb3HsioTxDeEmph[i] = config->usb3_ports[i].tx_de_emp; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 415 | } |
| 416 | if (config->usb3_ports[i].tx_downscale_amp) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 417 | s_cfg->Usb3HsioTxDownscaleAmpEnable[i] = 1; |
| 418 | s_cfg->Usb3HsioTxDownscaleAmp[i] = |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 419 | config->usb3_ports[i].tx_downscale_amp; |
| 420 | } |
| 421 | } |
| 422 | |
Maulik V Vaghela | 6935350 | 2021-04-14 14:01:02 +0530 | [diff] [blame] | 423 | for (i = 0; i < ARRAY_SIZE(config->tcss_ports); i++) { |
| 424 | if (config->tcss_ports[i].enable) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 425 | s_cfg->CpuUsb3OverCurrentPin[i] = config->tcss_ports[i].ocpin; |
Maulik V Vaghela | 6935350 | 2021-04-14 14:01:02 +0530 | [diff] [blame] | 426 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 427 | } |
Maulik V Vaghela | 6935350 | 2021-04-14 14:01:02 +0530 | [diff] [blame] | 428 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 429 | static void fill_fsps_xdci_params(FSP_S_CONFIG *s_cfg, |
| 430 | const struct soc_intel_alderlake_config *config) |
| 431 | { |
Angel Pons | c7cfe0b | 2021-06-23 12:39:22 +0200 | [diff] [blame] | 432 | s_cfg->XdciEnable = xdci_can_enable(PCH_DEVFN_USBOTG); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 433 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 434 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 435 | static void fill_fsps_uart_params(FSP_S_CONFIG *s_cfg, |
| 436 | const struct soc_intel_alderlake_config *config) |
| 437 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 438 | /* PCH UART selection for FSP Debug */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 439 | s_cfg->SerialIoDebugUartNumber = CONFIG_UART_FOR_CONSOLE; |
| 440 | ASSERT(ARRAY_SIZE(s_cfg->SerialIoUartAutoFlow) > CONFIG_UART_FOR_CONSOLE); |
| 441 | s_cfg->SerialIoUartAutoFlow[CONFIG_UART_FOR_CONSOLE] = 0; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 442 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 443 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 444 | static void fill_fsps_sata_params(FSP_S_CONFIG *s_cfg, |
| 445 | const struct soc_intel_alderlake_config *config) |
| 446 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 447 | /* SATA */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 448 | s_cfg->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA); |
| 449 | if (s_cfg->SataEnable) { |
| 450 | s_cfg->SataMode = config->SataMode; |
| 451 | s_cfg->SataSalpSupport = config->SataSalpSupport; |
| 452 | memcpy(s_cfg->SataPortsEnable, config->SataPortsEnable, |
| 453 | sizeof(s_cfg->SataPortsEnable)); |
| 454 | memcpy(s_cfg->SataPortsDevSlp, config->SataPortsDevSlp, |
| 455 | sizeof(s_cfg->SataPortsDevSlp)); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | /* |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 459 | * Power Optimizer for SATA. |
| 460 | * SataPwrOptimizeDisable is default to 0. |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 461 | * Boards not needing the optimizers explicitly disables them by setting |
| 462 | * these disable variables to 1 in devicetree overrides. |
| 463 | */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 464 | s_cfg->SataPwrOptEnable = !(config->SataPwrOptimizeDisable); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 465 | /* |
| 466 | * Enable DEVSLP Idle Timeout settings DmVal and DitoVal. |
| 467 | * SataPortsDmVal is the DITO multiplier. Default is 15. |
| 468 | * SataPortsDitoVal is the DEVSLP Idle Timeout (DITO), Default is 625ms. |
| 469 | * The default values can be changed from devicetree. |
| 470 | */ |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 471 | for (size_t i = 0; i < ARRAY_SIZE(config->SataPortsEnableDitoConfig); i++) { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 472 | if (config->SataPortsEnableDitoConfig[i]) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 473 | s_cfg->SataPortsDmVal[i] = config->SataPortsDmVal[i]; |
| 474 | s_cfg->SataPortsDitoVal[i] = config->SataPortsDitoVal[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 475 | } |
| 476 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 477 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 478 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 479 | static void fill_fsps_thermal_params(FSP_S_CONFIG *s_cfg, |
| 480 | const struct soc_intel_alderlake_config *config) |
| 481 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 482 | /* Enable TCPU for processor thermal control */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 483 | s_cfg->Device4Enable = is_devfn_enabled(SA_DEVFN_DPTF); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 484 | |
| 485 | /* Set TccActivationOffset */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 486 | s_cfg->TccActivationOffset = config->tcc_offset; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 487 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 488 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 489 | static void fill_fsps_lan_params(FSP_S_CONFIG *s_cfg, |
| 490 | const struct soc_intel_alderlake_config *config) |
| 491 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 492 | /* LAN */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 493 | s_cfg->PchLanEnable = is_devfn_enabled(PCH_DEVFN_GBE); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 494 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 495 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 496 | static void fill_fsps_cnvi_params(FSP_S_CONFIG *s_cfg, |
| 497 | const struct soc_intel_alderlake_config *config) |
| 498 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 499 | /* CNVi */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 500 | s_cfg->CnviMode = is_devfn_enabled(PCH_DEVFN_CNVI_WIFI); |
| 501 | s_cfg->CnviBtCore = config->CnviBtCore; |
| 502 | s_cfg->CnviBtAudioOffload = config->CnviBtAudioOffload; |
Cliff Huang | bc1941f | 2021-02-10 17:41:41 -0800 | [diff] [blame] | 503 | /* Assert if CNVi BT is enabled without CNVi being enabled. */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 504 | assert(s_cfg->CnviMode || !s_cfg->CnviBtCore); |
Cliff Huang | bc1941f | 2021-02-10 17:41:41 -0800 | [diff] [blame] | 505 | /* Assert if CNVi BT offload is enabled without CNVi BT being enabled. */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 506 | assert(s_cfg->CnviBtCore || !s_cfg->CnviBtAudioOffload); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 507 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 508 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 509 | static void fill_fsps_vmd_params(FSP_S_CONFIG *s_cfg, |
| 510 | const struct soc_intel_alderlake_config *config) |
| 511 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 512 | /* VMD */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 513 | s_cfg->VmdEnable = is_devfn_enabled(SA_DEVFN_VMD); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 514 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 515 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 516 | static void fill_fsps_thc_params(FSP_S_CONFIG *s_cfg, |
| 517 | const struct soc_intel_alderlake_config *config) |
| 518 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 519 | /* THC */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 520 | s_cfg->ThcPort0Assignment = is_devfn_enabled(PCH_DEVFN_THC0) ? THC_0 : THC_NONE; |
| 521 | s_cfg->ThcPort1Assignment = is_devfn_enabled(PCH_DEVFN_THC1) ? THC_1 : THC_NONE; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 522 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 523 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 524 | static void fill_fsps_tbt_params(FSP_S_CONFIG *s_cfg, |
| 525 | const struct soc_intel_alderlake_config *config) |
| 526 | { |
Bernardo Perez Priego | 095f97b | 2021-05-18 18:39:19 -0700 | [diff] [blame] | 527 | /* USB4/TBT */ |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 528 | for (int i = 0; i < ARRAY_SIZE(s_cfg->ITbtPcieRootPortEn); i++) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 529 | s_cfg->ITbtPcieRootPortEn[i] = is_devfn_enabled(SA_DEVFN_TBT(i)); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 530 | } |
Bernardo Perez Priego | 095f97b | 2021-05-18 18:39:19 -0700 | [diff] [blame] | 531 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 532 | static void fill_fsps_8254_params(FSP_S_CONFIG *s_cfg, |
| 533 | const struct soc_intel_alderlake_config *config) |
| 534 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 535 | /* Legacy 8254 timer support */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 536 | s_cfg->Enable8254ClockGating = !CONFIG(USE_LEGACY_8254_TIMER); |
| 537 | s_cfg->Enable8254ClockGatingOnS3 = !CONFIG(USE_LEGACY_8254_TIMER); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 538 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 539 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 540 | static void fill_fsps_storage_params(FSP_S_CONFIG *s_cfg, |
| 541 | const struct soc_intel_alderlake_config *config) |
| 542 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 543 | /* Enable Hybrid storage auto detection */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 544 | s_cfg->HybridStorageMode = config->HybridStorageMode; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 545 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 546 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 547 | static void fill_fsps_pcie_params(FSP_S_CONFIG *s_cfg, |
| 548 | const struct soc_intel_alderlake_config *config) |
| 549 | { |
| 550 | uint32_t enable_mask = pcie_rp_enable_mask(get_pch_pcie_rp_table()); |
| 551 | for (int i = 0; i < CONFIG_MAX_PCH_ROOT_PORTS; i++) { |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 552 | if (!(enable_mask & BIT(i))) |
| 553 | continue; |
| 554 | const struct pcie_rp_config *rp_cfg = &config->pch_pcie_rp[i]; |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 555 | s_cfg->PcieRpL1Substates[i] = |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 556 | get_l1_substate_control(rp_cfg->PcieRpL1Substates); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 557 | s_cfg->PcieRpLtrEnable[i] = !!(rp_cfg->flags & PCIE_RP_LTR); |
| 558 | s_cfg->PcieRpAdvancedErrorReporting[i] = !!(rp_cfg->flags & PCIE_RP_AER); |
| 559 | s_cfg->PcieRpHotPlug[i] = !!(rp_cfg->flags & PCIE_RP_HOTPLUG); |
| 560 | s_cfg->PcieRpClkReqDetect[i] = !!(rp_cfg->flags & PCIE_RP_CLK_REQ_DETECT); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 561 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 562 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 563 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 564 | static void fill_fsps_misc_power_params(FSP_S_CONFIG *s_cfg, |
| 565 | const struct soc_intel_alderlake_config *config) |
| 566 | { |
| 567 | /* |
| 568 | * Power Optimizer for DMI |
| 569 | * DmiPwrOptimizeDisable is default to 0. |
| 570 | * Boards not needing the optimizers explicitly disables them by setting |
| 571 | * these disable variables to 1 in devicetree overrides. |
| 572 | */ |
| 573 | s_cfg->PchPwrOptEnable = !(config->DmiPwrOptimizeDisable); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 574 | s_cfg->PmSupport = 1; |
| 575 | s_cfg->Hwp = 1; |
| 576 | s_cfg->Cx = 1; |
| 577 | s_cfg->PsOnEnable = 1; |
V Sowmya | 844dcb3 | 2021-06-21 10:03:53 +0530 | [diff] [blame] | 578 | /* Enable the energy efficient turbo mode */ |
| 579 | s_cfg->EnergyEfficientTurbo = 1; |
V Sowmya | af42906 | 2021-06-21 10:23:33 +0530 | [diff] [blame] | 580 | s_cfg->PkgCStateLimit = LIMIT_AUTO; |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 581 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 582 | |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 583 | static void fill_fsps_irq_params(FSP_S_CONFIG *s_cfg, |
| 584 | const struct soc_intel_alderlake_config *config) |
| 585 | { |
| 586 | if (!assign_pci_irqs(irq_constraints, ARRAY_SIZE(irq_constraints))) |
| 587 | die("ERROR: Unable to assign PCI IRQs, and no _PRT table available\n"); |
| 588 | |
| 589 | size_t pch_count = 0; |
| 590 | const SI_PCH_DEVICE_INTERRUPT_CONFIG *upd_irqs = pci_irq_to_fsp(&pch_count); |
| 591 | |
| 592 | s_cfg->DevIntConfigPtr = (UINT32)((uintptr_t)upd_irqs); |
| 593 | s_cfg->NumOfDevIntConfig = pch_count; |
| 594 | printk(BIOS_INFO, "IRQ: Using dynamically assigned PCI IO-APIC IRQs\n"); |
| 595 | } |
| 596 | |
V Sowmya | 418d37e | 2021-06-21 08:47:17 +0530 | [diff] [blame] | 597 | static void fill_fsps_fivr_params(FSP_S_CONFIG *s_cfg, |
| 598 | const struct soc_intel_alderlake_config *config) |
| 599 | { |
| 600 | /* PCH FIVR settings override */ |
| 601 | if (!config->ext_fivr_settings.configure_ext_fivr) |
| 602 | return; |
| 603 | |
| 604 | s_cfg->PchFivrExtV1p05RailEnabledStates = |
| 605 | config->ext_fivr_settings.v1p05_enable_bitmap; |
| 606 | |
| 607 | s_cfg->PchFivrExtV1p05RailSupportedVoltageStates = |
| 608 | config->ext_fivr_settings.v1p05_supported_voltage_bitmap; |
| 609 | |
| 610 | s_cfg->PchFivrExtVnnRailEnabledStates = |
| 611 | config->ext_fivr_settings.vnn_enable_bitmap; |
| 612 | |
| 613 | s_cfg->PchFivrExtVnnRailSupportedVoltageStates = |
| 614 | config->ext_fivr_settings.vnn_supported_voltage_bitmap; |
| 615 | |
| 616 | s_cfg->PchFivrExtVnnRailSxEnabledStates = |
| 617 | config->ext_fivr_settings.vnn_enable_bitmap; |
| 618 | |
| 619 | /* Convert the voltages to increments of 2.5mv */ |
| 620 | s_cfg->PchFivrExtV1p05RailVoltage = |
| 621 | (config->ext_fivr_settings.v1p05_voltage_mv * 10) / 25; |
| 622 | |
| 623 | s_cfg->PchFivrExtVnnRailVoltage = |
| 624 | (config->ext_fivr_settings.vnn_voltage_mv * 10) / 25; |
| 625 | |
| 626 | s_cfg->PchFivrExtVnnRailSxVoltage = |
| 627 | (config->ext_fivr_settings.vnn_sx_voltage_mv * 10 / 25); |
| 628 | |
| 629 | s_cfg->PchFivrExtV1p05RailIccMaximum = |
| 630 | config->ext_fivr_settings.v1p05_icc_max_ma; |
| 631 | |
| 632 | s_cfg->PchFivrExtVnnRailIccMaximum = |
| 633 | config->ext_fivr_settings.vnn_icc_max_ma; |
| 634 | } |
| 635 | |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 636 | static void arch_silicon_init_params(FSPS_ARCH_UPD *s_arch_cfg) |
| 637 | { |
| 638 | /* EnableMultiPhaseSiliconInit for running MultiPhaseSiInit */ |
| 639 | s_arch_cfg->EnableMultiPhaseSiliconInit = 1; |
| 640 | } |
| 641 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 642 | static void soc_silicon_init_params(FSP_S_CONFIG *s_cfg, |
| 643 | struct soc_intel_alderlake_config *config) |
| 644 | { |
| 645 | /* Override settings per board if required. */ |
| 646 | mainboard_update_soc_chip_config(config); |
| 647 | |
V Sowmya | 6464c2a | 2021-06-25 10:20:25 +0530 | [diff] [blame] | 648 | const void (*fill_fsps_params[])(FSP_S_CONFIG *s_cfg, |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 649 | const struct soc_intel_alderlake_config *config) = { |
| 650 | fill_fsps_lpss_params, |
| 651 | fill_fsps_cpu_params, |
| 652 | fill_fsps_igd_params, |
| 653 | fill_fsps_tcss_params, |
| 654 | fill_fsps_chipset_lockdown_params, |
| 655 | fill_fsps_xhci_params, |
| 656 | fill_fsps_xdci_params, |
| 657 | fill_fsps_uart_params, |
| 658 | fill_fsps_sata_params, |
| 659 | fill_fsps_thermal_params, |
| 660 | fill_fsps_lan_params, |
| 661 | fill_fsps_cnvi_params, |
| 662 | fill_fsps_vmd_params, |
| 663 | fill_fsps_thc_params, |
| 664 | fill_fsps_tbt_params, |
| 665 | fill_fsps_8254_params, |
| 666 | fill_fsps_storage_params, |
| 667 | fill_fsps_pcie_params, |
| 668 | fill_fsps_misc_power_params, |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 669 | fill_fsps_irq_params, |
V Sowmya | 418d37e | 2021-06-21 08:47:17 +0530 | [diff] [blame] | 670 | fill_fsps_fivr_params, |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 671 | }; |
| 672 | |
| 673 | for (size_t i = 0; i < ARRAY_SIZE(fill_fsps_params); i++) |
| 674 | fill_fsps_params[i](s_cfg, config); |
| 675 | } |
| 676 | |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 677 | /* UPD parameters to be initialized before SiliconInit */ |
| 678 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) |
| 679 | { |
| 680 | struct soc_intel_alderlake_config *config; |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 681 | FSP_S_CONFIG *s_cfg = &supd->FspsConfig; |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 682 | FSPS_ARCH_UPD *s_arch_cfg = &supd->FspsArchUpd; |
| 683 | |
| 684 | config = config_of_soc(); |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 685 | arch_silicon_init_params(s_arch_cfg); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 686 | soc_silicon_init_params(s_cfg, config); |
| 687 | mainboard_silicon_init_params(s_cfg); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 688 | } |
| 689 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 690 | /* |
| 691 | * Callbacks for SoC/Mainboard specific overrides for FspMultiPhaseSiInit |
| 692 | * This platform supports below MultiPhaseSIInit Phase(s): |
| 693 | * Phase | FSP return point | Purpose |
| 694 | * ------- + ------------------------------------------------ + ------------------------------- |
| 695 | * 1 | After TCSS initialization completed | for TCSS specific init |
| 696 | */ |
| 697 | void platform_fsp_multi_phase_init_cb(uint32_t phase_index) |
| 698 | { |
| 699 | switch (phase_index) { |
| 700 | case 1: |
| 701 | /* TCSS specific initialization here */ |
Deepti Deshatty | 8e7facf | 2021-05-12 17:45:37 +0530 | [diff] [blame] | 702 | printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n", |
| 703 | __FILE__, __func__); |
| 704 | |
| 705 | if (CONFIG(SOC_INTEL_COMMON_BLOCK_TCSS)) { |
| 706 | const config_t *config = config_of_soc(); |
| 707 | tcss_configure(config->typec_aux_bias_pads); |
| 708 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 709 | break; |
| 710 | default: |
| 711 | break; |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | /* Mainboard GPIO Configuration */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 716 | __weak void mainboard_silicon_init_params(FSP_S_CONFIG *s_cfg) |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 717 | { |
| 718 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 719 | } |