aboutsummaryrefslogtreecommitdiff
path: root/src/hw
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-03-10 11:22:45 +0100
committerGerd Hoffmann <kraxel@redhat.com>2020-03-16 14:29:41 +0100
commit67cbfedb334db0df7395cc48ccd6bacb2a86a30d (patch)
treedf599ff3c79f9e1e7adde4fcd1ecf626d22fb1a2 /src/hw
parent24d3938ca96a6420ec1a5f1f8479f90f2e9fdd56 (diff)
downloadseabios-hppa-67cbfedb334db0df7395cc48ccd6bacb2a86a30d.zip
seabios-hppa-67cbfedb334db0df7395cc48ccd6bacb2a86a30d.tar.gz
seabios-hppa-67cbfedb334db0df7395cc48ccd6bacb2a86a30d.tar.bz2
timer: add tsctimer_setfreq()
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 <kraxel@redhat.com> Message-id: 20200310102248.28412-1-kraxel@redhat.com
Diffstat (limited to 'src/hw')
-rw-r--r--src/hw/timer.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/hw/timer.c b/src/hw/timer.c
index bdcb3bf..56bb289 100644
--- a/src/hw/timer.c
+++ b/src/hw/timer.c
@@ -101,8 +101,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;
@@ -114,10 +116,32 @@ timer_setup(void)
}
void
+tsctimer_setfreq(u32 khz, const char *src)
+{
+ if (!CONFIG_TSC_TIMER)
+ return;
+ if (TimerPort != PORT_PIT_COUNTER0)
+ return; // have timer already
+
+ TimerKHz = khz;
+ ShiftTSC = 0;
+ while (TimerKHz >= 6000) {
+ ShiftTSC++;
+ TimerKHz = (TimerKHz + 1) >> 1;
+ }
+ TimerPort = 0;
+
+ dprintf(1, "CPU Mhz=%u (%s)\n", (TimerKHz << ShiftTSC) / 1000, src);
+}
+
+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);