Skip to content

Commit

Permalink
microblaze: timer: Use generic sched_clock implementation
Browse files Browse the repository at this point in the history
Remove sched_clock from the driver and use sched_clock_register
function.
Inspired-by:
"arch_timer: Move to generic sched_clock framework"
(sha1: 65cd4f6)

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
  • Loading branch information
Michal Simek committed Jan 27, 2014
1 parent 0f7e364 commit 839396a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
1 change: 1 addition & 0 deletions arch/microblaze/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 8 additions & 19 deletions arch/microblaze/kernel/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 839396a

Please sign in to comment.