aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-versatile
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-12-15 16:56:47 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-12-22 17:44:50 -0500
commit1da0c89c66753860ccfe81eb327c25db46c2a24a (patch)
tree565710dc2a57dca18a17d3e34465485f32191b81 /arch/arm/plat-versatile
parentf06a1624621527ef597ae4b3b795553fc1b2eff2 (diff)
ARM: versatile: convert sched_clock() to use new infrastructure
Convert versatile platforms to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds. Tested-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/plat-versatile')
-rw-r--r--arch/arm/plat-versatile/include/plat/sched_clock.h6
-rw-r--r--arch/arm/plat-versatile/sched-clock.c48
2 files changed, 32 insertions, 22 deletions
diff --git a/arch/arm/plat-versatile/include/plat/sched_clock.h b/arch/arm/plat-versatile/include/plat/sched_clock.h
new file mode 100644
index 00000000000..5c3e4fc9fa0
--- /dev/null
+++ b/arch/arm/plat-versatile/include/plat/sched_clock.h
@@ -0,0 +1,6 @@
1#ifndef ARM_PLAT_SCHED_CLOCK_H
2#define ARM_PLAT_SCHED_CLOCK_H
3
4void versatile_sched_clock_init(void __iomem *, unsigned long);
5
6#endif
diff --git a/arch/arm/plat-versatile/sched-clock.c b/arch/arm/plat-versatile/sched-clock.c
index 42efd14ed4b..3d6a4c292ca 100644
--- a/arch/arm/plat-versatile/sched-clock.c
+++ b/arch/arm/plat-versatile/sched-clock.c
@@ -18,37 +18,41 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21#include <linux/cnt32_to_63.h>
22#include <linux/io.h> 21#include <linux/io.h>
23#include <linux/sched.h> 22#include <linux/sched.h>
24#include <asm/div64.h>
25 23
26#include <mach/hardware.h> 24#include <asm/sched_clock.h>
27#include <mach/platform.h> 25#include <plat/sched_clock.h>
28 26
29#ifdef VERSATILE_SYS_BASE 27static DEFINE_CLOCK_DATA(cd);
30#define REFCOUNTER (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET) 28static void __iomem *ctr;
31#endif
32
33#ifdef REALVIEW_SYS_BASE
34#define REFCOUNTER (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_24MHz_OFFSET)
35#endif
36 29
37/* 30/*
38 * This is the Realview and Versatile sched_clock implementation. This 31 * Constants generated by clocks_calc_mult_shift(m, s, 24MHz, NSEC_PER_SEC, 60).
39 * has a resolution of 41.7ns, and a maximum value of about 35583 days. 32 * This gives a resolution of about 41ns and a wrap period of about 178s.
40 *
41 * The return value is guaranteed to be monotonic in that range as
42 * long as there is always less than 89 seconds between successive
43 * calls to this function.
44 */ 33 */
34#define SC_MULT 2796202667u
35#define SC_SHIFT 26
36
45unsigned long long notrace sched_clock(void) 37unsigned long long notrace sched_clock(void)
46{ 38{
47 unsigned long long v = cnt32_to_63(readl(REFCOUNTER)); 39 if (ctr) {
40 u32 cyc = readl(ctr);
41 return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0,
42 SC_MULT, SC_SHIFT);
43 } else
44 return 0;
45}
48 46
49 /* the <<1 gets rid of the cnt_32_to_63 top bit saving on a bic insn */ 47static void notrace versatile_update_sched_clock(void)
50 v *= 125<<1; 48{
51 do_div(v, 3<<1); 49 u32 cyc = readl(ctr);
50 update_sched_clock(&cd, cyc, (u32)~0);
51}
52 52
53 return v; 53void __init versatile_sched_clock_init(void __iomem *reg, unsigned long rate)
54{
55 ctr = reg;
56 init_fixed_sched_clock(&cd, versatile_update_sched_clock,
57 32, rate, SC_MULT, SC_SHIFT);
54} 58}