1655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng/****************************************************************************
2655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ****************************************************************************
3655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***
4655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   This header was automatically generated from a Linux kernel header
5655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   of the same name, to make information necessary for userspace to
6655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   call into the kernel available to libc.  It contains only constants,
7655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   structures, and macros generated from the original header, and thus,
8655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   contains no copyrightable information.
9655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***
10655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   To edit the content of this header, modify the corresponding
11655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   source file (e.g. under external/kernel-headers/original/) then
12655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   run bionic/libc/kernel/tools/update_all.py
13655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***
14655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   Any manual change here will be lost the next time this script will
15655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***   be run. You've been warned!
16655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ***
17655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ****************************************************************************
18655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng ****************************************************************************/
19655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#ifndef _PTP_CLOCK_H_
20655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#define _PTP_CLOCK_H_
21655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#include <linux/ioctl.h>
22655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#include <linux/types.h>
23d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao#define PTP_ENABLE_FEATURE (1 << 0)
24d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao#define PTP_RISING_EDGE (1 << 1)
25d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao#define PTP_FALLING_EDGE (1 << 2)
26655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Chengstruct ptp_clock_time {
27d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __s64 sec;
28d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u32 nsec;
29d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u32 reserved;
30655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng};
31655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Chengstruct ptp_clock_caps {
32d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  int max_adj;
33d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  int n_alarm;
34d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  int n_ext_ts;
35d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  int n_per_out;
36d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  int pps;
37d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  int n_pins;
38106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  int cross_timestamping;
39106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  int rsv[13];
40ba8d4f460b51161eb82cf1006cb34a3cc1389f47Christopher Ferris};
41655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Chengstruct ptp_extts_request {
42d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int index;
43106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  unsigned int flags;
44d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int rsv[2];
45655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng};
46655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Chengstruct ptp_perout_request {
47106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  struct ptp_clock_time start;
48d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  struct ptp_clock_time period;
49d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int index;
50d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int flags;
51106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  unsigned int rsv[4];
52ba8d4f460b51161eb82cf1006cb34a3cc1389f47Christopher Ferris};
53655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#define PTP_MAX_SAMPLES 25
54655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Chengstruct ptp_sys_offset {
55106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  unsigned int n_samples;
56d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int rsv[3];
57d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
58655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng};
59106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferrisstruct ptp_sys_offset_precise {
60106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  struct ptp_clock_time device;
61106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  struct ptp_clock_time sys_realtime;
62106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  struct ptp_clock_time sys_monoraw;
63106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris  unsigned int rsv[4];
64106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris};
65106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferrisenum ptp_pin_function {
66d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  PTP_PF_NONE,
67d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  PTP_PF_EXTTS,
68d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  PTP_PF_PEROUT,
69d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  PTP_PF_PHYSYNC,
70ba8d4f460b51161eb82cf1006cb34a3cc1389f47Christopher Ferris};
71ba8d4f460b51161eb82cf1006cb34a3cc1389f47Christopher Ferrisstruct ptp_pin_desc {
72d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  char name[64];
73d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int index;
74d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int func;
75d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int chan;
76d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int rsv[5];
77ba8d4f460b51161eb82cf1006cb34a3cc1389f47Christopher Ferris};
78655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#define PTP_CLK_MAGIC '='
79655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#define PTP_CLOCK_GETCAPS _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps)
80655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#define PTP_EXTTS_REQUEST _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request)
81655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request)
82655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#define PTP_ENABLE_PPS _IOW(PTP_CLK_MAGIC, 4, int)
83655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#define PTP_SYS_OFFSET _IOW(PTP_CLK_MAGIC, 5, struct ptp_sys_offset)
84ba8d4f460b51161eb82cf1006cb34a3cc1389f47Christopher Ferris#define PTP_PIN_GETFUNC _IOWR(PTP_CLK_MAGIC, 6, struct ptp_pin_desc)
85ba8d4f460b51161eb82cf1006cb34a3cc1389f47Christopher Ferris#define PTP_PIN_SETFUNC _IOW(PTP_CLK_MAGIC, 7, struct ptp_pin_desc)
86106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define PTP_SYS_OFFSET_PRECISE _IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise)
87655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Chengstruct ptp_extts_event {
88d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  struct ptp_clock_time t;
89d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int index;
90d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int flags;
91d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  unsigned int rsv[2];
92655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng};
93655a7c081f83b8351ed5f11a6c6accd9458293a8Ben Cheng#endif
94