aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pps_kernel.h
diff options
context:
space:
mode:
authorRodolfo Giometti <giometti@linux.it>2009-06-17 19:28:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-18 16:04:04 -0400
commiteae9d2ba0cfc27a2ad9765f23efb98fb80d80234 (patch)
treef4be40ca528b2f23f97fa9cb6ebe91b8d6696d5b /include/linux/pps_kernel.h
parent8820f27ad9a5ad2a62cdcdf425d7921c31831800 (diff)
LinuxPPS: core support
This patch adds the kernel side of the PPS support currently named "LinuxPPS". PPS means "pulse per second" and a PPS source is just a device which provides a high precision signal each second so that an application can use it to adjust system clock time. Common use is the combination of the NTPD as userland program with a GPS receiver as PPS source to obtain a wallclock-time with sub-millisecond synchronisation to UTC. To obtain this goal the userland programs shoud use the PPS API specification (RFC 2783 - Pulse-Per-Second API for UNIX-like Operating Systems, Version 1.0) which in part is implemented by this patch. It provides a set of chars devices, one per PPS source, which can be used to get the time signal. The RFC's functions can be implemented by accessing to these char devices. Signed-off-by: Rodolfo Giometti <giometti@linux.it> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Greg KH <greg@kroah.com> Cc: Randy Dunlap <randy.dunlap@oracle.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Michael Kerrisk <mtk.manpages@googlemail.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/pps_kernel.h')
-rw-r--r--include/linux/pps_kernel.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h
new file mode 100644
index 000000000000..e0a193f830ef
--- /dev/null
+++ b/include/linux/pps_kernel.h
@@ -0,0 +1,89 @@
1/*
2 * PPS API kernel header
3 *
4 * Copyright (C) 2009 Rodolfo Giometti <giometti@linux.it>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <linux/pps.h>
22
23#include <linux/cdev.h>
24#include <linux/device.h>
25#include <linux/time.h>
26
27/*
28 * Global defines
29 */
30
31/* The specific PPS source info */
32struct pps_source_info {
33 char name[PPS_MAX_NAME_LEN]; /* simbolic name */
34 char path[PPS_MAX_NAME_LEN]; /* path of connected device */
35 int mode; /* PPS's allowed mode */
36
37 void (*echo)(int source, int event, void *data); /* PPS echo function */
38
39 struct module *owner;
40 struct device *dev;
41};
42
43/* The main struct */
44struct pps_device {
45 struct pps_source_info info; /* PSS source info */
46
47 struct pps_kparams params; /* PPS's current params */
48
49 __u32 assert_sequence; /* PPS' assert event seq # */
50 __u32 clear_sequence; /* PPS' clear event seq # */
51 struct pps_ktime assert_tu;
52 struct pps_ktime clear_tu;
53 int current_mode; /* PPS mode at event time */
54
55 int go; /* PPS event is arrived? */
56 wait_queue_head_t queue; /* PPS event queue */
57
58 unsigned int id; /* PPS source unique ID */
59 struct cdev cdev;
60 struct device *dev;
61 int devno;
62 struct fasync_struct *async_queue; /* fasync method */
63 spinlock_t lock;
64
65 atomic_t usage; /* usage count */
66};
67
68/*
69 * Global variables
70 */
71
72extern spinlock_t pps_idr_lock;
73extern struct idr pps_idr;
74extern struct timespec pps_irq_ts[];
75
76extern struct device_attribute pps_attrs[];
77
78/*
79 * Exported functions
80 */
81
82struct pps_device *pps_get_source(int source);
83extern void pps_put_source(struct pps_device *pps);
84extern int pps_register_source(struct pps_source_info *info,
85 int default_params);
86extern void pps_unregister_source(int source);
87extern int pps_register_cdev(struct pps_device *pps);
88extern void pps_unregister_cdev(struct pps_device *pps);
89extern void pps_event(int source, struct pps_ktime *ts, int event, void *data);