Add function to set tsc frequency directly, without calibration.
Also tweak timer setup functions a bit: skip setup in case TimerPort
has not the default value any more, i.e. another timer has been setup
already.

Signed-off-by: Gerd Hoffmann <kra...@redhat.com>
---
 src/util.h     |  1 +
 src/hw/timer.c | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/util.h b/src/util.h
index d96db788d1b8..0a75a6e96c95 100644
--- a/src/util.h
+++ b/src/util.h
@@ -171,6 +171,7 @@ void sdcard_setup(void);
 // hw/timer.c
 void timer_setup(void);
 void pmtimer_setup(u16 ioport);
+void tsctimer_setfreq(u32 khz);
 u32 timer_calc(u32 msecs);
 u32 timer_calc_usec(u32 usecs);
 int timer_check(u32 end);
diff --git a/src/hw/timer.c b/src/hw/timer.c
index ce3d63cd75f6..a13f363b45a6 100644
--- a/src/hw/timer.c
+++ b/src/hw/timer.c
@@ -106,8 +106,10 @@ tsctimer_setup(void)
 void
 timer_setup(void)
 {
-    if (!CONFIG_TSC_TIMER || (CONFIG_PMTIMER && TimerPort != 
PORT_PIT_COUNTER0))
+    if (!CONFIG_TSC_TIMER)
         return;
+    if (TimerPort != PORT_PIT_COUNTER0)
+        return; // have timer already
 
     // Check if CPU has a timestamp counter
     u32 eax, ebx, ecx, edx, cpuid_features = 0;
@@ -118,11 +120,25 @@ timer_setup(void)
         tsctimer_setup();
 }
 
+void
+tsctimer_setfreq(u32 khz)
+{
+    if (!CONFIG_TSC_TIMER)
+        return;
+    if (TimerPort != PORT_PIT_COUNTER0)
+        return; // have timer already
+
+    tsctimer_configure((u64)khz * PMTIMER_TO_PIT * 1000);
+}
+
 void
 pmtimer_setup(u16 ioport)
 {
     if (!CONFIG_PMTIMER)
         return;
+    if (TimerPort != PORT_PIT_COUNTER0)
+        return; // have timer already
+
     dprintf(1, "Using pmtimer, ioport 0x%x\n", ioport);
     TimerPort = ioport;
     TimerKHz = DIV_ROUND_UP(PMTIMER_HZ, 1000);
-- 
2.18.2
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-le...@seabios.org

Reply via email to