ptp.txt 3.5 KB

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