x86: Save TSC frequency in the global data
authorBin Meng <bmeng.cn@gmail.com>
Sun, 9 Nov 2014 14:19:35 +0000 (22:19 +0800)
committerSimon Glass <sjg@chromium.org>
Fri, 21 Nov 2014 06:24:10 +0000 (07:24 +0100)
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-by: Simon Glass <sjg@chromium.org>
arch/x86/include/asm/global_data.h
arch/x86/lib/tsc_timer.c

index 3e3073ae5c20b0ef922889ae9a3304666c67a1f2..186b97e6dda9c96780fd34ef2a47fe8ed360f5d1 100644 (file)
@@ -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 */
 };
index ceff60c40e6c98e50fcce23a5b7c1c22e7a2140c..f091c9166946b7602929beed878e6428a0014045 100644 (file)
@@ -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;
 }