FreeBSD driver for the OCP TAP Time Card

From: John Hay <john_at_sanren.ac.za>
Date: Wed, 08 May 2024 04:27:47 UTC
Hi,

I have been working on a FreeBSD driver for the Open Compute Project (OCP)
Time Appliance Project (TAP) Time Card. The card consists of three main
parts, a clock module, a GNSS module and a FPGA module. The firmware for
the FPGA implements a counter that is synchronized to TAI using the GNSS
module and the clock module. The counter is implemented as two 32-bit
registers, seconds and nanoseconds, like struct timespec, and make that
available on the pci-e bus.

More about the Time Card is available at:
https://github.com/opencomputeproject/Time-Appliance-Project/tree/master/Time-Card

The driver / software consists of two main parts:

The kernel module timecard(4):
- Provides access to the card’s functionality,
- Implements a timecounter, “TimeCard”, using the timecounters(4) API,
- Make the PPS signal and timestamp available with the RFC 2783 Pulse Per
Second (PPS) API,
- Provides a timecard bus to which uart(4), iicbus(4) and spibus(4) drivers
can attach.

A daemon timecard(8):
- Provides a shm(28) driver for ntpd(8),
- Optionally synchronize the kernel time to the timecard(4) time,
- Discipline or train the clock on board of the TimeCard through the iic(4)
Clock interface.

With the above software and ntpd running and disciplining the kernel time,
the kernel time can stay within +-2ns according to ntpd. If neither ntpd
nor timecard(8) is set to discipline the kernel time, it will slowly drift
away because there is a small rounding error when converting from
timecounter nanoseconds read to bintime and then later to timespec. When
ntpd is set to discipline the kernel time and it has settled, ntpq’s
kerninfo command will report a pll frequency of 1.52588e-05 (ppm).

The card is Precision Time Protocol (PTP) capable, but the driver does not
support that.

The driver is available at:
https://github.com/JohnHay/TimeCard/

Regards

John