summaryrefslogtreecommitdiff
path: root/payloads
diff options
context:
space:
mode:
Diffstat (limited to 'payloads')
-rw-r--r--payloads/libpayload/drivers/timer/arm64_arch_timer.c2
-rw-r--r--payloads/libpayload/drivers/timer/generic.c4
-rw-r--r--payloads/libpayload/drivers/timer/rdtsc.c5
-rw-r--r--payloads/libpayload/include/libpayload.h2
-rw-r--r--payloads/libpayload/libc/time.c5
5 files changed, 8 insertions, 10 deletions
diff --git a/payloads/libpayload/drivers/timer/arm64_arch_timer.c b/payloads/libpayload/drivers/timer/arm64_arch_timer.c
index b4d2b865ae..087d9e7565 100644
--- a/payloads/libpayload/drivers/timer/arm64_arch_timer.c
+++ b/payloads/libpayload/drivers/timer/arm64_arch_timer.c
@@ -32,7 +32,7 @@
#include <arch/lib_helpers.h>
#include <libpayload.h>
-uint32_t timer_hz(void)
+uint64_t timer_hz(void)
{
return raw_read_cntfrq_el0();
}
diff --git a/payloads/libpayload/drivers/timer/generic.c b/payloads/libpayload/drivers/timer/generic.c
index bd5674be8c..46bc291c13 100644
--- a/payloads/libpayload/drivers/timer/generic.c
+++ b/payloads/libpayload/drivers/timer/generic.c
@@ -33,10 +33,8 @@
#include <assert.h>
#include <libpayload.h>
-uint32_t timer_hz(void)
+uint64_t timer_hz(void)
{
- /* libc/time.c currently requires all timers to be at least 1MHz. */
- assert(CONFIG_LP_TIMER_GENERIC_HZ >= 1000000);
return CONFIG_LP_TIMER_GENERIC_HZ;
}
diff --git a/payloads/libpayload/drivers/timer/rdtsc.c b/payloads/libpayload/drivers/timer/rdtsc.c
index 952bc0bb13..d5bf1d2057 100644
--- a/payloads/libpayload/drivers/timer/rdtsc.c
+++ b/payloads/libpayload/drivers/timer/rdtsc.c
@@ -35,10 +35,9 @@
#include <arch/rdtsc.h>
#include <assert.h>
-uint32_t timer_hz(void)
+uint64_t timer_hz(void)
{
- assert(UINT32_MAX / 1000 >= lib_sysinfo.cpu_khz);
- return lib_sysinfo.cpu_khz * 1000;
+ return (uint64_t)lib_sysinfo.cpu_khz * 1000;
}
uint64_t timer_raw_value(void)
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 6da4564734..5e34124c7e 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -519,7 +519,7 @@ void lib_sysinfo_get_memranges(struct memrange **ranges,
/* Timer functions. */
/* Defined by each architecture. */
-uint32_t timer_hz(void);
+uint64_t timer_hz(void);
uint64_t timer_raw_value(void);
uint64_t timer_us(uint64_t base);
/* Generic. */
diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c
index 28f2b3e2a9..64de80049c 100644
--- a/payloads/libpayload/libc/time.c
+++ b/payloads/libpayload/libc/time.c
@@ -171,14 +171,15 @@ void arch_ndelay(uint64_t ns)
u64 timer_us(u64 base)
{
- static u32 hz, mult = USECS_PER_SEC;
+ static u64 hz;
+ static u32 mult = USECS_PER_SEC;
u32 div;
// Only check timer_hz once. Assume it doesn't change.
if (hz == 0) {
hz = timer_hz();
if (hz < mult) {
- printf("Timer frequency %" PRIu32 " is too low, "
+ printf("Timer frequency %" PRIu64 " is too low, "
"must be at least 1MHz.\n", hz);
halt();
}