diff mbox

[U-Boot,4/4] x86: Save TSC frequency in the global data

Message ID 1415113122-16942-1-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Bin Meng Nov. 4, 2014, 2:58 p.m. UTC
Return the saved TSC frequency in get_tbclk_mhz().

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
 arch/x86/include/asm/global_data.h | 1 +
 arch/x86/lib/tsc_timer.c           | 4 ++++
 2 files changed, 5 insertions(+)

Comments

Simon Glass Nov. 7, 2014, 2:26 a.m. UTC | #1
On 4 November 2014 07:58, Bin Meng <bmeng.cn@gmail.com> wrote:
> Return the saved TSC frequency in get_tbclk_mhz().
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

Acked-by: Simon Glass <sjg@chromium.org>

Tested on link:
Tested-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h
index 721e7dc..7f22336 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 */
 };
 
diff --git a/arch/x86/lib/tsc_timer.c b/arch/x86/lib/tsc_timer.c
index 8a0abde..b5f0458 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;
 }