aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/timex.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/timex.h')
-rw-r--r--include/linux/timex.h58
1 files changed, 20 insertions, 38 deletions
diff --git a/include/linux/timex.h b/include/linux/timex.h
index d543d3871e38..049dfe4a11f2 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -69,34 +69,28 @@
69 * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours, 69 * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
70 * respectively. 70 * respectively.
71 */ 71 */
72#define SHIFT_KG 6 /* phase factor (shift) */ 72#define SHIFT_PLL 4 /* PLL frequency factor (shift) */
73#define SHIFT_KF 16 /* PLL frequency factor (shift) */ 73#define SHIFT_FLL 2 /* FLL frequency factor (shift) */
74#define SHIFT_KH 2 /* FLL frequency factor (shift) */ 74#define MAXTC 10 /* maximum time constant (shift) */
75#define MAXTC 6 /* maximum time constant (shift) */
76 75
77/* 76/*
78 * The SHIFT_SCALE define establishes the decimal point of the time_phase 77 * The SHIFT_UPDATE define establishes the decimal point of the
79 * variable which serves as an extension to the low-order bits of the 78 * time_offset variable which represents the current offset with
80 * system clock variable. The SHIFT_UPDATE define establishes the decimal 79 * respect to standard time.
81 * point of the time_offset variable which represents the current offset
82 * with respect to standard time. The FINENSEC define represents 1 nsec in
83 * scaled units.
84 * 80 *
85 * SHIFT_USEC defines the scaling (shift) of the time_freq and 81 * SHIFT_USEC defines the scaling (shift) of the time_freq and
86 * time_tolerance variables, which represent the current frequency 82 * time_tolerance variables, which represent the current frequency
87 * offset and maximum frequency tolerance. 83 * offset and maximum frequency tolerance.
88 *
89 * FINENSEC is 1 ns in SHIFT_UPDATE units of the time_phase variable.
90 */ 84 */
91#define SHIFT_SCALE 22 /* phase scale (shift) */ 85#define SHIFT_UPDATE (SHIFT_HZ + 1) /* time offset scale (shift) */
92#define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* time offset scale (shift) */
93#define SHIFT_USEC 16 /* frequency offset scale (shift) */ 86#define SHIFT_USEC 16 /* frequency offset scale (shift) */
94#define FINENSEC (1L << (SHIFT_SCALE - 10)) /* ~1 ns in phase units */ 87#define SHIFT_NSEC 12 /* kernel frequency offset scale */
95 88
96#define MAXPHASE 512000L /* max phase error (us) */ 89#define MAXPHASE 512000L /* max phase error (us) */
97#define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */ 90#define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */
98#define MINSEC 16L /* min interval between updates (s) */ 91#define MAXFREQ_NSEC (512000L << SHIFT_NSEC) /* max frequency error (ppb) */
99#define MAXSEC 1200L /* max interval between updates (s) */ 92#define MINSEC 256 /* min interval between updates (s) */
93#define MAXSEC 2048 /* max interval between updates (s) */
100#define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */ 94#define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */
101 95
102/* 96/*
@@ -204,33 +198,15 @@ extern int tickadj; /* amount of adjustment per tick */
204/* 198/*
205 * phase-lock loop variables 199 * phase-lock loop variables
206 */ 200 */
207extern int time_state; /* clock status */
208extern int time_status; /* clock synchronization status bits */ 201extern int time_status; /* clock synchronization status bits */
209extern long time_offset; /* time adjustment (us) */
210extern long time_constant; /* pll time constant */
211extern long time_tolerance; /* frequency tolerance (ppm) */
212extern long time_precision; /* clock precision (us) */
213extern long time_maxerror; /* maximum error */ 202extern long time_maxerror; /* maximum error */
214extern long time_esterror; /* estimated error */ 203extern long time_esterror; /* estimated error */
215 204
216extern long time_freq; /* frequency offset (scaled ppm) */ 205extern long time_freq; /* frequency offset (scaled ppm) */
217extern long time_reftime; /* time at last adjustment (s) */
218 206
219extern long time_adjust; /* The amount of adjtime left */ 207extern long time_adjust; /* The amount of adjtime left */
220extern long time_next_adjust; /* Value for time_adjust at next tick */
221 208
222/** 209extern void ntp_clear(void);
223 * ntp_clear - Clears the NTP state variables
224 *
225 * Must be called while holding a write on the xtime_lock
226 */
227static inline void ntp_clear(void)
228{
229 time_adjust = 0; /* stop active adjtime() */
230 time_status |= STA_UNSYNC;
231 time_maxerror = NTP_PHASE_LIMIT;
232 time_esterror = NTP_PHASE_LIMIT;
233}
234 210
235/** 211/**
236 * ntp_synced - Returns 1 if the NTP status is not UNSYNC 212 * ntp_synced - Returns 1 if the NTP status is not UNSYNC
@@ -294,11 +270,15 @@ extern void register_time_interpolator(struct time_interpolator *);
294extern void unregister_time_interpolator(struct time_interpolator *); 270extern void unregister_time_interpolator(struct time_interpolator *);
295extern void time_interpolator_reset(void); 271extern void time_interpolator_reset(void);
296extern unsigned long time_interpolator_get_offset(void); 272extern unsigned long time_interpolator_get_offset(void);
273extern void time_interpolator_update(long delta_nsec);
297 274
298#else /* !CONFIG_TIME_INTERPOLATION */ 275#else /* !CONFIG_TIME_INTERPOLATION */
299 276
300static inline void 277static inline void time_interpolator_reset(void)
301time_interpolator_reset(void) 278{
279}
280
281static inline void time_interpolator_update(long delta_nsec)
302{ 282{
303} 283}
304 284
@@ -309,6 +289,8 @@ time_interpolator_reset(void)
309/* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */ 289/* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */
310extern u64 current_tick_length(void); 290extern u64 current_tick_length(void);
311 291
292extern void second_overflow(void);
293extern void update_ntp_one_tick(void);
312extern int do_adjtimex(struct timex *); 294extern int do_adjtimex(struct timex *);
313 295
314#endif /* KERNEL */ 296#endif /* KERNEL */