1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
29
30
31#define PTP_ENABLE_FEATURE (1<<0)
32#define PTP_RISING_EDGE (1<<1)
33#define PTP_FALLING_EDGE (1<<2)
34#define PTP_STRICT_FLAGS (1<<3)
35#define PTP_EXTTS_EDGES (PTP_RISING_EDGE | PTP_FALLING_EDGE)
36
37
38
39
40#define PTP_EXTTS_VALID_FLAGS (PTP_ENABLE_FEATURE | \
41 PTP_RISING_EDGE | \
42 PTP_FALLING_EDGE | \
43 PTP_STRICT_FLAGS)
44
45
46
47
48
49#define PTP_EXTTS_V1_VALID_FLAGS (PTP_ENABLE_FEATURE | \
50 PTP_RISING_EDGE | \
51 PTP_FALLING_EDGE)
52
53
54
55
56#define PTP_PEROUT_ONE_SHOT (1<<0)
57#define PTP_PEROUT_DUTY_CYCLE (1<<1)
58#define PTP_PEROUT_PHASE (1<<2)
59
60
61
62
63#define PTP_PEROUT_VALID_FLAGS (PTP_PEROUT_ONE_SHOT | \
64 PTP_PEROUT_DUTY_CYCLE | \
65 PTP_PEROUT_PHASE)
66
67
68
69
70#define PTP_PEROUT_V1_VALID_FLAGS (0)
71
72
73
74
75
76
77
78
79
80
81struct ptp_clock_time {
82 __s64 sec;
83 __u32 nsec;
84 __u32 reserved;
85};
86
87struct ptp_clock_caps {
88 int max_adj;
89 int n_alarm;
90 int n_ext_ts;
91 int n_per_out;
92 int pps;
93 int n_pins;
94
95 int cross_timestamping;
96
97 int adjust_phase;
98 int rsv[12];
99};
100
101struct ptp_extts_request {
102 unsigned int index;
103 unsigned int flags;
104 unsigned int rsv[2];
105};
106
107struct ptp_perout_request {
108 union {
109
110
111
112
113 struct ptp_clock_time start;
114
115
116
117
118
119
120 struct ptp_clock_time phase;
121 };
122 struct ptp_clock_time period;
123 unsigned int index;
124 unsigned int flags;
125 union {
126
127
128
129
130
131 struct ptp_clock_time on;
132
133 unsigned int rsv[4];
134 };
135};
136
137#define PTP_MAX_SAMPLES 25
138
139struct ptp_sys_offset {
140 unsigned int n_samples;
141 unsigned int rsv[3];
142
143
144
145
146
147 struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
148};
149
150struct ptp_sys_offset_extended {
151 unsigned int n_samples;
152 unsigned int rsv[3];
153
154
155
156
157 struct ptp_clock_time ts[PTP_MAX_SAMPLES][3];
158};
159
160struct ptp_sys_offset_precise {
161 struct ptp_clock_time device;
162 struct ptp_clock_time sys_realtime;
163 struct ptp_clock_time sys_monoraw;
164 unsigned int rsv[4];
165};
166
167enum ptp_pin_function {
168 PTP_PF_NONE,
169 PTP_PF_EXTTS,
170 PTP_PF_PEROUT,
171 PTP_PF_PHYSYNC,
172};
173
174struct ptp_pin_desc {
175
176
177
178
179
180 char name[64];
181
182
183
184 unsigned int index;
185
186
187
188 unsigned int func;
189
190
191
192
193
194 unsigned int chan;
195
196
197
198 unsigned int rsv[5];
199};
200
201#define PTP_CLK_MAGIC '='
202
203#define PTP_CLOCK_GETCAPS _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps)
204#define PTP_EXTTS_REQUEST _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request)
205#define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request)
206#define PTP_ENABLE_PPS _IOW(PTP_CLK_MAGIC, 4, int)
207#define PTP_SYS_OFFSET _IOW(PTP_CLK_MAGIC, 5, struct ptp_sys_offset)
208#define PTP_PIN_GETFUNC _IOWR(PTP_CLK_MAGIC, 6, struct ptp_pin_desc)
209#define PTP_PIN_SETFUNC _IOW(PTP_CLK_MAGIC, 7, struct ptp_pin_desc)
210#define PTP_SYS_OFFSET_PRECISE \
211 _IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise)
212#define PTP_SYS_OFFSET_EXTENDED \
213 _IOWR(PTP_CLK_MAGIC, 9, struct ptp_sys_offset_extended)
214
215#define PTP_CLOCK_GETCAPS2 _IOR(PTP_CLK_MAGIC, 10, struct ptp_clock_caps)
216#define PTP_EXTTS_REQUEST2 _IOW(PTP_CLK_MAGIC, 11, struct ptp_extts_request)
217#define PTP_PEROUT_REQUEST2 _IOW(PTP_CLK_MAGIC, 12, struct ptp_perout_request)
218#define PTP_ENABLE_PPS2 _IOW(PTP_CLK_MAGIC, 13, int)
219#define PTP_SYS_OFFSET2 _IOW(PTP_CLK_MAGIC, 14, struct ptp_sys_offset)
220#define PTP_PIN_GETFUNC2 _IOWR(PTP_CLK_MAGIC, 15, struct ptp_pin_desc)
221#define PTP_PIN_SETFUNC2 _IOW(PTP_CLK_MAGIC, 16, struct ptp_pin_desc)
222#define PTP_SYS_OFFSET_PRECISE2 \
223 _IOWR(PTP_CLK_MAGIC, 17, struct ptp_sys_offset_precise)
224#define PTP_SYS_OFFSET_EXTENDED2 \
225 _IOWR(PTP_CLK_MAGIC, 18, struct ptp_sys_offset_extended)
226
227struct ptp_extts_event {
228 struct ptp_clock_time t;
229 unsigned int index;
230 unsigned int flags;
231 unsigned int rsv[2];
232};
233
234#endif
235