coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
fsp_params.c
Go to the documentation of this file.
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>
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 <string.h>
18 #include <types.h>
19 
20 /*
21  * ME End of Post configuration
22  * 0 - Disable EOP.
23  * 1 - Send in PEI (Applicable for FSP in API mode)
24  * 2 - Send in DXE (Not applicable for FSP in API mode)
25  */
26 enum {
28  EOP_PEI = 1,
29  EOP_DXE = 2,
31 
33 {
35 
36  /* LPSS controllers configuration */
37 
38  /* I2C */
39  FSP_ARRAY_LOAD(params->SerialIoI2cMode, config->SerialIoI2cMode);
40 
41  /* GSPI */
42  FSP_ARRAY_LOAD(params->SerialIoSpiMode, config->SerialIoGSpiMode);
43  FSP_ARRAY_LOAD(params->SerialIoSpiCsMode, config->SerialIoGSpiCsMode);
44  FSP_ARRAY_LOAD(params->SerialIoSpiCsState, config->SerialIoGSpiCsState);
45 
46  /* UART */
47  FSP_ARRAY_LOAD(params->SerialIoUartMode, config->SerialIoUartMode);
48 }
49 
50 /* UPD parameters to be initialized before SiliconInit */
52 {
53  unsigned int i;
54  FSP_S_CONFIG *params = &supd->FspsConfig;
56 
57  /* Parse device tree and fill in FSP UPDs */
59 
60  /* Load VBT before devicetree-specific config. */
61  params->GraphicsConfigPtr = (uintptr_t)vbt_get();
62 
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);
65 
66  params->PavpEnable = CONFIG(PAVP);
67 
68  /* Use coreboot MP PPI services if Kconfig is enabled */
69  if (CONFIG(USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI))
71 
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;
79 
80  /* coreboot will send EOP before loading payload */
81  params->EndOfPostMessage = EOP_DISABLE;
82 
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;
87 
88  /*
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!
94  */
95  params->EnableTcoTimer = 1;
96 
97  /* disable Legacy PME */
98  memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci));
99 
100  /* Enable ClkReqDetect for enabled port */
101  memcpy(params->PcieRpClkReqDetect, config->PcieRpClkReqDetect,
102  sizeof(config->PcieRpClkReqDetect));
103 
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;
111 
112  if (config->usb2_ports[i].enable)
113  params->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin;
114  else
115  params->Usb2OverCurrentPin[i] = 0xff;
116  }
117 
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;
122  } else {
123  params->Usb3OverCurrentPin[i] = 0xff;
124  }
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;
128  }
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;
133  }
134  }
135 
136  /* SATA */
137  params->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA);
138  if (params->SataEnable) {
139  params->SataMode = config->SataMode;
140  params->SataSalpSupport = config->SataSalpSupport;
141 
142  FSP_ARRAY_LOAD(params->SataPortsEnable, config->SataPortsEnable);
143  FSP_ARRAY_LOAD(params->SataPortsDevSlp, config->SataPortsDevSlp);
144  }
145 
146  /* VR Configuration */
147  params->ImonSlope[0] = config->ImonSlope;
148  params->ImonOffset[0] = config->ImonOffset;
149 
150  /* SDCard related configuration */
151  params->ScsSdCardEnabled = is_devfn_enabled(PCH_DEVFN_SDCARD);
152  if (params->ScsSdCardEnabled)
153  params->SdCardPowerEnableActiveHigh = config->SdCardPowerEnableActiveHigh;
154 
155  /* Enable Processor Thermal Control */
156  params->Device4Enable = is_devfn_enabled(SA_DEVFN_DPTF);
157 
158  /* Set TccActivationOffset */
159  params->TccActivationOffset = config->tcc_offset;
160 
161  /* eMMC configuration */
162  params->ScsEmmcEnabled = is_devfn_enabled(PCH_DEVFN_EMMC);
163  if (params->ScsEmmcEnabled)
164  params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled;
165 
166  params->XdciEnable = xdci_can_enable(PCH_DEVFN_USBOTG);
167 
168  /* Provide correct UART number for FSP debug logs */
169  params->SerialIoDebugUartNumber = CONFIG_UART_FOR_CONSOLE;
170 
171  /* Configure FIVR RFI related settings */
172  params->FivrRfiFrequency = config->FivrRfiFrequency;
173  params->FivrSpreadSpectrum = config->FivrSpreadSpectrum;
174 
175  /* Apply minimum assertion width settings if non-zero */
176  if (config->PchPmSlpS3MinAssert)
177  params->PchPmSlpS3MinAssert = config->PchPmSlpS3MinAssert;
178  if (config->PchPmSlpS4MinAssert)
179  params->PchPmSlpS4MinAssert = config->PchPmSlpS4MinAssert;
180  if (config->PchPmSlpSusMinAssert)
181  params->PchPmSlpSusMinAssert = config->PchPmSlpSusMinAssert;
182  if (config->PchPmSlpAMinAssert)
183  params->PchPmSlpAMinAssert = config->PchPmSlpAMinAssert;
184 
185  /* Set Power Cycle Duration */
186  if (config->PchPmPwrCycDur)
187  params->PchPmPwrCycDur = get_pm_pwr_cyc_dur(config->PchPmSlpS4MinAssert,
188  config->PchPmSlpS3MinAssert, config->PchPmSlpAMinAssert,
189  config->PchPmPwrCycDur);
190 
191  /*
192  * Fill Acoustic noise mitigation related configuration
193  * JSL only has single VR domain (VCCIN VR), thus filling only index 0 for
194  * Slew rate and FastPkgCRamp for VR0 only.
195  */
196  params->AcousticNoiseMitigation = config->AcousticNoiseMitigation;
197 
198  if (params->AcousticNoiseMitigation) {
199  params->FastPkgCRampDisable[0] = config->FastPkgCRampDisable;
200  params->SlowSlewRate[0] = config->SlowSlewRate;
201  params->PreWake = config->PreWake;
202  params->RampUp = config->RampUp;
203  params->RampDown = config->RampDown;
204  }
205 
206  if (config->disable_external_bypass_vr) {
207  params->PchFivrExtV1p05RailEnabledStates = 0;
208  params->PchFivrExtVnnRailSxEnabledStates = 0;
209  params->PchFivrExtVnnRailEnabledStates = 0;
210  }
211 
212  /*
213  * We intentionally want the default to be maximum value(0xff) to align with
214  * FSP, so we reserve the `0` value here to mean auto instead, and shift the
215  * other values by 1.
216  *
217  * Please refer to src/soc/intel/jasperlake/chip.h for the detail definition.
218  */
219  params->CdClock = config->cd_clock ? config->cd_clock - 1 : 0xff;
220 
221  /* Override/Fill FSP Silicon Param for mainboard */
223 }
224 
225 /* Mainboard GPIO Configuration */
227 {
228  printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
229 }
void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
Definition: fsp_params.c:879
@ EOP_DXE
Definition: fsp_params.c:55
@ EOP_DISABLE
Definition: fsp_params.c:53
@ EOP_PEI
Definition: fsp_params.c:54
__weak void mainboard_silicon_init_params(FSP_S_CONFIG *s_cfg)
Definition: fsp_params.c:915
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
void * memset(void *dstpp, int c, size_t len)
Definition: memset.c:12
static struct sdram_info params
Definition: sdram_configs.c:83
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
@ PAVP
Definition: cse_layout.h:26
bool is_devfn_enabled(unsigned int devfn)
Definition: device_const.c:382
#define FSP_ARRAY_LOAD(dst, src)
Definition: util.h:20
@ CONFIG
Definition: dsi_common.h:201
#define FSP_S_CONFIG
Definition: fsp_upd.h:9
#define config_of_soc()
Definition: device.h:394
static void parse_devicetree(FSP_S_CONFIG *params)
Definition: fsp_params.c:32
enum @599 EndOfPost
int get_lockdown_config(void)
Definition: lockdown.c:22
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
enum board_config config
Definition: memory.c:448
void * mp_fill_ppi_services_data(void)
Definition: mp_service1.c:73
unsigned int get_uint_option(const char *name, const unsigned int fallback)
Definition: option.c:116
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
void * vbt_get(void)
Definition: graphics.c:131
#define SA_DEVFN_DPTF
Definition: pci_devs.h:36
#define PCH_DEVFN_USBOTG
Definition: pci_devs.h:125
#define PCH_DEVFN_SATA
Definition: pci_devs.h:158
#define SA_DEVFN_IGD
Definition: pci_devs.h:32
#define PCH_DEVFN_SDCARD
Definition: pci_devs.h:144
#define PCH_DEVFN_EMMC
Definition: pci_devs.h:148
@ CHIPSET_LOCKDOWN_FSP
Definition: cfg.h:13
uint8_t get_pm_pwr_cyc_dur(uint8_t slp_s4_min_assert, uint8_t slp_s3_min_assert, uint8_t slp_a_min_assert, uint8_t pm_pwr_cyc_dur)
Definition: pmclib.c:724
unsigned long uintptr_t
Definition: stdint.h:21
bool xdci_can_enable(unsigned int xdci_devfn)
Definition: xdci.c:11