30#ifndef _SYS_TIMEPPS_H_
31#define _SYS_TIMEPPS_H_
34#include <sys/ioccom.h>
39#define hardpps _Timecounter_Discipline
45#define PPS_API_VERS_1 1
47typedef int pps_handle_t;
50typedef unsigned pps_seq_t;
52typedef Atomic_Uint pps_seq_t;
56 unsigned int integral;
57 unsigned int fractional;
61 struct timespec tspec;
63 unsigned long longpad[3];
67 pps_seq_t assert_sequence;
68 pps_seq_t clear_sequence;
75 pps_seq_t assert_sequence;
76 pps_seq_t clear_sequence;
79 ffcounter assert_ffcount;
80 ffcounter clear_ffcount;
84#define assert_timestamp assert_tu.tspec
85#define clear_timestamp clear_tu.tspec
87#define assert_timestamp_ntpfp assert_tu.ntpfp
88#define clear_timestamp_ntpfp clear_tu.ntpfp
97#define assert_offset assert_off_tu.tspec
98#define clear_offset clear_off_tu.tspec
100#define assert_offset_ntpfp assert_off_tu.ntpfp
101#define clear_offset_ntpfp clear_off_tu.ntpfp
104#define PPS_CAPTUREASSERT 0x01
105#define PPS_CAPTURECLEAR 0x02
106#define PPS_CAPTUREBOTH 0x03
108#define PPS_OFFSETASSERT 0x10
109#define PPS_OFFSETCLEAR 0x20
111#define PPS_ECHOASSERT 0x40
112#define PPS_ECHOCLEAR 0x80
114#define PPS_CANWAIT 0x100
115#define PPS_CANPOLL 0x200
117#define PPS_TSFMT_TSPEC 0x1000
118#define PPS_TSFMT_NTPFP 0x2000
120#define PPS_TSCLK_FBCK 0x10000
121#define PPS_TSCLK_FFWD 0x20000
122#define PPS_TSCLK_MASK 0x30000
124#define PPS_KC_HARDPPS 0
125#define PPS_KC_HARDPPS_PLL 1
126#define PPS_KC_HARDPPS_FLL 2
131 struct timespec timeout;
137 struct timespec timeout;
146#define PPS_IOC_CREATE _IO('1', 1)
147#define PPS_IOC_DESTROY _IO('1', 2)
148#define PPS_IOC_SETPARAMS _IOW('1', 3, pps_params_t)
149#define PPS_IOC_GETPARAMS _IOR('1', 4, pps_params_t)
150#define PPS_IOC_GETCAP _IOR('1', 5, int)
151#define PPS_IOC_FETCH _IOWR('1', 6, struct pps_fetch_args)
152#define PPS_IOC_KCBIND _IOW('1', 7, struct pps_kcbind_args)
153#define PPS_IOC_FETCH_FFCOUNTER _IOWR('1', 8, struct pps_fetch_ffc_args)
159#define KCMODE_EDGEMASK 0x03
160#define KCMODE_ABIFLAG 0x80000000
162#define PPS_ABI_VERSION 1
164#define PPSFLAG_MTX_SPIN 0x01
169 struct fftimehands *capffth;
180 unsigned ppscount[3];
196 int (*wait)(
struct pps_state *pps,
struct timespec timeout);
203 void (*wakeup)(
struct pps_state *pps);
210 struct mtx *driver_mtx;
214void pps_capture(
struct pps_state *pps);
215void pps_event(
struct pps_state *pps,
int event);
216void pps_init(
struct pps_state *pps);
217void pps_init_abi(
struct pps_state *pps);
218int pps_ioctl(
unsigned long cmd, caddr_t data,
struct pps_state *pps);
219void hardpps(
struct timespec *tsp,
long nsec);
224time_pps_create(
int filedes, pps_handle_t *handle)
229 error = ioctl(filedes, PPS_IOC_CREATE, 0);
237time_pps_destroy(pps_handle_t handle)
239 return (ioctl(handle, PPS_IOC_DESTROY, 0));
243time_pps_setparams(pps_handle_t handle,
const pps_params_t *ppsparams)
245 return (ioctl(handle, PPS_IOC_SETPARAMS, ppsparams));
249time_pps_getparams(pps_handle_t handle,
pps_params_t *ppsparams)
251 return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams));
255time_pps_getcap(pps_handle_t handle,
int *mode)
257 return (ioctl(handle, PPS_IOC_GETCAP, mode));
261time_pps_fetch(pps_handle_t handle,
const int tsformat,
262 pps_info_t *ppsinfobuf,
const struct timespec *timeout)
267 arg.tsformat = tsformat;
268 if (timeout ==
NULL) {
269 arg.timeout.tv_sec = -1;
270 arg.timeout.tv_nsec = -1;
272 arg.timeout = *timeout;
273 error = ioctl(handle, PPS_IOC_FETCH, &arg);
274 *ppsinfobuf = arg.pps_info_buf;
279time_pps_fetch_ffc(pps_handle_t handle,
const int tsformat,
285 arg.tsformat = tsformat;
286 if (timeout ==
NULL) {
287 arg.timeout.tv_sec = -1;
288 arg.timeout.tv_nsec = -1;
290 arg.timeout = *timeout;
292 error = ioctl(handle, PPS_IOC_FETCH_FFCOUNTER, &arg);
293 *ppsinfobuf = arg.pps_info_buf_ffc;
298time_pps_kcbind(pps_handle_t handle,
const int kernel_consumer,
299 const int edge,
const int tsformat)
303 arg.kernel_consumer = kernel_consumer;
305 arg.tsformat = tsformat;
306 return (ioctl(handle, PPS_IOC_KCBIND, &arg));
This header file provides interfaces of the feed-forward clock counter.
#define NULL
Requests a GPIO pin group configuration.
Definition: xil_types.h:54
This header file provides the interfaces of the Atomic Operations.
Definition: timepps.h:128
Definition: timepps.h:134
Definition: timepps.h:140
Definition: kern_tc.c:197