Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 245616
b: refs/heads/master
c: a1c57e0
h: refs/heads/master
v: v3
  • Loading branch information
John Stultz authored and John Stultz committed Feb 21, 2011
1 parent cc7c50a commit 3e68931
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 75c4fd8c7862f37eeae5c80f33bbe4dce97571d4
refs/heads/master: a1c57e0fec53defe745e64417eacdbd3618c3e66
35 changes: 2 additions & 33 deletions trunk/arch/blackfin/kernel/time-ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,6 @@
#include <asm/gptimers.h>
#include <asm/nmi.h>

/* Accelerators for sched_clock()
* convert from cycles(64bits) => nanoseconds (64bits)
* basic equation:
* ns = cycles / (freq / ns_per_sec)
* ns = cycles * (ns_per_sec / freq)
* ns = cycles * (10^9 / (cpu_khz * 10^3))
* ns = cycles * (10^6 / cpu_khz)
*
* Then we use scaling math (suggested by george@mvista.com) to get:
* ns = cycles * (10^6 * SC / cpu_khz) / SC
* ns = cycles * cyc2ns_scale / SC
*
* And since SC is a constant power of two, we can convert the div
* into a shift.
*
* We can use khz divisor instead of mhz to keep a better precision, since
* cyc2ns_scale is limited to 10^6 * 2^10, which fits in 32 bits.
* (mathieu.desnoyers@polymtl.ca)
*
* -johnstul@us.ibm.com "math is hard, lets go shopping!"
*/

#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */

#if defined(CONFIG_CYCLES_CLOCKSOURCE)

Expand All @@ -63,7 +40,6 @@ static struct clocksource bfin_cs_cycles = {
.rating = 400,
.read = bfin_read_cycles,
.mask = CLOCKSOURCE_MASK(64),
.shift = CYC2NS_SCALE_FACTOR,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

Expand All @@ -75,10 +51,7 @@ static inline unsigned long long bfin_cs_cycles_sched_clock(void)

static int __init bfin_cs_cycles_init(void)
{
bfin_cs_cycles.mult = \
clocksource_hz2mult(get_cclk(), bfin_cs_cycles.shift);

if (clocksource_register(&bfin_cs_cycles))
if (clocksource_register_hz(&bfin_cs_cycles, get_cclk()))
panic("failed to register clocksource");

return 0;
Expand Down Expand Up @@ -111,7 +84,6 @@ static struct clocksource bfin_cs_gptimer0 = {
.rating = 350,
.read = bfin_read_gptimer0,
.mask = CLOCKSOURCE_MASK(32),
.shift = CYC2NS_SCALE_FACTOR,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

Expand All @@ -125,10 +97,7 @@ static int __init bfin_cs_gptimer0_init(void)
{
setup_gptimer0();

bfin_cs_gptimer0.mult = \
clocksource_hz2mult(get_sclk(), bfin_cs_gptimer0.shift);

if (clocksource_register(&bfin_cs_gptimer0))
if (clocksource_register_hz(&bfin_cs_gptimer0, get_sclk()))
panic("failed to register clocksource");

return 0;
Expand Down

0 comments on commit 3e68931

Please sign in to comment.