]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/asm-arm/arch-ns9xxx/clock.h
Pull d-states into release branch
[linux-2.6-omap-h63xx.git] / include / asm-arm / arch-ns9xxx / clock.h
index a7c5ab3d90116088d381f48b567d7cec191233f4..bf30cbdcc2bf2d3ec47a7a5fd519015a7c77b931 100644 (file)
 #ifndef __ASM_ARCH_CLOCK_H
 #define __ASM_ARCH_CLOCK_H
 
+#include <asm/arch-ns9xxx/regs-sys.h>
+
+#define CRYSTAL 29491200 /* Hz */
+
+/* The HRM calls this value f_vco */
 static inline u32 ns9xxx_systemclock(void) __attribute__((const));
 static inline u32 ns9xxx_systemclock(void)
 {
+       u32 pll = SYS_PLL;
+
        /*
-        * This should be a multiple of HZ * TIMERCLOCKSELECT (in time.c)
+        * The system clock should be a multiple of HZ * TIMERCLOCKSELECT (in
+        * time.c).
+        *
+        * The following values are given:
+        *   - TIMERCLOCKSELECT == 2^i for an i in {0 .. 6}
+        *   - CRYSTAL == 29491200 == 2^17 * 3^2 * 5^2
+        *   - ND in {0 .. 31}
+        *   - FS in {0 .. 3}
+        *
+        * Assuming the worst, we consider:
+        *   - TIMERCLOCKSELECT == 64
+        *   - ND == 0
+        *   - FS == 3
+        *
+        * So HZ should be a divisor of:
+        *      (CRYSTAL * (ND + 1) >> FS) / TIMERCLOCKSELECT
+        *   == (2^17 * 3^2 * 5^2 * 1 >> 3) / 64
+        *   == 2^8 * 3^2 * 5^2
+        *   == 57600
+        *
+        * Currently HZ is defined to be 100 for this platform.
+        *
+        * Fine.
         */
-       return 353894400;
+       return CRYSTAL * (REGGET(pll, SYS_PLL, ND) + 1)
+               >> REGGET(pll, SYS_PLL, FS);
 }
 
 static inline u32 ns9xxx_cpuclock(void) __attribute__((const));