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