xref: /freebsd/sys/compat/linuxkpi/common/include/linux/ptp_clock_kernel.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1*972bf40bSBjoern A. Zeeb /*-
2*972bf40bSBjoern A. Zeeb  * Copyright (c) 2023 The FreeBSD Foundation
3*972bf40bSBjoern A. Zeeb  *
4*972bf40bSBjoern A. Zeeb  * This software was developed by Björn Zeeb under sponsorship from
5*972bf40bSBjoern A. Zeeb  * the FreeBSD Foundation.
6*972bf40bSBjoern A. Zeeb  *
7*972bf40bSBjoern A. Zeeb  * Redistribution and use in source and binary forms, with or without
8*972bf40bSBjoern A. Zeeb  * modification, are permitted provided that the following conditions
9*972bf40bSBjoern A. Zeeb  * are met:
10*972bf40bSBjoern A. Zeeb  * 1. Redistributions of source code must retain the above copyright
11*972bf40bSBjoern A. Zeeb  *    notice, this list of conditions and the following disclaimer.
12*972bf40bSBjoern A. Zeeb  * 2. Redistributions in binary form must reproduce the above copyright
13*972bf40bSBjoern A. Zeeb  *    notice, this list of conditions and the following disclaimer in the
14*972bf40bSBjoern A. Zeeb  *    documentation and/or other materials provided with the distribution.
15*972bf40bSBjoern A. Zeeb  *
16*972bf40bSBjoern A. Zeeb  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17*972bf40bSBjoern A. Zeeb  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*972bf40bSBjoern A. Zeeb  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*972bf40bSBjoern A. Zeeb  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20*972bf40bSBjoern A. Zeeb  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*972bf40bSBjoern A. Zeeb  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*972bf40bSBjoern A. Zeeb  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*972bf40bSBjoern A. Zeeb  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*972bf40bSBjoern A. Zeeb  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*972bf40bSBjoern A. Zeeb  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*972bf40bSBjoern A. Zeeb  * SUCH DAMAGE.
27*972bf40bSBjoern A. Zeeb  */
28*972bf40bSBjoern A. Zeeb 
29*972bf40bSBjoern A. Zeeb #ifndef	_LINUXKPI_LINUX_PTP_CLOCK_KERNEL_H
30*972bf40bSBjoern A. Zeeb #define	_LINUXKPI_LINUX_PTP_CLOCK_KERNEL_H
31*972bf40bSBjoern A. Zeeb 
32*972bf40bSBjoern A. Zeeb #include <linux/types.h>
33*972bf40bSBjoern A. Zeeb #include <linux/device.h>
34*972bf40bSBjoern A. Zeeb #include <linux/kernel.h>	/* pr_debug */
35*972bf40bSBjoern A. Zeeb #include <linux/ktime.h>	/* system_device_crosststamp */
36*972bf40bSBjoern A. Zeeb 
37*972bf40bSBjoern A. Zeeb /* This very likely belongs elsewhere. */
38*972bf40bSBjoern A. Zeeb struct system_device_crosststamp {
39*972bf40bSBjoern A. Zeeb 	ktime_t	device;
40*972bf40bSBjoern A. Zeeb 	ktime_t	sys_realtime;
41*972bf40bSBjoern A. Zeeb 	ktime_t	sys_monotonic_raw;	/* name guessed based on comment */
42*972bf40bSBjoern A. Zeeb };
43*972bf40bSBjoern A. Zeeb 
44*972bf40bSBjoern A. Zeeb struct ptp_clock_info {
45*972bf40bSBjoern A. Zeeb 	char		name[32];
46*972bf40bSBjoern A. Zeeb 	int		max_adj;
47*972bf40bSBjoern A. Zeeb 	void		*owner;			/* THIS_MODULE */
48*972bf40bSBjoern A. Zeeb 	int (*adjfine)(struct ptp_clock_info *, long);
49*972bf40bSBjoern A. Zeeb 	int (*adjtime)(struct ptp_clock_info *, s64);
50*972bf40bSBjoern A. Zeeb 	int (*getcrosststamp)(struct ptp_clock_info *, struct system_device_crosststamp *);
51*972bf40bSBjoern A. Zeeb 	int (*gettime64)(struct ptp_clock_info *, struct timespec *);
52*972bf40bSBjoern A. Zeeb };
53*972bf40bSBjoern A. Zeeb 
54*972bf40bSBjoern A. Zeeb static inline struct ptp_clock *
ptp_clock_register(struct ptp_clock_info * ptpci,struct device * dev)55*972bf40bSBjoern A. Zeeb ptp_clock_register(struct ptp_clock_info *ptpci, struct device *dev)
56*972bf40bSBjoern A. Zeeb {
57*972bf40bSBjoern A. Zeeb 
58*972bf40bSBjoern A. Zeeb 	pr_debug("%s: TODO\n", __func__);
59*972bf40bSBjoern A. Zeeb 	return (NULL);
60*972bf40bSBjoern A. Zeeb }
61*972bf40bSBjoern A. Zeeb 
62*972bf40bSBjoern A. Zeeb static inline void
ptp_clock_unregister(struct ptp_clock * ptpc)63*972bf40bSBjoern A. Zeeb ptp_clock_unregister(struct ptp_clock *ptpc)
64*972bf40bSBjoern A. Zeeb {
65*972bf40bSBjoern A. Zeeb 	pr_debug("%s: TODO\n", __func__);
66*972bf40bSBjoern A. Zeeb }
67*972bf40bSBjoern A. Zeeb 
68*972bf40bSBjoern A. Zeeb static inline int
ptp_clock_index(struct ptp_clock * ptpc)69*972bf40bSBjoern A. Zeeb ptp_clock_index(struct ptp_clock *ptpc)
70*972bf40bSBjoern A. Zeeb {
71*972bf40bSBjoern A. Zeeb 	pr_debug("%s: TODO\n", __func__);
72*972bf40bSBjoern A. Zeeb 	return (0);
73*972bf40bSBjoern A. Zeeb }
74*972bf40bSBjoern A. Zeeb 
75*972bf40bSBjoern A. Zeeb #endif	/* _LINUXKPI_LINUX_PTP_CLOCK_KERNEL_H */
76