davinci: Implement sched_clock()
Overwrite the default implementation of sched_clock that is based on jiffies by something more precise. This improves timestamps in ftrace. Implementation is copied from OMAP platform code. Signed-off-by: Andreas Gaeer <Andreas.Gaer@baslerweb.com> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
This commit is contained in:
parent
cf7d7e5a19
commit
6d1c57c84c
|
@ -272,14 +272,35 @@ static cycle_t read_cycles(struct clocksource *cs)
|
||||||
return (cycles_t)timer32_read(t);
|
return (cycles_t)timer32_read(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Kernel assumes that sched_clock can be called early but may not have
|
||||||
|
* things ready yet.
|
||||||
|
*/
|
||||||
|
static cycle_t read_dummy(struct clocksource *cs)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct clocksource clocksource_davinci = {
|
static struct clocksource clocksource_davinci = {
|
||||||
.rating = 300,
|
.rating = 300,
|
||||||
.read = read_cycles,
|
.read = read_dummy,
|
||||||
.mask = CLOCKSOURCE_MASK(32),
|
.mask = CLOCKSOURCE_MASK(32),
|
||||||
.shift = 24,
|
.shift = 24,
|
||||||
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
|
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Overwrite weak default sched_clock with something more precise
|
||||||
|
*/
|
||||||
|
unsigned long long notrace sched_clock(void)
|
||||||
|
{
|
||||||
|
const cycle_t cyc = clocksource_davinci.read(&clocksource_davinci);
|
||||||
|
|
||||||
|
return clocksource_cyc2ns(cyc, clocksource_davinci.mult,
|
||||||
|
clocksource_davinci.shift);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* clockevent
|
* clockevent
|
||||||
*/
|
*/
|
||||||
|
@ -377,6 +398,7 @@ static void __init davinci_timer_init(void)
|
||||||
davinci_clock_tick_rate = clk_get_rate(timer_clk);
|
davinci_clock_tick_rate = clk_get_rate(timer_clk);
|
||||||
|
|
||||||
/* setup clocksource */
|
/* setup clocksource */
|
||||||
|
clocksource_davinci.read = read_cycles;
|
||||||
clocksource_davinci.name = id_to_name[clocksource_id];
|
clocksource_davinci.name = id_to_name[clocksource_id];
|
||||||
clocksource_davinci.mult =
|
clocksource_davinci.mult =
|
||||||
clocksource_khz2mult(davinci_clock_tick_rate/1000,
|
clocksource_khz2mult(davinci_clock_tick_rate/1000,
|
||||||
|
|
Loading…
Reference in New Issue