21#ifndef _SYS_TIMEPPS_H_
22#define _SYS_TIMEPPS_H_
24#include <sys/_ffcounter.h>
25#include <sys/ioccom.h>
28#define PPS_API_VERS_1 1
30typedef int pps_handle_t;
32typedef unsigned pps_seq_t;
35 unsigned int integral;
36 unsigned int fractional;
40 struct timespec tspec;
42 unsigned long longpad[3];
46 pps_seq_t assert_sequence;
47 pps_seq_t clear_sequence;
54 pps_seq_t assert_sequence;
55 pps_seq_t clear_sequence;
58 ffcounter assert_ffcount;
59 ffcounter clear_ffcount;
63#define assert_timestamp assert_tu.tspec
64#define clear_timestamp clear_tu.tspec
66#define assert_timestamp_ntpfp assert_tu.ntpfp
67#define clear_timestamp_ntpfp clear_tu.ntpfp
76#define assert_offset assert_off_tu.tspec
77#define clear_offset clear_off_tu.tspec
79#define assert_offset_ntpfp assert_off_tu.ntpfp
80#define clear_offset_ntpfp clear_off_tu.ntpfp
83#define PPS_CAPTUREASSERT 0x01
84#define PPS_CAPTURECLEAR 0x02
85#define PPS_CAPTUREBOTH 0x03
87#define PPS_OFFSETASSERT 0x10
88#define PPS_OFFSETCLEAR 0x20
90#define PPS_ECHOASSERT 0x40
91#define PPS_ECHOCLEAR 0x80
93#define PPS_CANWAIT 0x100
94#define PPS_CANPOLL 0x200
96#define PPS_TSFMT_TSPEC 0x1000
97#define PPS_TSFMT_NTPFP 0x2000
99#define PPS_TSCLK_FBCK 0x10000
100#define PPS_TSCLK_FFWD 0x20000
101#define PPS_TSCLK_MASK 0x30000
103#define PPS_KC_HARDPPS 0
104#define PPS_KC_HARDPPS_PLL 1
105#define PPS_KC_HARDPPS_FLL 2
110 struct timespec timeout;
116 struct timespec timeout;
125#define PPS_IOC_CREATE _IO('1', 1)
126#define PPS_IOC_DESTROY _IO('1', 2)
127#define PPS_IOC_SETPARAMS _IOW('1', 3, pps_params_t)
128#define PPS_IOC_GETPARAMS _IOR('1', 4, pps_params_t)
129#define PPS_IOC_GETCAP _IOR('1', 5, int)
130#define PPS_IOC_FETCH _IOWR('1', 6, struct pps_fetch_args)
131#define PPS_IOC_KCBIND _IOW('1', 7, struct pps_kcbind_args)
132#define PPS_IOC_FETCH_FFCOUNTER _IOWR('1', 8, struct pps_fetch_ffc_args)
138#define KCMODE_EDGEMASK 0x03
139#define KCMODE_ABIFLAG 0x80000000
141#define PPS_ABI_VERSION 1
143#define PPSFLAG_MTX_SPIN 0x01
148 struct fftimehands *capffth;
159 unsigned ppscount[3];
165 struct mtx *driver_mtx;
169void pps_capture(
struct pps_state *pps);
170void pps_event(
struct pps_state *pps,
int event);
171void pps_init(
struct pps_state *pps);
172void pps_init_abi(
struct pps_state *pps);
173int pps_ioctl(
unsigned long cmd, caddr_t data,
struct pps_state *pps);
174void hardpps(
struct timespec *tsp,
long nsec);
179time_pps_create(
int filedes, pps_handle_t *handle)
184 error = ioctl(filedes, PPS_IOC_CREATE, 0);
192time_pps_destroy(pps_handle_t handle)
194 return (ioctl(handle, PPS_IOC_DESTROY, 0));
198time_pps_setparams(pps_handle_t handle,
const pps_params_t *ppsparams)
200 return (ioctl(handle, PPS_IOC_SETPARAMS, ppsparams));
204time_pps_getparams(pps_handle_t handle,
pps_params_t *ppsparams)
206 return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams));
210time_pps_getcap(pps_handle_t handle,
int *mode)
212 return (ioctl(handle, PPS_IOC_GETCAP, mode));
216time_pps_fetch(pps_handle_t handle,
const int tsformat,
217 pps_info_t *ppsinfobuf,
const struct timespec *timeout)
222 arg.tsformat = tsformat;
223 if (timeout ==
NULL) {
224 arg.timeout.tv_sec = -1;
225 arg.timeout.tv_nsec = -1;
227 arg.timeout = *timeout;
228 error = ioctl(handle, PPS_IOC_FETCH, &arg);
229 *ppsinfobuf = arg.pps_info_buf;
234time_pps_fetch_ffc(pps_handle_t handle,
const int tsformat,
240 arg.tsformat = tsformat;
241 if (timeout ==
NULL) {
242 arg.timeout.tv_sec = -1;
243 arg.timeout.tv_nsec = -1;
245 arg.timeout = *timeout;
247 error = ioctl(handle, PPS_IOC_FETCH_FFCOUNTER, &arg);
248 *ppsinfobuf = arg.pps_info_buf_ffc;
253time_pps_kcbind(pps_handle_t handle,
const int kernel_consumer,
254 const int edge,
const int tsformat)
258 arg.kernel_consumer = kernel_consumer;
260 arg.tsformat = tsformat;
261 return (ioctl(handle, PPS_IOC_KCBIND, &arg));
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
Definition: if_fxpvar.h:78
Definition: timepps.h:107
Definition: timepps.h:113
Definition: timepps.h:119
Definition: kern_tc.c:165