aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource
diff options
context:
space:
mode:
authorSoren Brinkmann <soren.brinkmann@xilinx.com>2013-07-08 12:51:38 -0400
committerDaniel Lezcano <daniel.lezcano@linaro.org>2013-07-18 09:27:34 -0400
commit3d77b30efc72d126c2b74070b41a03869611228d (patch)
treeafb1f066786838338bac582aca8ddc8983449120 /drivers/clocksource
parent9bbf914043e04f65e619f3c0ff67c387812f9458 (diff)
clocksource: cadence_ttc: Reuse clocksource as sched_clock
Reuse the TTC clocksource timer as sched clock provider. Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/cadence_ttc_timer.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/clocksource/cadence_ttc_timer.c b/drivers/clocksource/cadence_ttc_timer.c
index 0eefc8d8622b..b2bb3a4bc205 100644
--- a/drivers/clocksource/cadence_ttc_timer.c
+++ b/drivers/clocksource/cadence_ttc_timer.c
@@ -21,6 +21,7 @@
21#include <linux/of_address.h> 21#include <linux/of_address.h>
22#include <linux/of_irq.h> 22#include <linux/of_irq.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/sched_clock.h>
24 25
25/* 26/*
26 * This driver configures the 2 16-bit count-up timers as follows: 27 * This driver configures the 2 16-bit count-up timers as follows:
@@ -94,6 +95,8 @@ struct ttc_timer_clockevent {
94#define to_ttc_timer_clkevent(x) \ 95#define to_ttc_timer_clkevent(x) \
95 container_of(x, struct ttc_timer_clockevent, ce) 96 container_of(x, struct ttc_timer_clockevent, ce)
96 97
98static void __iomem *ttc_sched_clock_val_reg;
99
97/** 100/**
98 * ttc_set_interval - Set the timer interval value 101 * ttc_set_interval - Set the timer interval value
99 * 102 *
@@ -155,6 +158,11 @@ static cycle_t __ttc_clocksource_read(struct clocksource *cs)
155 TTC_COUNT_VAL_OFFSET); 158 TTC_COUNT_VAL_OFFSET);
156} 159}
157 160
161static u32 notrace ttc_sched_clock_read(void)
162{
163 return __raw_readl(ttc_sched_clock_val_reg);
164}
165
158/** 166/**
159 * ttc_set_next_event - Sets the time interval for next event 167 * ttc_set_next_event - Sets the time interval for next event
160 * 168 *
@@ -296,6 +304,10 @@ static void __init ttc_setup_clocksource(struct clk *clk, void __iomem *base)
296 kfree(ttccs); 304 kfree(ttccs);
297 return; 305 return;
298 } 306 }
307
308 ttc_sched_clock_val_reg = base + TTC_COUNT_VAL_OFFSET;
309 setup_sched_clock(ttc_sched_clock_read, 16,
310 clk_get_rate(ttccs->ttc.clk) / PRESCALE);
299} 311}
300 312
301static int ttc_rate_change_clockevent_cb(struct notifier_block *nb, 313static int ttc_rate_change_clockevent_cb(struct notifier_block *nb,