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