Werner Zeh has uploaded this change for review. ( https://review.coreboot.org/21518
Change subject: siemens/mc_apl1: Add delay to wait for legacy devices
......................................................................
siemens/mc_apl1: Add delay to wait for legacy devices
There are old legacy onboard devices which are too slow for a coreboot
boot with log level BIOS_ERR. In this case coreboot is so fast that these
devices do not have enough time to become visible on the PCI bus and
this in turn leads to missing resource allocation for this devices. The
most generic way to work around this problem on existing hardware is to
introduce a delay right before the PCI enumeration starts. The needed
delay time depends on the hardware and will therefore be get from
hwinfo.
Change-Id: Ia91babc81e3a347bbc498c3def97b2ea70e10922
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
M src/mainboard/siemens/mc_apl1/mainboard.c
1 file changed, 31 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/18/21518/1
diff --git a/src/mainboard/siemens/mc_apl1/mainboard.c b/src/mainboard/siemens/mc_apl1/mainboard.c
index d8374fc..fb849f9 100644
--- a/src/mainboard/siemens/mc_apl1/mainboard.c
+++ b/src/mainboard/siemens/mc_apl1/mainboard.c
@@ -23,6 +23,9 @@
#include <intelblocks/lpc_lib.h>
#include <soc/pci_devs.h>
#include <string.h>
+#include <bootstate.h>
+#include <timer.h>
+#include <timestamp.h>
#include "brd_gpio.h"
#include "ptn3460.h"
@@ -141,6 +144,34 @@
}
}
+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);
+ while (!stopwatch_expired(&sw))
+ ;
+ printk(BIOS_NOTICE, "done!\n");
+}
+
+BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL);
+
struct chip_operations mainboard_ops = {
.init = mainboard_init,
.final = mainboard_final,
--
To view, visit https://review.coreboot.org/21518
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia91babc81e3a347bbc498c3def97b2ea70e10922
Gerrit-Change-Number: 21518
Gerrit-PatchSet: 1
Gerrit-Owner: Werner Zeh <werner.zeh(a)siemens.com>
Werner Zeh has uploaded this change for review. ( https://review.coreboot.org/21517
Change subject: vendorcode/siemens: Add LegacyDelay to hwilib
......................................................................
vendorcode/siemens: Add LegacyDelay to hwilib
Add a new parameter to hwilib called LegacyDelay. It will be used to
define a delay time to wait for legacy devices if coreboot is too fast
for old and slow onboard devices.
Change-Id: Id0386fdea0ecfb3c1ff6ec1c456071246529950a
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
M src/vendorcode/siemens/hwilib/hwilib.c
M src/vendorcode/siemens/hwilib/hwilib.h
2 files changed, 5 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/17/21517/1
diff --git a/src/vendorcode/siemens/hwilib/hwilib.c b/src/vendorcode/siemens/hwilib/hwilib.c
index 0d4a7a0..4c0cd63 100644
--- a/src/vendorcode/siemens/hwilib/hwilib.c
+++ b/src/vendorcode/siemens/hwilib/hwilib.c
@@ -385,7 +385,9 @@
[FANSensorCfg7] = {
.pos[0] = {.blk_type = BLK_XIB, .offset = 0xd8, .len = 20},
.get_field = hwilib_read_bytes },
-
+ [LegacyDelay] = {
+ .pos[0] = {.blk_type = BLK_XIB, .offset = 0x20c, .len = 4},
+ .get_field = hwilib_read_bytes },
};
/** \brief This functions reads the given field from the first valid hwinfo
diff --git a/src/vendorcode/siemens/hwilib/hwilib.h b/src/vendorcode/siemens/hwilib/hwilib.h
index 9739cf3..6850f07 100644
--- a/src/vendorcode/siemens/hwilib/hwilib.h
+++ b/src/vendorcode/siemens/hwilib/hwilib.h
@@ -115,8 +115,8 @@
netKind7,
netKind8,
netKind9,
- netKind10
-
+ netKind10,
+ LegacyDelay
} hwinfo_field_t;
/* Define used values in supported fields */
--
To view, visit https://review.coreboot.org/21517
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0386fdea0ecfb3c1ff6ec1c456071246529950a
Gerrit-Change-Number: 21517
Gerrit-PatchSet: 1
Gerrit-Owner: Werner Zeh <werner.zeh(a)siemens.com>
Werner Zeh has uploaded this change for review. ( https://review.coreboot.org/21516
Change subject: timestamp: Add function to get time since boot
......................................................................
timestamp: Add function to get time since boot
Add a function to retrieve the elapsed time since boot. For that purpose
use the base time in the timestamp table among with the current
timestamp at call time of the function. So more precise the returned
time is the elapsed time since the timestamp was initialized scaled
in microseconds. This was chosen to get a reliable value even on
platforms where the TSC might not be reset on software reset or warm
start.
Change-Id: Ib93ad89078645c0ebe256048cb48f9622c90451f
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
M src/include/timestamp.h
M src/lib/timestamp.c
2 files changed, 22 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/16/21516/1
diff --git a/src/include/timestamp.h b/src/include/timestamp.h
index 95470f5..f8a5297 100644
--- a/src/include/timestamp.h
+++ b/src/include/timestamp.h
@@ -40,11 +40,20 @@
/* Apply a factor of N/M to all timestamps recorded so far. */
void timestamp_rescale_table(uint16_t N, uint16_t M);
+/*
+ * Get the time since boot scaled in microseconds. Therefore use the base time
+ * of the timestamps to get the initial value which is subtracted from
+ * current timestamp at call time.This will provide a more reliable value even
+ * if the TSC is not reset on soft reset or warm start.
+ */
+uint32_t get_us_since_boot(void);
+
#else
#define timestamp_init(base)
#define timestamp_add(id, time)
#define timestamp_add_now(id)
#define timestamp_rescale_table(N, M)
+#define get_us_since_boot() 0
#endif
/* Implemented by the architecture code */
diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c
index 30f7c13..76a9aca 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -327,6 +327,19 @@
}
}
+/*
+ * Get the time in microseconds since boot (or more precise: since timestamp
+ * table was initialized).
+ */
+uint32_t get_us_since_boot(void)
+{
+ struct timestamp_table *ts = timestamp_table_get();
+
+ if (ts == NULL)
+ return 0;
+ return ((timestamp_get() - ts->base_time) / ts->tick_freq_mhz);
+}
+
ROMSTAGE_CBMEM_INIT_HOOK(timestamp_sync_cache_to_cbmem)
RAMSTAGE_CBMEM_INIT_HOOK(timestamp_sync_cache_to_cbmem)
--
To view, visit https://review.coreboot.org/21516
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib93ad89078645c0ebe256048cb48f9622c90451f
Gerrit-Change-Number: 21516
Gerrit-PatchSet: 1
Gerrit-Owner: Werner Zeh <werner.zeh(a)siemens.com>