174ba9207SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2d94ba80eSRichard Cochran /*
3d94ba80eSRichard Cochran  * PTP 1588 clock support
4d94ba80eSRichard Cochran  *
5d94ba80eSRichard Cochran  * Copyright (C) 2010 OMICRON electronics GmbH
6d94ba80eSRichard Cochran  */
7d94ba80eSRichard Cochran 
8d94ba80eSRichard Cochran #ifndef _PTP_CLOCK_KERNEL_H_
9d94ba80eSRichard Cochran #define _PTP_CLOCK_KERNEL_H_
10d94ba80eSRichard Cochran 
111ef76158SRichard Cochran #include <linux/device.h>
12220a60a4SBen Hutchings #include <linux/pps_kernel.h>
13d94ba80eSRichard Cochran #include <linux/ptp_clock.h>
145d43f951SYangbo Lu #include <linux/timecounter.h>
15d94ba80eSRichard Cochran 
165d43f951SYangbo Lu #define PTP_CLOCK_NAME_LEN	32
17d04a53b1SAhmad Fatoum /**
18d04a53b1SAhmad Fatoum  * struct ptp_clock_request - request PTP clock event
19d04a53b1SAhmad Fatoum  *
20d04a53b1SAhmad Fatoum  * @type:   The type of the request.
21d04a53b1SAhmad Fatoum  *	    EXTTS:  Configure external trigger timestamping
22d04a53b1SAhmad Fatoum  *	    PEROUT: Configure periodic output signal (e.g. PPS)
23d04a53b1SAhmad Fatoum  *	    PPS:    trigger internal PPS event for input
24d04a53b1SAhmad Fatoum  *	            into kernel PPS subsystem
25d04a53b1SAhmad Fatoum  * @extts:  describes configuration for external trigger timestamping.
26d04a53b1SAhmad Fatoum  *          This is only valid when event == PTP_CLK_REQ_EXTTS.
27d04a53b1SAhmad Fatoum  * @perout: describes configuration for periodic output.
28d04a53b1SAhmad Fatoum  *	    This is only valid when event == PTP_CLK_REQ_PEROUT.
29d04a53b1SAhmad Fatoum  */
30d94ba80eSRichard Cochran 
31d94ba80eSRichard Cochran struct ptp_clock_request {
32d94ba80eSRichard Cochran 	enum {
33d94ba80eSRichard Cochran 		PTP_CLK_REQ_EXTTS,
34d94ba80eSRichard Cochran 		PTP_CLK_REQ_PEROUT,
35d94ba80eSRichard Cochran 		PTP_CLK_REQ_PPS,
36d94ba80eSRichard Cochran 	} type;
37d94ba80eSRichard Cochran 	union {
38d94ba80eSRichard Cochran 		struct ptp_extts_request extts;
39d94ba80eSRichard Cochran 		struct ptp_perout_request perout;
40d94ba80eSRichard Cochran 	};
41d94ba80eSRichard Cochran };
42d94ba80eSRichard Cochran 
43719f1aa4SChristopher S. Hall struct system_device_crosststamp;
4436180087SMiroslav Lichvar 
4536180087SMiroslav Lichvar /**
4636180087SMiroslav Lichvar  * struct ptp_system_timestamp - system time corresponding to a PHC timestamp
4736180087SMiroslav Lichvar  */
4836180087SMiroslav Lichvar struct ptp_system_timestamp {
4936180087SMiroslav Lichvar 	struct timespec64 pre_ts;
5036180087SMiroslav Lichvar 	struct timespec64 post_ts;
5136180087SMiroslav Lichvar };
5236180087SMiroslav Lichvar 
53d94ba80eSRichard Cochran /**
54184ecc9eSVincent Cheng  * struct ptp_clock_info - describes a PTP hardware clock
55d94ba80eSRichard Cochran  *
56d94ba80eSRichard Cochran  * @owner:     The clock driver should set to THIS_MODULE.
57de465846SRichard Cochran  * @name:      A short "friendly name" to identify the clock and to
58de465846SRichard Cochran  *             help distinguish PHY based devices from MAC based ones.
59de465846SRichard Cochran  *             The string is not meant to be a unique id.
60d94ba80eSRichard Cochran  * @max_adj:   The maximum possible frequency adjustment, in parts per billon.
61d94ba80eSRichard Cochran  * @n_alarm:   The number of programmable alarms.
62d94ba80eSRichard Cochran  * @n_ext_ts:  The number of external time stamp channels.
63d94ba80eSRichard Cochran  * @n_per_out: The number of programmable periodic signals.
646092315dSRichard Cochran  * @n_pins:    The number of programmable pins.
65d94ba80eSRichard Cochran  * @pps:       Indicates whether the clock supports a PPS callback.
666092315dSRichard Cochran  * @pin_config: Array of length 'n_pins'. If the number of
676092315dSRichard Cochran  *              programmable pins is nonzero, then drivers must
686092315dSRichard Cochran  *              allocate and initialize this array.
69d94ba80eSRichard Cochran  *
70d94ba80eSRichard Cochran  * clock operations
71d94ba80eSRichard Cochran  *
72d8d26354SRichard Cochran  * @adjfine:  Adjusts the frequency of the hardware clock.
73d8d26354SRichard Cochran  *            parameter scaled_ppm: Desired frequency offset from
74d8d26354SRichard Cochran  *            nominal frequency in parts per million, but with a
75d8d26354SRichard Cochran  *            16 bit binary fractional field.
76d8d26354SRichard Cochran  *
77d94ba80eSRichard Cochran  * @adjfreq:  Adjusts the frequency of the hardware clock.
78d8d26354SRichard Cochran  *            This method is deprecated.  New drivers should implement
79d8d26354SRichard Cochran  *            the @adjfine method instead.
8087f4d7c1SJacob Keller  *            parameter delta: Desired frequency offset from nominal frequency
8187f4d7c1SJacob Keller  *            in parts per billion
82d94ba80eSRichard Cochran  *
83184ecc9eSVincent Cheng  * @adjphase:  Adjusts the phase offset of the hardware clock.
84184ecc9eSVincent Cheng  *             parameter delta: Desired change in nanoseconds.
85184ecc9eSVincent Cheng  *
86d94ba80eSRichard Cochran  * @adjtime:  Shifts the time of the hardware clock.
87d94ba80eSRichard Cochran  *            parameter delta: Desired change in nanoseconds.
88d94ba80eSRichard Cochran  *
8992f17194SRichard Cochran  * @gettime64:  Reads the current time from the hardware clock.
90916444dfSMiroslav Lichvar  *              This method is deprecated.  New drivers should implement
91916444dfSMiroslav Lichvar  *              the @gettimex64 method instead.
9292f17194SRichard Cochran  *              parameter ts: Holds the result.
9392f17194SRichard Cochran  *
9436180087SMiroslav Lichvar  * @gettimex64:  Reads the current time from the hardware clock and optionally
9536180087SMiroslav Lichvar  *               also the system clock.
9636180087SMiroslav Lichvar  *               parameter ts: Holds the PHC timestamp.
9736180087SMiroslav Lichvar  *               parameter sts: If not NULL, it holds a pair of timestamps from
9836180087SMiroslav Lichvar  *               the system clock. The first reading is made right before
9936180087SMiroslav Lichvar  *               reading the lowest bits of the PHC timestamp and the second
10036180087SMiroslav Lichvar  *               reading immediately follows that.
10136180087SMiroslav Lichvar  *
102719f1aa4SChristopher S. Hall  * @getcrosststamp:  Reads the current time from the hardware clock and
103719f1aa4SChristopher S. Hall  *                   system clock simultaneously.
104719f1aa4SChristopher S. Hall  *                   parameter cts: Contains timestamp (device,system) pair,
105719f1aa4SChristopher S. Hall  *                   where system time is realtime and monotonic.
106719f1aa4SChristopher S. Hall  *
10792f17194SRichard Cochran  * @settime64:  Set the current time on the hardware clock.
108d94ba80eSRichard Cochran  *              parameter ts: Time value to set.
109d94ba80eSRichard Cochran  *
110d94ba80eSRichard Cochran  * @enable:   Request driver to enable or disable an ancillary feature.
111d94ba80eSRichard Cochran  *            parameter request: Desired resource to enable or disable.
112d94ba80eSRichard Cochran  *            parameter on: Caller passes one to enable or zero to disable.
113d94ba80eSRichard Cochran  *
1146092315dSRichard Cochran  * @verify:   Confirm that a pin can perform a given function. The PTP
1156092315dSRichard Cochran  *            Hardware Clock subsystem maintains the 'pin_config'
1166092315dSRichard Cochran  *            array on behalf of the drivers, but the PHC subsystem
1176092315dSRichard Cochran  *            assumes that every pin can perform every function. This
1186092315dSRichard Cochran  *            hook gives drivers a way of telling the core about
1196092315dSRichard Cochran  *            limitations on specific pins. This function must return
1206092315dSRichard Cochran  *            zero if the function can be assigned to this pin, and
1216092315dSRichard Cochran  *            nonzero otherwise.
1226092315dSRichard Cochran  *            parameter pin: index of the pin in question.
1236092315dSRichard Cochran  *            parameter func: the desired function to use.
1246092315dSRichard Cochran  *            parameter chan: the function channel index to use.
1256092315dSRichard Cochran  *
1262c864c78SJacob Keller  * @do_aux_work:  Request driver to perform auxiliary (periodic) operations
1272c864c78SJacob Keller  *                Driver should return delay of the next auxiliary work
1282c864c78SJacob Keller  *                scheduling time (>=0) or negative value in case further
1292c864c78SJacob Keller  *                scheduling is not required.
130d9535cb7SGrygorii Strashko  *
131d94ba80eSRichard Cochran  * Drivers should embed their ptp_clock_info within a private
132d94ba80eSRichard Cochran  * structure, obtaining a reference to it using container_of().
133d94ba80eSRichard Cochran  *
134d94ba80eSRichard Cochran  * The callbacks must all return zero on success, non-zero otherwise.
135d94ba80eSRichard Cochran  */
136d94ba80eSRichard Cochran 
137d94ba80eSRichard Cochran struct ptp_clock_info {
138d94ba80eSRichard Cochran 	struct module *owner;
1395d43f951SYangbo Lu 	char name[PTP_CLOCK_NAME_LEN];
140d94ba80eSRichard Cochran 	s32 max_adj;
141d94ba80eSRichard Cochran 	int n_alarm;
142d94ba80eSRichard Cochran 	int n_ext_ts;
143d94ba80eSRichard Cochran 	int n_per_out;
1446092315dSRichard Cochran 	int n_pins;
145d94ba80eSRichard Cochran 	int pps;
1466092315dSRichard Cochran 	struct ptp_pin_desc *pin_config;
147d8d26354SRichard Cochran 	int (*adjfine)(struct ptp_clock_info *ptp, long scaled_ppm);
148d94ba80eSRichard Cochran 	int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta);
149184ecc9eSVincent Cheng 	int (*adjphase)(struct ptp_clock_info *ptp, s32 phase);
150d94ba80eSRichard Cochran 	int (*adjtime)(struct ptp_clock_info *ptp, s64 delta);
15192f17194SRichard Cochran 	int (*gettime64)(struct ptp_clock_info *ptp, struct timespec64 *ts);
15236180087SMiroslav Lichvar 	int (*gettimex64)(struct ptp_clock_info *ptp, struct timespec64 *ts,
15336180087SMiroslav Lichvar 			  struct ptp_system_timestamp *sts);
154719f1aa4SChristopher S. Hall 	int (*getcrosststamp)(struct ptp_clock_info *ptp,
155719f1aa4SChristopher S. Hall 			      struct system_device_crosststamp *cts);
15692f17194SRichard Cochran 	int (*settime64)(struct ptp_clock_info *p, const struct timespec64 *ts);
157d94ba80eSRichard Cochran 	int (*enable)(struct ptp_clock_info *ptp,
158d94ba80eSRichard Cochran 		      struct ptp_clock_request *request, int on);
1596092315dSRichard Cochran 	int (*verify)(struct ptp_clock_info *ptp, unsigned int pin,
1606092315dSRichard Cochran 		      enum ptp_pin_function func, unsigned int chan);
161d9535cb7SGrygorii Strashko 	long (*do_aux_work)(struct ptp_clock_info *ptp);
162d94ba80eSRichard Cochran };
163d94ba80eSRichard Cochran 
164d94ba80eSRichard Cochran struct ptp_clock;
165d94ba80eSRichard Cochran 
166d94ba80eSRichard Cochran enum ptp_clock_events {
167d94ba80eSRichard Cochran 	PTP_CLOCK_ALARM,
168d94ba80eSRichard Cochran 	PTP_CLOCK_EXTTS,
169d94ba80eSRichard Cochran 	PTP_CLOCK_PPS,
170220a60a4SBen Hutchings 	PTP_CLOCK_PPSUSR,
171d94ba80eSRichard Cochran };
172d94ba80eSRichard Cochran 
173d94ba80eSRichard Cochran /**
174d94ba80eSRichard Cochran  * struct ptp_clock_event - decribes a PTP hardware clock event
175d94ba80eSRichard Cochran  *
176d94ba80eSRichard Cochran  * @type:  One of the ptp_clock_events enumeration values.
177d94ba80eSRichard Cochran  * @index: Identifies the source of the event.
178220a60a4SBen Hutchings  * @timestamp: When the event occurred (%PTP_CLOCK_EXTTS only).
179220a60a4SBen Hutchings  * @pps_times: When the event occurred (%PTP_CLOCK_PPSUSR only).
180d94ba80eSRichard Cochran  */
181d94ba80eSRichard Cochran 
182d94ba80eSRichard Cochran struct ptp_clock_event {
183d94ba80eSRichard Cochran 	int type;
184d94ba80eSRichard Cochran 	int index;
185220a60a4SBen Hutchings 	union {
186d94ba80eSRichard Cochran 		u64 timestamp;
187220a60a4SBen Hutchings 		struct pps_event_time pps_times;
188220a60a4SBen Hutchings 	};
189d94ba80eSRichard Cochran };
190d94ba80eSRichard Cochran 
1919d9d415fSRadu Pirea (NXP OSS) /**
1929d9d415fSRadu Pirea (NXP OSS)  * scaled_ppm_to_ppb() - convert scaled ppm to ppb
1939d9d415fSRadu Pirea (NXP OSS)  *
1949d9d415fSRadu Pirea (NXP OSS)  * @ppm:    Parts per million, but with a 16 bit binary fractional field
1959d9d415fSRadu Pirea (NXP OSS)  */
196adc2e56eSJakub Kicinski static inline long scaled_ppm_to_ppb(long ppm)
1979d9d415fSRadu Pirea (NXP OSS) {
1989d9d415fSRadu Pirea (NXP OSS) 	/*
1999d9d415fSRadu Pirea (NXP OSS) 	 * The 'freq' field in the 'struct timex' is in parts per
2009d9d415fSRadu Pirea (NXP OSS) 	 * million, but with a 16 bit binary fractional field.
2019d9d415fSRadu Pirea (NXP OSS) 	 *
2029d9d415fSRadu Pirea (NXP OSS) 	 * We want to calculate
2039d9d415fSRadu Pirea (NXP OSS) 	 *
2049d9d415fSRadu Pirea (NXP OSS) 	 *    ppb = scaled_ppm * 1000 / 2^16
2059d9d415fSRadu Pirea (NXP OSS) 	 *
2069d9d415fSRadu Pirea (NXP OSS) 	 * which simplifies to
2079d9d415fSRadu Pirea (NXP OSS) 	 *
2089d9d415fSRadu Pirea (NXP OSS) 	 *    ppb = scaled_ppm * 125 / 2^13
2099d9d415fSRadu Pirea (NXP OSS) 	 */
2109d9d415fSRadu Pirea (NXP OSS) 	s64 ppb = 1 + ppm;
2119d9d415fSRadu Pirea (NXP OSS) 
2129d9d415fSRadu Pirea (NXP OSS) 	ppb *= 125;
2139d9d415fSRadu Pirea (NXP OSS) 	ppb >>= 13;
214adc2e56eSJakub Kicinski 	return (long)ppb;
2159d9d415fSRadu Pirea (NXP OSS) }
2169d9d415fSRadu Pirea (NXP OSS) 
217d1cbfd77SNicolas Pitre #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
218d1cbfd77SNicolas Pitre 
219d1cbfd77SNicolas Pitre /**
220d1cbfd77SNicolas Pitre  * ptp_clock_register() - register a PTP hardware clock driver
221d1cbfd77SNicolas Pitre  *
222d1cbfd77SNicolas Pitre  * @info:   Structure describing the new clock.
223d1cbfd77SNicolas Pitre  * @parent: Pointer to the parent device of the new clock.
224d1cbfd77SNicolas Pitre  *
225d1cbfd77SNicolas Pitre  * Returns a valid pointer on success or PTR_ERR on failure.  If PHC
226d1cbfd77SNicolas Pitre  * support is missing at the configuration level, this function
227d1cbfd77SNicolas Pitre  * returns NULL, and drivers are expected to gracefully handle that
228d1cbfd77SNicolas Pitre  * case separately.
229d1cbfd77SNicolas Pitre  */
230d1cbfd77SNicolas Pitre 
231d1cbfd77SNicolas Pitre extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
232d1cbfd77SNicolas Pitre 					    struct device *parent);
233d1cbfd77SNicolas Pitre 
234d1cbfd77SNicolas Pitre /**
235d1cbfd77SNicolas Pitre  * ptp_clock_unregister() - unregister a PTP hardware clock driver
236d1cbfd77SNicolas Pitre  *
237d1cbfd77SNicolas Pitre  * @ptp:  The clock to remove from service.
238d1cbfd77SNicolas Pitre  */
239d1cbfd77SNicolas Pitre 
240d1cbfd77SNicolas Pitre extern int ptp_clock_unregister(struct ptp_clock *ptp);
241d1cbfd77SNicolas Pitre 
242d94ba80eSRichard Cochran /**
243d94ba80eSRichard Cochran  * ptp_clock_event() - notify the PTP layer about an event
244d94ba80eSRichard Cochran  *
245d94ba80eSRichard Cochran  * @ptp:    The clock obtained from ptp_clock_register().
246d94ba80eSRichard Cochran  * @event:  Message structure describing the event.
247d94ba80eSRichard Cochran  */
248d94ba80eSRichard Cochran 
249d94ba80eSRichard Cochran extern void ptp_clock_event(struct ptp_clock *ptp,
250d94ba80eSRichard Cochran 			    struct ptp_clock_event *event);
251d94ba80eSRichard Cochran 
252995a9090SRichard Cochran /**
253995a9090SRichard Cochran  * ptp_clock_index() - obtain the device index of a PTP clock
254995a9090SRichard Cochran  *
255995a9090SRichard Cochran  * @ptp:    The clock obtained from ptp_clock_register().
256995a9090SRichard Cochran  */
257995a9090SRichard Cochran 
258995a9090SRichard Cochran extern int ptp_clock_index(struct ptp_clock *ptp);
259995a9090SRichard Cochran 
2606092315dSRichard Cochran /**
2616092315dSRichard Cochran  * ptp_find_pin() - obtain the pin index of a given auxiliary function
2626092315dSRichard Cochran  *
26362582a7eSRichard Cochran  * The caller must hold ptp_clock::pincfg_mux.  Drivers do not have
26462582a7eSRichard Cochran  * access to that mutex as ptp_clock is an opaque type.  However, the
26562582a7eSRichard Cochran  * core code acquires the mutex before invoking the driver's
26662582a7eSRichard Cochran  * ptp_clock_info::enable() callback, and so drivers may call this
26762582a7eSRichard Cochran  * function from that context.
26862582a7eSRichard Cochran  *
2696092315dSRichard Cochran  * @ptp:    The clock obtained from ptp_clock_register().
2706092315dSRichard Cochran  * @func:   One of the ptp_pin_function enumerated values.
2716092315dSRichard Cochran  * @chan:   The particular functional channel to find.
2726092315dSRichard Cochran  * Return:  Pin index in the range of zero to ptp_clock_caps.n_pins - 1,
2736092315dSRichard Cochran  *          or -1 if the auxiliary function cannot be found.
2746092315dSRichard Cochran  */
2756092315dSRichard Cochran 
2766092315dSRichard Cochran int ptp_find_pin(struct ptp_clock *ptp,
2776092315dSRichard Cochran 		 enum ptp_pin_function func, unsigned int chan);
2786092315dSRichard Cochran 
279d9535cb7SGrygorii Strashko /**
28062582a7eSRichard Cochran  * ptp_find_pin_unlocked() - wrapper for ptp_find_pin()
28162582a7eSRichard Cochran  *
28262582a7eSRichard Cochran  * This function acquires the ptp_clock::pincfg_mux mutex before
28362582a7eSRichard Cochran  * invoking ptp_find_pin().  Instead of using this function, drivers
28462582a7eSRichard Cochran  * should most likely call ptp_find_pin() directly from their
28562582a7eSRichard Cochran  * ptp_clock_info::enable() method.
28662582a7eSRichard Cochran  *
28762582a7eSRichard Cochran  */
28862582a7eSRichard Cochran 
28962582a7eSRichard Cochran int ptp_find_pin_unlocked(struct ptp_clock *ptp,
29062582a7eSRichard Cochran 			  enum ptp_pin_function func, unsigned int chan);
29162582a7eSRichard Cochran 
29262582a7eSRichard Cochran /**
293d9535cb7SGrygorii Strashko  * ptp_schedule_worker() - schedule ptp auxiliary work
294d9535cb7SGrygorii Strashko  *
295d9535cb7SGrygorii Strashko  * @ptp:    The clock obtained from ptp_clock_register().
296d9535cb7SGrygorii Strashko  * @delay:  number of jiffies to wait before queuing
297d9535cb7SGrygorii Strashko  *          See kthread_queue_delayed_work() for more info.
298d9535cb7SGrygorii Strashko  */
299d9535cb7SGrygorii Strashko 
300d9535cb7SGrygorii Strashko int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay);
301d9535cb7SGrygorii Strashko 
302544fed47SVladimir Oltean /**
303544fed47SVladimir Oltean  * ptp_cancel_worker_sync() - cancel ptp auxiliary clock
304544fed47SVladimir Oltean  *
305544fed47SVladimir Oltean  * @ptp:     The clock obtained from ptp_clock_register().
306544fed47SVladimir Oltean  */
307544fed47SVladimir Oltean void ptp_cancel_worker_sync(struct ptp_clock *ptp);
308544fed47SVladimir Oltean 
309*acb288e8SYangbo Lu /**
310*acb288e8SYangbo Lu  * ptp_get_vclocks_index() - get all vclocks index on pclock, and
311*acb288e8SYangbo Lu  *                           caller is responsible to free memory
312*acb288e8SYangbo Lu  *                           of vclock_index
313*acb288e8SYangbo Lu  *
314*acb288e8SYangbo Lu  * @pclock_index: phc index of ptp pclock.
315*acb288e8SYangbo Lu  * @vclock_index: pointer to pointer of vclock index.
316*acb288e8SYangbo Lu  *
317*acb288e8SYangbo Lu  * return number of vclocks.
318*acb288e8SYangbo Lu  */
319*acb288e8SYangbo Lu int ptp_get_vclocks_index(int pclock_index, int **vclock_index);
320*acb288e8SYangbo Lu 
321d1cbfd77SNicolas Pitre #else
322d1cbfd77SNicolas Pitre static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
323d1cbfd77SNicolas Pitre 						   struct device *parent)
324d1cbfd77SNicolas Pitre { return NULL; }
325d1cbfd77SNicolas Pitre static inline int ptp_clock_unregister(struct ptp_clock *ptp)
326d1cbfd77SNicolas Pitre { return 0; }
327d1cbfd77SNicolas Pitre static inline void ptp_clock_event(struct ptp_clock *ptp,
328d1cbfd77SNicolas Pitre 				   struct ptp_clock_event *event)
329d1cbfd77SNicolas Pitre { }
330d1cbfd77SNicolas Pitre static inline int ptp_clock_index(struct ptp_clock *ptp)
331d1cbfd77SNicolas Pitre { return -1; }
332d1cbfd77SNicolas Pitre static inline int ptp_find_pin(struct ptp_clock *ptp,
333d1cbfd77SNicolas Pitre 			       enum ptp_pin_function func, unsigned int chan)
334d1cbfd77SNicolas Pitre { return -1; }
335d9535cb7SGrygorii Strashko static inline int ptp_schedule_worker(struct ptp_clock *ptp,
336d9535cb7SGrygorii Strashko 				      unsigned long delay)
337d9535cb7SGrygorii Strashko { return -EOPNOTSUPP; }
338544fed47SVladimir Oltean static inline void ptp_cancel_worker_sync(struct ptp_clock *ptp)
339544fed47SVladimir Oltean { }
340*acb288e8SYangbo Lu static inline int ptp_get_vclocks_index(int pclock_index, int **vclock_index)
341*acb288e8SYangbo Lu { return 0; }
342d9535cb7SGrygorii Strashko 
343d1cbfd77SNicolas Pitre #endif
344d1cbfd77SNicolas Pitre 
34536180087SMiroslav Lichvar static inline void ptp_read_system_prets(struct ptp_system_timestamp *sts)
34636180087SMiroslav Lichvar {
34736180087SMiroslav Lichvar 	if (sts)
34836180087SMiroslav Lichvar 		ktime_get_real_ts64(&sts->pre_ts);
34936180087SMiroslav Lichvar }
35036180087SMiroslav Lichvar 
35136180087SMiroslav Lichvar static inline void ptp_read_system_postts(struct ptp_system_timestamp *sts)
35236180087SMiroslav Lichvar {
35336180087SMiroslav Lichvar 	if (sts)
35436180087SMiroslav Lichvar 		ktime_get_real_ts64(&sts->post_ts);
35536180087SMiroslav Lichvar }
35636180087SMiroslav Lichvar 
357d94ba80eSRichard Cochran #endif
358