Fix VIA-based TB/Decrementer calibration , previously it wouldn't work

properly with HZ != 100, causing tb_to_us to be wrong and gettimeofday()
to return strangely "off" results
parent b87d0087
...@@ -166,7 +166,7 @@ via_calibrate_decr(void) ...@@ -166,7 +166,7 @@ via_calibrate_decr(void)
{ {
struct device_node *vias; struct device_node *vias;
volatile unsigned char *via; volatile unsigned char *via;
int count = VIA_TIMER_FREQ_6 / HZ; int count = VIA_TIMER_FREQ_6 / 100;
unsigned int dstart, dend; unsigned int dstart, dend;
vias = find_devices("via-cuda"); vias = find_devices("via-cuda");
...@@ -196,7 +196,7 @@ via_calibrate_decr(void) ...@@ -196,7 +196,7 @@ via_calibrate_decr(void)
; ;
dend = get_dec(); dend = get_dec();
tb_ticks_per_jiffy = (dstart - dend) / 6; tb_ticks_per_jiffy = (dstart - dend) / (6 * (HZ/100));
tb_to_us = mulhwu_scale_factor(dstart - dend, 60000); tb_to_us = mulhwu_scale_factor(dstart - dend, 60000);
printk(KERN_INFO "via_calibrate_decr: ticks per jiffy = %u (%u ticks)\n", printk(KERN_INFO "via_calibrate_decr: ticks per jiffy = %u (%u ticks)\n",
...@@ -260,7 +260,9 @@ pmac_calibrate_decr(void) ...@@ -260,7 +260,9 @@ pmac_calibrate_decr(void)
* calibration. That's better since the VIA itself seems * calibration. That's better since the VIA itself seems
* to be slightly off. --BenH * to be slightly off. --BenH
*/ */
if (!machine_is_compatible("MacRISC2")) if (!machine_is_compatible("MacRISC2") &&
!machine_is_compatible("MacRISC3") &&
!machine_is_compatible("MacRISC4"))
if (via_calibrate_decr()) if (via_calibrate_decr())
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment