Skip to content

Commit

Permalink
m68knommu: add sched_clock() for the DMA timer
Browse files Browse the repository at this point in the history
with this printk() and other sched_clock() user use the more precise
timestamps. The highly optimized math is from arch/x86/kernel/tsc_32.c.

Signed-off-by: Sebastian Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
  • Loading branch information
Sebastian Siewior authored and Greg Ungerer committed Jul 23, 2008
1 parent 95469bd commit 5bed10a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions arch/m68knommu/platform/coldfire/dma_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,19 @@ static int __init init_cf_dt_clocksource(void)
}

arch_initcall(init_cf_dt_clocksource);

#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
#define CYC2NS_SCALE ((1000000 << CYC2NS_SCALE_FACTOR) / (DMA_FREQ / 1000))

static unsigned long long cycles2ns(unsigned long cycl)
{
return (unsigned long long) ((unsigned long long)cycl *
CYC2NS_SCALE) >> CYC2NS_SCALE_FACTOR;
}

unsigned long long sched_clock(void)
{
unsigned long cycl = __raw_readl(DTCN0);

return cycles2ns(cycl);
}

0 comments on commit 5bed10a

Please sign in to comment.