Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <assert.h> |
| 4 | #include <console/console.h> |
| 5 | #include <cpu/x86/msr.h> |
Meera Ravindranath | 3b03798 | 2021-11-11 18:02:13 +0530 | [diff] [blame] | 6 | #include <cpu/intel/cpu_ids.h> |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 7 | #include <device/device.h> |
| 8 | #include <fsp/util.h> |
| 9 | #include <intelblocks/cpulib.h> |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 10 | #include <intelblocks/pcie_rp.h> |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 11 | #include <soc/gpio_soc_defs.h> |
| 12 | #include <soc/iomap.h> |
| 13 | #include <soc/msr.h> |
| 14 | #include <soc/pci_devs.h> |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 15 | #include <soc/pcie.h> |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 16 | #include <soc/romstage.h> |
| 17 | #include <soc/soc_chip.h> |
| 18 | #include <string.h> |
| 19 | |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 20 | #define FSP_CLK_NOTUSED 0xFF |
| 21 | #define FSP_CLK_LAN 0x70 |
| 22 | #define FSP_CLK_FREE_RUNNING 0x80 |
| 23 | |
| 24 | #define CPU_PCIE_BASE 0x40 |
| 25 | |
Meera Ravindranath | a3f7deb | 2021-03-26 15:10:48 +0530 | [diff] [blame] | 26 | enum vtd_base_index_type { |
| 27 | VTD_GFX, |
| 28 | VTD_IPU, |
| 29 | VTD_VTVCO, |
Sridhar Siricilla | d047927 | 2021-05-28 20:00:02 +0530 | [diff] [blame] | 30 | VTD_TBT0, |
| 31 | VTD_TBT1, |
| 32 | VTD_TBT2, |
| 33 | VTD_TBT3, |
Meera Ravindranath | a3f7deb | 2021-03-26 15:10:48 +0530 | [diff] [blame] | 34 | }; |
| 35 | |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 36 | static uint8_t clk_src_to_fsp(enum pcie_rp_type type, int rp_number) |
| 37 | { |
Tim Wawrzynczak | 461ff1d | 2021-12-02 16:16:48 -0700 | [diff] [blame] | 38 | assert(type == PCIE_RP_PCH || type == PCIE_RP_CPU); |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 39 | |
Tim Wawrzynczak | 461ff1d | 2021-12-02 16:16:48 -0700 | [diff] [blame] | 40 | if (type == PCIE_RP_PCH) |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 41 | return rp_number; |
Tim Wawrzynczak | 461ff1d | 2021-12-02 16:16:48 -0700 | [diff] [blame] | 42 | else // type == PCIE_RP_CPU |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 43 | return CPU_PCIE_BASE + rp_number; |
| 44 | } |
| 45 | |
| 46 | static void pcie_rp_init(FSP_M_CONFIG *m_cfg, uint32_t en_mask, enum pcie_rp_type type, |
| 47 | const struct pcie_rp_config *cfg, size_t cfg_count) |
| 48 | { |
| 49 | size_t i; |
Kane Chen | ff553ba | 2021-12-16 17:46:33 +0800 | [diff] [blame] | 50 | /* bitmask to save the status of clkreq assignment */ |
| 51 | static unsigned int clk_req_mapping = 0; |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 52 | |
| 53 | for (i = 0; i < cfg_count; i++) { |
| 54 | if (!(en_mask & BIT(i))) |
| 55 | continue; |
| 56 | if (cfg[i].flags & PCIE_RP_CLK_SRC_UNUSED) |
| 57 | continue; |
Kane Chen | ff553ba | 2021-12-16 17:46:33 +0800 | [diff] [blame] | 58 | if (clk_req_mapping & (1 << cfg[i].clk_req)) |
| 59 | printk(BIOS_WARNING, "Found overlapped clkreq assignment on clk req %d\n" |
| 60 | , cfg[i].clk_req); |
| 61 | if (!(cfg[i].flags & PCIE_RP_CLK_REQ_UNUSED)) { |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 62 | m_cfg->PcieClkSrcClkReq[cfg[i].clk_src] = cfg[i].clk_req; |
Kane Chen | ff553ba | 2021-12-16 17:46:33 +0800 | [diff] [blame] | 63 | clk_req_mapping |= 1 << cfg[i].clk_req; |
| 64 | } |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 65 | m_cfg->PcieClkSrcUsage[cfg[i].clk_src] = clk_src_to_fsp(type, i); |
| 66 | } |
| 67 | } |
| 68 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 69 | static void fill_fspm_pcie_rp_params(FSP_M_CONFIG *m_cfg, |
| 70 | const struct soc_intel_alderlake_config *config) |
| 71 | { |
| 72 | /* Disable all PCIe clock sources by default. And set RP irrelevant clock. */ |
| 73 | unsigned int i; |
| 74 | |
| 75 | for (i = 0; i < CONFIG_MAX_PCIE_CLOCK_SRC; i++) { |
| 76 | if (config->pcie_clk_config_flag[i] & PCIE_CLK_FREE_RUNNING) |
| 77 | m_cfg->PcieClkSrcUsage[i] = FSP_CLK_FREE_RUNNING; |
| 78 | else if (config->pcie_clk_config_flag[i] & PCIE_CLK_LAN) |
| 79 | m_cfg->PcieClkSrcUsage[i] = FSP_CLK_LAN; |
| 80 | else |
| 81 | m_cfg->PcieClkSrcUsage[i] = FSP_CLK_NOTUSED; |
| 82 | m_cfg->PcieClkSrcClkReq[i] = FSP_CLK_NOTUSED; |
| 83 | } |
| 84 | |
| 85 | /* Configure PCH PCIE ports */ |
| 86 | m_cfg->PcieRpEnableMask = pcie_rp_enable_mask(get_pch_pcie_rp_table()); |
Tim Wawrzynczak | 461ff1d | 2021-12-02 16:16:48 -0700 | [diff] [blame] | 87 | pcie_rp_init(m_cfg, m_cfg->PcieRpEnableMask, PCIE_RP_PCH, config->pch_pcie_rp, |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 88 | CONFIG_MAX_PCH_ROOT_PORTS); |
| 89 | |
| 90 | /* Configure CPU PCIE ports */ |
| 91 | m_cfg->CpuPcieRpEnableMask = pcie_rp_enable_mask(get_cpu_pcie_rp_table()); |
Tim Wawrzynczak | 461ff1d | 2021-12-02 16:16:48 -0700 | [diff] [blame] | 92 | pcie_rp_init(m_cfg, m_cfg->CpuPcieRpEnableMask, PCIE_RP_CPU, config->cpu_pcie_rp, |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 93 | CONFIG_MAX_CPU_ROOT_PORTS); |
| 94 | } |
| 95 | |
| 96 | static void fill_fspm_igd_params(FSP_M_CONFIG *m_cfg, |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 97 | const struct soc_intel_alderlake_config *config) |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 98 | { |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 99 | unsigned int i; |
Subrata Banik | 8a18bd8 | 2021-06-09 21:57:49 +0530 | [diff] [blame] | 100 | const struct ddi_port_upds { |
| 101 | uint8_t *ddc; |
| 102 | uint8_t *hpd; |
| 103 | } ddi_port_upds[] = { |
| 104 | [DDI_PORT_A] = {&m_cfg->DdiPortADdc, &m_cfg->DdiPortAHpd}, |
| 105 | [DDI_PORT_B] = {&m_cfg->DdiPortBDdc, &m_cfg->DdiPortBHpd}, |
| 106 | [DDI_PORT_C] = {&m_cfg->DdiPortCDdc, &m_cfg->DdiPortCHpd}, |
| 107 | [DDI_PORT_1] = {&m_cfg->DdiPort1Ddc, &m_cfg->DdiPort1Hpd}, |
| 108 | [DDI_PORT_2] = {&m_cfg->DdiPort2Ddc, &m_cfg->DdiPort2Hpd}, |
| 109 | [DDI_PORT_3] = {&m_cfg->DdiPort3Ddc, &m_cfg->DdiPort3Hpd}, |
| 110 | [DDI_PORT_4] = {&m_cfg->DdiPort4Ddc, &m_cfg->DdiPort4Hpd}, |
| 111 | }; |
Subrata Banik | 50134ec | 2021-06-09 04:14:50 +0530 | [diff] [blame] | 112 | m_cfg->InternalGfx = !CONFIG(SOC_INTEL_DISABLE_IGD) && is_devfn_enabled(SA_DEVFN_IGD); |
Subrata Banik | 8a18bd8 | 2021-06-09 21:57:49 +0530 | [diff] [blame] | 113 | if (m_cfg->InternalGfx) { |
| 114 | /* IGD is enabled, set IGD stolen size to 60MB. */ |
| 115 | m_cfg->IgdDvmt50PreAlloc = IGD_SM_60MB; |
| 116 | /* DP port config */ |
| 117 | m_cfg->DdiPortAConfig = config->DdiPortAConfig; |
| 118 | m_cfg->DdiPortBConfig = config->DdiPortBConfig; |
| 119 | for (i = 0; i < ARRAY_SIZE(ddi_port_upds); i++) { |
| 120 | *ddi_port_upds[i].ddc = !!(config->ddi_ports_config[i] & |
| 121 | DDI_ENABLE_DDC); |
| 122 | *ddi_port_upds[i].hpd = !!(config->ddi_ports_config[i] & |
| 123 | DDI_ENABLE_HPD); |
| 124 | } |
| 125 | } else { |
| 126 | /* IGD is disabled, skip IGD init in FSP. */ |
| 127 | m_cfg->IgdDvmt50PreAlloc = 0; |
| 128 | /* DP port config */ |
| 129 | m_cfg->DdiPortAConfig = 0; |
| 130 | m_cfg->DdiPortBConfig = 0; |
| 131 | for (i = 0; i < ARRAY_SIZE(ddi_port_upds); i++) { |
| 132 | *ddi_port_upds[i].ddc = 0; |
| 133 | *ddi_port_upds[i].hpd = 0; |
| 134 | } |
| 135 | } |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 136 | } |
| 137 | static void fill_fspm_mrc_params(FSP_M_CONFIG *m_cfg, |
| 138 | const struct soc_intel_alderlake_config *config) |
| 139 | { |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 140 | m_cfg->SaGv = config->SaGv; |
| 141 | m_cfg->RMT = config->RMT; |
Casper Chang | 8fcefd3 | 2021-09-22 22:35:54 -0400 | [diff] [blame] | 142 | if (config->MaxDramSpeed) |
| 143 | m_cfg->DdrFreqLimit = config->MaxDramSpeed; |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 144 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 145 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 146 | static void fill_fspm_cpu_params(FSP_M_CONFIG *m_cfg, |
| 147 | const struct soc_intel_alderlake_config *config) |
| 148 | { |
| 149 | m_cfg->TsegSize = CONFIG_SMM_TSEG_SIZE; |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 150 | /* CpuRatio Settings */ |
| 151 | if (config->cpu_ratio_override) |
| 152 | m_cfg->CpuRatio = config->cpu_ratio_override; |
| 153 | else |
| 154 | /* Set CpuRatio to match existing MSR value */ |
| 155 | m_cfg->CpuRatio = (rdmsr(MSR_FLEX_RATIO).lo >> 8) & 0xff; |
| 156 | |
Subrata Banik | 80835a1 | 2020-09-23 17:46:11 +0530 | [diff] [blame] | 157 | m_cfg->PrmrrSize = get_valid_prmrr_size(); |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 158 | m_cfg->EnableC6Dram = config->enable_c6dram; |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 159 | /* Enable Hyper Threading */ |
| 160 | m_cfg->HyperThreading = 1; |
| 161 | } |
| 162 | |
| 163 | static void fill_fspm_security_params(FSP_M_CONFIG *m_cfg, |
| 164 | const struct soc_intel_alderlake_config *config) |
| 165 | { |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 166 | /* Disable BIOS Guard */ |
| 167 | m_cfg->BiosGuard = 0; |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 168 | m_cfg->TmeEnable = CONFIG(INTEL_TME); |
| 169 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 170 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 171 | static void fill_fspm_uart_params(FSP_M_CONFIG *m_cfg, |
| 172 | const struct soc_intel_alderlake_config *config) |
| 173 | { |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 174 | /* UART Debug Log */ |
| 175 | m_cfg->PcdDebugInterfaceFlags = CONFIG(DRIVERS_UART_8250IO) ? |
| 176 | DEBUG_INTERFACE_UART_8250IO : DEBUG_INTERFACE_LPSS_SERIAL_IO; |
| 177 | if (CONFIG(DRIVERS_UART_8250IO)) |
| 178 | m_cfg->PcdIsaSerialUartBase = ISA_SERIAL_BASE_ADDR_3F8; |
| 179 | m_cfg->SerialIoUartDebugMode = PchSerialIoSkipInit; |
| 180 | m_cfg->SerialIoUartDebugControllerNumber = CONFIG_UART_FOR_CONSOLE; |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 181 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 182 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 183 | static void fill_fspm_ipu_params(FSP_M_CONFIG *m_cfg, |
| 184 | const struct soc_intel_alderlake_config *config) |
| 185 | { |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 186 | /* Image clock: disable all clocks for bypassing FSP pin mux */ |
| 187 | memset(m_cfg->ImguClkOutEn, 0, sizeof(m_cfg->ImguClkOutEn)); |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 188 | /* IPU */ |
| 189 | m_cfg->SaIpuEnable = is_devfn_enabled(SA_DEVFN_IPU); |
| 190 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 191 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 192 | static void fill_fspm_smbus_params(FSP_M_CONFIG *m_cfg, |
| 193 | const struct soc_intel_alderlake_config *config) |
| 194 | { |
| 195 | m_cfg->SmbusEnable = is_devfn_enabled(PCH_DEVFN_SMBUS); |
| 196 | } |
| 197 | |
| 198 | static void fill_fspm_misc_params(FSP_M_CONFIG *m_cfg, |
| 199 | const struct soc_intel_alderlake_config *config) |
| 200 | { |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 201 | /* Disable Lock PCU Thermal Management registers */ |
| 202 | m_cfg->LockPTMregs = 0; |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 203 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 204 | /* Skip CPU replacement check */ |
| 205 | m_cfg->SkipCpuReplacementCheck = !config->CpuReplacementCheck; |
| 206 | |
| 207 | /* Skip GPIO configuration from FSP */ |
| 208 | m_cfg->GpioOverride = 0x1; |
MAULIK V VAGHELA | 9a7fbbc | 2021-10-13 11:52:17 +0530 | [diff] [blame] | 209 | |
Ronak Kanabar | fc69b9d | 2021-10-06 13:02:34 +0530 | [diff] [blame] | 210 | /* CNVi DDR RFI Mitigation */ |
| 211 | m_cfg->CnviDdrRfim = config->CnviDdrRfim; |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | static void fill_fspm_audio_params(FSP_M_CONFIG *m_cfg, |
| 215 | const struct soc_intel_alderlake_config *config) |
| 216 | { |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 217 | /* Audio: HDAUDIO_LINK_MODE I2S/SNDW */ |
Subrata Banik | 50134ec | 2021-06-09 04:14:50 +0530 | [diff] [blame] | 218 | m_cfg->PchHdaEnable = is_devfn_enabled(PCH_DEVFN_HDA); |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 219 | m_cfg->PchHdaDspEnable = config->PchHdaDspEnable; |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 220 | m_cfg->PchHdaIDispLinkTmode = config->PchHdaIDispLinkTmode; |
| 221 | m_cfg->PchHdaIDispLinkFrequency = config->PchHdaIDispLinkFrequency; |
| 222 | m_cfg->PchHdaIDispCodecDisconnect = !config->PchHdaIDispCodecEnable; |
Furquan Shaikh | c1c1ba5 | 2021-04-20 16:57:59 -0700 | [diff] [blame] | 223 | /* |
| 224 | * All the PchHdaAudioLink{Hda|Dmic|Ssp|Sndw}Enable UPDs are used by FSP only to |
| 225 | * configure GPIO pads for audio. Mainboard is expected to perform all GPIO |
| 226 | * configuration in coreboot and hence these UPDs are set to 0 to skip FSP GPIO |
| 227 | * configuration for audio pads. |
| 228 | */ |
| 229 | m_cfg->PchHdaAudioLinkHdaEnable = 0; |
| 230 | memset(m_cfg->PchHdaAudioLinkDmicEnable, 0, sizeof(m_cfg->PchHdaAudioLinkDmicEnable)); |
| 231 | memset(m_cfg->PchHdaAudioLinkSspEnable, 0, sizeof(m_cfg->PchHdaAudioLinkSspEnable)); |
| 232 | memset(m_cfg->PchHdaAudioLinkSndwEnable, 0, sizeof(m_cfg->PchHdaAudioLinkSndwEnable)); |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 233 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 234 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 235 | static void fill_fspm_ish_params(FSP_M_CONFIG *m_cfg, |
| 236 | const struct soc_intel_alderlake_config *config) |
| 237 | { |
Subrata Banik | 50134ec | 2021-06-09 04:14:50 +0530 | [diff] [blame] | 238 | m_cfg->PchIshEnable = is_devfn_enabled(PCH_DEVFN_ISH); |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 239 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 240 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 241 | static void fill_fspm_tcss_params(FSP_M_CONFIG *m_cfg, |
| 242 | const struct soc_intel_alderlake_config *config) |
| 243 | { |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 244 | /* Tcss USB */ |
Subrata Banik | 50134ec | 2021-06-09 04:14:50 +0530 | [diff] [blame] | 245 | m_cfg->TcssXhciEn = is_devfn_enabled(SA_DEVFN_TCSS_XHCI); |
| 246 | m_cfg->TcssXdciEn = is_devfn_enabled(SA_DEVFN_TCSS_XDCI); |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 247 | |
| 248 | /* TCSS DMA */ |
Subrata Banik | 50134ec | 2021-06-09 04:14:50 +0530 | [diff] [blame] | 249 | m_cfg->TcssDma0En = is_devfn_enabled(SA_DEVFN_TCSS_DMA0); |
| 250 | m_cfg->TcssDma1En = is_devfn_enabled(SA_DEVFN_TCSS_DMA1); |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 251 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 252 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 253 | static void fill_fspm_usb4_params(FSP_M_CONFIG *m_cfg, |
| 254 | const struct soc_intel_alderlake_config *config) |
| 255 | { |
Subrata Banik | 50134ec | 2021-06-09 04:14:50 +0530 | [diff] [blame] | 256 | m_cfg->TcssItbtPcie0En = is_devfn_enabled(SA_DEVFN_TBT0); |
| 257 | m_cfg->TcssItbtPcie1En = is_devfn_enabled(SA_DEVFN_TBT1); |
| 258 | m_cfg->TcssItbtPcie2En = is_devfn_enabled(SA_DEVFN_TBT2); |
| 259 | m_cfg->TcssItbtPcie3En = is_devfn_enabled(SA_DEVFN_TBT3); |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 260 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 261 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 262 | static void fill_fspm_vtd_params(FSP_M_CONFIG *m_cfg, |
| 263 | const struct soc_intel_alderlake_config *config) |
| 264 | { |
Meera Ravindranath | 3b03798 | 2021-11-11 18:02:13 +0530 | [diff] [blame] | 265 | const uint32_t cpuid = cpu_get_cpuid(); |
| 266 | |
| 267 | /* Disable VT-d for early silicon steppings as it results in a CPU hard hang */ |
| 268 | if (cpuid == CPUID_ALDERLAKE_A0 || cpuid == CPUID_ALDERLAKE_A1) { |
| 269 | m_cfg->VtdDisable = 1; |
| 270 | return; |
| 271 | } |
| 272 | |
Meera Ravindranath | a3f7deb | 2021-03-26 15:10:48 +0530 | [diff] [blame] | 273 | m_cfg->VtdBaseAddress[VTD_GFX] = GFXVT_BASE_ADDRESS; |
| 274 | m_cfg->VtdBaseAddress[VTD_IPU] = IPUVT_BASE_ADDRESS; |
| 275 | m_cfg->VtdBaseAddress[VTD_VTVCO] = VTVC0_BASE_ADDRESS; |
| 276 | |
| 277 | m_cfg->VtdDisable = 0; |
| 278 | m_cfg->VtdIopEnable = !m_cfg->VtdDisable; |
| 279 | m_cfg->VtdIgdEnable = m_cfg->InternalGfx; |
| 280 | m_cfg->VtdIpuEnable = m_cfg->SaIpuEnable; |
| 281 | |
| 282 | if (m_cfg->VtdIgdEnable && m_cfg->VtdBaseAddress[VTD_GFX] == 0) { |
| 283 | m_cfg->VtdIgdEnable = 0; |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame] | 284 | printk(BIOS_ERR, "Requested IGD VT-d, but GFXVT_BASE_ADDRESS is 0\n"); |
Meera Ravindranath | a3f7deb | 2021-03-26 15:10:48 +0530 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | if (m_cfg->VtdIpuEnable && m_cfg->VtdBaseAddress[VTD_IPU] == 0) { |
| 288 | m_cfg->VtdIpuEnable = 0; |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame] | 289 | printk(BIOS_ERR, "Requested IPU VT-d, but IPUVT_BASE_ADDRESS is 0\n"); |
Meera Ravindranath | a3f7deb | 2021-03-26 15:10:48 +0530 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | if (!m_cfg->VtdDisable && m_cfg->VtdBaseAddress[VTD_VTVCO] == 0) { |
| 293 | m_cfg->VtdDisable = 1; |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame] | 294 | printk(BIOS_ERR, "Requested VT-d, but VTVCO_BASE_ADDRESS is 0\n"); |
Meera Ravindranath | a3f7deb | 2021-03-26 15:10:48 +0530 | [diff] [blame] | 295 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 296 | |
Sridhar Siricilla | d047927 | 2021-05-28 20:00:02 +0530 | [diff] [blame] | 297 | if (m_cfg->TcssDma0En || m_cfg->TcssDma1En) |
| 298 | m_cfg->VtdItbtEnable = 1; |
| 299 | |
| 300 | if (m_cfg->TcssItbtPcie0En) |
| 301 | m_cfg->VtdBaseAddress[VTD_TBT0] = TBT0_BASE_ADDRESS; |
| 302 | |
| 303 | if (m_cfg->TcssItbtPcie1En) |
| 304 | m_cfg->VtdBaseAddress[VTD_TBT1] = TBT1_BASE_ADDRESS; |
| 305 | |
| 306 | if (m_cfg->TcssItbtPcie2En) |
| 307 | m_cfg->VtdBaseAddress[VTD_TBT2] = TBT2_BASE_ADDRESS; |
| 308 | |
| 309 | if (m_cfg->TcssItbtPcie3En) |
| 310 | m_cfg->VtdBaseAddress[VTD_TBT3] = TBT3_BASE_ADDRESS; |
| 311 | |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 312 | /* Change VmxEnable UPD value according to ENABLE_VMX Kconfig */ |
| 313 | m_cfg->VmxEnable = CONFIG(ENABLE_VMX); |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 314 | } |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 315 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 316 | static void fill_fspm_trace_params(FSP_M_CONFIG *m_cfg, |
| 317 | const struct soc_intel_alderlake_config *config) |
| 318 | { |
Subrata Banik | b4a169a | 2021-12-29 18:36:23 +0000 | [diff] [blame] | 319 | /* Set MRC debug level */ |
| 320 | m_cfg->SerialDebugMrcLevel = fsp_map_console_log_level(); |
| 321 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 322 | /* Set debug probe type */ |
| 323 | m_cfg->PlatformDebugConsent = CONFIG_SOC_INTEL_ALDERLAKE_DEBUG_CONSENT; |
Francois Toguo | cea4f92 | 2021-04-16 21:20:39 -0700 | [diff] [blame] | 324 | |
| 325 | /* CrashLog config */ |
Subrata Banik | 7b8d11b | 2021-07-14 13:11:53 +0530 | [diff] [blame] | 326 | m_cfg->CpuCrashLogDevice = CONFIG(SOC_INTEL_CRASHLOG) && is_devfn_enabled(SA_DEVFN_TMT); |
| 327 | m_cfg->CpuCrashLogEnable = m_cfg->CpuCrashLogDevice; |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 328 | } |
| 329 | |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 330 | static void soc_memory_init_params(FSP_M_CONFIG *m_cfg, |
| 331 | const struct soc_intel_alderlake_config *config) |
| 332 | { |
Arthur Heymans | 02967e6 | 2022-02-18 13:22:25 +0100 | [diff] [blame] | 333 | void (*const fill_fspm_params[])(FSP_M_CONFIG *m_cfg, |
Subrata Banik | 85c9dda | 2021-06-09 22:03:57 +0530 | [diff] [blame] | 334 | const struct soc_intel_alderlake_config *config) = { |
| 335 | fill_fspm_igd_params, |
| 336 | fill_fspm_mrc_params, |
| 337 | fill_fspm_cpu_params, |
| 338 | fill_fspm_security_params, |
| 339 | fill_fspm_uart_params, |
| 340 | fill_fspm_ipu_params, |
| 341 | fill_fspm_smbus_params, |
| 342 | fill_fspm_misc_params, |
| 343 | fill_fspm_audio_params, |
| 344 | fill_fspm_pcie_rp_params, |
| 345 | fill_fspm_ish_params, |
| 346 | fill_fspm_tcss_params, |
| 347 | fill_fspm_usb4_params, |
| 348 | fill_fspm_vtd_params, |
| 349 | fill_fspm_trace_params, |
| 350 | }; |
| 351 | |
| 352 | for (size_t i = 0; i < ARRAY_SIZE(fill_fspm_params); i++) |
| 353 | fill_fspm_params[i](m_cfg, config); |
| 354 | } |
| 355 | |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 356 | void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) |
| 357 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 358 | const struct soc_intel_alderlake_config *config; |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 359 | FSP_M_CONFIG *m_cfg = &mupd->FspmConfig; |
| 360 | |
| 361 | config = config_of_soc(); |
| 362 | |
| 363 | soc_memory_init_params(m_cfg, config); |
Zhuohao Lee | 09f3b6c | 2022-01-20 21:30:12 +0800 | [diff] [blame] | 364 | mainboard_memory_init_params(mupd); |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 365 | } |
| 366 | |
Zhuohao Lee | 09f3b6c | 2022-01-20 21:30:12 +0800 | [diff] [blame] | 367 | __weak void mainboard_memory_init_params(FSPM_UPD *memupd) |
Subrata Banik | 292afef | 2020-09-09 13:34:18 +0530 | [diff] [blame] | 368 | { |
| 369 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 370 | } |