aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus/clock.h
blob: bb493e73d50229bf9efaffba9796e8c03dc058b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef _LITMUS_CLOCK_H_
#define _LITMUS_CLOCK_H_

#if defined(CONFIG_EXYNOS_MCT)

/*
 * Only used if we are using the EXYNOS MCT clock.
 */

#include <linux/clocksource.h>
extern struct clocksource mct_frc;

static inline cycles_t mct_frc_read(void)
{
	cycle_t cycles = mct_frc.read(&mct_frc);
	return cycles;
}

static inline s64 litmus_cycles_to_ns(cycles_t cycles)
{
	return clocksource_cyc2ns(cycles, mct_frc.mult, mct_frc.shift);
}

#define litmus_get_cycles mct_frc_read

#elif defined(CONFIG_CPU_V7) && !defined(CONFIG_HW_PERF_EVENTS)

#include <asm/timex.h>

static inline cycles_t v7_get_cycles (void)
{
	u32 value;
        /* read CCNT register */
        asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(value));
	return value;
}

#define litmus_get_cycles v7_get_cycles

#else
#include <asm/timex.h>

#define litmus_get_cycles get_cycles

#endif

#endif