RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / include / asm-arm / arch-ns9xxx / clock.h
blobbf30cbdcc2bf2d3ec47a7a5fd519015a7c77b931
1 /*
2 * include/asm-arm/arch-ns9xxx/clock.h
4 * Copyright (C) 2007 by Digi International Inc.
5 * All rights reserved.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
11 #ifndef __ASM_ARCH_CLOCK_H
12 #define __ASM_ARCH_CLOCK_H
14 #include <asm/arch-ns9xxx/regs-sys.h>
16 #define CRYSTAL 29491200 /* Hz */
18 /* The HRM calls this value f_vco */
19 static inline u32 ns9xxx_systemclock(void) __attribute__((const));
20 static inline u32 ns9xxx_systemclock(void)
22 u32 pll = SYS_PLL;
25 * The system clock should be a multiple of HZ * TIMERCLOCKSELECT (in
26 * time.c).
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}
34 * Assuming the worst, we consider:
35 * - TIMERCLOCKSELECT == 64
36 * - ND == 0
37 * - FS == 3
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
45 * Currently HZ is defined to be 100 for this platform.
47 * Fine.
49 return CRYSTAL * (REGGET(pll, SYS_PLL, ND) + 1)
50 >> REGGET(pll, SYS_PLL, FS);
53 static inline u32 ns9xxx_cpuclock(void) __attribute__((const));
54 static inline u32 ns9xxx_cpuclock(void)
56 return ns9xxx_systemclock() / 2;
59 static inline u32 ns9xxx_ahbclock(void) __attribute__((const));
60 static inline u32 ns9xxx_ahbclock(void)
62 return ns9xxx_systemclock() / 4;
65 static inline u32 ns9xxx_bbusclock(void) __attribute__((const));
66 static inline u32 ns9xxx_bbusclock(void)
68 return ns9xxx_systemclock() / 8;
71 #endif /* ifndef __ASM_ARCH_CLOCK_H */