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> |
| 11 | #include <intelblocks/lpss.h> |
| 12 | #include <intelblocks/xdci.h> |
| 13 | #include <intelpch/lockdown.h> |
| 14 | #include <intelblocks/mp_init.h> |
Deepti Deshatty | 8e7facf | 2021-05-12 17:45:37 +0530 | [diff] [blame] | 15 | #include <intelblocks/tcss.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 16 | #include <soc/gpio_soc_defs.h> |
| 17 | #include <soc/intel/common/vbt.h> |
| 18 | #include <soc/pci_devs.h> |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 19 | #include <soc/pcie.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 20 | #include <soc/ramstage.h> |
| 21 | #include <soc/soc_chip.h> |
| 22 | #include <string.h> |
| 23 | |
| 24 | /* THC assignment definition */ |
| 25 | #define THC_NONE 0 |
| 26 | #define THC_0 1 |
| 27 | #define THC_1 2 |
| 28 | |
| 29 | /* SATA DEVSLP idle timeout default values */ |
| 30 | #define DEF_DMVAL 15 |
| 31 | #define DEF_DITOVAL 625 |
| 32 | |
| 33 | /* |
| 34 | * Chip config parameter PcieRpL1Substates uses (UPD value + 1) |
| 35 | * because UPD value of 0 for PcieRpL1Substates means disabled for FSP. |
| 36 | * In order to ensure that mainboard setting does not disable L1 substates |
| 37 | * incorrectly, chip config parameter values are offset by 1 with 0 meaning |
| 38 | * use FSP UPD default. get_l1_substate_control() ensures that the right UPD |
| 39 | * value is set in fsp_params. |
| 40 | * 0: Use FSP UPD default |
| 41 | * 1: Disable L1 substates |
| 42 | * 2: Use L1.1 |
| 43 | * 3: Use L1.2 (FSP UPD default) |
| 44 | */ |
| 45 | static int get_l1_substate_control(enum L1_substates_control ctl) |
| 46 | { |
| 47 | if ((ctl > L1_SS_L1_2) || (ctl == L1_SS_FSP_DEFAULT)) |
| 48 | ctl = L1_SS_L1_2; |
| 49 | return ctl - 1; |
| 50 | } |
| 51 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 52 | __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] | 53 | { |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 54 | /* Override settings per board. */ |
| 55 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 56 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 57 | static void fill_fsps_lpss_params(FSP_S_CONFIG *s_cfg, |
| 58 | const struct soc_intel_alderlake_config *config) |
| 59 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 60 | for (int i = 0; i < CONFIG_SOC_INTEL_I2C_DEV_MAX; i++) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 61 | s_cfg->SerialIoI2cMode[i] = config->SerialIoI2cMode[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 62 | |
| 63 | 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] | 64 | s_cfg->SerialIoSpiMode[i] = config->SerialIoGSpiMode[i]; |
| 65 | s_cfg->SerialIoSpiCsMode[i] = config->SerialIoGSpiCsMode[i]; |
| 66 | s_cfg->SerialIoSpiCsState[i] = config->SerialIoGSpiCsState[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | for (int i = 0; i < CONFIG_SOC_INTEL_UART_DEV_MAX; i++) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 70 | s_cfg->SerialIoUartMode[i] = config->SerialIoUartMode[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 71 | } |
| 72 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 73 | static void fill_fsps_cpu_params(FSP_S_CONFIG *s_cfg, |
| 74 | const struct soc_intel_alderlake_config *config) |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 75 | { |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 76 | const struct microcode *microcode_file; |
| 77 | size_t microcode_len; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 78 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 79 | /* Locate microcode and pass to FSP-S for 2nd microcode loading */ |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 80 | microcode_file = cbfs_map("cpu_microcode_blob.bin", µcode_len); |
| 81 | |
| 82 | if ((microcode_file != NULL) && (microcode_len != 0)) { |
| 83 | /* Update CPU Microcode patch base address/size */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 84 | s_cfg->MicrocodeRegionBase = (uint32_t)microcode_file; |
| 85 | s_cfg->MicrocodeRegionSize = (uint32_t)microcode_len; |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 86 | } |
| 87 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 88 | /* Use coreboot MP PPI services if Kconfig is enabled */ |
| 89 | if (CONFIG(USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI)) |
| 90 | s_cfg->CpuMpPpi = (uintptr_t) mp_fill_ppi_services_data(); |
| 91 | } |
| 92 | |
| 93 | static void fill_fsps_igd_params(FSP_S_CONFIG *s_cfg, |
| 94 | const struct soc_intel_alderlake_config *config) |
| 95 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 96 | /* Load VBT before devicetree-specific config. */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 97 | s_cfg->GraphicsConfigPtr = (uintptr_t)vbt_get(); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 98 | |
| 99 | /* Check if IGD is present and fill Graphics init param accordingly */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 100 | s_cfg->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD); |
| 101 | s_cfg->LidStatus = CONFIG(RUN_FSP_GOP); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 102 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 103 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 104 | static void fill_fsps_tcss_params(FSP_S_CONFIG *s_cfg, |
| 105 | const struct soc_intel_alderlake_config *config) |
| 106 | { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 107 | s_cfg->TcssAuxOri = config->TcssAuxOri; |
Deepti Deshatty | 8e7facf | 2021-05-12 17:45:37 +0530 | [diff] [blame] | 108 | |
| 109 | /* Explicitly clear this field to avoid using defaults */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 110 | memset(s_cfg->IomTypeCPortPadCfg, 0, sizeof(s_cfg->IomTypeCPortPadCfg)); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 111 | |
| 112 | /* |
| 113 | * Set FSPS UPD ITbtConnectTopologyTimeoutInMs with value 0. FSP will |
| 114 | * evaluate this UPD value and skip sending command. There will be no |
| 115 | * delay for command completion. |
| 116 | */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 117 | s_cfg->ITbtConnectTopologyTimeoutInMs = 0; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 118 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 119 | /* D3Hot and D3Cold for TCSS */ |
| 120 | s_cfg->D3HotEnable = !config->TcssD3HotDisable; |
| 121 | s_cfg->D3ColdEnable = !config->TcssD3ColdDisable; |
| 122 | } |
| 123 | |
| 124 | static void fill_fsps_chipset_lockdown_params(FSP_S_CONFIG *s_cfg, |
| 125 | const struct soc_intel_alderlake_config *config) |
| 126 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 127 | /* Chipset Lockdown */ |
| 128 | if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 129 | s_cfg->PchLockDownGlobalSmi = 0; |
| 130 | s_cfg->PchLockDownBiosInterface = 0; |
| 131 | s_cfg->PchUnlockGpioPads = 1; |
| 132 | s_cfg->RtcMemoryLock = 0; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 133 | } else { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 134 | s_cfg->PchLockDownGlobalSmi = 1; |
| 135 | s_cfg->PchLockDownBiosInterface = 1; |
| 136 | s_cfg->PchUnlockGpioPads = 0; |
| 137 | s_cfg->RtcMemoryLock = 1; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 138 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 139 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 140 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 141 | static void fill_fsps_xhci_params(FSP_S_CONFIG *s_cfg, |
| 142 | const struct soc_intel_alderlake_config *config) |
| 143 | { |
| 144 | int i; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 145 | /* USB */ |
| 146 | for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 147 | s_cfg->PortUsb20Enable[i] = config->usb2_ports[i].enable; |
| 148 | s_cfg->Usb2PhyPetxiset[i] = config->usb2_ports[i].pre_emp_bias; |
| 149 | s_cfg->Usb2PhyTxiset[i] = config->usb2_ports[i].tx_bias; |
| 150 | s_cfg->Usb2PhyPredeemp[i] = config->usb2_ports[i].tx_emp_enable; |
| 151 | s_cfg->Usb2PhyPehalfbit[i] = config->usb2_ports[i].pre_emp_bit; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 152 | |
| 153 | if (config->usb2_ports[i].enable) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 154 | s_cfg->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 155 | else |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 156 | s_cfg->Usb2OverCurrentPin[i] = OC_SKIP; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 160 | s_cfg->PortUsb30Enable[i] = config->usb3_ports[i].enable; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 161 | if (config->usb3_ports[i].enable) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 162 | s_cfg->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 163 | else |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 164 | s_cfg->Usb3OverCurrentPin[i] = OC_SKIP; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 165 | |
| 166 | if (config->usb3_ports[i].tx_de_emp) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 167 | s_cfg->Usb3HsioTxDeEmphEnable[i] = 1; |
| 168 | s_cfg->Usb3HsioTxDeEmph[i] = config->usb3_ports[i].tx_de_emp; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 169 | } |
| 170 | if (config->usb3_ports[i].tx_downscale_amp) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 171 | s_cfg->Usb3HsioTxDownscaleAmpEnable[i] = 1; |
| 172 | s_cfg->Usb3HsioTxDownscaleAmp[i] = |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 173 | config->usb3_ports[i].tx_downscale_amp; |
| 174 | } |
| 175 | } |
| 176 | |
Maulik V Vaghela | 6935350 | 2021-04-14 14:01:02 +0530 | [diff] [blame] | 177 | for (i = 0; i < ARRAY_SIZE(config->tcss_ports); i++) { |
| 178 | if (config->tcss_ports[i].enable) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 179 | s_cfg->CpuUsb3OverCurrentPin[i] = config->tcss_ports[i].ocpin; |
Maulik V Vaghela | 6935350 | 2021-04-14 14:01:02 +0530 | [diff] [blame] | 180 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 181 | } |
Maulik V Vaghela | 6935350 | 2021-04-14 14:01:02 +0530 | [diff] [blame] | 182 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 183 | static void fill_fsps_xdci_params(FSP_S_CONFIG *s_cfg, |
| 184 | const struct soc_intel_alderlake_config *config) |
| 185 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 186 | /* Enable xDCI controller if enabled in devicetree and allowed */ |
Subrata Banik | e633804 | 2021-06-21 19:26:10 +0530 | [diff] [blame] | 187 | if (!xdci_can_enable()) |
| 188 | devfn_disable(pci_root_bus(), PCH_DEVFN_USBOTG); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 189 | s_cfg->XdciEnable = is_devfn_enabled(PCH_DEVFN_USBOTG); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 190 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 191 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 192 | static void fill_fsps_uart_params(FSP_S_CONFIG *s_cfg, |
| 193 | const struct soc_intel_alderlake_config *config) |
| 194 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 195 | /* PCH UART selection for FSP Debug */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 196 | s_cfg->SerialIoDebugUartNumber = CONFIG_UART_FOR_CONSOLE; |
| 197 | ASSERT(ARRAY_SIZE(s_cfg->SerialIoUartAutoFlow) > CONFIG_UART_FOR_CONSOLE); |
| 198 | s_cfg->SerialIoUartAutoFlow[CONFIG_UART_FOR_CONSOLE] = 0; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 199 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 200 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 201 | static void fill_fsps_sata_params(FSP_S_CONFIG *s_cfg, |
| 202 | const struct soc_intel_alderlake_config *config) |
| 203 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 204 | /* SATA */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 205 | s_cfg->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA); |
| 206 | if (s_cfg->SataEnable) { |
| 207 | s_cfg->SataMode = config->SataMode; |
| 208 | s_cfg->SataSalpSupport = config->SataSalpSupport; |
| 209 | memcpy(s_cfg->SataPortsEnable, config->SataPortsEnable, |
| 210 | sizeof(s_cfg->SataPortsEnable)); |
| 211 | memcpy(s_cfg->SataPortsDevSlp, config->SataPortsDevSlp, |
| 212 | sizeof(s_cfg->SataPortsDevSlp)); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | /* |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 216 | * Power Optimizer for SATA. |
| 217 | * SataPwrOptimizeDisable is default to 0. |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 218 | * Boards not needing the optimizers explicitly disables them by setting |
| 219 | * these disable variables to 1 in devicetree overrides. |
| 220 | */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 221 | s_cfg->SataPwrOptEnable = !(config->SataPwrOptimizeDisable); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 222 | /* |
| 223 | * Enable DEVSLP Idle Timeout settings DmVal and DitoVal. |
| 224 | * SataPortsDmVal is the DITO multiplier. Default is 15. |
| 225 | * SataPortsDitoVal is the DEVSLP Idle Timeout (DITO), Default is 625ms. |
| 226 | * The default values can be changed from devicetree. |
| 227 | */ |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 228 | for (size_t i = 0; i < ARRAY_SIZE(config->SataPortsEnableDitoConfig); i++) { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 229 | if (config->SataPortsEnableDitoConfig[i]) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 230 | s_cfg->SataPortsDmVal[i] = config->SataPortsDmVal[i]; |
| 231 | s_cfg->SataPortsDitoVal[i] = config->SataPortsDitoVal[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 232 | } |
| 233 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 234 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 235 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 236 | static void fill_fsps_thermal_params(FSP_S_CONFIG *s_cfg, |
| 237 | const struct soc_intel_alderlake_config *config) |
| 238 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 239 | /* Enable TCPU for processor thermal control */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 240 | s_cfg->Device4Enable = is_devfn_enabled(SA_DEVFN_DPTF); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 241 | |
| 242 | /* Set TccActivationOffset */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 243 | s_cfg->TccActivationOffset = config->tcc_offset; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 244 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 245 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 246 | static void fill_fsps_lan_params(FSP_S_CONFIG *s_cfg, |
| 247 | const struct soc_intel_alderlake_config *config) |
| 248 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 249 | /* LAN */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 250 | s_cfg->PchLanEnable = is_devfn_enabled(PCH_DEVFN_GBE); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 251 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 252 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 253 | static void fill_fsps_cnvi_params(FSP_S_CONFIG *s_cfg, |
| 254 | const struct soc_intel_alderlake_config *config) |
| 255 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 256 | /* CNVi */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 257 | s_cfg->CnviMode = is_devfn_enabled(PCH_DEVFN_CNVI_WIFI); |
| 258 | s_cfg->CnviBtCore = config->CnviBtCore; |
| 259 | s_cfg->CnviBtAudioOffload = config->CnviBtAudioOffload; |
Cliff Huang | bc1941f | 2021-02-10 17:41:41 -0800 | [diff] [blame] | 260 | /* Assert if CNVi BT is enabled without CNVi being enabled. */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 261 | assert(s_cfg->CnviMode || !s_cfg->CnviBtCore); |
Cliff Huang | bc1941f | 2021-02-10 17:41:41 -0800 | [diff] [blame] | 262 | /* Assert if CNVi BT offload is enabled without CNVi BT being enabled. */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 263 | assert(s_cfg->CnviBtCore || !s_cfg->CnviBtAudioOffload); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 264 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 265 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 266 | static void fill_fsps_vmd_params(FSP_S_CONFIG *s_cfg, |
| 267 | const struct soc_intel_alderlake_config *config) |
| 268 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 269 | /* VMD */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 270 | s_cfg->VmdEnable = is_devfn_enabled(SA_DEVFN_VMD); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 271 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 272 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 273 | static void fill_fsps_thc_params(FSP_S_CONFIG *s_cfg, |
| 274 | const struct soc_intel_alderlake_config *config) |
| 275 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 276 | /* THC */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 277 | s_cfg->ThcPort0Assignment = is_devfn_enabled(PCH_DEVFN_THC0) ? THC_0 : THC_NONE; |
| 278 | 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] | 279 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 280 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 281 | static void fill_fsps_tbt_params(FSP_S_CONFIG *s_cfg, |
| 282 | const struct soc_intel_alderlake_config *config) |
| 283 | { |
Bernardo Perez Priego | 095f97b | 2021-05-18 18:39:19 -0700 | [diff] [blame] | 284 | /* USB4/TBT */ |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 285 | for (int i = 0; i < ARRAY_SIZE(s_cfg->ITbtPcieRootPortEn); i++) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 286 | s_cfg->ITbtPcieRootPortEn[i] = is_devfn_enabled(SA_DEVFN_TBT(i)); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 287 | } |
Bernardo Perez Priego | 095f97b | 2021-05-18 18:39:19 -0700 | [diff] [blame] | 288 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 289 | static void fill_fsps_8254_params(FSP_S_CONFIG *s_cfg, |
| 290 | const struct soc_intel_alderlake_config *config) |
| 291 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 292 | /* Legacy 8254 timer support */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 293 | s_cfg->Enable8254ClockGating = !CONFIG(USE_LEGACY_8254_TIMER); |
| 294 | s_cfg->Enable8254ClockGatingOnS3 = !CONFIG(USE_LEGACY_8254_TIMER); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 295 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 296 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 297 | static void fill_fsps_storage_params(FSP_S_CONFIG *s_cfg, |
| 298 | const struct soc_intel_alderlake_config *config) |
| 299 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 300 | /* Enable Hybrid storage auto detection */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 301 | s_cfg->HybridStorageMode = config->HybridStorageMode; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 302 | } |
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 | static void fill_fsps_pcie_params(FSP_S_CONFIG *s_cfg, |
| 305 | const struct soc_intel_alderlake_config *config) |
| 306 | { |
| 307 | uint32_t enable_mask = pcie_rp_enable_mask(get_pch_pcie_rp_table()); |
| 308 | for (int i = 0; i < CONFIG_MAX_PCH_ROOT_PORTS; i++) { |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 309 | if (!(enable_mask & BIT(i))) |
| 310 | continue; |
| 311 | const struct pcie_rp_config *rp_cfg = &config->pch_pcie_rp[i]; |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 312 | s_cfg->PcieRpL1Substates[i] = |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 313 | get_l1_substate_control(rp_cfg->PcieRpL1Substates); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 314 | s_cfg->PcieRpLtrEnable[i] = !!(rp_cfg->flags & PCIE_RP_LTR); |
| 315 | s_cfg->PcieRpAdvancedErrorReporting[i] = !!(rp_cfg->flags & PCIE_RP_AER); |
| 316 | s_cfg->PcieRpHotPlug[i] = !!(rp_cfg->flags & PCIE_RP_HOTPLUG); |
| 317 | s_cfg->PcieRpClkReqDetect[i] = !!(rp_cfg->flags & PCIE_RP_CLK_REQ_DETECT); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 318 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 319 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 320 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 321 | static void fill_fsps_misc_power_params(FSP_S_CONFIG *s_cfg, |
| 322 | const struct soc_intel_alderlake_config *config) |
| 323 | { |
| 324 | /* |
| 325 | * Power Optimizer for DMI |
| 326 | * DmiPwrOptimizeDisable is default to 0. |
| 327 | * Boards not needing the optimizers explicitly disables them by setting |
| 328 | * these disable variables to 1 in devicetree overrides. |
| 329 | */ |
| 330 | s_cfg->PchPwrOptEnable = !(config->DmiPwrOptimizeDisable); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 331 | s_cfg->PmSupport = 1; |
| 332 | s_cfg->Hwp = 1; |
| 333 | s_cfg->Cx = 1; |
| 334 | s_cfg->PsOnEnable = 1; |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 335 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 336 | |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 337 | static void arch_silicon_init_params(FSPS_ARCH_UPD *s_arch_cfg) |
| 338 | { |
| 339 | /* EnableMultiPhaseSiliconInit for running MultiPhaseSiInit */ |
| 340 | s_arch_cfg->EnableMultiPhaseSiliconInit = 1; |
| 341 | } |
| 342 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 343 | static void soc_silicon_init_params(FSP_S_CONFIG *s_cfg, |
| 344 | struct soc_intel_alderlake_config *config) |
| 345 | { |
| 346 | /* Override settings per board if required. */ |
| 347 | mainboard_update_soc_chip_config(config); |
| 348 | |
V Sowmya | 6464c2a | 2021-06-25 10:20:25 +0530 | [diff] [blame^] | 349 | const void (*fill_fsps_params[])(FSP_S_CONFIG *s_cfg, |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 350 | const struct soc_intel_alderlake_config *config) = { |
| 351 | fill_fsps_lpss_params, |
| 352 | fill_fsps_cpu_params, |
| 353 | fill_fsps_igd_params, |
| 354 | fill_fsps_tcss_params, |
| 355 | fill_fsps_chipset_lockdown_params, |
| 356 | fill_fsps_xhci_params, |
| 357 | fill_fsps_xdci_params, |
| 358 | fill_fsps_uart_params, |
| 359 | fill_fsps_sata_params, |
| 360 | fill_fsps_thermal_params, |
| 361 | fill_fsps_lan_params, |
| 362 | fill_fsps_cnvi_params, |
| 363 | fill_fsps_vmd_params, |
| 364 | fill_fsps_thc_params, |
| 365 | fill_fsps_tbt_params, |
| 366 | fill_fsps_8254_params, |
| 367 | fill_fsps_storage_params, |
| 368 | fill_fsps_pcie_params, |
| 369 | fill_fsps_misc_power_params, |
| 370 | }; |
| 371 | |
| 372 | for (size_t i = 0; i < ARRAY_SIZE(fill_fsps_params); i++) |
| 373 | fill_fsps_params[i](s_cfg, config); |
| 374 | } |
| 375 | |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 376 | /* UPD parameters to be initialized before SiliconInit */ |
| 377 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) |
| 378 | { |
| 379 | struct soc_intel_alderlake_config *config; |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 380 | FSP_S_CONFIG *s_cfg = &supd->FspsConfig; |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 381 | FSPS_ARCH_UPD *s_arch_cfg = &supd->FspsArchUpd; |
| 382 | |
| 383 | config = config_of_soc(); |
| 384 | |
| 385 | arch_silicon_init_params(s_arch_cfg); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 386 | soc_silicon_init_params(s_cfg, config); |
| 387 | mainboard_silicon_init_params(s_cfg); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 388 | } |
| 389 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 390 | /* |
| 391 | * Callbacks for SoC/Mainboard specific overrides for FspMultiPhaseSiInit |
| 392 | * This platform supports below MultiPhaseSIInit Phase(s): |
| 393 | * Phase | FSP return point | Purpose |
| 394 | * ------- + ------------------------------------------------ + ------------------------------- |
| 395 | * 1 | After TCSS initialization completed | for TCSS specific init |
| 396 | */ |
| 397 | void platform_fsp_multi_phase_init_cb(uint32_t phase_index) |
| 398 | { |
| 399 | switch (phase_index) { |
| 400 | case 1: |
| 401 | /* TCSS specific initialization here */ |
Deepti Deshatty | 8e7facf | 2021-05-12 17:45:37 +0530 | [diff] [blame] | 402 | printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n", |
| 403 | __FILE__, __func__); |
| 404 | |
| 405 | if (CONFIG(SOC_INTEL_COMMON_BLOCK_TCSS)) { |
| 406 | const config_t *config = config_of_soc(); |
| 407 | tcss_configure(config->typec_aux_bias_pads); |
| 408 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 409 | break; |
| 410 | default: |
| 411 | break; |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | /* Mainboard GPIO Configuration */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 416 | __weak void mainboard_silicon_init_params(FSP_S_CONFIG *s_cfg) |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 417 | { |
| 418 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 419 | } |