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