diff options
author | Michal Simek <michal.simek@xilinx.com> | 2013-12-20 04:16:40 -0500 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2014-01-27 05:25:46 -0500 |
commit | 839396ab88e4ac0107a88cb85fa59a7ec3f94416 (patch) | |
tree | 73c78182d9f4d2c8b48856e9f8e0d5bc792104a2 /arch/microblaze/kernel | |
parent | 0f7e36406cd1d519ebde736f86731695b1bb3eb7 (diff) |
microblaze: timer: Use generic sched_clock implementation
Remove sched_clock from the driver and use sched_clock_register
function.
Inspired-by:
"arch_timer: Move to generic sched_clock framework"
(sha1: 65cd4f6c99c1170bd0114dbd71b978012ea44d28)
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'arch/microblaze/kernel')
-rw-r--r-- | arch/microblaze/kernel/timer.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c index 55b19400951f..06609e01f1cf 100644 --- a/arch/microblaze/kernel/timer.c +++ b/arch/microblaze/kernel/timer.c | |||
@@ -12,12 +12,12 @@ | |||
12 | #include <linux/interrupt.h> | 12 | #include <linux/interrupt.h> |
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
15 | #include <linux/sched_clock.h> | ||
15 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
16 | #include <linux/clockchips.h> | 17 | #include <linux/clockchips.h> |
17 | #include <linux/of_address.h> | 18 | #include <linux/of_address.h> |
18 | #include <linux/of_irq.h> | 19 | #include <linux/of_irq.h> |
19 | #include <asm/cpuinfo.h> | 20 | #include <asm/cpuinfo.h> |
20 | #include <linux/cnt32_to_63.h> | ||
21 | 21 | ||
22 | static void __iomem *timer_baseaddr; | 22 | static void __iomem *timer_baseaddr; |
23 | 23 | ||
@@ -167,10 +167,15 @@ static __init void xilinx_clockevent_init(void) | |||
167 | clockevents_register_device(&clockevent_xilinx_timer); | 167 | clockevents_register_device(&clockevent_xilinx_timer); |
168 | } | 168 | } |
169 | 169 | ||
170 | static u64 xilinx_clock_read(void) | ||
171 | { | ||
172 | return in_be32(timer_baseaddr + TCR1); | ||
173 | } | ||
174 | |||
170 | static cycle_t xilinx_read(struct clocksource *cs) | 175 | static cycle_t xilinx_read(struct clocksource *cs) |
171 | { | 176 | { |
172 | /* reading actual value of timer 1 */ | 177 | /* reading actual value of timer 1 */ |
173 | return (cycle_t) (in_be32(timer_baseaddr + TCR1)); | 178 | return (cycle_t)xilinx_clock_read(); |
174 | } | 179 | } |
175 | 180 | ||
176 | static struct timecounter xilinx_tc = { | 181 | static struct timecounter xilinx_tc = { |
@@ -222,12 +227,6 @@ static int __init xilinx_clocksource_init(void) | |||
222 | return 0; | 227 | return 0; |
223 | } | 228 | } |
224 | 229 | ||
225 | /* | ||
226 | * We have to protect accesses before timer initialization | ||
227 | * and return 0 for sched_clock function below. | ||
228 | */ | ||
229 | static int timer_initialized; | ||
230 | |||
231 | static void __init xilinx_timer_init(struct device_node *timer) | 230 | static void __init xilinx_timer_init(struct device_node *timer) |
232 | { | 231 | { |
233 | struct clk *clk; | 232 | struct clk *clk; |
@@ -273,18 +272,8 @@ static void __init xilinx_timer_init(struct device_node *timer) | |||
273 | #endif | 272 | #endif |
274 | xilinx_clocksource_init(); | 273 | xilinx_clocksource_init(); |
275 | xilinx_clockevent_init(); | 274 | xilinx_clockevent_init(); |
276 | timer_initialized = 1; | ||
277 | } | ||
278 | |||
279 | unsigned long long notrace sched_clock(void) | ||
280 | { | ||
281 | if (timer_initialized) { | ||
282 | struct clocksource *cs = &clocksource_microblaze; | ||
283 | 275 | ||
284 | cycle_t cyc = cnt32_to_63(cs->read(NULL)) & LLONG_MAX; | 276 | sched_clock_register(xilinx_clock_read, 32, timer_clock_freq); |
285 | return clocksource_cyc2ns(cyc, cs->mult, cs->shift); | ||
286 | } | ||
287 | return 0; | ||
288 | } | 277 | } |
289 | 278 | ||
290 | CLOCKSOURCE_OF_DECLARE(xilinx_timer, "xlnx,xps-timer-1.00.a", | 279 | CLOCKSOURCE_OF_DECLARE(xilinx_timer, "xlnx,xps-timer-1.00.a", |