From: Bin Meng Date: Sun, 9 Nov 2014 14:19:35 +0000 (+0800) Subject: x86: Save TSC frequency in the global data X-Git-Tag: v2025.01-rc5-pxa1908~14237^2~36 X-Git-Url: http://git.dujemihanovic.xyz/%22/img/sics.gif/%22/static/git-favicon.png?a=commitdiff_plain;h=258b1357c6b324b0a45ca0c1cf3dfd1ef1b4c5c4;p=u-boot.git x86: Save TSC frequency in the global data Return the saved TSC frequency in get_tbclk_mhz(). Signed-off-by: Bin Meng Acked-by: Simon Glass Tested-by: Simon Glass --- diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h index 3e3073ae5c..186b97e6dd 100644 --- a/arch/x86/include/asm/global_data.h +++ b/arch/x86/include/asm/global_data.h @@ -21,6 +21,7 @@ struct arch_global_data { uint64_t tsc_base; /* Initial value returned by rdtsc() */ uint32_t tsc_base_kclocks; /* Initial tsc as a kclocks value */ uint32_t tsc_prev; /* For show_boot_progress() */ + uint32_t tsc_mhz; /* TSC frequency in MHz */ void *new_fdt; /* Relocated FDT */ uint32_t bist; /* Built-in self test value */ }; diff --git a/arch/x86/lib/tsc_timer.c b/arch/x86/lib/tsc_timer.c index ceff60c40e..f091c91669 100644 --- a/arch/x86/lib/tsc_timer.c +++ b/arch/x86/lib/tsc_timer.c @@ -293,6 +293,9 @@ unsigned __attribute__((no_instrument_function)) long get_tbclk_mhz(void) { unsigned long fast_calibrate; + if (gd->arch.tsc_mhz) + return gd->arch.tsc_mhz; + fast_calibrate = try_msr_calibrate_tsc(); if (fast_calibrate) return fast_calibrate; @@ -301,6 +304,7 @@ unsigned __attribute__((no_instrument_function)) long get_tbclk_mhz(void) if (!fast_calibrate) panic("TSC frequency is ZERO"); + gd->arch.tsc_mhz = fast_calibrate; return fast_calibrate; }