1*607ca46eSDavid Howells /* 2*607ca46eSDavid Howells * PTP 1588 clock support - user space interface 3*607ca46eSDavid Howells * 4*607ca46eSDavid Howells * Copyright (C) 2010 OMICRON electronics GmbH 5*607ca46eSDavid Howells * 6*607ca46eSDavid Howells * This program is free software; you can redistribute it and/or modify 7*607ca46eSDavid Howells * it under the terms of the GNU General Public License as published by 8*607ca46eSDavid Howells * the Free Software Foundation; either version 2 of the License, or 9*607ca46eSDavid Howells * (at your option) any later version. 10*607ca46eSDavid Howells * 11*607ca46eSDavid Howells * This program is distributed in the hope that it will be useful, 12*607ca46eSDavid Howells * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*607ca46eSDavid Howells * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*607ca46eSDavid Howells * GNU General Public License for more details. 15*607ca46eSDavid Howells * 16*607ca46eSDavid Howells * You should have received a copy of the GNU General Public License 17*607ca46eSDavid Howells * along with this program; if not, write to the Free Software 18*607ca46eSDavid Howells * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19*607ca46eSDavid Howells */ 20*607ca46eSDavid Howells 21*607ca46eSDavid Howells #ifndef _PTP_CLOCK_H_ 22*607ca46eSDavid Howells #define _PTP_CLOCK_H_ 23*607ca46eSDavid Howells 24*607ca46eSDavid Howells #include <linux/ioctl.h> 25*607ca46eSDavid Howells #include <linux/types.h> 26*607ca46eSDavid Howells 27*607ca46eSDavid Howells /* PTP_xxx bits, for the flags field within the request structures. */ 28*607ca46eSDavid Howells #define PTP_ENABLE_FEATURE (1<<0) 29*607ca46eSDavid Howells #define PTP_RISING_EDGE (1<<1) 30*607ca46eSDavid Howells #define PTP_FALLING_EDGE (1<<2) 31*607ca46eSDavid Howells 32*607ca46eSDavid Howells /* 33*607ca46eSDavid Howells * struct ptp_clock_time - represents a time value 34*607ca46eSDavid Howells * 35*607ca46eSDavid Howells * The sign of the seconds field applies to the whole value. The 36*607ca46eSDavid Howells * nanoseconds field is always unsigned. The reserved field is 37*607ca46eSDavid Howells * included for sub-nanosecond resolution, should the demand for 38*607ca46eSDavid Howells * this ever appear. 39*607ca46eSDavid Howells * 40*607ca46eSDavid Howells */ 41*607ca46eSDavid Howells struct ptp_clock_time { 42*607ca46eSDavid Howells __s64 sec; /* seconds */ 43*607ca46eSDavid Howells __u32 nsec; /* nanoseconds */ 44*607ca46eSDavid Howells __u32 reserved; 45*607ca46eSDavid Howells }; 46*607ca46eSDavid Howells 47*607ca46eSDavid Howells struct ptp_clock_caps { 48*607ca46eSDavid Howells int max_adj; /* Maximum frequency adjustment in parts per billon. */ 49*607ca46eSDavid Howells int n_alarm; /* Number of programmable alarms. */ 50*607ca46eSDavid Howells int n_ext_ts; /* Number of external time stamp channels. */ 51*607ca46eSDavid Howells int n_per_out; /* Number of programmable periodic signals. */ 52*607ca46eSDavid Howells int pps; /* Whether the clock supports a PPS callback. */ 53*607ca46eSDavid Howells int rsv[15]; /* Reserved for future use. */ 54*607ca46eSDavid Howells }; 55*607ca46eSDavid Howells 56*607ca46eSDavid Howells struct ptp_extts_request { 57*607ca46eSDavid Howells unsigned int index; /* Which channel to configure. */ 58*607ca46eSDavid Howells unsigned int flags; /* Bit field for PTP_xxx flags. */ 59*607ca46eSDavid Howells unsigned int rsv[2]; /* Reserved for future use. */ 60*607ca46eSDavid Howells }; 61*607ca46eSDavid Howells 62*607ca46eSDavid Howells struct ptp_perout_request { 63*607ca46eSDavid Howells struct ptp_clock_time start; /* Absolute start time. */ 64*607ca46eSDavid Howells struct ptp_clock_time period; /* Desired period, zero means disable. */ 65*607ca46eSDavid Howells unsigned int index; /* Which channel to configure. */ 66*607ca46eSDavid Howells unsigned int flags; /* Reserved for future use. */ 67*607ca46eSDavid Howells unsigned int rsv[4]; /* Reserved for future use. */ 68*607ca46eSDavid Howells }; 69*607ca46eSDavid Howells 70*607ca46eSDavid Howells #define PTP_CLK_MAGIC '=' 71*607ca46eSDavid Howells 72*607ca46eSDavid Howells #define PTP_CLOCK_GETCAPS _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps) 73*607ca46eSDavid Howells #define PTP_EXTTS_REQUEST _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request) 74*607ca46eSDavid Howells #define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request) 75*607ca46eSDavid Howells #define PTP_ENABLE_PPS _IOW(PTP_CLK_MAGIC, 4, int) 76*607ca46eSDavid Howells 77*607ca46eSDavid Howells struct ptp_extts_event { 78*607ca46eSDavid Howells struct ptp_clock_time t; /* Time event occured. */ 79*607ca46eSDavid Howells unsigned int index; /* Which channel produced the event. */ 80*607ca46eSDavid Howells unsigned int flags; /* Reserved for future use. */ 81*607ca46eSDavid Howells unsigned int rsv[2]; /* Reserved for future use. */ 82*607ca46eSDavid Howells }; 83*607ca46eSDavid Howells 84*607ca46eSDavid Howells #endif 85