ptp_clock.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * PTP 1588 clock support - user space interface
  3. *
  4. * Copyright (C) 2010 OMICRON electronics GmbH
  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. #ifndef _PTP_CLOCK_H_
  21. #define _PTP_CLOCK_H_
  22. #include <linux/ioctl.h>
  23. #include <linux/types.h>
  24. /* PTP_xxx bits, for the flags field within the request structures. */
  25. #define PTP_ENABLE_FEATURE (1<<0)
  26. #define PTP_RISING_EDGE (1<<1)
  27. #define PTP_FALLING_EDGE (1<<2)
  28. /*
  29. * struct ptp_clock_time - represents a time value
  30. *
  31. * The sign of the seconds field applies to the whole value. The
  32. * nanoseconds field is always unsigned. The reserved field is
  33. * included for sub-nanosecond resolution, should the demand for
  34. * this ever appear.
  35. *
  36. */
  37. struct ptp_clock_time {
  38. __s64 sec; /* seconds */
  39. __u32 nsec; /* nanoseconds */
  40. __u32 reserved;
  41. };
  42. struct ptp_clock_caps {
  43. int max_adj; /* Maximum frequency adjustment in parts per billon. */
  44. int n_alarm; /* Number of programmable alarms. */
  45. int n_ext_ts; /* Number of external time stamp channels. */
  46. int n_per_out; /* Number of programmable periodic signals. */
  47. int pps; /* Whether the clock supports a PPS callback. */
  48. int rsv[15]; /* Reserved for future use. */
  49. };
  50. struct ptp_extts_request {
  51. unsigned int index; /* Which channel to configure. */
  52. unsigned int flags; /* Bit field for PTP_xxx flags. */
  53. unsigned int rsv[2]; /* Reserved for future use. */
  54. };
  55. struct ptp_perout_request {
  56. struct ptp_clock_time start; /* Absolute start time. */
  57. struct ptp_clock_time period; /* Desired period, zero means disable. */
  58. unsigned int index; /* Which channel to configure. */
  59. unsigned int flags; /* Reserved for future use. */
  60. unsigned int rsv[4]; /* Reserved for future use. */
  61. };
  62. #define PTP_CLK_MAGIC '='
  63. #define PTP_CLOCK_GETCAPS _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps)
  64. #define PTP_EXTTS_REQUEST _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request)
  65. #define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request)
  66. #define PTP_ENABLE_PPS _IOW(PTP_CLK_MAGIC, 4, int)
  67. struct ptp_extts_event {
  68. struct ptp_clock_time t; /* Time event occured. */
  69. unsigned int index; /* Which channel produced the event. */
  70. unsigned int flags; /* Reserved for future use. */
  71. unsigned int rsv[2]; /* Reserved for future use. */
  72. };
  73. #endif