Lines Matching +full:ld +full:- +full:pulse +full:- +full:delay +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0
49 * phase-lock loop variables
82 /* constant (boot-param configurable) NTP tick adjustment (upscaled) */
91 * The following variables are used when a pulse-per-second (PPS) signal
142 * pps_clear - Clears the PPS state variables
161 pps_valid--; in pps_dec_valid()
195 txc->ppsfreq = shift_right((pps_freq >> PPM_SCALE_INV_SHIFT) * in pps_fill_timex()
197 txc->jitter = pps_jitter; in pps_fill_timex()
199 txc->jitter = pps_jitter / NSEC_PER_USEC; in pps_fill_timex()
200 txc->shift = pps_shift; in pps_fill_timex()
201 txc->stabil = pps_stabil; in pps_fill_timex()
202 txc->jitcnt = pps_jitcnt; in pps_fill_timex()
203 txc->calcnt = pps_calcnt; in pps_fill_timex()
204 txc->errcnt = pps_errcnt; in pps_fill_timex()
205 txc->stbcnt = pps_stbcnt; in pps_fill_timex()
228 txc->ppsfreq = 0; in pps_fill_timex()
229 txc->jitter = 0; in pps_fill_timex()
230 txc->shift = 0; in pps_fill_timex()
231 txc->stabil = 0; in pps_fill_timex()
232 txc->jitcnt = 0; in pps_fill_timex()
233 txc->calcnt = 0; in pps_fill_timex()
234 txc->errcnt = 0; in pps_fill_timex()
235 txc->stbcnt = 0; in pps_fill_timex()
242 * ntp_synced - Returns 1 if the NTP status is not UNSYNC
277 tick_length += new_base - tick_length_base; in ntp_update_frequency()
293 return div64_long(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs); in ntp_update_offset_fll()
307 offset = clamp(offset, -USEC_PER_SEC, USEC_PER_SEC); in ntp_update_offset()
315 offset = clamp(offset, -MAXPHASE, MAXPHASE); in ntp_update_offset()
321 secs = (long)(__ktime_get_real_seconds() - time_reftime); in ntp_update_offset()
339 (NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant)); in ntp_update_offset()
343 time_freq = max(freq_adj, -MAXFREQ_SCALED); in ntp_update_offset()
349 * ntp_clear - Clears the NTP state variables
375 * ntp_get_next_leap - Returns the next leapsecond in CLOCK_REALTIME ktime_t
407 * Leap second processing. If in leap-insert state at the end of the in second_overflow()
408 * day, the system clock is set back one second; if in leap-delete in second_overflow()
416 ntp_next_leap_sec = secs + SECS_PER_DAY - rem; in second_overflow()
420 ntp_next_leap_sec = secs + SECS_PER_DAY - rem; in second_overflow()
428 leap = -1; in second_overflow()
468 time_offset -= delta; in second_overflow()
478 time_adjust -= MAX_TICKADJ; in second_overflow()
483 if (time_adjust < -MAX_TICKADJ) { in second_overflow()
485 tick_length -= MAX_TICKADJ_SCALED; in second_overflow()
513 * the algorithm is very likely to require a short-sleep retry in sched_sync_hw_clock()
519 /* Compute the needed delay that will get to tv_nsec == target_nsec */ in sched_sync_hw_clock()
520 next.tv_nsec = target_nsec - next.tv_nsec; in sched_sync_hw_clock()
525 next.tv_nsec -= NSEC_PER_SEC; in sched_sync_hw_clock()
545 adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); in sync_rtc_clock()
552 if (rc == -ENODEV) in sync_rtc_clock()
561 return -ENODEV; in update_persistent_clock64()
570 int rc = -EPROTO; in sync_cmos_clock()
588 if (rtc_tv_nsec_ok(-1 * target_nsec, &adjust, &now)) { in sync_cmos_clock()
590 adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); in sync_cmos_clock()
596 if (rc == -ENODEV) { in sync_cmos_clock()
636 * Propagate a new txc->status value into the NTP state:
640 if ((time_status & STA_PLL) && !(txc->status & STA_PLL)) { in process_adj_status()
652 if (!(time_status & STA_PLL) && (txc->status & STA_PLL)) in process_adj_status()
657 time_status |= txc->status & ~STA_RONLY; in process_adj_status()
664 if (txc->modes & ADJ_STATUS) in process_adjtimex_modes()
667 if (txc->modes & ADJ_NANO) in process_adjtimex_modes()
670 if (txc->modes & ADJ_MICRO) in process_adjtimex_modes()
673 if (txc->modes & ADJ_FREQUENCY) { in process_adjtimex_modes()
674 time_freq = txc->freq * PPM_SCALE; in process_adjtimex_modes()
676 time_freq = max(time_freq, -MAXFREQ_SCALED); in process_adjtimex_modes()
681 if (txc->modes & ADJ_MAXERROR) in process_adjtimex_modes()
682 time_maxerror = txc->maxerror; in process_adjtimex_modes()
684 if (txc->modes & ADJ_ESTERROR) in process_adjtimex_modes()
685 time_esterror = txc->esterror; in process_adjtimex_modes()
687 if (txc->modes & ADJ_TIMECONST) { in process_adjtimex_modes()
688 time_constant = txc->constant; in process_adjtimex_modes()
695 if (txc->modes & ADJ_TAI && in process_adjtimex_modes()
696 txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET) in process_adjtimex_modes()
697 *time_tai = txc->constant; in process_adjtimex_modes()
699 if (txc->modes & ADJ_OFFSET) in process_adjtimex_modes()
700 ntp_update_offset(txc->offset); in process_adjtimex_modes()
702 if (txc->modes & ADJ_TICK) in process_adjtimex_modes()
703 tick_usec = txc->tick; in process_adjtimex_modes()
705 if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET)) in process_adjtimex_modes()
712 * kernel time-keeping variables. used by xntpd.
719 if (txc->modes & ADJ_ADJTIME) { in __do_adjtimex()
722 if (!(txc->modes & ADJ_OFFSET_READONLY)) { in __do_adjtimex()
724 time_adjust = txc->offset; in __do_adjtimex()
730 txc->offset = save_adjust; in __do_adjtimex()
733 if (txc->modes) { in __do_adjtimex()
749 txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ, in __do_adjtimex()
752 txc->offset = (u32)txc->offset / NSEC_PER_USEC; in __do_adjtimex()
760 txc->freq = shift_right((time_freq >> PPM_SCALE_INV_SHIFT) * in __do_adjtimex()
762 txc->maxerror = time_maxerror; in __do_adjtimex()
763 txc->esterror = time_esterror; in __do_adjtimex()
764 txc->status = time_status; in __do_adjtimex()
765 txc->constant = time_constant; in __do_adjtimex()
766 txc->precision = 1; in __do_adjtimex()
767 txc->tolerance = MAXFREQ_SCALED / PPM_SCALE; in __do_adjtimex()
768 txc->tick = tick_usec; in __do_adjtimex()
769 txc->tai = *time_tai; in __do_adjtimex()
774 txc->time.tv_sec = ts->tv_sec; in __do_adjtimex()
775 txc->time.tv_usec = ts->tv_nsec; in __do_adjtimex()
777 txc->time.tv_usec = ts->tv_nsec / NSEC_PER_USEC; in __do_adjtimex()
780 if (unlikely(ts->tv_sec >= ntp_next_leap_sec)) { in __do_adjtimex()
783 txc->tai++; in __do_adjtimex()
784 txc->time.tv_sec--; in __do_adjtimex()
788 txc->tai--; in __do_adjtimex()
789 txc->time.tv_sec++; in __do_adjtimex()
792 (ts->tv_sec == ntp_next_leap_sec)) { in __do_adjtimex()
804 * pps_normtime.nsec has a range of ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ]
812 ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] interval */
821 norm.nsec -= NSEC_PER_SEC; in pps_normalize_ts()
831 *jitter = pps_tf[0] - pps_tf[1]; in pps_phase_filter_get()
833 *jitter = -*jitter; in pps_phase_filter_get()
852 if (--pps_intcnt <= -PPS_INTCOUNT) { in pps_dec_freq_interval()
853 pps_intcnt = -PPS_INTCOUNT; in pps_dec_freq_interval()
855 pps_shift--; in pps_dec_freq_interval()
895 "hardpps: PPSERROR: interval too long - %lld s\n", in hardpps_update_freq()
904 ftemp = div_s64(((s64)(-freq_norm.nsec)) << NTP_SCALE_SHIFT, in hardpps_update_freq()
906 delta = shift_right(ftemp - pps_freq, NTP_SCALE_SHIFT); in hardpps_update_freq()
908 if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) { in hardpps_update_freq()
910 "hardpps: PPSWANDER: change=%ld\n", delta); in hardpps_update_freq()
924 delta_mod = -delta_mod; in hardpps_update_freq()
926 (NTP_SCALE_SHIFT - SHIFT_USEC), in hardpps_update_freq()
927 NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN; in hardpps_update_freq()
942 long correction = -error; in hardpps_update_phase()
955 "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n", in hardpps_update_phase()
967 pps_jitter += (jitter - pps_jitter) >> PPS_INTMIN; in hardpps_update_phase()
971 * __hardpps() - discipline CPU clock oscillator to external PPS signal
1006 * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it */ in __hardpps()
1009 (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) { in __hardpps()
1013 printk_deferred(KERN_ERR "hardpps: PPSJITTER: bad pulse\n"); in __hardpps()