diff options
Diffstat (limited to 'include/linux/timex.h')
-rw-r--r-- | include/linux/timex.h | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/include/linux/timex.h b/include/linux/timex.h index 8ea3e71ba7fa..fc6035d29d56 100644 --- a/include/linux/timex.h +++ b/include/linux/timex.h | |||
@@ -58,6 +58,8 @@ | |||
58 | 58 | ||
59 | #include <asm/param.h> | 59 | #include <asm/param.h> |
60 | 60 | ||
61 | #define NTP_API 4 /* NTP API version */ | ||
62 | |||
61 | /* | 63 | /* |
62 | * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen | 64 | * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen |
63 | * for a slightly underdamped convergence characteristic. SHIFT_KH | 65 | * for a slightly underdamped convergence characteristic. SHIFT_KH |
@@ -74,24 +76,22 @@ | |||
74 | #define MAXTC 10 /* maximum time constant (shift) */ | 76 | #define MAXTC 10 /* maximum time constant (shift) */ |
75 | 77 | ||
76 | /* | 78 | /* |
77 | * The SHIFT_UPDATE define establishes the decimal point of the | ||
78 | * time_offset variable which represents the current offset with | ||
79 | * respect to standard time. | ||
80 | * | ||
81 | * SHIFT_USEC defines the scaling (shift) of the time_freq and | 79 | * SHIFT_USEC defines the scaling (shift) of the time_freq and |
82 | * time_tolerance variables, which represent the current frequency | 80 | * time_tolerance variables, which represent the current frequency |
83 | * offset and maximum frequency tolerance. | 81 | * offset and maximum frequency tolerance. |
84 | */ | 82 | */ |
85 | #define SHIFT_UPDATE (SHIFT_HZ + 1) /* time offset scale (shift) */ | ||
86 | #define SHIFT_USEC 16 /* frequency offset scale (shift) */ | 83 | #define SHIFT_USEC 16 /* frequency offset scale (shift) */ |
87 | #define SHIFT_NSEC 12 /* kernel frequency offset scale */ | 84 | #define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC)) |
88 | 85 | #define PPM_SCALE_INV_SHIFT 20 | |
89 | #define MAXPHASE 512000L /* max phase error (us) */ | 86 | #define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \ |
90 | #define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */ | 87 | PPM_SCALE + 1) |
91 | #define MAXFREQ_NSEC (512000L << SHIFT_NSEC) /* max frequency error (ppb) */ | 88 | |
89 | #define MAXPHASE 500000000l /* max phase error (ns) */ | ||
90 | #define MAXFREQ 500000 /* max frequency error (ns/s) */ | ||
91 | #define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT) | ||
92 | #define MINSEC 256 /* min interval between updates (s) */ | 92 | #define MINSEC 256 /* min interval between updates (s) */ |
93 | #define MAXSEC 2048 /* max interval between updates (s) */ | 93 | #define MAXSEC 2048 /* max interval between updates (s) */ |
94 | #define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */ | 94 | #define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */ |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * syscall interface - used (mainly by NTP daemon) | 97 | * syscall interface - used (mainly by NTP daemon) |
@@ -121,9 +121,11 @@ struct timex { | |||
121 | long errcnt; /* calibration errors (ro) */ | 121 | long errcnt; /* calibration errors (ro) */ |
122 | long stbcnt; /* stability limit exceeded (ro) */ | 122 | long stbcnt; /* stability limit exceeded (ro) */ |
123 | 123 | ||
124 | int tai; /* TAI offset (ro) */ | ||
125 | |||
124 | int :32; int :32; int :32; int :32; | 126 | int :32; int :32; int :32; int :32; |
125 | int :32; int :32; int :32; int :32; | 127 | int :32; int :32; int :32; int :32; |
126 | int :32; int :32; int :32; int :32; | 128 | int :32; int :32; int :32; |
127 | }; | 129 | }; |
128 | 130 | ||
129 | /* | 131 | /* |
@@ -135,6 +137,9 @@ struct timex { | |||
135 | #define ADJ_ESTERROR 0x0008 /* estimated time error */ | 137 | #define ADJ_ESTERROR 0x0008 /* estimated time error */ |
136 | #define ADJ_STATUS 0x0010 /* clock status */ | 138 | #define ADJ_STATUS 0x0010 /* clock status */ |
137 | #define ADJ_TIMECONST 0x0020 /* pll time constant */ | 139 | #define ADJ_TIMECONST 0x0020 /* pll time constant */ |
140 | #define ADJ_TAI 0x0080 /* set TAI offset */ | ||
141 | #define ADJ_MICRO 0x1000 /* select microsecond resolution */ | ||
142 | #define ADJ_NANO 0x2000 /* select nanosecond resolution */ | ||
138 | #define ADJ_TICK 0x4000 /* tick value */ | 143 | #define ADJ_TICK 0x4000 /* tick value */ |
139 | #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ | 144 | #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ |
140 | #define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ | 145 | #define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ |
@@ -146,8 +151,6 @@ struct timex { | |||
146 | #define MOD_ESTERROR ADJ_ESTERROR | 151 | #define MOD_ESTERROR ADJ_ESTERROR |
147 | #define MOD_STATUS ADJ_STATUS | 152 | #define MOD_STATUS ADJ_STATUS |
148 | #define MOD_TIMECONST ADJ_TIMECONST | 153 | #define MOD_TIMECONST ADJ_TIMECONST |
149 | #define MOD_CLKB ADJ_TICK | ||
150 | #define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */ | ||
151 | 154 | ||
152 | 155 | ||
153 | /* | 156 | /* |
@@ -169,9 +172,13 @@ struct timex { | |||
169 | #define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ | 172 | #define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ |
170 | 173 | ||
171 | #define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ | 174 | #define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ |
175 | #define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ | ||
176 | #define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ | ||
177 | #define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ | ||
172 | 178 | ||
179 | /* read-only bits */ | ||
173 | #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ | 180 | #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ |
174 | STA_PPSERROR | STA_CLOCKERR) /* read-only bits */ | 181 | STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) |
175 | 182 | ||
176 | /* | 183 | /* |
177 | * Clock states (time_state) | 184 | * Clock states (time_state) |
@@ -203,10 +210,9 @@ extern int time_status; /* clock synchronization status bits */ | |||
203 | extern long time_maxerror; /* maximum error */ | 210 | extern long time_maxerror; /* maximum error */ |
204 | extern long time_esterror; /* estimated error */ | 211 | extern long time_esterror; /* estimated error */ |
205 | 212 | ||
206 | extern long time_freq; /* frequency offset (scaled ppm) */ | ||
207 | |||
208 | extern long time_adjust; /* The amount of adjtime left */ | 213 | extern long time_adjust; /* The amount of adjtime left */ |
209 | 214 | ||
215 | extern void ntp_init(void); | ||
210 | extern void ntp_clear(void); | 216 | extern void ntp_clear(void); |
211 | 217 | ||
212 | /** | 218 | /** |
@@ -225,7 +231,7 @@ static inline int ntp_synced(void) | |||
225 | __x < 0 ? -(-__x >> __s) : __x >> __s; \ | 231 | __x < 0 ? -(-__x >> __s) : __x >> __s; \ |
226 | }) | 232 | }) |
227 | 233 | ||
228 | #define TICK_LENGTH_SHIFT 32 | 234 | #define NTP_SCALE_SHIFT 32 |
229 | 235 | ||
230 | #ifdef CONFIG_NO_HZ | 236 | #ifdef CONFIG_NO_HZ |
231 | #define NTP_INTERVAL_FREQ (2) | 237 | #define NTP_INTERVAL_FREQ (2) |
@@ -234,8 +240,8 @@ static inline int ntp_synced(void) | |||
234 | #endif | 240 | #endif |
235 | #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) | 241 | #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) |
236 | 242 | ||
237 | /* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */ | 243 | /* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */ |
238 | extern u64 current_tick_length(void); | 244 | extern u64 tick_length; |
239 | 245 | ||
240 | extern void second_overflow(void); | 246 | extern void second_overflow(void); |
241 | extern void update_ntp_one_tick(void); | 247 | extern void update_ntp_one_tick(void); |