summaryrefslogtreecommitdiffstats
path: root/src/mainboard/siemens
diff options
context:
space:
mode:
authorWerner Zeh <werner.zeh@siemens.com>2021-06-11 06:55:50 +0200
committerPaul Fagerburg <pfagerburg@chromium.org>2021-08-02 15:07:23 +0000
commit4cec1a2770c1ac5257e704eda4117477d5d28d69 (patch)
tree8d0956984677de3b15725b36bb73a02d29fda7cb /src/mainboard/siemens
parentc1adf40e1184e59d3fd159d01864ec01f1652eba (diff)
downloadcoreboot-4cec1a2770c1ac5257e704eda4117477d5d28d69.tar.gz
coreboot-4cec1a2770c1ac5257e704eda4117477d5d28d69.tar.bz2
coreboot-4cec1a2770c1ac5257e704eda4117477d5d28d69.zip
mb/siemens/mc_ehl: Add code to wait for legacy devices before PCI scan
Boards based on mc_ehl have, just like some mc_apl variants, legacy devices on the PCI bus which take longer to boot. In order to ensure that they will be enumerated correctly wait for them to come up before PCI scan starts. TEST=Checked that the new message is visible in the log. Change-Id: If2f935b69ddaa9364566deacfada5e7d41fcdabd Signed-off-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/56631 Reviewed-by: Mario Scheithauer <mario.scheithauer@siemens.com> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/mainboard/siemens')
-rw-r--r--src/mainboard/siemens/mc_ehl/mainboard.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mainboard/siemens/mc_ehl/mainboard.c b/src/mainboard/siemens/mc_ehl/mainboard.c
index fc7d31f29df0..4cc5490f2a39 100644
--- a/src/mainboard/siemens/mc_ehl/mainboard.c
+++ b/src/mainboard/siemens/mc_ehl/mainboard.c
@@ -1,12 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <baseboard/variants.h>
+#include <bootstate.h>
#include <console/console.h>
#include <device/device.h>
#include <hwilib.h>
#include <i210.h>
#include <soc/gpio.h>
#include <string.h>
+#include <timer.h>
+#include <timestamp.h>
#define MAX_PATH_DEPTH 12
#define MAX_NUM_MAPPINGS 10
@@ -83,6 +86,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_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,
+ sizeof(legacy_delay)) != sizeof(legacy_delay))
+ 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)
+ return;
+ stopwatch_init_msecs_expire(&sw, (legacy_delay - us_since_boot) / 1000);
+ printk(BIOS_NOTICE, "Wait remaining %d of %d us for legacy devices...",
+ legacy_delay - us_since_boot, legacy_delay);
+ stopwatch_wait_until_expired(&sw);
+ printk(BIOS_NOTICE, "done!\n");
+}
+
static void mainboard_init(void *chip_info)
{
const struct pad_config *pads;
@@ -95,3 +123,5 @@ static void mainboard_init(void *chip_info)
struct chip_operations mainboard_ops = {
.init = mainboard_init,
};
+
+BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL);