linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [POWERPC] 8xx: timebase frequency should not depend on bus-frequency
@ 2008-02-21 19:45 Anton Vorontsov
  2008-02-21 19:48 ` Scott Wood
  0 siblings, 1 reply; 8+ messages in thread
From: Anton Vorontsov @ 2008-02-21 19:45 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Scott Wood

m8xx_setup.c says:
   /* Force all 8xx processors to use divide by 16 processor clock. */

And at the same time it is using bus-frequency for calculating
timebase. It is okay for most setups because bus-frequency is
equal to clock-frequency.

The problem emerges when cpu frequency is > 66MHz, quoting
u-boot/cpu/mpc8xx/speed.c:

        if (gd->cpu_clk <= 66000000) {
                sccr_reg |= SCCR_EBDF00;        /* bus division factor = 1 */
                gd->bus_clk = gd->cpu_clk;
        } else {
                sccr_reg |= SCCR_EBDF01;        /* bus division factor = 2 */
                gd->bus_clk = gd->cpu_clk / 2;
        }

So in case of cpu clock > 66MHz, bus_clk = cpu_clk / 2. An then, from
Linux, we calculate timebase frequency as tb_freq = bus_clk / 16,
that is cpu_clk / 2 / 16, which is wrong.

This patch fixes system time drifting problem on the EP885C board
running at 133MHz.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 arch/powerpc/platforms/8xx/m8xx_setup.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c
index 184f998..0d9f75c 100644
--- a/arch/powerpc/platforms/8xx/m8xx_setup.c
+++ b/arch/powerpc/platforms/8xx/m8xx_setup.c
@@ -111,17 +111,12 @@ void __init mpc8xx_calibrate_decr(void)
 
 	/* Processor frequency is MHz.
 	 */
-	ppc_tb_freq = 50000000;
-	if (!get_freq("bus-frequency", &ppc_tb_freq)) {
-		printk(KERN_ERR "WARNING: Estimating decrementer frequency "
-		                "(not found)\n");
-	}
-	ppc_tb_freq /= 16;
 	ppc_proc_freq = 50000000;
 	if (!get_freq("clock-frequency", &ppc_proc_freq))
 		printk(KERN_ERR "WARNING: Estimating processor frequency "
 		                "(not found)\n");
 
+	ppc_tb_freq = ppc_proc_freq / 16;
 	printk("Decrementer Frequency = 0x%lx\n", ppc_tb_freq);
 
 	/* Perform some more timer/timebase initialization.  This used
-- 
1.5.2.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-02-22 13:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-21 19:45 [PATCH] [POWERPC] 8xx: timebase frequency should not depend on bus-frequency Anton Vorontsov
2008-02-21 19:48 ` Scott Wood
2008-02-21 19:59   ` Anton Vorontsov
2008-02-21 20:06     ` Scott Wood
2008-02-21 21:13       ` Anton Vorontsov
2008-02-21 21:20         ` Scott Wood
2008-02-21 23:41           ` Anton Vorontsov
2008-02-22 13:01             ` Bryan O'Donoghue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).