diff options
author | Tom Rini <trini@konsulko.com> | 2024-10-18 22:32:45 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-10-18 22:32:45 -0600 |
commit | 7036abbd5c3934059b020d5fd5bcb8b3bf3c788c (patch) | |
tree | 0fb8fd19b51862cf5742ec68ef889e4ad441dde7 /drivers/timer/tsc_timer.c | |
parent | f83e36fd83c74b4e28a45a9d56abc4ad9b7848b9 (diff) | |
parent | 44917d586657eeae0401bc29af80011a264002e7 (diff) |
Merge tag 'dm-pull-17oct24-take2' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
A few new x86 commands and minor improvements
expo improvements
binman support for signing FIT images
Diffstat (limited to 'drivers/timer/tsc_timer.c')
-rw-r--r-- | drivers/timer/tsc_timer.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c index 80c084f380d..dd16ab320b2 100644 --- a/drivers/timer/tsc_timer.c +++ b/drivers/timer/tsc_timer.c @@ -83,7 +83,7 @@ static unsigned long cpu_mhz_from_cpuid(void) if (cpuid_eax(0) < 0x16) return 0; - return cpuid_eax(0x16); + return cpuid_eax(0x15); } /* @@ -299,10 +299,19 @@ static unsigned long __maybe_unused quick_pit_calibrate(void) if (!pit_expect_msb(0xff-i, &delta, &d2)) break; + delta -= tsc; + + /* + * Extrapolate the error and fail fast if the error will + * never be below 500 ppm. + */ + if (i == 1 && + d1 + d2 >= (delta * MAX_QUICK_PIT_ITERATIONS) >> 11) + return 0; + /* * Iterate until the error is less than 500 ppm */ - delta -= tsc; if (d1+d2 >= delta >> 11) continue; @@ -403,6 +412,10 @@ static void tsc_timer_ensure_setup(bool early) if (!gd->arch.clock_rate) { unsigned long fast_calibrate; + /* deal with this being called before x86_cpu_init_f() */ + if (!gd->arch.x86_vendor) + x86_get_identity_for_timer(); + /** * There is no obvious way to obtain this information from EFI * boot services. This value was measured on a Framework Laptop @@ -438,6 +451,7 @@ static void tsc_timer_ensure_setup(bool early) return; done: + fast_calibrate = min(fast_calibrate, 4000UL); if (!gd->arch.clock_rate) gd->arch.clock_rate = fast_calibrate * 1000000; } |