[POWERPC] 8xx: Timebase frequency should not depend on bus-frequency
commit50530378161fa8d7837243119ed9140ee65e55d4
authorAnton Vorontsov <avorontsov@ru.mvista.com>
Thu, 21 Feb 2008 19:45:08 +0000 (22 06:45 +1100)
committerPaul Mackerras <paulus@samba.org>
Tue, 26 Feb 2008 11:17:03 +0000 (26 22:17 +1100)
treeb3ae4e02f34a9d115bb4cf703ac19b17ec13688b
parentd9d1063d47cbfe45f8b369475a35c3cdd64fb69c
[POWERPC] 8xx: Timebase frequency should not depend on bus-frequency

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 fixes the system time drifting problem on the EP885C board
running at 133MHz.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/platforms/8xx/m8xx_setup.c