diff options
author | Rabin Vincent <rabin.vincent@stericsson.com> | 2011-09-27 11:04:33 +0530 |
---|---|---|
committer | Philippe Langlais <philippe.langlais@stericsson.com> | 2012-05-22 10:59:15 +0200 |
commit | fcd4d651204ac31dba7698c5c7021d32c7ffd092 (patch) | |
tree | 481986cc598aa5ae2b5c4c578a5a31b9a44a213c /drivers/clocksource/db5500-mtimer.c | |
parent | 549174ab70724aa8d8e19c19d62ccdd98d5865ea (diff) |
u5500: add MTIMER clocksource
ST-Ericsson ID: 368260
ST-Ericsson Linux next: NA
ST-Ericsson FOSS-OUT ID: Trivial
Depends-On: I5307cb7f58fdf890896d641a8e4f49098a90b68e
Change-Id: I9ef4ff1c63f6ec9293ece4013f13cf3caa707d9d
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/34307
Reviewed-by: QATOOLS
Reviewed-by: QABUILD
Diffstat (limited to 'drivers/clocksource/db5500-mtimer.c')
-rw-r--r-- | drivers/clocksource/db5500-mtimer.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/clocksource/db5500-mtimer.c b/drivers/clocksource/db5500-mtimer.c new file mode 100644 index 00000000000..641279707a8 --- /dev/null +++ b/drivers/clocksource/db5500-mtimer.c @@ -0,0 +1,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 +} |