aboutsummaryrefslogtreecommitdiffstats
path: root/arch/c6x/kernel/time.c
diff options
context:
space:
mode:
authorAurelien Jacquiot <a-jacquiot@ti.com>2011-10-04 11:05:33 -0400
committerMark Salter <msalter@redhat.com>2011-10-06 19:47:51 -0400
commit546a39546c64ad7e73796c5508ef5487af42cae2 (patch)
tree9ab7fb5512ac1a99ab29267482469dcd8a8252ff /arch/c6x/kernel/time.c
parent03a347558749caaab482f34410ae5d27e893db89 (diff)
C6X: time management
Original port to early 2.6 kernel using TI COFF toolchain. Brought up to date by Mark Salter <msalter@redhat.com> Signed-off-by: Aurelien Jacquiot <a-jacquiot@ti.com> Signed-off-by: Mark Salter <msalter@redhat.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/c6x/kernel/time.c')
-rw-r--r--arch/c6x/kernel/time.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/c6x/kernel/time.c b/arch/c6x/kernel/time.c
new file mode 100644
index 000000000000..4c9f136165f7
--- /dev/null
+++ b/arch/c6x/kernel/time.c
@@ -0,0 +1,65 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/clocksource.h>
14#include <linux/errno.h>
15#include <linux/sched.h>
16#include <linux/param.h>
17#include <linux/string.h>
18#include <linux/mm.h>
19#include <linux/interrupt.h>
20#include <linux/timex.h>
21#include <linux/profile.h>
22
23#include <asm/timer64.h>
24
25static u32 sched_clock_multiplier;
26#define SCHED_CLOCK_SHIFT 16
27
28static cycle_t tsc_read(struct clocksource *cs)
29{
30 return get_cycles();
31}
32
33static struct clocksource clocksource_tsc = {
34 .name = "timestamp",
35 .rating = 300,
36 .read = tsc_read,
37 .mask = CLOCKSOURCE_MASK(64),
38 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
39};
40
41/*
42 * scheduler clock - returns current time in nanoseconds.
43 */
44u64 sched_clock(void)
45{
46 u64 tsc = get_cycles();
47
48 return (tsc * sched_clock_multiplier) >> SCHED_CLOCK_SHIFT;
49}
50
51void time_init(void)
52{
53 u64 tmp = (u64)NSEC_PER_SEC << SCHED_CLOCK_SHIFT;
54
55 do_div(tmp, c6x_core_freq);
56 sched_clock_multiplier = tmp;
57
58 clocksource_register_hz(&clocksource_tsc, c6x_core_freq);
59
60 /* write anything into TSCL to enable counting */
61 set_creg(TSCL, 0);
62
63 /* probe for timer64 event timer */
64 timer64_init();
65}