Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/87191?usp=email )
Change subject: b/google/fatcat: Introduce phased pre-memory GPIO configuration ......................................................................
b/google/fatcat: Introduce phased pre-memory GPIO configuration
This commit restructures the `fw_config_configure_pre_mem_gpio` function for fatcat variant to perform GPIO configuration in two distinct phases:
- Phase 1: This phase configures essential GPIOs related to WWAN and storage power sequencing, as well as fingerprint presence detection. This aligns with the initial power-up requirements of these critical components.
- Phase 2: This phase handles GPIO configurations for various peripherals like storage type, audio codec, WiFi, cellular interface (post initial power sequence), SD card slot, touchpad, touchscreen, ISH, PEG/x4 slot wake disable, and fingerprint enable/disable based on FW_CONFIG probes.
This phased approach aims to:
- Improve power sequencing: By configuring GPIOs in a specific order, we ensure that power rails for different IP blocks are enabled with the necessary delays, avoiding potential power-up issues. - Optimize boot time: Moving more GPIO configurations to the pre-memory stage allows these configurations to happen in parallel with FSP-S execution. This reduces the amount of GPIO configuration needed during the ramstage, potentially saving around 20ms during device setup and PCIe bus scanning.
TEST=Able to save ~20ms of the device setup time while booting google/fatcat.
w/o patch:
``` 70:device setup done 1,339,599 (95,023) ```
w/ patch:
``` 70:device setup done 1,319,613 (72,381) ```
Change-Id: I9c2e58ae012cad06f8e498c75745efaa9bad4a25 Signed-off-by: Subrata Banik subratabanik@google.com --- M src/mainboard/google/fatcat/variants/fatcat/fw_config.c 1 file changed, 105 insertions(+), 92 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/91/87191/1
diff --git a/src/mainboard/google/fatcat/variants/fatcat/fw_config.c b/src/mainboard/google/fatcat/variants/fatcat/fw_config.c index cdc7bf9..02786ae 100644 --- a/src/mainboard/google/fatcat/variants/fatcat/fw_config.c +++ b/src/mainboard/google/fatcat/variants/fatcat/fw_config.c @@ -512,13 +512,99 @@ PAD_CFG_GPO(GPP_C15, 0, DEEP), };
-void fw_config_configure_pre_mem_gpio(void) +static void fw_config_configure_pre_mem_gpio_phase_2(void) { - if (!fw_config_is_provisioned()) { - printk(BIOS_WARNING, "FW_CONFIG is not provisioned, Exiting\n"); - return; + if (fw_config_probe(FW_CONFIG(STORAGE, STORAGE_NVME_GEN4))) { + GPIO_CONFIGURE_PADS(gen4_ssd_pads); + } else if (fw_config_probe(FW_CONFIG(STORAGE, STORAGE_NVME_GEN5))) { + GPIO_CONFIGURE_PADS(gen5_ssd_pads); + } else if (fw_config_probe(FW_CONFIG(STORAGE, STORAGE_UFS))) { + GPIO_CONFIGURE_PADS(ufs_enable_pads); + } else if (fw_config_probe(FW_CONFIG(STORAGE, STORAGE_UNKNOWN))) { + GPIO_CONFIGURE_PADS(gen4_ssd_pads); + GPIO_CONFIGURE_PADS(gen5_ssd_pads); + GPIO_CONFIGURE_PADS(ufs_enable_pads); }
+ if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_NONE))) { + GPIO_CONFIGURE_PADS(audio_disable_pads); + GPIO_CONFIGURE_PADS(bt_i2s_disable_pads); + } else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_MAX98360_ALC5682I_I2S))) { + printk(BIOS_INFO, "Configure GPIOs for I2S MAX98360 ALC5682 audio.\n"); + GPIO_CONFIGURE_PADS(i2s_enable_pads); + printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); + GPIO_CONFIGURE_PADS(bt_i2s_enable_pads); + } else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_MAX98373_ALC5682_SNDW))) { + GPIO_CONFIGURE_PADS(sndw_external_codec_enable_pads); + GPIO_CONFIGURE_PADS(bt_i2s_disable_pads); + } else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_ALC722_SNDW)) || + fw_config_probe(FW_CONFIG(AUDIO, AUDIO_ALC721_SNDW))) { + printk(BIOS_INFO, "Configure GPIOs for Soundwire audio.\n"); + GPIO_CONFIGURE_PADS(sndw_alc722_enable_pads); + printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); + GPIO_CONFIGURE_PADS(bt_i2s_enable_pads); + } else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_ALC256_HDA))) { + printk(BIOS_INFO, "Configure GPIOs for HDA ALC 256 mode.\n"); + GPIO_CONFIGURE_PADS(hda_enable_pads); + GPIO_CONFIGURE_PADS(bt_i2s_disable_pads); + } + + if (fw_config_probe(FW_CONFIG(WIFI, WIFI_PCIE_6)) || + fw_config_probe(FW_CONFIG(WIFI, WIFI_PCIE_7))) { + GPIO_CONFIGURE_PADS(pcie_wlan_enable_pads); + GPIO_CONFIGURE_PADS(cnvi_disable_pads); + } else if (fw_config_probe(FW_CONFIG(WIFI, WIFI_CNVI_6)) || + fw_config_probe(FW_CONFIG(WIFI, WIFI_CNVI_7))) { + GPIO_CONFIGURE_PADS(cnvi_enable_pads); + GPIO_CONFIGURE_PADS(pcie_wlan_disable_pads); + } + + if (fw_config_probe(FW_CONFIG(CELLULAR, CELLULAR_PCIE)) || + fw_config_probe(FW_CONFIG(CELLULAR, CELLULAR_USB))) { + GPIO_CONFIGURE_PADS(wwan_pwr_seq3_pads); + } else { + GPIO_CONFIGURE_PADS(wwan_disable_pads); + } + + if (fw_config_probe(FW_CONFIG(SD, SD_NONE))) + GPIO_CONFIGURE_PADS(x1slot_disable_pads); + else + GPIO_CONFIGURE_PADS(x1slot_pads); + + if (fw_config_probe(FW_CONFIG(TOUCHPAD, TOUCHPAD_LPSS_I2C))) + GPIO_CONFIGURE_PADS(touchpad_lpss_i2c_enable_pads); + else if (fw_config_probe(FW_CONFIG(TOUCHPAD, TOUCHPAD_THC_I2C))) + GPIO_CONFIGURE_PADS(touchpad_thc_i2c_enable_pads); + else + GPIO_CONFIGURE_PADS(touchpad_i2c_disable_pads); + + if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_LPSS_I2C))) + GPIO_CONFIGURE_PADS(touchscreen_lpss_i2c_enable_pads); + else if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_THC_I2C))) + GPIO_CONFIGURE_PADS(touchscreen_thc_i2c_enable_pads); + else if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_GSPI))) + GPIO_CONFIGURE_PADS(touchscreen_gspi_enable_pads); + else if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_THC_SPI))) + GPIO_CONFIGURE_PADS(touchscreen_thc_spi_enable_pads); + else + GPIO_CONFIGURE_PADS(touchscreen_disable_pads); + + if (fw_config_probe(FW_CONFIG(ISH, ISH_DISABLE))) + GPIO_CONFIGURE_PADS(ish_disable_pads); + else + GPIO_CONFIGURE_PADS(ish_enable_pads); + + /* NOTE: disable PEG (x8 slot) and x4 slot wake for now */ + GPIO_CONFIGURE_PADS(peg_x4slot_wake_disable_pads); + + if (fw_config_probe(FW_CONFIG(FP, FP_PRESENT))) + GPIO_CONFIGURE_PADS(fp_enable_pads); + else + GPIO_CONFIGURE_PADS(fp_disable_pads); +} + +static void fw_config_configure_pre_mem_gpio_phase_1(void) +{ if (!fw_config_probe(FW_CONFIG(CELLULAR, CELLULAR_ABSENT))) GPIO_CONFIGURE_PADS(pre_mem_wwan_pwr_seq1_pads);
@@ -546,101 +632,28 @@
if (fw_config_probe(FW_CONFIG(FP, FP_PRESENT))) GPIO_CONFIGURE_PADS(pre_mem_fp_enable_pads); - }
-void fw_config_gpio_padbased_override(struct pad_config *padbased_table) +void fw_config_configure_pre_mem_gpio(void) { if (!fw_config_is_provisioned()) { printk(BIOS_WARNING, "FW_CONFIG is not provisioned, Exiting\n"); return; }
- if (fw_config_probe(FW_CONFIG(STORAGE, STORAGE_NVME_GEN4))) { - GPIO_PADBASED_OVERRIDE(padbased_table, gen4_ssd_pads); - } else if (fw_config_probe(FW_CONFIG(STORAGE, STORAGE_NVME_GEN5))) { - GPIO_PADBASED_OVERRIDE(padbased_table, gen5_ssd_pads); - } else if (fw_config_probe(FW_CONFIG(STORAGE, STORAGE_UFS))) { - GPIO_PADBASED_OVERRIDE(padbased_table, ufs_enable_pads); - } else if (fw_config_probe(FW_CONFIG(STORAGE, STORAGE_UNKNOWN))) { - GPIO_PADBASED_OVERRIDE(padbased_table, gen4_ssd_pads); - GPIO_PADBASED_OVERRIDE(padbased_table, gen5_ssd_pads); - GPIO_PADBASED_OVERRIDE(padbased_table, ufs_enable_pads); - } + /* + * Program GPIOs in phases to align with power sequencing requirements + * of different IP blocks. This phased approach ensures sufficient delay + * for power rails to stabilize without introducing explicit static delays + * in the code. + * + * By completing early GPIO configuration before ramstage, we aim to: + * - Ensure all IP blocks are properly powered and initialized. + * - Reduce the overall boot time by approximately 20ms by overlapping + * power sequencing with FSP-S execution and avoiding delays during + * PCIe bus scan and device setup. + */ + fw_config_configure_pre_mem_gpio_phase_1();
- if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_NONE))) { - GPIO_PADBASED_OVERRIDE(padbased_table, audio_disable_pads); - GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); - } else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_MAX98360_ALC5682I_I2S))) { - printk(BIOS_INFO, "Configure GPIOs for I2S MAX98360 ALC5682 audio.\n"); - GPIO_PADBASED_OVERRIDE(padbased_table, i2s_enable_pads); - printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); - GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); - } else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_MAX98373_ALC5682_SNDW))) { - GPIO_PADBASED_OVERRIDE(padbased_table, sndw_external_codec_enable_pads); - GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); - } else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_ALC722_SNDW)) || - fw_config_probe(FW_CONFIG(AUDIO, AUDIO_ALC721_SNDW))) { - printk(BIOS_INFO, "Configure GPIOs for Soundwire audio.\n"); - GPIO_PADBASED_OVERRIDE(padbased_table, sndw_alc722_enable_pads); - printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); - GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); - } else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_ALC256_HDA))) { - printk(BIOS_INFO, "Configure GPIOs for HDA ALC 256 mode.\n"); - GPIO_PADBASED_OVERRIDE(padbased_table, hda_enable_pads); - GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); - } - - if (fw_config_probe(FW_CONFIG(WIFI, WIFI_PCIE_6)) || - fw_config_probe(FW_CONFIG(WIFI, WIFI_PCIE_7))) { - GPIO_PADBASED_OVERRIDE(padbased_table, pcie_wlan_enable_pads); - GPIO_PADBASED_OVERRIDE(padbased_table, cnvi_disable_pads); - } else if (fw_config_probe(FW_CONFIG(WIFI, WIFI_CNVI_6)) || - fw_config_probe(FW_CONFIG(WIFI, WIFI_CNVI_7))) { - GPIO_PADBASED_OVERRIDE(padbased_table, cnvi_enable_pads); - GPIO_PADBASED_OVERRIDE(padbased_table, pcie_wlan_disable_pads); - } - - if (fw_config_probe(FW_CONFIG(CELLULAR, CELLULAR_PCIE)) || - fw_config_probe(FW_CONFIG(CELLULAR, CELLULAR_USB))) { - GPIO_PADBASED_OVERRIDE(padbased_table, wwan_pwr_seq3_pads); - } else { - GPIO_PADBASED_OVERRIDE(padbased_table, wwan_disable_pads); - } - - if (fw_config_probe(FW_CONFIG(SD, SD_NONE))) - GPIO_PADBASED_OVERRIDE(padbased_table, x1slot_disable_pads); - else - GPIO_PADBASED_OVERRIDE(padbased_table, x1slot_pads); - - if (fw_config_probe(FW_CONFIG(TOUCHPAD, TOUCHPAD_LPSS_I2C))) - GPIO_PADBASED_OVERRIDE(padbased_table, touchpad_lpss_i2c_enable_pads); - else if (fw_config_probe(FW_CONFIG(TOUCHPAD, TOUCHPAD_THC_I2C))) - GPIO_PADBASED_OVERRIDE(padbased_table, touchpad_thc_i2c_enable_pads); - else - GPIO_PADBASED_OVERRIDE(padbased_table, touchpad_i2c_disable_pads); - - if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_LPSS_I2C))) - GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_lpss_i2c_enable_pads); - else if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_THC_I2C))) - GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_thc_i2c_enable_pads); - else if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_GSPI))) - GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_gspi_enable_pads); - else if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_THC_SPI))) - GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_thc_spi_enable_pads); - else - GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_disable_pads); - - if (fw_config_probe(FW_CONFIG(ISH, ISH_DISABLE))) - GPIO_PADBASED_OVERRIDE(padbased_table, ish_disable_pads); - else - GPIO_PADBASED_OVERRIDE(padbased_table, ish_enable_pads); - - /* NOTE: disable PEG (x8 slot) and x4 slot wake for now */ - GPIO_PADBASED_OVERRIDE(padbased_table, peg_x4slot_wake_disable_pads); - - if (fw_config_probe(FW_CONFIG(FP, FP_PRESENT))) - GPIO_PADBASED_OVERRIDE(padbased_table, fp_enable_pads); - else - GPIO_PADBASED_OVERRIDE(padbased_table, fp_disable_pads); + fw_config_configure_pre_mem_gpio_phase_2(); }