Commit 220a60a425146b0e37998cc0b3082f0541aad866
1 parent
ef2c7d7b59
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
pps/ptp: Allow PHC devices to adjust PPS events for known delay
Initial version by Stuart Hodgson <smhodgson@solarflare.com> Some PHC device drivers may deliver PPS events with a significant and variable delay, but still be able to measure precisely what that delay is. Add a pps_sub_ts() function for subtracting a delay from the timestamp(s) in a PPS event, and a PTP event type (PTP_CLOCK_PPSUSR) for which the caller provides a complete PPS event. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Showing 3 changed files with 22 additions and 2 deletions Side-by-side Diff
drivers/ptp/ptp_clock.c
... | ... | @@ -300,6 +300,11 @@ |
300 | 300 | pps_get_ts(&evt); |
301 | 301 | pps_event(ptp->pps_source, &evt, PTP_PPS_EVENT, NULL); |
302 | 302 | break; |
303 | + | |
304 | + case PTP_CLOCK_PPSUSR: | |
305 | + pps_event(ptp->pps_source, &event->pps_times, | |
306 | + PTP_PPS_EVENT, NULL); | |
307 | + break; | |
303 | 308 | } |
304 | 309 | } |
305 | 310 | EXPORT_SYMBOL(ptp_clock_event); |
include/linux/pps_kernel.h
... | ... | @@ -116,5 +116,14 @@ |
116 | 116 | |
117 | 117 | #endif /* CONFIG_NTP_PPS */ |
118 | 118 | |
119 | +/* Subtract known time delay from PPS event time(s) */ | |
120 | +static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec delta) | |
121 | +{ | |
122 | + ts->ts_real = timespec_sub(ts->ts_real, delta); | |
123 | +#ifdef CONFIG_NTP_PPS | |
124 | + ts->ts_raw = timespec_sub(ts->ts_raw, delta); | |
125 | +#endif | |
126 | +} | |
127 | + | |
119 | 128 | #endif /* LINUX_PPS_KERNEL_H */ |
include/linux/ptp_clock_kernel.h
... | ... | @@ -21,6 +21,7 @@ |
21 | 21 | #ifndef _PTP_CLOCK_KERNEL_H_ |
22 | 22 | #define _PTP_CLOCK_KERNEL_H_ |
23 | 23 | |
24 | +#include <linux/pps_kernel.h> | |
24 | 25 | #include <linux/ptp_clock.h> |
25 | 26 | |
26 | 27 | |
... | ... | @@ -110,6 +111,7 @@ |
110 | 111 | PTP_CLOCK_ALARM, |
111 | 112 | PTP_CLOCK_EXTTS, |
112 | 113 | PTP_CLOCK_PPS, |
114 | + PTP_CLOCK_PPSUSR, | |
113 | 115 | }; |
114 | 116 | |
115 | 117 | /** |
116 | 118 | |
... | ... | @@ -117,13 +119,17 @@ |
117 | 119 | * |
118 | 120 | * @type: One of the ptp_clock_events enumeration values. |
119 | 121 | * @index: Identifies the source of the event. |
120 | - * @timestamp: When the event occured. | |
122 | + * @timestamp: When the event occurred (%PTP_CLOCK_EXTTS only). | |
123 | + * @pps_times: When the event occurred (%PTP_CLOCK_PPSUSR only). | |
121 | 124 | */ |
122 | 125 | |
123 | 126 | struct ptp_clock_event { |
124 | 127 | int type; |
125 | 128 | int index; |
126 | - u64 timestamp; | |
129 | + union { | |
130 | + u64 timestamp; | |
131 | + struct pps_event_time pps_times; | |
132 | + }; | |
127 | 133 | }; |
128 | 134 | |
129 | 135 | /** |