From 10361583b3226bfdca3e4f86b9669a5702fcbadc Mon Sep 17 00:00:00 2001 From: Kilian Krause Date: Tue, 30 Sep 2025 16:12:12 +0200 Subject: [PATCH] mb/siemens/mc_rpl: Add code to wait for legacy devices before PCI scan All mc_rpl boards have, like the mc_apl and mc_ehl variants, legacy PCI devices which take longer to boot. To ensure their correct enumeration, a delay is added before the PCI scan starts. The delay value is provided by hwinfo. TEST=Built and booted on mc_rpl board. Verified legacy PCI devices enumerate correctly after delay implementation. Log excerpt while testing function: ``` [INFO ] tlcl2_extend: response is 0x0 [DEBUG] TPM: Digest of `CBFS: hwinfo.hex` to PCR 3 measured [NOTE ] Wait remaining 6595702 of 10000000 us for legacy devices...done! [DEBUG] BS: BS_DEV_ENUMERATE entry times (exec / console): 6597 / 64 ms [INFO ] Enumerating buses... ``` Change-Id: I97885a7cf060bc69c7fef75a9fa917bc8a176582 Signed-off-by: Kilian Krause Reviewed-on: https://review.coreboot.org/c/coreboot/+/89393 Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh --- src/mainboard/siemens/mc_rpl/mainboard.c | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/mainboard/siemens/mc_rpl/mainboard.c b/src/mainboard/siemens/mc_rpl/mainboard.c index 69670aa0ec..44b11a0825 100644 --- a/src/mainboard/siemens/mc_rpl/mainboard.c +++ b/src/mainboard/siemens/mc_rpl/mainboard.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -14,6 +15,8 @@ #include #include #include +#include +#include #define MAX_PATH_DEPTH 12 #define MAX_NUM_MAPPINGS 10 @@ -91,6 +94,31 @@ enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[MAC_ADDR_L return CB_ERR; } +static void wait_for_legacy_dev(void *unused) +{ + uint32_t legacy_delay_us, us_since_boot; + struct stopwatch sw; + + /* Open main hwinfo block. */ + if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS) + return; + + /* Get legacy delay parameter from hwinfo. */ + if (hwilib_get_field(LegacyDelay, (uint8_t *)&legacy_delay_us, + sizeof(legacy_delay_us)) != sizeof(legacy_delay_us)) + return; + + us_since_boot = get_us_since_boot(); + /* No need to wait if the time since boot is already long enough.*/ + if (us_since_boot > legacy_delay_us) + return; + stopwatch_init_msecs_expire(&sw, (legacy_delay_us - us_since_boot) / 1000); + printk(BIOS_NOTICE, "Wait remaining %d of %d us for legacy devices...", + legacy_delay_us - us_since_boot, legacy_delay_us); + stopwatch_wait_until_expired(&sw); + printk(BIOS_NOTICE, " done!\n"); +} + void mainboard_silicon_init_params(FSP_S_CONFIG *params) { params->Eist = 0; @@ -130,3 +158,5 @@ struct chip_operations mainboard_ops = { .init = mainboard_init, .final = mainboard_final, }; + +BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL);