summaryrefslogtreecommitdiff
path: root/src/cpu/x86/tsc
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-04-08 21:41:01 -0500
committerMartin Roth <martinroth@google.com>2016-04-11 16:15:57 +0200
commitb8671eafde839cb93aa4af3888f2fedf59401899 (patch)
treef81072f0e2c08a4ac3bd2f71864d12f30db2748e /src/cpu/x86/tsc
parent01dfdc5369de3899731982a015ce708184552ac6 (diff)
downloadcoreboot-b8671eafde839cb93aa4af3888f2fedf59401899.tar.xz
cpu/x86/tsc: remove conditional compilation
The delay_tsc.c compilation unit used the C preprocessor to conditionally compile different code paths. Instead of guarding large blocks of code allow the compiler to optimize out unreachable code. Change-Id: I660c21d6f4099b0d7aefa84b14f1e68d6fd732c3 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/14302 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh <furquan@google.com> Reviewed-by: Andrey Petrov <andrey.petrov@intel.com>
Diffstat (limited to 'src/cpu/x86/tsc')
-rw-r--r--src/cpu/x86/tsc/delay_tsc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cpu/x86/tsc/delay_tsc.c b/src/cpu/x86/tsc/delay_tsc.c
index 439b477283..6120b88e96 100644
--- a/src/cpu/x86/tsc/delay_tsc.c
+++ b/src/cpu/x86/tsc/delay_tsc.c
@@ -9,12 +9,6 @@
static unsigned long clocks_per_usec CAR_GLOBAL;
-#if CONFIG_TSC_CONSTANT_RATE
-static unsigned long calibrate_tsc(void)
-{
- return tsc_freq_mhz();
-}
-#else /* CONFIG_TSC_CONSTANT_RATE */
#define CLOCK_TICK_RATE 1193180U /* Underlying HZ */
/* ------ Calibrate the TSC -------
@@ -28,7 +22,7 @@ static unsigned long calibrate_tsc(void)
#define CALIBRATE_INTERVAL ((2*CLOCK_TICK_RATE)/1000) /* 2ms */
#define CALIBRATE_DIVISOR (2*1000) /* 2ms / 2000 == 1usec */
-static unsigned long long calibrate_tsc(void)
+static unsigned long calibrate_tsc_with_pit(void)
{
/* Set the Gate high, disable speaker */
outb((inb(0x61) & ~0x02) | 0x01, 0x61);
@@ -89,7 +83,13 @@ bad_ctc:
return 0;
}
-#endif /* CONFIG_TSC_CONSTANT_RATE */
+static unsigned long calibrate_tsc(void)
+{
+ if (IS_ENABLED(CONFIG_TSC_CONSTANT_RATE))
+ return tsc_freq_mhz();
+ else
+ return calibrate_tsc_with_pit();
+}
void init_timer(void)
{