blob: 641279707a842187d48837575e5b4a663c9ff4e4 (
plain)
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
48
49
50
51
52
|
/*
* Copyright (C) ST-Ericsson SA 2011
*
* License Terms: GNU General Public License v2
*/
#include <linux/io.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/clockchips.h>
#include <linux/clksrc-db5500-mtimer.h>
#include <asm/sched_clock.h>
#define MTIMER_PRIMARY_COUNTER 0x18
static void __iomem *db5500_mtimer_base;
#ifdef CONFIG_CLKSRC_DB5500_MTIMER_SCHED_CLOCK
static DEFINE_CLOCK_DATA(cd);
unsigned long long notrace sched_clock(void)
{
u32 cyc;
if (unlikely(!db5500_mtimer_base))
return 0;
cyc = readl_relaxed(db5500_mtimer_base + MTIMER_PRIMARY_COUNTER);
return cyc_to_sched_clock(&cd, cyc, (u32)~0);
}
static void notrace db5500_mtimer_update_sched_clock(void)
{
u32 cyc = readl_relaxed(db5500_mtimer_base + MTIMER_PRIMARY_COUNTER);
update_sched_clock(&cd, cyc, (u32)~0);
}
#endif
void __init db5500_mtimer_init(void __iomem *base)
{
db5500_mtimer_base = base;
clocksource_mmio_init(base + MTIMER_PRIMARY_COUNTER, "mtimer", 32768,
400, 32, clocksource_mmio_readl_up);
#ifdef CONFIG_CLKSRC_DB5500_MTIMER_SCHED_CLOCK
init_sched_clock(&cd, db5500_mtimer_update_sched_clock,
32, 32768);
#endif
}
|