1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef _PTP_PRIVATE_H_
21#define _PTP_PRIVATE_H_
22
23#include <linux/cdev.h>
24#include <linux/device.h>
25#include <linux/kthread.h>
26#include <linux/mutex.h>
27#include <linux/posix-clock.h>
28#include <linux/ptp_clock.h>
29#include <linux/ptp_clock_kernel.h>
30#include <linux/time.h>
31
32#define PTP_MAX_TIMESTAMPS 128
33#define PTP_BUF_TIMESTAMPS 30
34
35struct timestamp_event_queue {
36 struct ptp_extts_event buf[PTP_MAX_TIMESTAMPS];
37 int head;
38 int tail;
39 spinlock_t lock;
40};
41
42struct ptp_clock {
43 struct posix_clock clock;
44 struct device *dev;
45 struct ptp_clock_info *info;
46 dev_t devid;
47 int index;
48 struct pps_device *pps_source;
49 long dialed_frequency;
50 struct timestamp_event_queue tsevq;
51 struct mutex tsevq_mux;
52 struct mutex pincfg_mux;
53 wait_queue_head_t tsev_wq;
54 int defunct;
55 struct device_attribute *pin_dev_attr;
56 struct attribute **pin_attr;
57 struct attribute_group pin_attr_group;
58
59 const struct attribute_group *pin_attr_groups[2];
60 struct kthread_worker *kworker;
61 struct kthread_delayed_work aux_work;
62};
63
64
65
66
67
68
69
70
71static inline int queue_cnt(struct timestamp_event_queue *q)
72{
73 int cnt = q->tail - q->head;
74 return cnt < 0 ? PTP_MAX_TIMESTAMPS + cnt : cnt;
75}
76
77
78
79
80
81
82int ptp_set_pinfunc(struct ptp_clock *ptp, unsigned int pin,
83 enum ptp_pin_function func, unsigned int chan);
84
85long ptp_ioctl(struct posix_clock *pc,
86 unsigned int cmd, unsigned long arg);
87
88int ptp_open(struct posix_clock *pc, fmode_t fmode);
89
90ssize_t ptp_read(struct posix_clock *pc,
91 uint flags, char __user *buf, size_t cnt);
92
93__poll_t ptp_poll(struct posix_clock *pc,
94 struct file *fp, poll_table *wait);
95
96
97
98
99
100extern const struct attribute_group *ptp_groups[];
101
102int ptp_populate_pin_groups(struct ptp_clock *ptp);
103void ptp_cleanup_pin_groups(struct ptp_clock *ptp);
104
105#endif
106