]> granicus.if.org Git - strace/blob - linux/ptp_clock.h
travis: add build environment information to the travis log
[strace] / linux / ptp_clock.h
1 /*
2  * PTP 1588 clock support - user space interface
3  *
4  * Copyright (c) 2010 OMICRON electronics GmbH
5  * Copyright (c) 2010-2017 The strace developers.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #ifndef _PTP_CLOCK_H_
23 #define _PTP_CLOCK_H_
24
25 #include <linux/ioctl.h>
26 #include <linux/types.h>
27
28 /* PTP_xxx bits, for the flags field within the request structures. */
29 #define PTP_ENABLE_FEATURE (1<<0)
30 #define PTP_RISING_EDGE    (1<<1)
31 #define PTP_FALLING_EDGE   (1<<2)
32
33 /*
34  * struct ptp_clock_time - represents a time value
35  *
36  * The sign of the seconds field applies to the whole value. The
37  * nanoseconds field is always unsigned. The reserved field is
38  * included for sub-nanosecond resolution, should the demand for
39  * this ever appear.
40  *
41  */
42 struct ptp_clock_time {
43         __s64 sec;  /* seconds */
44         __u32 nsec; /* nanoseconds */
45         __u32 reserved;
46 };
47
48 struct ptp_clock_caps {
49         int max_adj;   /* Maximum frequency adjustment in parts per billon. */
50         int n_alarm;   /* Number of programmable alarms. */
51         int n_ext_ts;  /* Number of external time stamp channels. */
52         int n_per_out; /* Number of programmable periodic signals. */
53         int pps;       /* Whether the clock supports a PPS callback. */
54         int rsv[15];   /* Reserved for future use. */
55 };
56
57 struct ptp_extts_request {
58         unsigned int index;  /* Which channel to configure. */
59         unsigned int flags;  /* Bit field for PTP_xxx flags. */
60         unsigned int rsv[2]; /* Reserved for future use. */
61 };
62
63 struct ptp_perout_request {
64         struct ptp_clock_time start;  /* Absolute start time. */
65         struct ptp_clock_time period; /* Desired period, zero means disable. */
66         unsigned int index;           /* Which channel to configure. */
67         unsigned int flags;           /* Reserved for future use. */
68         unsigned int rsv[4];          /* Reserved for future use. */
69 };
70
71 #define PTP_MAX_SAMPLES 25 /* Maximum allowed offset measurement samples. */
72
73 struct ptp_sys_offset {
74         unsigned int n_samples; /* Desired number of measurements. */
75         unsigned int rsv[3];    /* Reserved for future use. */
76         /*
77          * Array of interleaved system/phc time stamps. The kernel
78          * will provide 2*n_samples + 1 time stamps, with the last
79          * one as a system time stamp.
80          */
81         struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
82 };
83
84 #define PTP_CLK_MAGIC '='
85
86 #define PTP_CLOCK_GETCAPS  _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps)
87 #define PTP_EXTTS_REQUEST  _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request)
88 #define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request)
89 #define PTP_ENABLE_PPS     _IOW(PTP_CLK_MAGIC, 4, int)
90 #define PTP_SYS_OFFSET     _IOW(PTP_CLK_MAGIC, 5, struct ptp_sys_offset)
91
92 struct ptp_extts_event {
93         struct ptp_clock_time t; /* Time event occurred. */
94         unsigned int index;      /* Which channel produced the event. */
95         unsigned int flags;      /* Reserved for future use. */
96         unsigned int rsv[2];     /* Reserved for future use. */
97 };
98
99 #endif