diff options
-rw-r--r-- | drivers/ptp/ptp_clock.c | 5 | ||||
-rw-r--r-- | include/linux/pps_kernel.h | 9 | ||||
-rw-r--r-- | include/linux/ptp_clock_kernel.h | 10 |
3 files changed, 22 insertions, 2 deletions
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index 1e528b539a07..966875dcda56 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c | |||
@@ -300,6 +300,11 @@ void ptp_clock_event(struct ptp_clock *ptp, struct ptp_clock_event *event) | |||
300 | pps_get_ts(&evt); | 300 | pps_get_ts(&evt); |
301 | pps_event(ptp->pps_source, &evt, PTP_PPS_EVENT, NULL); | 301 | pps_event(ptp->pps_source, &evt, PTP_PPS_EVENT, NULL); |
302 | break; | 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 | EXPORT_SYMBOL(ptp_clock_event); | 310 | EXPORT_SYMBOL(ptp_clock_event); |
diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h index 94048547f29a..0cc45ae1afd5 100644 --- a/include/linux/pps_kernel.h +++ b/include/linux/pps_kernel.h | |||
@@ -116,5 +116,14 @@ static inline void pps_get_ts(struct pps_event_time *ts) | |||
116 | 116 | ||
117 | #endif /* CONFIG_NTP_PPS */ | 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 | #endif /* LINUX_PPS_KERNEL_H */ | 128 | #endif /* LINUX_PPS_KERNEL_H */ |
120 | 129 | ||
diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h index 945704c2ed65..a644b29f1161 100644 --- a/include/linux/ptp_clock_kernel.h +++ b/include/linux/ptp_clock_kernel.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #ifndef _PTP_CLOCK_KERNEL_H_ | 21 | #ifndef _PTP_CLOCK_KERNEL_H_ |
22 | #define _PTP_CLOCK_KERNEL_H_ | 22 | #define _PTP_CLOCK_KERNEL_H_ |
23 | 23 | ||
24 | #include <linux/pps_kernel.h> | ||
24 | #include <linux/ptp_clock.h> | 25 | #include <linux/ptp_clock.h> |
25 | 26 | ||
26 | 27 | ||
@@ -110,6 +111,7 @@ enum ptp_clock_events { | |||
110 | PTP_CLOCK_ALARM, | 111 | PTP_CLOCK_ALARM, |
111 | PTP_CLOCK_EXTTS, | 112 | PTP_CLOCK_EXTTS, |
112 | PTP_CLOCK_PPS, | 113 | PTP_CLOCK_PPS, |
114 | PTP_CLOCK_PPSUSR, | ||
113 | }; | 115 | }; |
114 | 116 | ||
115 | /** | 117 | /** |
@@ -117,13 +119,17 @@ enum ptp_clock_events { | |||
117 | * | 119 | * |
118 | * @type: One of the ptp_clock_events enumeration values. | 120 | * @type: One of the ptp_clock_events enumeration values. |
119 | * @index: Identifies the source of the event. | 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 | struct ptp_clock_event { | 126 | struct ptp_clock_event { |
124 | int type; | 127 | int type; |
125 | int index; | 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 | /** |