Skip to content
Snippets Groups Projects
Commit 94e72a6b authored by Bin Meng's avatar Bin Meng
Browse files

x86: timer: tsc: Allow specifying clock rate from device tree again


With the introduction of early timer support in the TSC driver,
the capability of getting clock rate from device tree was lost
unfortunately. Now we bring such functionality back, but with a
limitation that when TSC is used as early timer, specifying clock
rate from device tree does not work.

This fixes random boot failures seen on QEMU targets: printing "TSC
frequency is ZERO" and reset forever.

Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
parent 2121bbe4
No related branches found
No related tags found
No related merge requests found
...@@ -377,14 +377,23 @@ static int tsc_timer_probe(struct udevice *dev) ...@@ -377,14 +377,23 @@ static int tsc_timer_probe(struct udevice *dev)
{ {
struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
tsc_timer_ensure_setup(); if (!uc_priv->clock_rate) {
uc_priv->clock_rate = gd->arch.clock_rate; tsc_timer_ensure_setup();
uc_priv->clock_rate = gd->arch.clock_rate;
} else {
gd->arch.tsc_base = rdtsc();
}
return 0; return 0;
} }
unsigned long notrace timer_early_get_rate(void) unsigned long notrace timer_early_get_rate(void)
{ {
/*
* When TSC timer is used as the early timer, be warned that the timer
* clock rate can only be calibrated via some hardware ways. Specifying
* it in the device tree won't work for the early timer.
*/
tsc_timer_ensure_setup(); tsc_timer_ensure_setup();
return gd->arch.clock_rate; return gd->arch.clock_rate;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment