Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

/sys/class/ptp

FieldValue
SubsystemPTP (Precision Time Protocol) hardware clock core, drivers/ptp/ (obj-$(CONFIG_PTP_1588_CLOCK) += ptp.o, torvalds/linux master)
Config gateCONFIG_PTP_1588_CLOCK (obj line verified against torvalds/linux master 2026)
ABI documentationDocumentation/ABI/testing/sysfs-ptp (16 What entries; the file carries dates from September 2010 but no KernelVersion lines)
Sincenot stated as versions: entries dated September 2010 (core), March 2014 (n_pins, pins), May 2021 (n_vclocks, max_vclocks)
Live (5.10.134 host)class present with 1 device: ptp0 = “KVM virtual PTP” (values read live on the host; see Attributes)
Ledger IDSYSC-ptp

What it represents

One directory per PTP hardware clock (PHC), ptpN – NIC PHY/MAC clocks, SoC timers, virtual clocks. Sysfs advertises the clock’s capabilities: clock_name (human-readable “friendly name” to distinguish PHY-based from MAC-based devices, explicitly not required to be unique), max_adjustment (maximum frequency adjustment in parts per billion), and the channel counts n_alarms, n_external_timestamps, n_periodic_outputs, n_programmable_pins/n_pins. The timestamping and pin-routing control plane lives on /dev/ptpN ioctls (host header /usr/include/linux/ptp_clock.h: PTP_CLOCK_GETCAPS, PTP_PF_* function values that the sysfs pins documentation points to). The 2021 additions manage virtual clocks: writing n_vclocks creates that many vclocks and makes the physical clock free-running; max_vclocks caps the pool.

Relationship to the device model

/sys/class/ptp/ptpN is a class view over the clock’s parent device under /sys/devices/.... The live host instance is a virtual one: ptp0 -> ../../devices/virtual/ptp/ptp0, dev = 249:0, registered by the KVM ptp_kvm driver. PHCs feed PPS events into the PPS subsystem when enabled via pps_enable (per sysfs-ptp), and large multi-function appliances expose their own class beside this one: timecard links back to its PHC via its ptp symlink. Time-adjacent siblings: pps, rtc.

Attributes

AttributeR/WUnit/formatConditional?Source
ptpN/clock_nameROhuman-readable clock name stringalwaysABI testing sysfs-ptp (Sep 2010)
ptpN/max_adjustmentROpositive integer, parts per billionalwaysABI testing sysfs-ptp (Sep 2010)
ptpN/n_alarmsROnumber of periodic or one-shot alarmsalwaysABI testing sysfs-ptp (Sep 2010)
ptpN/n_external_timestampsROnumber of external timestamp channelsalwaysABI testing sysfs-ptp (Sep 2010)
ptpN/n_periodic_outputsROnumber of programmable periodic output channelsalwaysABI testing sysfs-ptp (Sep 2010)
ptpN/n_pinsROnumber of programmable pinsconditional: absent on host ptp0 (0 pins)ABI testing sysfs-ptp (Mar 2014)
ptpN/pins/<name>RWtwo integers: assigned function (PTP_PF_*, linux/ptp_clock.h) and channelper pinABI testing sysfs-ptp (Mar 2014)
ptpN/pps_availableRO1 if the clock can deliver PPS to the host CPU, else 0alwaysABI testing sysfs-ptp (Sep 2010)
ptpN/extts_enableWO“<channel index> 1” to enable, “… 0” to disable external timestampsalwaysABI testing sysfs-ptp (Sep 2010)
ptpN/fifoROexternal event timestamps: channel index, seconds, nanosecondsalwaysABI testing sysfs-ptp (Sep 2010)
ptpN/periodWOfive integers: channel, start sec/nsec, period sec/nsec; zeros disablealwaysABI testing sysfs-ptp (Sep 2010)
ptpN/pps_enableWO1/0: deliver PPS events to the Linux PPS subsystemalwaysABI testing sysfs-ptp (Sep 2010)
ptpN/n_vclocksRWvirtual clocks in use; 0 = physical clock adjustablealways (ABI entry dated May 2021)ABI testing sysfs-ptp (May 2021)
ptpN/max_vclocksRWmaximum number of ptp vclocks; write to reconfigurealways (ABI entry dated May 2021)ABI testing sysfs-ptp (May 2021)

Live cross-check on host ptp0 (5.10.134): clock_name = “KVM virtual PTP”, max_adjustment/n_alarms/n_external_timestamps/n_periodic_outputs/ n_programmable_pins/pps_available all read 0, dev = 249:0 – the zero-pin clock omits n_pins/pins, exactly the conditional behavior the ABI describes.

Safety and writes

The write-only controls (extts_enable, period, pps_enable) program hardware event plumbing; pins and the vclock pair reconfigure clock routing and clock topology (creating vclocks makes the physical clock free-running, which changes what time synchronization daemons see). The ABI states no capability requirements; in practice writes need root. Reads are safe.

References

  • Documentation/ABI/testing/sysfs-ptp (cached copy; online: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-ptp)
  • /usr/include/linux/ptp_clock.h (host header: PTP_CLOCK_GETCAPS, PTP_PF_*)
  • drivers/ptp/Makefile (torvalds/linux master; fetched obj line)
  • Live values: /sys/class/ptp/ptp0/* read directly on the 5.10.134 host
  • Ledger row SYSC-ptp; live enumeration per source-cache/live-sys/class-list.txt
  • Sibling pages: pps, rtc, timecard