blob: cfe5c7214ec61f10e3ff5b011ec4ab2e677426e4 [file] [log] [blame]
Rodolfo Giomettieae9d2b2009-06-17 16:28:37 -07001/*
2 * PPS API header
3 *
4 * Copyright (C) 2005-2009 Rodolfo Giometti <giometti@linux.it>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21
22#ifndef _PPS_H_
23#define _PPS_H_
24
25#define PPS_VERSION "5.3.6"
26#define PPS_MAX_SOURCES 16 /* should be enough... */
27
28/* Implementation note: the logical states ``assert'' and ``clear''
29 * are implemented in terms of the chip register, i.e. ``assert''
30 * means the bit is set. */
31
32/*
33 * 3.2 New data structures
34 */
35
36#define PPS_API_VERS_1 1
37#define PPS_API_VERS PPS_API_VERS_1 /* we use API version 1 */
38#define PPS_MAX_NAME_LEN 32
39
40/* 32-bit vs. 64-bit compatibility.
41 *
42 * 0n i386, the alignment of a uint64_t is only 4 bytes, while on most other
43 * architectures it's 8 bytes. On i386, there will be no padding between the
44 * two consecutive 'struct pps_ktime' members of struct pps_kinfo and struct
45 * pps_kparams. But on most platforms there will be padding to ensure correct
46 * alignment.
47 *
48 * The simple fix is probably to add an explicit padding.
49 * [David Woodhouse]
50 */
51struct pps_ktime {
52 __s64 sec;
53 __s32 nsec;
54 __u32 flags;
55};
56#define PPS_TIME_INVALID (1<<0) /* used to specify timeout==NULL */
57
58struct pps_kinfo {
59 __u32 assert_sequence; /* seq. num. of assert event */
60 __u32 clear_sequence; /* seq. num. of clear event */
61 struct pps_ktime assert_tu; /* time of assert event */
62 struct pps_ktime clear_tu; /* time of clear event */
63 int current_mode; /* current mode bits */
64};
65
66struct pps_kparams {
67 int api_version; /* API version # */
68 int mode; /* mode bits */
69 struct pps_ktime assert_off_tu; /* offset compensation for assert */
70 struct pps_ktime clear_off_tu; /* offset compensation for clear */
71};
72
73/*
74 * 3.3 Mode bit definitions
75 */
76
77/* Device/implementation parameters */
78#define PPS_CAPTUREASSERT 0x01 /* capture assert events */
79#define PPS_CAPTURECLEAR 0x02 /* capture clear events */
80#define PPS_CAPTUREBOTH 0x03 /* capture assert and clear events */
81
82#define PPS_OFFSETASSERT 0x10 /* apply compensation for assert ev. */
83#define PPS_OFFSETCLEAR 0x20 /* apply compensation for clear ev. */
84
85#define PPS_CANWAIT 0x100 /* can we wait for an event? */
86#define PPS_CANPOLL 0x200 /* bit reserved for future use */
87
88/* Kernel actions */
89#define PPS_ECHOASSERT 0x40 /* feed back assert event to output */
90#define PPS_ECHOCLEAR 0x80 /* feed back clear event to output */
91
92/* Timestamp formats */
93#define PPS_TSFMT_TSPEC 0x1000 /* select timespec format */
94#define PPS_TSFMT_NTPFP 0x2000 /* select NTP format */
95
96/*
97 * 3.4.4 New functions: disciplining the kernel timebase
98 */
99
100/* Kernel consumers */
101#define PPS_KC_HARDPPS 0 /* hardpps() (or equivalent) */
102#define PPS_KC_HARDPPS_PLL 1 /* hardpps() constrained to
103 use a phase-locked loop */
104#define PPS_KC_HARDPPS_FLL 2 /* hardpps() constrained to
105 use a frequency-locked loop */
106/*
107 * Here begins the implementation-specific part!
108 */
109
110struct pps_fdata {
111 struct pps_kinfo info;
112 struct pps_ktime timeout;
113};
114
115#include <linux/ioctl.h>
116
117#define PPS_GETPARAMS _IOR('p', 0xa1, struct pps_kparams *)
118#define PPS_SETPARAMS _IOW('p', 0xa2, struct pps_kparams *)
119#define PPS_GETCAP _IOR('p', 0xa3, int *)
120#define PPS_FETCH _IOWR('p', 0xa4, struct pps_fdata *)
121
122#endif /* _PPS_H_ */