diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/m68knommu/platform/coldfire/dma_timer.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/m68knommu/platform/coldfire/dma_timer.c b/arch/m68knommu/platform/coldfire/dma_timer.c index b623c993219e..772578b1084f 100644 --- a/arch/m68knommu/platform/coldfire/dma_timer.c +++ b/arch/m68knommu/platform/coldfire/dma_timer.c | |||
@@ -66,3 +66,19 @@ static int __init init_cf_dt_clocksource(void) | |||
66 | } | 66 | } |
67 | 67 | ||
68 | arch_initcall(init_cf_dt_clocksource); | 68 | arch_initcall(init_cf_dt_clocksource); |
69 | |||
70 | #define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */ | ||
71 | #define CYC2NS_SCALE ((1000000 << CYC2NS_SCALE_FACTOR) / (DMA_FREQ / 1000)) | ||
72 | |||
73 | static unsigned long long cycles2ns(unsigned long cycl) | ||
74 | { | ||
75 | return (unsigned long long) ((unsigned long long)cycl * | ||
76 | CYC2NS_SCALE) >> CYC2NS_SCALE_FACTOR; | ||
77 | } | ||
78 | |||
79 | unsigned long long sched_clock(void) | ||
80 | { | ||
81 | unsigned long cycl = __raw_readl(DTCN0); | ||
82 | |||
83 | return cycles2ns(cycl); | ||
84 | } | ||