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/mutex.h>
26#include <linux/posix-clock.h>
27#include <linux/ptp_clock.h>
28#include <linux/ptp_clock_kernel.h>
29#include <linux/time.h>
30
31#define PTP_MAX_TIMESTAMPS 128
32#define PTP_BUF_TIMESTAMPS 30
33
34struct timestamp_event_queue {
35 struct ptp_extts_event buf[PTP_MAX_TIMESTAMPS];
36 int head;
37 int tail;
38 spinlock_t lock;
39};
40
41struct ptp_clock {
42 struct posix_clock clock;
43 struct device *dev;
44 struct ptp_clock_info *info;
45 dev_t devid;
46 int index;
47 struct pps_device *pps_source;
48 long dialed_frequency;
49 struct timestamp_event_queue tsevq;
50 struct mutex tsevq_mux;
51 struct mutex pincfg_mux;
52 wait_queue_head_t tsev_wq;
53 int defunct;
54 struct device_attribute *pin_dev_attr;
55 struct attribute **pin_attr;
56 struct attribute_group pin_attr_group;
57};
58
59
60
61
62
63
64
65
66static inline int queue_cnt(struct timestamp_event_queue *q)
67{
68 int cnt = q->tail - q->head;
69 return cnt < 0 ? PTP_MAX_TIMESTAMPS + cnt : cnt;
70}
71
72
73
74
75
76
77int ptp_set_pinfunc(struct ptp_clock *ptp, unsigned int pin,
78 enum ptp_pin_function func, unsigned int chan);
79
80long ptp_ioctl(struct posix_clock *pc,
81 unsigned int cmd, unsigned long arg);
82
83int ptp_open(struct posix_clock *pc, fmode_t fmode);
84
85ssize_t ptp_read(struct posix_clock *pc,
86 uint flags, char __user *buf, size_t cnt);
87
88uint ptp_poll(struct posix_clock *pc,
89 struct file *fp, poll_table *wait);
90
91
92
93
94
95extern const struct attribute_group *ptp_groups[];
96
97int ptp_cleanup_sysfs(struct ptp_clock *ptp);
98
99int ptp_populate_sysfs(struct ptp_clock *ptp);
100
101#endif
102