diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-19 20:44:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-19 20:44:13 -0400 |
commit | 0f1bdc1815c4cb29b3cd71a7091b478e426faa0b (patch) | |
tree | b4d70c6a305d91bf7d1c8a6bbf87508587d55633 /arch/blackfin/kernel | |
parent | 80fe02b5daf176f99d3afc8f6c9dc9dece019836 (diff) | |
parent | a18f22a968de17b29f2310cdb7ba69163e65ec15 (diff) |
Merge branch 'timers-clocksource-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'timers-clocksource-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
clocksource: convert mips to generic i8253 clocksource
clocksource: convert x86 to generic i8253 clocksource
clocksource: convert footbridge to generic i8253 clocksource
clocksource: add common i8253 PIT clocksource
blackfin: convert to clocksource_register_hz
mips: convert to clocksource_register_hz/khz
sparc: convert to clocksource_register_hz/khz
alpha: convert to clocksource_register_hz
microblaze: convert to clocksource_register_hz/khz
ia64: convert to clocksource_register_hz/khz
x86: Convert remaining x86 clocksources to clocksource_register_hz/khz
Make clocksource name const
Diffstat (limited to 'arch/blackfin/kernel')
-rw-r--r-- | arch/blackfin/kernel/time-ts.c | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/arch/blackfin/kernel/time-ts.c b/arch/blackfin/kernel/time-ts.c index cdb4beb6bc8f..9e9b60d969dc 100644 --- a/arch/blackfin/kernel/time-ts.c +++ b/arch/blackfin/kernel/time-ts.c | |||
@@ -23,29 +23,6 @@ | |||
23 | #include <asm/gptimers.h> | 23 | #include <asm/gptimers.h> |
24 | #include <asm/nmi.h> | 24 | #include <asm/nmi.h> |
25 | 25 | ||
26 | /* Accelerators for sched_clock() | ||
27 | * convert from cycles(64bits) => nanoseconds (64bits) | ||
28 | * basic equation: | ||
29 | * ns = cycles / (freq / ns_per_sec) | ||
30 | * ns = cycles * (ns_per_sec / freq) | ||
31 | * ns = cycles * (10^9 / (cpu_khz * 10^3)) | ||
32 | * ns = cycles * (10^6 / cpu_khz) | ||
33 | * | ||
34 | * Then we use scaling math (suggested by george@mvista.com) to get: | ||
35 | * ns = cycles * (10^6 * SC / cpu_khz) / SC | ||
36 | * ns = cycles * cyc2ns_scale / SC | ||
37 | * | ||
38 | * And since SC is a constant power of two, we can convert the div | ||
39 | * into a shift. | ||
40 | * | ||
41 | * We can use khz divisor instead of mhz to keep a better precision, since | ||
42 | * cyc2ns_scale is limited to 10^6 * 2^10, which fits in 32 bits. | ||
43 | * (mathieu.desnoyers@polymtl.ca) | ||
44 | * | ||
45 | * -johnstul@us.ibm.com "math is hard, lets go shopping!" | ||
46 | */ | ||
47 | |||
48 | #define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */ | ||
49 | 26 | ||
50 | #if defined(CONFIG_CYCLES_CLOCKSOURCE) | 27 | #if defined(CONFIG_CYCLES_CLOCKSOURCE) |
51 | 28 | ||
@@ -63,7 +40,6 @@ static struct clocksource bfin_cs_cycles = { | |||
63 | .rating = 400, | 40 | .rating = 400, |
64 | .read = bfin_read_cycles, | 41 | .read = bfin_read_cycles, |
65 | .mask = CLOCKSOURCE_MASK(64), | 42 | .mask = CLOCKSOURCE_MASK(64), |
66 | .shift = CYC2NS_SCALE_FACTOR, | ||
67 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 43 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
68 | }; | 44 | }; |
69 | 45 | ||
@@ -75,10 +51,7 @@ static inline unsigned long long bfin_cs_cycles_sched_clock(void) | |||
75 | 51 | ||
76 | static int __init bfin_cs_cycles_init(void) | 52 | static int __init bfin_cs_cycles_init(void) |
77 | { | 53 | { |
78 | bfin_cs_cycles.mult = \ | 54 | if (clocksource_register_hz(&bfin_cs_cycles, get_cclk())) |
79 | clocksource_hz2mult(get_cclk(), bfin_cs_cycles.shift); | ||
80 | |||
81 | if (clocksource_register(&bfin_cs_cycles)) | ||
82 | panic("failed to register clocksource"); | 55 | panic("failed to register clocksource"); |
83 | 56 | ||
84 | return 0; | 57 | return 0; |
@@ -111,7 +84,6 @@ static struct clocksource bfin_cs_gptimer0 = { | |||
111 | .rating = 350, | 84 | .rating = 350, |
112 | .read = bfin_read_gptimer0, | 85 | .read = bfin_read_gptimer0, |
113 | .mask = CLOCKSOURCE_MASK(32), | 86 | .mask = CLOCKSOURCE_MASK(32), |
114 | .shift = CYC2NS_SCALE_FACTOR, | ||
115 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 87 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
116 | }; | 88 | }; |
117 | 89 | ||
@@ -125,10 +97,7 @@ static int __init bfin_cs_gptimer0_init(void) | |||
125 | { | 97 | { |
126 | setup_gptimer0(); | 98 | setup_gptimer0(); |
127 | 99 | ||
128 | bfin_cs_gptimer0.mult = \ | 100 | if (clocksource_register_hz(&bfin_cs_gptimer0, get_sclk())) |
129 | clocksource_hz2mult(get_sclk(), bfin_cs_gptimer0.shift); | ||
130 | |||
131 | if (clocksource_register(&bfin_cs_gptimer0)) | ||
132 | panic("failed to register clocksource"); | 101 | panic("failed to register clocksource"); |
133 | 102 | ||
134 | return 0; | 103 | return 0; |