Debian Codegraph @

src/soc/intel/jasperlake/fsp_params.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #include <assert.h>
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <fsp/api.h>
6 #include <fsp/ppi/mp_service_ppi.h>
7 #include <fsp/util.h>
8 #include <option.h>
9 #include <intelblocks/lpss.h>
10 #include <intelblocks/pmclib.h>
11 #include <intelblocks/xdci.h>
12 #include <intelpch/lockdown.h>
13 #include <soc/intel/common/vbt.h>
14 #include <soc/pci_devs.h>
15 #include <soc/ramstage.h>
16 #include <soc/soc_chip.h>
17 #include <static.h>
18 #include <string.h>
19 #include <types.h>
20
21 /*
22 * ME End of Post configuration
23 * 0 - Disable EOP.
24 * 1 - Send in PEI (Applicable for FSP in API mode)
25 * 2 - Send in DXE (Not applicable for FSP in API mode)
26 */
27 enum {
28 EOP_DISABLE = 0,
29 EOP_PEI = 1,
30 EOP_DXE = 2,
31 } EndOfPost;
32
33 static void parse_devicetree(FSP_S_CONFIG *params)
34 {
35 const struct soc_intel_jasperlake_config *config = config_of_soc();
36
37 /* LPSS controllers configuration */
38
39 /* I2C */
40 FSP_ARRAY_LOAD(params->SerialIoI2cMode, config->SerialIoI2cMode);
41
42 /* GSPI */
43 FSP_ARRAY_LOAD(params->SerialIoSpiMode, config->SerialIoGSpiMode);
44 FSP_ARRAY_LOAD(params->SerialIoSpiCsMode, config->SerialIoGSpiCsMode);
45 FSP_ARRAY_LOAD(params->SerialIoSpiCsState, config->SerialIoGSpiCsState);
46
47 /* UART */
48 FSP_ARRAY_LOAD(params->SerialIoUartMode, config->SerialIoUartMode);
49 }
50
51 /* UPD parameters to be initialized before SiliconInit */
52 void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
53 {
54 unsigned int i;
55 FSP_S_CONFIG *params = &supd->FspsConfig;
56 struct soc_intel_jasperlake_config *config = config_of_soc();
57
58 /* Parse device tree and fill in FSP UPDs */
59 parse_devicetree(params);
60
61 /* Load VBT before devicetree-specific config. */
62 params->GraphicsConfigPtr = (uintptr_t)vbt_get();
63
64 /* Check if IGD is present and fill Graphics init param accordingly */
65 params->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD);
66
67 params->PavpEnable = CONFIG(PAVP);
68
69 /* Use coreboot MP PPI services if Kconfig is enabled */
70 if (CONFIG(USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI))
71 params->CpuMpPpi = (uintptr_t)mp_fill_ppi_services_data();
72
73 /* Chipset Lockdown */
74 const bool lockdown_by_fsp = get_lockdown_config() == CHIPSET_LOCKDOWN_FSP;
75 params->PchLockDownGlobalSmi = lockdown_by_fsp;
76 params->PchLockDownBiosInterface = lockdown_by_fsp;
77 params->PchUnlockGpioPads = !lockdown_by_fsp;
78 params->RtcMemoryLock = lockdown_by_fsp;
79 params->SkipPamLock = !lockdown_by_fsp;
80
81 /* coreboot will send EOP before loading payload */
82 params->EndOfPostMessage = EOP_DISABLE;
83
84 /* Legacy 8254 timer support */
85 bool use_8254 = get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER));
86 params->Enable8254ClockGating = !use_8254;
87 params->Enable8254ClockGatingOnS3 = 1;
88
89 /*
90 * Legacy PM ACPI Timer (and TCO Timer)
91 * This *must* be 1 in any case to keep FSP from
92 * 1) enabling PM ACPI Timer emulation in uCode.
93 * 2) disabling the PM ACPI Timer.
94 * We handle both by ourself!
95 */
96 params->EnableTcoTimer = 1;
97
98 /* disable Legacy PME */
99 memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
100
101 /* Enable ClkReqDetect for enabled port */
102 memcpy(params->PcieRpClkReqDetect, config->PcieRpClkReqDetect,
103 sizeof(config->PcieRpClkReqDetect));
104
105 /* USB configuration */
106 for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) {
107 params->PortUsb20Enable[i] = config->usb2_ports[i].enable;
108 params->Usb2PhyPetxiset[i] = config->usb2_ports[i].pre_emp_bias;
109 params->Usb2PhyTxiset[i] = config->usb2_ports[i].tx_bias;
110 params->Usb2PhyPredeemp[i] = config->usb2_ports[i].tx_emp_enable;
111 params->Usb2PhyPehalfbit[i] = config->usb2_ports[i].pre_emp_bit;
112
113 if (config->usb2_ports[i].enable)
114 params->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin;
115 else
116 params->Usb2OverCurrentPin[i] = 0xff;
117 }
118
119 for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) {
120 params->PortUsb30Enable[i] = config->usb3_ports[i].enable;
121 if (config->usb3_ports[i].enable) {
122 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin;
123 } else {
124 params->Usb3OverCurrentPin[i] = 0xff;
125 }
126 if (config->usb3_ports[i].tx_de_emp) {
127 params->Usb3HsioTxDeEmphEnable[i] = 1;
128 params->Usb3HsioTxDeEmph[i] = config->usb3_ports[i].tx_de_emp;
129 }
130 if (config->usb3_ports[i].tx_downscale_amp) {
131 params->Usb3HsioTxDownscaleAmpEnable[i] = 1;
132 params->Usb3HsioTxDownscaleAmp[i] =
133 config->usb3_ports[i].tx_downscale_amp;
134 }
135 /* Enable USB3 Gen2 */
136 if (config->usb3_ports[i].gen2_tx_rate0_uniq_tran_enable) {
137 params->Usb3HsioTxRate0UniqTranEnable[i] = 1;
138 params->Usb3HsioTxRate0UniqTran[i] =
139 config->usb3_ports[i].gen2_tx_rate0_uniq_tran;
140 }
141 if (config->usb3_ports[i].gen2_tx_rate1_uniq_tran_enable) {
142 params->Usb3HsioTxRate1UniqTranEnable[i] = 1;
143 params->Usb3HsioTxRate1UniqTran[i] =
144 config->usb3_ports[i].gen2_tx_rate1_uniq_tran;
145 }
146 if (config->usb3_ports[i].gen2_tx_rate2_uniq_tran_enable) {
147 params->Usb3HsioTxRate2UniqTranEnable[i] = 1;
148 params->Usb3HsioTxRate2UniqTran[i] =
149 config->usb3_ports[i].gen2_tx_rate2_uniq_tran;
150 }
151 if (config->usb3_ports[i].gen2_tx_rate3_uniq_tran_enable) {
152 params->Usb3HsioTxRate3UniqTranEnable[i] = 1;
153 params->Usb3HsioTxRate3UniqTran[i] =
154 config->usb3_ports[i].gen2_tx_rate3_uniq_tran;
155 }
156 }
157
158 /* SATA */
159 params->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA);
160 if (params->SataEnable) {
161 params->SataMode = config->SataMode;
162 params->SataSalpSupport = config->SataSalpSupport;
163
164 FSP_ARRAY_LOAD(params->SataPortsEnable, config->SataPortsEnable);
165 FSP_ARRAY_LOAD(params->SataPortsDevSlp, config->SataPortsDevSlp);
166 }
167
168 /* VR Configuration */
169 params->ImonSlope[0] = config->ImonSlope;
170 params->ImonOffset[0] = config->ImonOffset;
171
172 /* SDCard related configuration */
173 params->ScsSdCardEnabled = is_devfn_enabled(PCH_DEVFN_SDCARD);
174 if (params->ScsSdCardEnabled)
175 params->SdCardPowerEnableActiveHigh = config->SdCardPowerEnableActiveHigh;
176
177 /* Enable Processor Thermal Control */
178 params->Device4Enable = is_devfn_enabled(SA_DEVFN_DPTF);
179
180 /* Set TccActivationOffset */
181 params->TccActivationOffset = config->tcc_offset;
182
183 /* eMMC configuration */
184 params->ScsEmmcEnabled = is_devfn_enabled(PCH_DEVFN_EMMC);
185 if (params->ScsEmmcEnabled)
186 params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
187
188 params->XdciEnable = xdci_can_enable(PCH_DEVFN_USBOTG);
189
190 /* Provide correct UART number for FSP debug logs */
191 params->SerialIoDebugUartNumber = CONFIG_UART_FOR_CONSOLE;
192
193 /* PCIe Root Ports LTR mechanism */
194 for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++)
195 params->PcieRpLtrEnable[i] = config->PcieRpLtrEnable[i];
196
197 /* Configure FIVR RFI related settings */
198 params->FivrRfiFrequency = config->FivrRfiFrequency;
199 params->FivrSpreadSpectrum = config->FivrSpreadSpectrum;
200
201 /* Apply minimum assertion width settings if non-zero */
202 if (config->PchPmSlpS3MinAssert)
203 params->PchPmSlpS3MinAssert = config->PchPmSlpS3MinAssert;
204 if (config->PchPmSlpS4MinAssert)
205 params->PchPmSlpS4MinAssert = config->PchPmSlpS4MinAssert;
206 if (config->PchPmSlpSusMinAssert)
207 params->PchPmSlpSusMinAssert = config->PchPmSlpSusMinAssert;
208 if (config->PchPmSlpAMinAssert)
209 params->PchPmSlpAMinAssert = config->PchPmSlpAMinAssert;
210
211 /* Set Power Cycle Duration */
212 if (config->PchPmPwrCycDur)
213 params->PchPmPwrCycDur = get_pm_pwr_cyc_dur(config->PchPmSlpS4MinAssert,
214 config->PchPmSlpS3MinAssert, config->PchPmSlpAMinAssert,
215 config->PchPmPwrCycDur);
216
217 /* Set PsysPmax */
218 if (config->PsysPmax) {
219 printk(BIOS_DEBUG, "PsysPmax = %dW\n", config->PsysPmax);
220 /* PsysPmax is in unit of 1/8 Watt */
221 params->PsysPmax = config->PsysPmax * 8;
222 }
223
224 /*
225 * Fill Acoustic noise mitigation related configuration
226 * JSL only has single VR domain (VCCIN VR), thus filling only index 0 for
227 * Slew rate and FastPkgCRamp for VR0 only.
228 */
229 params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
230
231 if (params->AcousticNoiseMitigation) {
232 params->FastPkgCRampDisable[0] = config->FastPkgCRampDisable;
233 params->SlowSlewRate[0] = config->SlowSlewRate;
234 params->PreWake = config->PreWake;
235 params->RampUp = config->RampUp;
236 params->RampDown = config->RampDown;
237 }
238
239 if (config->disable_external_bypass_vr) {
240 params->PchFivrExtV1p05RailEnabledStates = 0;
241 params->PchFivrExtVnnRailSxEnabledStates = 0;
242 params->PchFivrExtVnnRailEnabledStates = 0;
243 }
244
245 /*
246 * We intentionally want the default to be maximum value(0xff) to align with
247 * FSP, so we reserve the `0` value here to mean auto instead, and shift the
248 * other values by 1.
249 *
250 * Please refer to src/soc/intel/jasperlake/chip.h for the detail definition.
251 */
252 params->CdClock = config->cd_clock ? config->cd_clock - 1 : 0xff;
253
254 /* Override/Fill FSP Silicon Param for mainboard */
255 mainboard_silicon_init_params(params);
256
257 /* Runtime configuration of S0ix */
258 config->s0ix_enable = get_uint_option("s0ix_enable", config->s0ix_enable);
259 }
260
261 /* Mainboard GPIO Configuration */
262 __weak void mainboard_silicon_init_params(FSP_S_CONFIG *params)
263 {
264 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
265 }