diff options
-rw-r--r-- | arch/microblaze/Kconfig | 1 | ||||
-rw-r--r-- | arch/microblaze/kernel/timer.c | 27 |
2 files changed, 9 insertions, 19 deletions
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index a715eeaf9959..c9f8bb4046d7 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig | |||
@@ -27,6 +27,7 @@ config MICROBLAZE | |||
27 | select GENERIC_ATOMIC64 | 27 | select GENERIC_ATOMIC64 |
28 | select GENERIC_CLOCKEVENTS | 28 | select GENERIC_CLOCKEVENTS |
29 | select COMMON_CLK | 29 | select COMMON_CLK |
30 | select GENERIC_SCHED_CLOCK | ||
30 | select GENERIC_IDLE_POLL_SETUP | 31 | select GENERIC_IDLE_POLL_SETUP |
31 | select MODULES_USE_ELF_RELA | 32 | select MODULES_USE_ELF_RELA |
32 | select CLONE_BACKWARDS3 | 33 | select CLONE_BACKWARDS3 |
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", |