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: 65cd4f6c99)

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
This commit is contained in:
Michal Simek 2013-12-20 10:16:40 +01:00
parent 0f7e36406c
commit 839396ab88
2 changed files with 9 additions and 19 deletions

View File

@ -27,6 +27,7 @@ config MICROBLAZE
select GENERIC_ATOMIC64
select GENERIC_CLOCKEVENTS
select COMMON_CLK
select GENERIC_SCHED_CLOCK
select GENERIC_IDLE_POLL_SETUP
select MODULES_USE_ELF_RELA
select CLONE_BACKWARDS3

View File

@ -12,12 +12,12 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/sched_clock.h>
#include <linux/clk.h>
#include <linux/clockchips.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <asm/cpuinfo.h>
#include <linux/cnt32_to_63.h>
static void __iomem *timer_baseaddr;
@ -167,10 +167,15 @@ static __init void xilinx_clockevent_init(void)
clockevents_register_device(&clockevent_xilinx_timer);
}
static u64 xilinx_clock_read(void)
{
return in_be32(timer_baseaddr + TCR1);
}
static cycle_t xilinx_read(struct clocksource *cs)
{
/* reading actual value of timer 1 */
return (cycle_t) (in_be32(timer_baseaddr + TCR1));
return (cycle_t)xilinx_clock_read();
}
static struct timecounter xilinx_tc = {
@ -222,12 +227,6 @@ static int __init xilinx_clocksource_init(void)
return 0;
}
/*
* We have to protect accesses before timer initialization
* and return 0 for sched_clock function below.
*/
static int timer_initialized;
static void __init xilinx_timer_init(struct device_node *timer)
{
struct clk *clk;
@ -273,18 +272,8 @@ static void __init xilinx_timer_init(struct device_node *timer)
#endif
xilinx_clocksource_init();
xilinx_clockevent_init();
timer_initialized = 1;
}
unsigned long long notrace sched_clock(void)
{
if (timer_initialized) {
struct clocksource *cs = &clocksource_microblaze;
cycle_t cyc = cnt32_to_63(cs->read(NULL)) & LLONG_MAX;
return clocksource_cyc2ns(cyc, cs->mult, cs->shift);
}
return 0;
sched_clock_register(xilinx_clock_read, 32, timer_clock_freq);
}
CLOCKSOURCE_OF_DECLARE(xilinx_timer, "xlnx,xps-timer-1.00.a",