STRUCT PTP_CLOCK_INFO(9)
π struct ptp_clock_info(9) β Kernel API Manual, bestie edition π
okay so grab a snack because we're diving into <hotpink>struct ptp_clock_info</hotpink>, straight out of the Kernel API Manual section 9, and honestly? it's giving the blueprint of a PTP hardware clock. iykyk β¨
πΈ NAME πΈ
struct ptp_clock_info β literally just describes a PTP hardware clock, that's the whole vibe π°οΈπ
π¦ SYNOPSIS π¦
struct ptp_clock_info {
struct module *owner;
char name[PTP_CLOCK_NAME_LEN];
s32 max_adj;
int n_alarm;
int n_ext_ts;
int n_per_out;
int n_pins;
int n_per_lp;
int pps;
unsigned int supported_perout_flags;
unsigned int supported_extts_flags;
struct ptp_pin_desc *pin_config;
int (*adjfine)(struct ptp_clock_info *ptp, long scaled_ppm);
int (*adjphase)(struct ptp_clock_info *ptp, s32 phase);
s32 (*getmaxphase)(struct ptp_clock_info *ptp);
int (*adjtime)(struct ptp_clock_info *ptp, s64 delta);
int (*gettime64)(struct ptp_clock_info *ptp, struct timespec64 *ts);
int (*gettimex64)(struct ptp_clock_info *ptp, struct timespec64 *ts,
struct ptp_system_timestamp *sts);
int (*getcrosststamp)(struct ptp_clock_info *ptp, struct
system_device_crosststamp *cts);
int (*settime64)(struct ptp_clock_info *p, const struct timespec64
*ts);
int (*getcycles64)(struct ptp_clock_info *ptp, struct timespec64
*ts);
int (*getcyclesx64)(struct ptp_clock_info *ptp, struct timespec64
*ts, struct ptp_system_timestamp *sts);
int (*getcrosscycles)(struct ptp_clock_info *ptp, struct
system_device_crosststamp *cts);
int (*enable)(struct ptp_clock_info *ptp, struct ptp_clock_request
*request, int on);
int (*verify)(struct ptp_clock_info *ptp, unsigned int pin, enum
ptp_pin_function func, unsigned int chan);
long (*do_aux_work)(struct ptp_clock_info *ptp);
int (*perout_loopback)(struct ptp_clock_info *ptp, unsigned int
index, int on);
};
like, look at all those function pointers. main character energy fr fr π
π Members π
okay so here's the cast of characters, one by one:
ownerβ the clock driver should set this toTHIS_MODULE. that's it, that's the whole job π«Άnameβ a short "friendly name" to identify the clock and to help distinguish PHY based devices from MAC based ones. important: the string is not meant to be a unique id, so don't come for it for not being special πmax_adjβ the maximum possible frequency adjustment, in parts per billon.n_alarmβ the number of programmable alarms β°n_ext_tsβ the number of external time stamp channels.n_per_outβ the number of programmable periodic signals.n_pinsβ the number of programmable pins πn_per_lpβ the number of channels that support loopback the periodic output signal.ppsβ indicates whether the clock supports a PPS callback.supported_perout_flagsβ the set of flags the driver supports for thePTP_PEROUT_REQUESTioctl. the PTP core will reject a request with any flag not specified here π«supported_extts_flagsβ the set of flags the driver supports for thePTP_EXTTS_REQUESTioctl. the PTP core will use this list to reject unsupported requests.PTP_ENABLE_FEATUREis assumed and does not need to be included. IfPTP_STRICT_FLAGSis not set, then bothPTP_RISING_EDGEandPTP_FALLING_EDGEwill be assumed. Note thatPTP_STRICT_FLAGSmust be set if the drivers wants to honorPTP_EXTTS_REQUEST2and any future flags. lowkey the most detail-dense member and i respect it πpin_configβ array of length 'n_pins'. If the number of programmable pins is nonzero, then drivers must allocate and initialize this array. no skipping this step bestie β¨adjfineβ adjusts the frequency of the hardware clock. parameterscaled_ppm: Desired frequency offset from nominal frequency in parts per million, but with a 16 bit binary fractional field. fancy πadjphaseβ indicates that the PHC should use an internal servo algorithm to correct the provided phase offset. parameterdelta: PHC servo phase adjustment target in nanoseconds.getmaxphaseβ advertises maximum offset that can be provided to the hardware clock's phase control functionality throughadjphase.adjtimeβ shifts the time of the hardware clock. parameterdelta: Desired change in nanoseconds.gettime64β reads the current time from the hardware clock. this method is deprecated π¨ new drivers should implement thegettimex64method instead. parameterts: Holds the result.gettimex64β reads the current time from the hardware clock and optionally also the system clock. parameterts: Holds the PHC timestamp. parametersts: If notNULL, it holds a pair of timestamps from the system clock. The first reading is made right before reading the lowest bits of the PHC timestamp and the second reading immediately follows that. the timing of this is so precise it's honestly iconic πgetcrosststampβ reads the current time from the hardware clock and system clock simultaneously. parametercts: Contains timestamp (device,system) pair, where system time is realtime and monotonic.settime64β set the current time on the hardware clock. parameterts: Time value to set. (note the param here is namedp, notptpβ keep it exactly as-is π«‘)getcycles64β reads the current free running cycle counter from the hardware clock. Ifgetcycles64andgetcyclesx64are not supported, thengettime64orgettimex64will be used as default implementation. parameterts: Holds the result.getcyclesx64β reads the current free running cycle counter from the hardware clock and optionally also the system clock. Ifgetcycles64andgetcyclesx64are not supported, thengettimex64will be used as default implementation if available. parameterts: Holds the PHC timestamp. parametersts: If notNULL, it holds a pair of timestamps from the system clock. The first reading is made right before reading the lowest bits of the PHC timestamp and the second reading immediately follows that. same energy, cycle counter edition πgetcrosscyclesβ reads the current free running cycle counter from the hardware clock and system clock simultaneously. Ifgetcycles64andgetcyclesx64are not supported, thengetcrosststampwill be used as default implementation if available. parametercts: Contains timestamp (device,system) pair, where system time is realtime and monotonic.enableβ request driver to enable or disable an ancillary feature. parameterrequest: Desired resource to enable or disable. parameteron: Caller passes one to enable or zero to disable. simple, clean, slay π₯verifyβ confirm that a pin can perform a given function. The PTP Hardware Clock subsystem maintains the 'pin_config' array on behalf of the drivers, but the PHC subsystem assumes that every pin can perform every function. This hook gives drivers a way of telling the core about limitations on specific pins. This function must return zero if the function can be assigned to this pin, and nonzero otherwise. parameterpin: index of the pin in question. parameterfunc: the desired function to use. parameterchan: the function channel index to use. ngl this one's the vibe check for pins β¨do_aux_workβ request driver to perform auxiliary (periodic) operations. Driver should return delay of the next auxiliary work scheduling time (>=0) or negative value in case further scheduling is not required. negative = we're done here, bye πperout_loopbackβ request driver to enable or disable the periodic output signal loopback. parameterindex: index of the periodic output signal channel. parameteron: caller passes one to enable or zero to disable.
π Description π
clock operations β±οΈ that's the description. short king.
Drivers should embed their ptp_clock_info within a private structure, obtaining a reference to it using container_of. this is like, THE move, okay? π«Ά
The callbacks must all return zero on success, non-zero otherwise. all of them. no exceptions, no cap π―
β SEE ALSO β
go read these next, bestie, they're all linked up:
- Kernel file
./include/linux/ptp_clock_kernel.hstruct ptp_clock_request(9)struct ptp_system_timestamp(9)struct ptp_clock_event(9)scaled_ppm_to_ppb(9)diff_by_scaled_ppm(9)adjust_by_scaled_ppm(9)ptp_clock_register(9)ptp_clock_unregister(9)ptp_clock_event(9)ptp_clock_index(9)ptp_clock_index_by_of_node(9)ptp_clock_index_by_dev(9)ptp_find_pin(9)ptp_find_pin_unlocked(9)ptp_schedule_worker(9)ptp_cancel_worker_sync(9)ptp_get_vclocks_index(9)ptp_convert_timestamp(9)
π‘ friendly heads up:gettime64is deprecated β usegettimex64in new drivers, fr fr. and if you've got nonzeron_pins, you must allocate and initializepin_config.
and that's the page!! π huge thank you to the <cyan>./include/linux</cyan> crew, dated <peach>October 2026</peach>, for bringing us <rainbow>struct ptp_clock_info(9)</rainbow> β periodt, go write a clock driver ππ¦β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms