diff options
Diffstat (limited to 'include/linux/clocksource.h')
-rw-r--r-- | include/linux/clocksource.h | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index abcafaa20b86..9c78d15d33e4 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h | |||
@@ -18,8 +18,6 @@ | |||
18 | #include <asm/div64.h> | 18 | #include <asm/div64.h> |
19 | #include <asm/io.h> | 19 | #include <asm/io.h> |
20 | 20 | ||
21 | /* clocksource cycle base type */ | ||
22 | typedef u64 cycle_t; | ||
23 | struct clocksource; | 21 | struct clocksource; |
24 | struct module; | 22 | struct module; |
25 | 23 | ||
@@ -28,106 +26,6 @@ struct module; | |||
28 | #endif | 26 | #endif |
29 | 27 | ||
30 | /** | 28 | /** |
31 | * struct cyclecounter - hardware abstraction for a free running counter | ||
32 | * Provides completely state-free accessors to the underlying hardware. | ||
33 | * Depending on which hardware it reads, the cycle counter may wrap | ||
34 | * around quickly. Locking rules (if necessary) have to be defined | ||
35 | * by the implementor and user of specific instances of this API. | ||
36 | * | ||
37 | * @read: returns the current cycle value | ||
38 | * @mask: bitmask for two's complement | ||
39 | * subtraction of non 64 bit counters, | ||
40 | * see CLOCKSOURCE_MASK() helper macro | ||
41 | * @mult: cycle to nanosecond multiplier | ||
42 | * @shift: cycle to nanosecond divisor (power of two) | ||
43 | */ | ||
44 | struct cyclecounter { | ||
45 | cycle_t (*read)(const struct cyclecounter *cc); | ||
46 | cycle_t mask; | ||
47 | u32 mult; | ||
48 | u32 shift; | ||
49 | }; | ||
50 | |||
51 | /** | ||
52 | * struct timecounter - layer above a %struct cyclecounter which counts nanoseconds | ||
53 | * Contains the state needed by timecounter_read() to detect | ||
54 | * cycle counter wrap around. Initialize with | ||
55 | * timecounter_init(). Also used to convert cycle counts into the | ||
56 | * corresponding nanosecond counts with timecounter_cyc2time(). Users | ||
57 | * of this code are responsible for initializing the underlying | ||
58 | * cycle counter hardware, locking issues and reading the time | ||
59 | * more often than the cycle counter wraps around. The nanosecond | ||
60 | * counter will only wrap around after ~585 years. | ||
61 | * | ||
62 | * @cc: the cycle counter used by this instance | ||
63 | * @cycle_last: most recent cycle counter value seen by | ||
64 | * timecounter_read() | ||
65 | * @nsec: continuously increasing count | ||
66 | */ | ||
67 | struct timecounter { | ||
68 | const struct cyclecounter *cc; | ||
69 | cycle_t cycle_last; | ||
70 | u64 nsec; | ||
71 | }; | ||
72 | |||
73 | /** | ||
74 | * cyclecounter_cyc2ns - converts cycle counter cycles to nanoseconds | ||
75 | * @cc: Pointer to cycle counter. | ||
76 | * @cycles: Cycles | ||
77 | * | ||
78 | * XXX - This could use some mult_lxl_ll() asm optimization. Same code | ||
79 | * as in cyc2ns, but with unsigned result. | ||
80 | */ | ||
81 | static inline u64 cyclecounter_cyc2ns(const struct cyclecounter *cc, | ||
82 | cycle_t cycles) | ||
83 | { | ||
84 | u64 ret = (u64)cycles; | ||
85 | ret = (ret * cc->mult) >> cc->shift; | ||
86 | return ret; | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * timecounter_init - initialize a time counter | ||
91 | * @tc: Pointer to time counter which is to be initialized/reset | ||
92 | * @cc: A cycle counter, ready to be used. | ||
93 | * @start_tstamp: Arbitrary initial time stamp. | ||
94 | * | ||
95 | * After this call the current cycle register (roughly) corresponds to | ||
96 | * the initial time stamp. Every call to timecounter_read() increments | ||
97 | * the time stamp counter by the number of elapsed nanoseconds. | ||
98 | */ | ||
99 | extern void timecounter_init(struct timecounter *tc, | ||
100 | const struct cyclecounter *cc, | ||
101 | u64 start_tstamp); | ||
102 | |||
103 | /** | ||
104 | * timecounter_read - return nanoseconds elapsed since timecounter_init() | ||
105 | * plus the initial time stamp | ||
106 | * @tc: Pointer to time counter. | ||
107 | * | ||
108 | * In other words, keeps track of time since the same epoch as | ||
109 | * the function which generated the initial time stamp. | ||
110 | */ | ||
111 | extern u64 timecounter_read(struct timecounter *tc); | ||
112 | |||
113 | /** | ||
114 | * timecounter_cyc2time - convert a cycle counter to same | ||
115 | * time base as values returned by | ||
116 | * timecounter_read() | ||
117 | * @tc: Pointer to time counter. | ||
118 | * @cycle_tstamp: a value returned by tc->cc->read() | ||
119 | * | ||
120 | * Cycle counts that are converted correctly as long as they | ||
121 | * fall into the interval [-1/2 max cycle count, +1/2 max cycle count], | ||
122 | * with "max cycle count" == cs->mask+1. | ||
123 | * | ||
124 | * This allows conversion of cycle counter values which were generated | ||
125 | * in the past. | ||
126 | */ | ||
127 | extern u64 timecounter_cyc2time(struct timecounter *tc, | ||
128 | cycle_t cycle_tstamp); | ||
129 | |||
130 | /** | ||
131 | * struct clocksource - hardware abstraction for a free running counter | 29 | * struct clocksource - hardware abstraction for a free running counter |
132 | * Provides mostly state-free accessors to the underlying hardware. | 30 | * Provides mostly state-free accessors to the underlying hardware. |
133 | * This is the structure used for system time. | 31 | * This is the structure used for system time. |