1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <device/device.h>
6 #include <fsp/ppi/mp_service_ppi.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>
21 * ME End of Post configuration
23 * 1 - Send in PEI (Applicable for FSP in API mode)
24 * 2 - Send in DXE (Not applicable for FSP in API mode)
32 static void parse_devicetree(FSP_S_CONFIG
*params
)
34 const struct soc_intel_jasperlake_config
*config
= config_of_soc();
36 /* LPSS controllers configuration */
39 FSP_ARRAY_LOAD(params
->SerialIoI2cMode
, config
->SerialIoI2cMode
);
42 FSP_ARRAY_LOAD(params
->SerialIoSpiMode
, config
->SerialIoGSpiMode
);
43 FSP_ARRAY_LOAD(params
->SerialIoSpiCsMode
, config
->SerialIoGSpiCsMode
);
44 FSP_ARRAY_LOAD(params
->SerialIoSpiCsState
, config
->SerialIoGSpiCsState
);
47 FSP_ARRAY_LOAD(params
->SerialIoUartMode
, config
->SerialIoUartMode
);
50 /* UPD parameters to be initialized before SiliconInit */
51 void platform_fsp_silicon_init_params_cb(FSPS_UPD
*supd
)
54 FSP_S_CONFIG
*params
= &supd
->FspsConfig
;
55 struct soc_intel_jasperlake_config
*config
= config_of_soc();
57 /* Parse device tree and fill in FSP UPDs */
58 parse_devicetree(params
);
60 /* Load VBT before devicetree-specific config. */
61 params
->GraphicsConfigPtr
= (uintptr_t)vbt_get();
63 /* Check if IGD is present and fill Graphics init param accordingly */
64 params
->PeiGraphicsPeimInit
= CONFIG(RUN_FSP_GOP
) && is_devfn_enabled(SA_DEVFN_IGD
);
66 params
->PavpEnable
= CONFIG(PAVP
);
68 /* Use coreboot MP PPI services if Kconfig is enabled */
69 if (CONFIG(USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI
))
70 params
->CpuMpPpi
= (uintptr_t)mp_fill_ppi_services_data();
72 /* Chipset Lockdown */
73 const bool lockdown_by_fsp
= get_lockdown_config() == CHIPSET_LOCKDOWN_FSP
;
74 params
->PchLockDownGlobalSmi
= lockdown_by_fsp
;
75 params
->PchLockDownBiosInterface
= lockdown_by_fsp
;
76 params
->PchUnlockGpioPads
= !lockdown_by_fsp
;
77 params
->RtcMemoryLock
= lockdown_by_fsp
;
78 params
->SkipPamLock
= !lockdown_by_fsp
;
80 /* coreboot will send EOP before loading payload */
81 params
->EndOfPostMessage
= EOP_DISABLE
;
83 /* Legacy 8254 timer support */
84 bool use_8254
= get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER
));
85 params
->Enable8254ClockGating
= !use_8254
;
86 params
->Enable8254ClockGatingOnS3
= 1;
89 * Legacy PM ACPI Timer (and TCO Timer)
90 * This *must* be 1 in any case to keep FSP from
91 * 1) enabling PM ACPI Timer emulation in uCode.
92 * 2) disabling the PM ACPI Timer.
93 * We handle both by ourself!
95 params
->EnableTcoTimer
= 1;
97 /* disable Legacy PME */
98 memset(params
->PcieRpPmSci
, 0, sizeof(params
->PcieRpPmSci
));
100 /* Enable ClkReqDetect for enabled port */
101 memcpy(params
->PcieRpClkReqDetect
, config
->PcieRpClkReqDetect
,
102 sizeof(config
->PcieRpClkReqDetect
));
104 /* USB configuration */
105 for (i
= 0; i
< ARRAY_SIZE(config
->usb2_ports
); i
++) {
106 params
->PortUsb20Enable
[i
] = config
->usb2_ports
[i
].enable
;
107 params
->Usb2PhyPetxiset
[i
] = config
->usb2_ports
[i
].pre_emp_bias
;
108 params
->Usb2PhyTxiset
[i
] = config
->usb2_ports
[i
].tx_bias
;
109 params
->Usb2PhyPredeemp
[i
] = config
->usb2_ports
[i
].tx_emp_enable
;
110 params
->Usb2PhyPehalfbit
[i
] = config
->usb2_ports
[i
].pre_emp_bit
;
112 if (config
->usb2_ports
[i
].enable
)
113 params
->Usb2OverCurrentPin
[i
] = config
->usb2_ports
[i
].ocpin
;
115 params
->Usb2OverCurrentPin
[i
] = 0xff;
118 for (i
= 0; i
< ARRAY_SIZE(config
->usb3_ports
); i
++) {
119 params
->PortUsb30Enable
[i
] = config
->usb3_ports
[i
].enable
;
120 if (config
->usb3_ports
[i
].enable
) {
121 params
->Usb3OverCurrentPin
[i
] = config
->usb3_ports
[i
].ocpin
;
123 params
->Usb3OverCurrentPin
[i
] = 0xff;
125 if (config
->usb3_ports
[i
].tx_de_emp
) {
126 params
->Usb3HsioTxDeEmphEnable
[i
] = 1;
127 params
->Usb3HsioTxDeEmph
[i
] = config
->usb3_ports
[i
].tx_de_emp
;
129 if (config
->usb3_ports
[i
].tx_downscale_amp
) {
130 params
->Usb3HsioTxDownscaleAmpEnable
[i
] = 1;
131 params
->Usb3HsioTxDownscaleAmp
[i
] =
132 config
->usb3_ports
[i
].tx_downscale_amp
;
134 /* Enable USB3 Gen2 */
135 if (config
->usb3_ports
[i
].gen2_tx_rate0_uniq_tran_enable
) {
136 params
->Usb3HsioTxRate0UniqTranEnable
[i
] = 1;
137 params
->Usb3HsioTxRate0UniqTran
[i
] =
138 config
->usb3_ports
[i
].gen2_tx_rate0_uniq_tran
;
140 if (config
->usb3_ports
[i
].gen2_tx_rate1_uniq_tran_enable
) {
141 params
->Usb3HsioTxRate1UniqTranEnable
[i
] = 1;
142 params
->Usb3HsioTxRate1UniqTran
[i
] =
143 config
->usb3_ports
[i
].gen2_tx_rate1_uniq_tran
;
145 if (config
->usb3_ports
[i
].gen2_tx_rate2_uniq_tran_enable
) {
146 params
->Usb3HsioTxRate2UniqTranEnable
[i
] = 1;
147 params
->Usb3HsioTxRate2UniqTran
[i
] =
148 config
->usb3_ports
[i
].gen2_tx_rate2_uniq_tran
;
150 if (config
->usb3_ports
[i
].gen2_tx_rate3_uniq_tran_enable
) {
151 params
->Usb3HsioTxRate3UniqTranEnable
[i
] = 1;
152 params
->Usb3HsioTxRate3UniqTran
[i
] =
153 config
->usb3_ports
[i
].gen2_tx_rate3_uniq_tran
;
158 params
->SataEnable
= is_devfn_enabled(PCH_DEVFN_SATA
);
159 if (params
->SataEnable
) {
160 params
->SataMode
= config
->SataMode
;
161 params
->SataSalpSupport
= config
->SataSalpSupport
;
163 FSP_ARRAY_LOAD(params
->SataPortsEnable
, config
->SataPortsEnable
);
164 FSP_ARRAY_LOAD(params
->SataPortsDevSlp
, config
->SataPortsDevSlp
);
167 /* VR Configuration */
168 params
->ImonSlope
[0] = config
->ImonSlope
;
169 params
->ImonOffset
[0] = config
->ImonOffset
;
171 /* SDCard related configuration */
172 params
->ScsSdCardEnabled
= is_devfn_enabled(PCH_DEVFN_SDCARD
);
173 if (params
->ScsSdCardEnabled
)
174 params
->SdCardPowerEnableActiveHigh
= config
->SdCardPowerEnableActiveHigh
;
176 /* Enable Processor Thermal Control */
177 params
->Device4Enable
= is_devfn_enabled(SA_DEVFN_DPTF
);
179 /* Set TccActivationOffset */
180 params
->TccActivationOffset
= config
->tcc_offset
;
182 /* eMMC configuration */
183 params
->ScsEmmcEnabled
= is_devfn_enabled(PCH_DEVFN_EMMC
);
184 if (params
->ScsEmmcEnabled
)
185 params
->ScsEmmcHs400Enabled
= config
->ScsEmmcHs400Enabled
;
187 params
->XdciEnable
= xdci_can_enable(PCH_DEVFN_USBOTG
);
189 /* Provide correct UART number for FSP debug logs */
190 params
->SerialIoDebugUartNumber
= CONFIG_UART_FOR_CONSOLE
;
192 /* Configure FIVR RFI related settings */
193 params
->FivrRfiFrequency
= config
->FivrRfiFrequency
;
194 params
->FivrSpreadSpectrum
= config
->FivrSpreadSpectrum
;
196 /* Apply minimum assertion width settings if non-zero */
197 if (config
->PchPmSlpS3MinAssert
)
198 params
->PchPmSlpS3MinAssert
= config
->PchPmSlpS3MinAssert
;
199 if (config
->PchPmSlpS4MinAssert
)
200 params
->PchPmSlpS4MinAssert
= config
->PchPmSlpS4MinAssert
;
201 if (config
->PchPmSlpSusMinAssert
)
202 params
->PchPmSlpSusMinAssert
= config
->PchPmSlpSusMinAssert
;
203 if (config
->PchPmSlpAMinAssert
)
204 params
->PchPmSlpAMinAssert
= config
->PchPmSlpAMinAssert
;
206 /* Set Power Cycle Duration */
207 if (config
->PchPmPwrCycDur
)
208 params
->PchPmPwrCycDur
= get_pm_pwr_cyc_dur(config
->PchPmSlpS4MinAssert
,
209 config
->PchPmSlpS3MinAssert
, config
->PchPmSlpAMinAssert
,
210 config
->PchPmPwrCycDur
);
213 if (config
->PsysPmax
) {
214 printk(BIOS_DEBUG
, "PsysPmax = %dW\n", config
->PsysPmax
);
215 /* PsysPmax is in unit of 1/8 Watt */
216 params
->PsysPmax
= config
->PsysPmax
* 8;
220 * Fill Acoustic noise mitigation related configuration
221 * JSL only has single VR domain (VCCIN VR), thus filling only index 0 for
222 * Slew rate and FastPkgCRamp for VR0 only.
224 params
->AcousticNoiseMitigation
= config
->AcousticNoiseMitigation
;
226 if (params
->AcousticNoiseMitigation
) {
227 params
->FastPkgCRampDisable
[0] = config
->FastPkgCRampDisable
;
228 params
->SlowSlewRate
[0] = config
->SlowSlewRate
;
229 params
->PreWake
= config
->PreWake
;
230 params
->RampUp
= config
->RampUp
;
231 params
->RampDown
= config
->RampDown
;
234 if (config
->disable_external_bypass_vr
) {
235 params
->PchFivrExtV1p05RailEnabledStates
= 0;
236 params
->PchFivrExtVnnRailSxEnabledStates
= 0;
237 params
->PchFivrExtVnnRailEnabledStates
= 0;
241 * We intentionally want the default to be maximum value(0xff) to align with
242 * FSP, so we reserve the `0` value here to mean auto instead, and shift the
245 * Please refer to src/soc/intel/jasperlake/chip.h for the detail definition.
247 params
->CdClock
= config
->cd_clock
? config
->cd_clock
- 1 : 0xff;
249 /* Override/Fill FSP Silicon Param for mainboard */
250 mainboard_silicon_init_params(params
);
253 /* Mainboard GPIO Configuration */
254 __weak
void mainboard_silicon_init_params(FSP_S_CONFIG
*params
)
256 printk(BIOS_DEBUG
, "WEAK: %s/%s called\n", __FILE__
, __func__
);