ptp.txt 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. * PTP hardware clock infrastructure for Linux
  2. This patch set introduces support for IEEE 1588 PTP clocks in
  3. Linux. Together with the SO_TIMESTAMPING socket options, this
  4. presents a standardized method for developing PTP user space
  5. programs, synchronizing Linux with external clocks, and using the
  6. ancillary features of PTP hardware clocks.
  7. A new class driver exports a kernel interface for specific clock
  8. drivers and a user space interface. The infrastructure supports a
  9. complete set of PTP hardware clock functionality.
  10. + Basic clock operations
  11. - Set time
  12. - Get time
  13. - Shift the clock by a given offset atomically
  14. - Adjust clock frequency
  15. + Ancillary clock features
  16. - One short or periodic alarms, with signal delivery to user program
  17. - Time stamp external events
  18. - Period output signals configurable from user space
  19. - Synchronization of the Linux system time via the PPS subsystem
  20. ** PTP hardware clock kernel API
  21. A PTP clock driver registers itself with the class driver. The
  22. class driver handles all of the dealings with user space. The
  23. author of a clock driver need only implement the details of
  24. programming the clock hardware. The clock driver notifies the class
  25. driver of asynchronous events (alarms and external time stamps) via
  26. a simple message passing interface.
  27. The class driver supports multiple PTP clock drivers. In normal use
  28. cases, only one PTP clock is needed. However, for testing and
  29. development, it can be useful to have more than one clock in a
  30. single system, in order to allow performance comparisons.
  31. ** PTP hardware clock user space API
  32. The class driver also creates a character device for each
  33. registered clock. User space can use an open file descriptor from
  34. the character device as a POSIX clock id and may call
  35. clock_gettime, clock_settime, and clock_adjtime. These calls
  36. implement the basic clock operations.
  37. User space programs may control the clock using standardized
  38. ioctls. A program may query, enable, configure, and disable the
  39. ancillary clock features. User space can receive time stamped
  40. events via blocking read() and poll(). One shot and periodic
  41. signals may be configured via the POSIX timer_settime() system
  42. call.
  43. ** Writing clock drivers
  44. Clock drivers include include/linux/ptp_clock_kernel.h and register
  45. themselves by presenting a 'struct ptp_clock_info' to the
  46. registration method. Clock drivers must implement all of the
  47. functions in the interface. If a clock does not offer a particular
  48. ancillary feature, then the driver should just return -EOPNOTSUPP
  49. from those functions.
  50. Drivers must ensure that all of the methods in interface are
  51. reentrant. Since most hardware implementations treat the time value
  52. as a 64 bit integer accessed as two 32 bit registers, drivers
  53. should use spin_lock_irqsave/spin_unlock_irqrestore to protect
  54. against concurrent access. This locking cannot be accomplished in
  55. class driver, since the lock may also be needed by the clock
  56. driver's interrupt service routine.
  57. ** Supported hardware
  58. + Freescale eTSEC gianfar
  59. - 2 Time stamp external triggers, programmable polarity (opt. interrupt)
  60. - 2 Alarm registers (optional interrupt)
  61. - 3 Periodic signals (optional interrupt)
  62. + National DP83640
  63. - 6 GPIOs programmable as inputs or outputs
  64. - 6 GPIOs with dedicated functions (LED/JTAG/clock) can also be
  65. used as general inputs or outputs
  66. - GPIO inputs can time stamp external triggers
  67. - GPIO outputs can produce periodic signals
  68. - 1 interrupt pin
  69. + Intel IXP465
  70. - Auxiliary Slave/Master Mode Snapshot (optional interrupt)
  71. - Target Time (optional interrupt)