| 1 | |
| 2 | * PPS API header
|
| 3 | *
|
| 4 | * Copyright (C) 2005-2009 Rodolfo Giometti <[email protected]>
|
| 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 |
|
| 22 | #ifndef _PPS_H_
|
| 23 | #define _PPS_H_
|
| 24 |
|
| 25 | #include <linux/types.h>
|
| 26 |
|
| 27 | #define PPS_VERSION "5.3.6"
|
| 28 | #define PPS_MAX_SOURCES 16
|
| 29 |
|
| 30 | |
| 31 | * are implemented in terms of the chip register, i.e. ``assert''
|
| 32 | * means the bit is set.
|
| 33 |
|
| 34 | |
| 35 | * 3.2 New data structures
|
| 36 |
|
| 37 |
|
| 38 | #define PPS_API_VERS_1 1
|
| 39 | #define PPS_API_VERS PPS_API_VERS_1
|
| 40 | #define PPS_MAX_NAME_LEN 32
|
| 41 |
|
| 42 | |
| 43 | *
|
| 44 | * 0n i386, the alignment of a uint64_t is only 4 bytes, while on most other
|
| 45 | * architectures it's 8 bytes. On i386, there will be no padding between the
|
| 46 | * two consecutive 'struct pps_ktime' members of struct pps_kinfo and struct
|
| 47 | * pps_kparams. But on most platforms there will be padding to ensure correct
|
| 48 | * alignment.
|
| 49 | *
|
| 50 | * The simple fix is probably to add an explicit padding.
|
| 51 | * [David Woodhouse]
|
| 52 |
|
| 53 | struct pps_ktime {
|
| 54 | __s64 sec;
|
| 55 | __s32 nsec;
|
| 56 | __u32 flags;
|
| 57 | };
|
| 58 | #define PPS_TIME_INVALID (1<<0)
|
| 59 |
|
| 60 | struct pps_kinfo {
|
| 61 | __u32 assert_sequence;
|
| 62 | __u32 clear_sequence;
|
| 63 | struct pps_ktime assert_tu;
|
| 64 | struct pps_ktime clear_tu;
|
| 65 | int current_mode;
|
| 66 | };
|
| 67 |
|
| 68 | struct pps_kparams {
|
| 69 | int api_version;
|
| 70 | int mode;
|
| 71 | struct pps_ktime assert_off_tu;
|
| 72 | struct pps_ktime clear_off_tu;
|
| 73 | };
|
| 74 |
|
| 75 | |
| 76 | * 3.3 Mode bit definitions
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 | #define PPS_CAPTUREASSERT 0x01
|
| 81 | #define PPS_CAPTURECLEAR 0x02
|
| 82 | #define PPS_CAPTUREBOTH 0x03
|
| 83 |
|
| 84 | #define PPS_OFFSETASSERT 0x10
|
| 85 | #define PPS_OFFSETCLEAR 0x20
|
| 86 |
|
| 87 | #define PPS_CANWAIT 0x100
|
| 88 | #define PPS_CANPOLL 0x200
|
| 89 |
|
| 90 |
|
| 91 | #define PPS_ECHOASSERT 0x40
|
| 92 | #define PPS_ECHOCLEAR 0x80
|
| 93 |
|
| 94 |
|
| 95 | #define PPS_TSFMT_TSPEC 0x1000
|
| 96 | #define PPS_TSFMT_NTPFP 0x2000
|
| 97 |
|
| 98 | |
| 99 | * 3.4.4 New functions: disciplining the kernel timebase
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 | #define PPS_KC_HARDPPS 0
|
| 104 | #define PPS_KC_HARDPPS_PLL 1 |
| 105 | use a phase-locked loop
|
| 106 | #define PPS_KC_HARDPPS_FLL 2 |
| 107 | use a frequency-locked loop
|
| 108 | |
| 109 | * Here begins the implementation-specific part!
|
| 110 |
|
| 111 |
|
| 112 | struct pps_fdata {
|
| 113 | struct pps_kinfo info;
|
| 114 | struct pps_ktime timeout;
|
| 115 | };
|
| 116 |
|
| 117 | struct pps_bind_args {
|
| 118 | int tsformat;
|
| 119 | int edge;
|
| 120 | int consumer;
|
| 121 | };
|
| 122 |
|
| 123 | #include <linux/ioctl.h>
|
| 124 |
|
| 125 | #define PPS_GETPARAMS _IOR('p', 0xa1, struct pps_kparams *)
|
| 126 | #define PPS_SETPARAMS _IOW('p', 0xa2, struct pps_kparams *)
|
| 127 | #define PPS_GETCAP _IOR('p', 0xa3, int *)
|
| 128 | #define PPS_FETCH _IOWR('p', 0xa4, struct pps_fdata *)
|
| 129 | #define PPS_KC_BIND _IOW('p', 0xa5, struct pps_bind_args *)
|
| 130 |
|
| 131 | #endif
|