2 * Port on Texas Instruments TMS320C6x architecture
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
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.
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>
19 #include <linux/interrupt.h>
20 #include <linux/timex.h>
21 #include <linux/profile.h>
23 #include <asm/timer64.h>
25 static u32 sched_clock_multiplier
;
26 #define SCHED_CLOCK_SHIFT 16
28 static cycle_t
tsc_read(struct clocksource
*cs
)
33 static struct clocksource clocksource_tsc
= {
37 .mask
= CLOCKSOURCE_MASK(64),
38 .flags
= CLOCK_SOURCE_IS_CONTINUOUS
,
42 * scheduler clock - returns current time in nanoseconds.
46 u64 tsc
= get_cycles();
48 return (tsc
* sched_clock_multiplier
) >> SCHED_CLOCK_SHIFT
;
53 u64 tmp
= (u64
)NSEC_PER_SEC
<< SCHED_CLOCK_SHIFT
;
55 do_div(tmp
, c6x_core_freq
);
56 sched_clock_multiplier
= tmp
;
58 clocksource_register_hz(&clocksource_tsc
, c6x_core_freq
);
60 /* write anything into TSCL to enable counting */
63 /* probe for timer64 event timer */