common: Drop linux/delay.h from common header
[oweals/u-boot.git] / drivers / timer / tsc_timer.c
index 0df551f94cce09167a072125f1f98c67ec3fdf50..93c959ff44452c8e4bc5f834e5e7d9962e9a2382 100644 (file)
@@ -7,7 +7,9 @@
  */
 
 #include <common.h>
+#include <bootstage.h>
 #include <dm.h>
+#include <log.h>
 #include <malloc.h>
 #include <time.h>
 #include <timer.h>
@@ -17,6 +19,7 @@
 #include <asm/ibmpc.h>
 #include <asm/msr.h>
 #include <asm/u-boot-x86.h>
+#include <linux/delay.h>
 
 #define MAX_NUM_FREQS  9
 
@@ -50,8 +53,7 @@ static unsigned long native_calibrate_tsc(void)
                return 0;
 
        crystal_freq = tsc_info.ecx / 1000;
-
-       if (!crystal_freq) {
+       if (!CONFIG_IS_ENABLED(X86_TSC_TIMER_NATIVE) && !crystal_freq) {
                switch (gd->arch.x86_model) {
                case INTEL_FAM6_SKYLAKE_MOBILE:
                case INTEL_FAM6_SKYLAKE_DESKTOP:
@@ -397,7 +399,8 @@ static void tsc_timer_ensure_setup(bool early)
 {
        if (gd->arch.tsc_inited)
                return;
-       gd->arch.tsc_base = rdtsc();
+       if (IS_ENABLED(CONFIG_X86_TSC_READ_BASE))
+               gd->arch.tsc_base = rdtsc();
 
        if (!gd->arch.clock_rate) {
                unsigned long fast_calibrate;
@@ -406,6 +409,10 @@ static void tsc_timer_ensure_setup(bool early)
                if (fast_calibrate)
                        goto done;
 
+               /* Reduce code size by dropping other methods */
+               if (CONFIG_IS_ENABLED(X86_TSC_TIMER_NATIVE))
+                       panic("no timer");
+
                fast_calibrate = cpu_mhz_from_cpuid();
                if (fast_calibrate)
                        goto done;