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