blob: 5014936c1bee91eb6bf26231c27b2eabb6cfe58e [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Ben Cheng655a7c02013-10-16 16:09:24 -07007#ifndef _PTP_CLOCK_H_
8#define _PTP_CLOCK_H_
9#include <linux/ioctl.h>
10#include <linux/types.h>
Tao Baod7db5942015-01-28 10:07:51 -080011#define PTP_ENABLE_FEATURE (1 << 0)
12#define PTP_RISING_EDGE (1 << 1)
13#define PTP_FALLING_EDGE (1 << 2)
Christopher Ferris9584fa42019-12-09 15:36:13 -080014#define PTP_STRICT_FLAGS (1 << 3)
Christopher Ferris7f4c8372024-06-03 14:22:19 -070015#define PTP_EXT_OFFSET (1 << 4)
Christopher Ferris9584fa42019-12-09 15:36:13 -080016#define PTP_EXTTS_EDGES (PTP_RISING_EDGE | PTP_FALLING_EDGE)
Christopher Ferris7f4c8372024-06-03 14:22:19 -070017#define PTP_EXTTS_VALID_FLAGS (PTP_ENABLE_FEATURE | PTP_RISING_EDGE | PTP_FALLING_EDGE | PTP_STRICT_FLAGS | PTP_EXT_OFFSET)
Christopher Ferris9584fa42019-12-09 15:36:13 -080018#define PTP_EXTTS_V1_VALID_FLAGS (PTP_ENABLE_FEATURE | PTP_RISING_EDGE | PTP_FALLING_EDGE)
Christopher Ferris7f4c8372024-06-03 14:22:19 -070019#define PTP_EXTTS_EVENT_VALID (PTP_ENABLE_FEATURE)
Christopher Ferris9584fa42019-12-09 15:36:13 -080020#define PTP_PEROUT_ONE_SHOT (1 << 0)
Christopher Ferris25c18d42020-10-14 17:42:58 -070021#define PTP_PEROUT_DUTY_CYCLE (1 << 1)
22#define PTP_PEROUT_PHASE (1 << 2)
23#define PTP_PEROUT_VALID_FLAGS (PTP_PEROUT_ONE_SHOT | PTP_PEROUT_DUTY_CYCLE | PTP_PEROUT_PHASE)
Christopher Ferris9584fa42019-12-09 15:36:13 -080024#define PTP_PEROUT_V1_VALID_FLAGS (0)
Ben Cheng655a7c02013-10-16 16:09:24 -070025struct ptp_clock_time {
Tao Baod7db5942015-01-28 10:07:51 -080026 __s64 sec;
27 __u32 nsec;
28 __u32 reserved;
Ben Cheng655a7c02013-10-16 16:09:24 -070029};
Ben Cheng655a7c02013-10-16 16:09:24 -070030struct ptp_clock_caps {
Tao Baod7db5942015-01-28 10:07:51 -080031 int max_adj;
32 int n_alarm;
33 int n_ext_ts;
Tao Baod7db5942015-01-28 10:07:51 -080034 int n_per_out;
35 int pps;
36 int n_pins;
Christopher Ferris106b3a82016-08-24 12:15:38 -070037 int cross_timestamping;
Christopher Ferris8177cdf2020-08-03 11:53:55 -070038 int adjust_phase;
Christopher Ferris8666d042023-09-06 14:55:31 -070039 int max_phase_adj;
40 int rsv[11];
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070041};
Ben Cheng655a7c02013-10-16 16:09:24 -070042struct ptp_extts_request {
Tao Baod7db5942015-01-28 10:07:51 -080043 unsigned int index;
Christopher Ferris106b3a82016-08-24 12:15:38 -070044 unsigned int flags;
Tao Baod7db5942015-01-28 10:07:51 -080045 unsigned int rsv[2];
Ben Cheng655a7c02013-10-16 16:09:24 -070046};
47struct ptp_perout_request {
Christopher Ferris25c18d42020-10-14 17:42:58 -070048 union {
49 struct ptp_clock_time start;
50 struct ptp_clock_time phase;
51 };
Tao Baod7db5942015-01-28 10:07:51 -080052 struct ptp_clock_time period;
53 unsigned int index;
54 unsigned int flags;
Christopher Ferris25c18d42020-10-14 17:42:58 -070055 union {
56 struct ptp_clock_time on;
57 unsigned int rsv[4];
58 };
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070059};
Ben Cheng655a7c02013-10-16 16:09:24 -070060#define PTP_MAX_SAMPLES 25
61struct ptp_sys_offset {
Christopher Ferris106b3a82016-08-24 12:15:38 -070062 unsigned int n_samples;
Tao Baod7db5942015-01-28 10:07:51 -080063 unsigned int rsv[3];
64 struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
Ben Cheng655a7c02013-10-16 16:09:24 -070065};
Christopher Ferrisd842e432019-03-07 10:21:59 -080066struct ptp_sys_offset_extended {
67 unsigned int n_samples;
68 unsigned int rsv[3];
69 struct ptp_clock_time ts[PTP_MAX_SAMPLES][3];
70};
Christopher Ferris106b3a82016-08-24 12:15:38 -070071struct ptp_sys_offset_precise {
72 struct ptp_clock_time device;
73 struct ptp_clock_time sys_realtime;
74 struct ptp_clock_time sys_monoraw;
Christopher Ferris106b3a82016-08-24 12:15:38 -070075 unsigned int rsv[4];
76};
77enum ptp_pin_function {
Tao Baod7db5942015-01-28 10:07:51 -080078 PTP_PF_NONE,
79 PTP_PF_EXTTS,
80 PTP_PF_PEROUT,
81 PTP_PF_PHYSYNC,
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070082};
83struct ptp_pin_desc {
Tao Baod7db5942015-01-28 10:07:51 -080084 char name[64];
85 unsigned int index;
Tao Baod7db5942015-01-28 10:07:51 -080086 unsigned int func;
87 unsigned int chan;
88 unsigned int rsv[5];
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070089};
Ben Cheng655a7c02013-10-16 16:09:24 -070090#define PTP_CLK_MAGIC '='
91#define PTP_CLOCK_GETCAPS _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps)
Ben Cheng655a7c02013-10-16 16:09:24 -070092#define PTP_EXTTS_REQUEST _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request)
93#define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request)
94#define PTP_ENABLE_PPS _IOW(PTP_CLK_MAGIC, 4, int)
95#define PTP_SYS_OFFSET _IOW(PTP_CLK_MAGIC, 5, struct ptp_sys_offset)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070096#define PTP_PIN_GETFUNC _IOWR(PTP_CLK_MAGIC, 6, struct ptp_pin_desc)
97#define PTP_PIN_SETFUNC _IOW(PTP_CLK_MAGIC, 7, struct ptp_pin_desc)
Christopher Ferris106b3a82016-08-24 12:15:38 -070098#define PTP_SYS_OFFSET_PRECISE _IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise)
Christopher Ferrisd842e432019-03-07 10:21:59 -080099#define PTP_SYS_OFFSET_EXTENDED _IOWR(PTP_CLK_MAGIC, 9, struct ptp_sys_offset_extended)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800100#define PTP_CLOCK_GETCAPS2 _IOR(PTP_CLK_MAGIC, 10, struct ptp_clock_caps)
101#define PTP_EXTTS_REQUEST2 _IOW(PTP_CLK_MAGIC, 11, struct ptp_extts_request)
102#define PTP_PEROUT_REQUEST2 _IOW(PTP_CLK_MAGIC, 12, struct ptp_perout_request)
103#define PTP_ENABLE_PPS2 _IOW(PTP_CLK_MAGIC, 13, int)
104#define PTP_SYS_OFFSET2 _IOW(PTP_CLK_MAGIC, 14, struct ptp_sys_offset)
105#define PTP_PIN_GETFUNC2 _IOWR(PTP_CLK_MAGIC, 15, struct ptp_pin_desc)
106#define PTP_PIN_SETFUNC2 _IOW(PTP_CLK_MAGIC, 16, struct ptp_pin_desc)
107#define PTP_SYS_OFFSET_PRECISE2 _IOWR(PTP_CLK_MAGIC, 17, struct ptp_sys_offset_precise)
108#define PTP_SYS_OFFSET_EXTENDED2 _IOWR(PTP_CLK_MAGIC, 18, struct ptp_sys_offset_extended)
Christopher Ferris0f795212024-01-17 14:17:28 -0800109#define PTP_MASK_CLEAR_ALL _IO(PTP_CLK_MAGIC, 19)
110#define PTP_MASK_EN_SINGLE _IOW(PTP_CLK_MAGIC, 20, unsigned int)
Ben Cheng655a7c02013-10-16 16:09:24 -0700111struct ptp_extts_event {
Tao Baod7db5942015-01-28 10:07:51 -0800112 struct ptp_clock_time t;
113 unsigned int index;
114 unsigned int flags;
Tao Baod7db5942015-01-28 10:07:51 -0800115 unsigned int rsv[2];
Ben Cheng655a7c02013-10-16 16:09:24 -0700116};
117#endif