diff options
Diffstat (limited to 'include/linux/pps_kernel.h')
-rw-r--r-- | include/linux/pps_kernel.h | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h index e0a193f830e..94048547f29 100644 --- a/include/linux/pps_kernel.h +++ b/include/linux/pps_kernel.h | |||
@@ -18,6 +18,9 @@ | |||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef LINUX_PPS_KERNEL_H | ||
22 | #define LINUX_PPS_KERNEL_H | ||
23 | |||
21 | #include <linux/pps.h> | 24 | #include <linux/pps.h> |
22 | 25 | ||
23 | #include <linux/cdev.h> | 26 | #include <linux/cdev.h> |
@@ -28,18 +31,28 @@ | |||
28 | * Global defines | 31 | * Global defines |
29 | */ | 32 | */ |
30 | 33 | ||
34 | struct pps_device; | ||
35 | |||
31 | /* The specific PPS source info */ | 36 | /* The specific PPS source info */ |
32 | struct pps_source_info { | 37 | struct pps_source_info { |
33 | char name[PPS_MAX_NAME_LEN]; /* simbolic name */ | 38 | char name[PPS_MAX_NAME_LEN]; /* simbolic name */ |
34 | char path[PPS_MAX_NAME_LEN]; /* path of connected device */ | 39 | char path[PPS_MAX_NAME_LEN]; /* path of connected device */ |
35 | int mode; /* PPS's allowed mode */ | 40 | int mode; /* PPS's allowed mode */ |
36 | 41 | ||
37 | void (*echo)(int source, int event, void *data); /* PPS echo function */ | 42 | void (*echo)(struct pps_device *pps, |
43 | int event, void *data); /* PPS echo function */ | ||
38 | 44 | ||
39 | struct module *owner; | 45 | struct module *owner; |
40 | struct device *dev; | 46 | struct device *dev; |
41 | }; | 47 | }; |
42 | 48 | ||
49 | struct pps_event_time { | ||
50 | #ifdef CONFIG_NTP_PPS | ||
51 | struct timespec ts_raw; | ||
52 | #endif /* CONFIG_NTP_PPS */ | ||
53 | struct timespec ts_real; | ||
54 | }; | ||
55 | |||
43 | /* The main struct */ | 56 | /* The main struct */ |
44 | struct pps_device { | 57 | struct pps_device { |
45 | struct pps_source_info info; /* PSS source info */ | 58 | struct pps_source_info info; /* PSS source info */ |
@@ -52,38 +65,56 @@ struct pps_device { | |||
52 | struct pps_ktime clear_tu; | 65 | struct pps_ktime clear_tu; |
53 | int current_mode; /* PPS mode at event time */ | 66 | int current_mode; /* PPS mode at event time */ |
54 | 67 | ||
55 | int go; /* PPS event is arrived? */ | 68 | unsigned int last_ev; /* last PPS event id */ |
56 | wait_queue_head_t queue; /* PPS event queue */ | 69 | wait_queue_head_t queue; /* PPS event queue */ |
57 | 70 | ||
58 | unsigned int id; /* PPS source unique ID */ | 71 | unsigned int id; /* PPS source unique ID */ |
59 | struct cdev cdev; | 72 | struct cdev cdev; |
60 | struct device *dev; | 73 | struct device *dev; |
61 | int devno; | ||
62 | struct fasync_struct *async_queue; /* fasync method */ | 74 | struct fasync_struct *async_queue; /* fasync method */ |
63 | spinlock_t lock; | 75 | spinlock_t lock; |
64 | |||
65 | atomic_t usage; /* usage count */ | ||
66 | }; | 76 | }; |
67 | 77 | ||
68 | /* | 78 | /* |
69 | * Global variables | 79 | * Global variables |
70 | */ | 80 | */ |
71 | 81 | ||
72 | extern spinlock_t pps_idr_lock; | ||
73 | extern struct idr pps_idr; | ||
74 | extern struct timespec pps_irq_ts[]; | ||
75 | |||
76 | extern struct device_attribute pps_attrs[]; | 82 | extern struct device_attribute pps_attrs[]; |
77 | 83 | ||
78 | /* | 84 | /* |
79 | * Exported functions | 85 | * Exported functions |
80 | */ | 86 | */ |
81 | 87 | ||
82 | struct pps_device *pps_get_source(int source); | 88 | extern struct pps_device *pps_register_source( |
83 | extern void pps_put_source(struct pps_device *pps); | 89 | struct pps_source_info *info, int default_params); |
84 | extern int pps_register_source(struct pps_source_info *info, | 90 | extern void pps_unregister_source(struct pps_device *pps); |
85 | int default_params); | ||
86 | extern void pps_unregister_source(int source); | ||
87 | extern int pps_register_cdev(struct pps_device *pps); | 91 | extern int pps_register_cdev(struct pps_device *pps); |
88 | extern void pps_unregister_cdev(struct pps_device *pps); | 92 | extern void pps_unregister_cdev(struct pps_device *pps); |
89 | extern void pps_event(int source, struct pps_ktime *ts, int event, void *data); | 93 | extern void pps_event(struct pps_device *pps, |
94 | struct pps_event_time *ts, int event, void *data); | ||
95 | |||
96 | static inline void timespec_to_pps_ktime(struct pps_ktime *kt, | ||
97 | struct timespec ts) | ||
98 | { | ||
99 | kt->sec = ts.tv_sec; | ||
100 | kt->nsec = ts.tv_nsec; | ||
101 | } | ||
102 | |||
103 | #ifdef CONFIG_NTP_PPS | ||
104 | |||
105 | static inline void pps_get_ts(struct pps_event_time *ts) | ||
106 | { | ||
107 | getnstime_raw_and_real(&ts->ts_raw, &ts->ts_real); | ||
108 | } | ||
109 | |||
110 | #else /* CONFIG_NTP_PPS */ | ||
111 | |||
112 | static inline void pps_get_ts(struct pps_event_time *ts) | ||
113 | { | ||
114 | getnstimeofday(&ts->ts_real); | ||
115 | } | ||
116 | |||
117 | #endif /* CONFIG_NTP_PPS */ | ||
118 | |||
119 | #endif /* LINUX_PPS_KERNEL_H */ | ||
120 | |||