1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright (C) 2025 Intel Corporation 4 */ 5 #ifndef __iwl_mld_ptp_h__ 6 #define __iwl_mld_ptp_h__ 7 8 #include <linux/ptp_clock_kernel.h> 9 10 /** 11 * struct ptp_data - PTP hardware clock data 12 * 13 * @ptp_clock: struct ptp_clock pointer returned by the ptp_clock_register() 14 * function. 15 * @ptp_clock_info: struct ptp_clock_info that describes a PTP hardware clock 16 * @lock: protects the time adjustments data 17 * @delta: delta between hardware clock and ptp clock in nanoseconds 18 * @scale_update_gp2: GP2 time when the scale was last updated 19 * @scale_update_adj_time_ns: adjusted time when the scale was last updated, 20 * in nanoseconds 21 * @scaled_freq: clock frequency offset, scaled to 65536000000 22 * @last_gp2: the last GP2 reading from the hardware, used for tracking GP2 23 * wraparounds 24 * @wrap_counter: number of wraparounds since scale_update_adj_time_ns 25 * @dwork: worker scheduled every 1 hour to detect workarounds 26 */ 27 struct ptp_data { 28 struct ptp_clock *ptp_clock; 29 struct ptp_clock_info ptp_clock_info; 30 31 spinlock_t lock; 32 s64 delta; 33 u32 scale_update_gp2; 34 u64 scale_update_adj_time_ns; 35 u64 scaled_freq; 36 u32 last_gp2; 37 u32 wrap_counter; 38 struct delayed_work dwork; 39 }; 40 41 void iwl_mld_ptp_init(struct iwl_mld *mld); 42 void iwl_mld_ptp_remove(struct iwl_mld *mld); 43 u64 iwl_mld_ptp_get_adj_time(struct iwl_mld *mld, u64 base_time_ns); 44 45 #endif /* __iwl_mld_ptp_h__ */ 46