diff options
-rw-r--r-- | include/asm-arm/arch-ns9xxx/clock.h | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/include/asm-arm/arch-ns9xxx/clock.h b/include/asm-arm/arch-ns9xxx/clock.h index a7c5ab3d9011..bf30cbdcc2bf 100644 --- a/include/asm-arm/arch-ns9xxx/clock.h +++ b/include/asm-arm/arch-ns9xxx/clock.h | |||
@@ -11,13 +11,43 @@ | |||
11 | #ifndef __ASM_ARCH_CLOCK_H | 11 | #ifndef __ASM_ARCH_CLOCK_H |
12 | #define __ASM_ARCH_CLOCK_H | 12 | #define __ASM_ARCH_CLOCK_H |
13 | 13 | ||
14 | #include <asm/arch-ns9xxx/regs-sys.h> | ||
15 | |||
16 | #define CRYSTAL 29491200 /* Hz */ | ||
17 | |||
18 | /* The HRM calls this value f_vco */ | ||
14 | static inline u32 ns9xxx_systemclock(void) __attribute__((const)); | 19 | static inline u32 ns9xxx_systemclock(void) __attribute__((const)); |
15 | static inline u32 ns9xxx_systemclock(void) | 20 | static inline u32 ns9xxx_systemclock(void) |
16 | { | 21 | { |
22 | u32 pll = SYS_PLL; | ||
23 | |||
17 | /* | 24 | /* |
18 | * This should be a multiple of HZ * TIMERCLOCKSELECT (in time.c) | 25 | * The system clock should be a multiple of HZ * TIMERCLOCKSELECT (in |
26 | * time.c). | ||
27 | * | ||
28 | * The following values are given: | ||
29 | * - TIMERCLOCKSELECT == 2^i for an i in {0 .. 6} | ||
30 | * - CRYSTAL == 29491200 == 2^17 * 3^2 * 5^2 | ||
31 | * - ND in {0 .. 31} | ||
32 | * - FS in {0 .. 3} | ||
33 | * | ||
34 | * Assuming the worst, we consider: | ||
35 | * - TIMERCLOCKSELECT == 64 | ||
36 | * - ND == 0 | ||
37 | * - FS == 3 | ||
38 | * | ||
39 | * So HZ should be a divisor of: | ||
40 | * (CRYSTAL * (ND + 1) >> FS) / TIMERCLOCKSELECT | ||
41 | * == (2^17 * 3^2 * 5^2 * 1 >> 3) / 64 | ||
42 | * == 2^8 * 3^2 * 5^2 | ||
43 | * == 57600 | ||
44 | * | ||
45 | * Currently HZ is defined to be 100 for this platform. | ||
46 | * | ||
47 | * Fine. | ||
19 | */ | 48 | */ |
20 | return 353894400; | 49 | return CRYSTAL * (REGGET(pll, SYS_PLL, ND) + 1) |
50 | >> REGGET(pll, SYS_PLL, FS); | ||
21 | } | 51 | } |
22 | 52 | ||
23 | static inline u32 ns9xxx_cpuclock(void) __attribute__((const)); | 53 | static inline u32 ns9xxx_cpuclock(void) __attribute__((const)); |