Skip to content

Commit

Permalink
clocksource: cadence_ttc: Reuse clocksource as sched_clock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Soren Brinkmann authored and Daniel Lezcano committed Jul 18, 2013
1 parent 9bbf914 commit 3d77b30
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/clocksource/cadence_ttc_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/slab.h>
#include <linux/sched_clock.h>

/*
* This driver configures the 2 16-bit count-up timers as follows:
Expand Down Expand Up @@ -94,6 +95,8 @@ struct ttc_timer_clockevent {
#define to_ttc_timer_clkevent(x) \
container_of(x, struct ttc_timer_clockevent, ce)

static void __iomem *ttc_sched_clock_val_reg;

/**
* ttc_set_interval - Set the timer interval value
*
Expand Down Expand Up @@ -155,6 +158,11 @@ static cycle_t __ttc_clocksource_read(struct clocksource *cs)
TTC_COUNT_VAL_OFFSET);
}

static u32 notrace ttc_sched_clock_read(void)
{
return __raw_readl(ttc_sched_clock_val_reg);
}

/**
* ttc_set_next_event - Sets the time interval for next event
*
Expand Down Expand Up @@ -296,6 +304,10 @@ static void __init ttc_setup_clocksource(struct clk *clk, void __iomem *base)
kfree(ttccs);
return;
}

ttc_sched_clock_val_reg = base + TTC_COUNT_VAL_OFFSET;
setup_sched_clock(ttc_sched_clock_read, 16,
clk_get_rate(ttccs->ttc.clk) / PRESCALE);
}

static int ttc_rate_change_clockevent_cb(struct notifier_block *nb,
Expand Down

0 comments on commit 3d77b30

Please sign in to comment.