Subversion Repositories Kolibri OS

Rev

Rev 6936 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6936 Rev 7143
Line 116... Line 116...
116
#define CLOCK_SOURCE_RESELECT			0x100
116
#define CLOCK_SOURCE_RESELECT			0x100
Line 117... Line 117...
117
 
117
 
118
/* simplify initialization of mask field */
118
/* simplify initialization of mask field */
Line -... Line 119...
-
 
119
#define CLOCKSOURCE_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
-
 
120
 
-
 
121
static inline u32 clocksource_freq2mult(u32 freq, u32 shift_constant, u64 from)
-
 
122
{
-
 
123
	/*  freq = cyc/from
-
 
124
	 *  mult/2^shift  = ns/cyc
-
 
125
	 *  mult = ns/cyc * 2^shift
-
 
126
	 *  mult = from/freq * 2^shift
-
 
127
	 *  mult = from * 2^shift / freq
-
 
128
	 *  mult = (from<
-
 
129
	 */
-
 
130
	u64 tmp = ((u64)from) << shift_constant;
-
 
131
 
-
 
132
	tmp += freq/2; /* round for do_div */
-
 
133
	do_div(tmp, freq);
-
 
134
 
-
 
135
	return (u32)tmp;
119
#define CLOCKSOURCE_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
136
}
120
 
137
 
121
/**
138
/**
122
 * clocksource_khz2mult - calculates mult from khz and shift
139
 * clocksource_khz2mult - calculates mult from khz and shift
123
 * @khz:		Clocksource frequency in KHz
140
 * @khz:		Clocksource frequency in KHz
124
 * @shift_constant:	Clocksource shift factor
141
 * @shift_constant:	Clocksource shift factor
125
 *
142
 *
126
 * Helper functions that converts a khz counter frequency to a timsource
143
 * Helper functions that converts a khz counter frequency to a timsource
127
 * multiplier, given the clocksource shift value
144
 * multiplier, given the clocksource shift value
128
 */
145
 */
129
static inline u32 clocksource_khz2mult(u32 khz, u32 shift_constant)
-
 
130
{
-
 
131
	/*  khz = cyc/(Million ns)
-
 
132
	 *  mult/2^shift  = ns/cyc
-
 
133
	 *  mult = ns/cyc * 2^shift
-
 
134
	 *  mult = 1Million/khz * 2^shift
-
 
135
	 *  mult = 1000000 * 2^shift / khz
-
 
136
	 *  mult = (1000000<
146
static inline u32 clocksource_khz2mult(u32 khz, u32 shift_constant)
137
	 */
-
 
138
	u64 tmp = ((u64)1000000) << shift_constant;
-
 
139
 
-
 
140
	tmp += khz/2; /* round for do_div */
-
 
141
	do_div(tmp, khz);
-
 
142
 
147
{
Line 143... Line 148...
143
	return (u32)tmp;
148
	return clocksource_freq2mult(khz, shift_constant, NSEC_PER_MSEC);
144
}
149
}
145
 
150
 
Line 152... Line 157...
152
 * frequency to a timsource multiplier, given the
157
 * frequency to a timsource multiplier, given the
153
 * clocksource shift value
158
 * clocksource shift value
154
 */
159
 */
155
static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant)
160
static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant)
156
{
161
{
157
	/*  hz = cyc/(Billion ns)
-
 
158
	 *  mult/2^shift  = ns/cyc
-
 
159
	 *  mult = ns/cyc * 2^shift
-
 
160
	 *  mult = 1Billion/hz * 2^shift
-
 
161
	 *  mult = 1000000000 * 2^shift / hz
-
 
162
	 *  mult = (1000000000<
-
 
163
	 */
-
 
164
	u64 tmp = ((u64)1000000000) << shift_constant;
162
	return clocksource_freq2mult(hz, shift_constant, NSEC_PER_SEC);
165
 
-
 
166
	tmp += hz/2; /* round for do_div */
-
 
167
	do_div(tmp, hz);
-
 
168
 
-
 
169
	return (u32)tmp;
-
 
170
}
163
}
Line 171... Line 164...
171
 
164
 
172
/**
165
/**
173
 * clocksource_cyc2ns - converts clocksource cycles to nanoseconds
166
 * clocksource_cyc2ns - converts clocksource cycles to nanoseconds