Skip to content

Latest commit

 

History

History

README.md

Linux Time Card Driver

The Linux driver is based on the upstream kernel module for CentOS and Ubuntu. Kernel 5.12 or newer is recommended.

Build and install

Make sure VT-d is enabled in the BIOS. Build the module for the running kernel:

cd DRV/Linux
./remake

Install and load it with:

sudo ./remake install
sudo modprobe ptp_ocp

Run ./remake clean to remove kernel-module build output. KVER and KDIR can override the target kernel release and build directory.

Modern kernels (6.x and later)

ptp_ocp.c carries version guards so it builds from 5.x up to current kernels (verified against 7.0). The guarded APIs include the PTM cross-timestamp interface, timer APIs, const-qualified struct bin_attribute callbacks and groups, the device_find_child() match signature, and the embedded PPS device.

PTM (Precision Time Measurement)

With LitePCIe-with-PTM gateware (TimeCardPTM_V31 or later), the driver enables PCIe PTM at probe and implements getcrosststamp() through hardware PTM dialogs. This allows PTP_SYS_OFFSET_PRECISE to work and lets tools such as phc2sys and chrony use the hardware cross timestamp. The root port above the card must advertise the PTM Root capability.

Verify PTM after boot:

lspci -vvv -s <card> | grep -A3 "Precision Time"
dmesg | grep "PTM enabled"

Flashing note (spi-xilinx)

Updating gateware with devlink dev flash on modern kernels requires 0002-spi-xilinx-Inhibit-transmitter-modern-kernels.patch. It is a current rebase of the original spi-xilinx patch. Install the patched spi-xilinx.ko under /lib/modules/$(uname -r)/updates/ before flashing.

Exposed resources

The main resource directory is /sys/class/timecard/ocpN. It provides links to the Time Card PHC and serial devices, along with configuration attributes for clock sources, SMA routing, cable delays, UTC/TAI offset, and board status.

Device links can be used directly in scripts:

tty=$(basename "$(readlink /sys/class/timecard/ocp0/ttyGNSS)")
ptp=$(basename "$(readlink /sys/class/timecard/ocp0/ptp)")

echo "/dev/$tty"
echo "/dev/$ptp"

After the driver loads, the card exposes:

  • a PTP POSIX hardware clock (/dev/ptpN)
  • GNSS serial (ttyGNSS)
  • atomic clock serial (ttyMAC)
  • NMEA output serial (ttyNMEA)
  • an I2C controller (/dev/i2c-*)

Standard linuxptp tools such as phc2sys, ptp4l, and ts2phc can use the PHC.

Upstream kernel support