Lines Matching +full:clock +full:- +full:mult

14  *      - Redistributions of source code must retain the above
18 * - Redistributions in binary form must reproduce the above
39 /* mlx4_en_read_clock - read raw cycle counter (to be used by time counter)
45 struct mlx4_dev *dev = mdev->dev; in mlx4_en_read_clock()
47 return mlx4_read_clock(dev) & tc->mask; in mlx4_en_read_clock()
55 lo = (u64)be16_to_cpu(ts_cqe->timestamp_lo); in mlx4_en_get_cqe_ts()
56 hi = ((u64)be32_to_cpu(ts_cqe->timestamp_hi) + !lo) << 16; in mlx4_en_get_cqe_ts()
69 seq = read_seqbegin(&mdev->clock_lock); in mlx4_en_fill_hwtstamps()
70 nsec = timecounter_cyc2time(&mdev->clock, timestamp); in mlx4_en_fill_hwtstamps()
71 } while (read_seqretry(&mdev->clock_lock, seq)); in mlx4_en_fill_hwtstamps()
74 hwts->hwtstamp = ns_to_ktime(nsec); in mlx4_en_fill_hwtstamps()
78 * mlx4_en_remove_timestamp - disable PTP device
85 if (mdev->ptp_clock) { in mlx4_en_remove_timestamp()
86 ptp_clock_unregister(mdev->ptp_clock); in mlx4_en_remove_timestamp()
87 mdev->ptp_clock = NULL; in mlx4_en_remove_timestamp()
101 bool timeout = time_is_before_jiffies(mdev->last_overflow_check + in mlx4_en_ptp_overflow_check()
106 write_seqlock_irqsave(&mdev->clock_lock, flags); in mlx4_en_ptp_overflow_check()
107 timecounter_read(&mdev->clock); in mlx4_en_ptp_overflow_check()
108 write_sequnlock_irqrestore(&mdev->clock_lock, flags); in mlx4_en_ptp_overflow_check()
109 mdev->last_overflow_check = jiffies; in mlx4_en_ptp_overflow_check()
114 * mlx4_en_phc_adjfreq - adjust the frequency of the hardware clock
115 * @ptp: ptp clock structure
124 u32 diff, mult; in mlx4_en_phc_adjfreq() local
132 delta = -delta; in mlx4_en_phc_adjfreq()
134 mult = mdev->nominal_c_mult; in mlx4_en_phc_adjfreq()
135 adj = mult; in mlx4_en_phc_adjfreq()
139 write_seqlock_irqsave(&mdev->clock_lock, flags); in mlx4_en_phc_adjfreq()
140 timecounter_read(&mdev->clock); in mlx4_en_phc_adjfreq()
141 mdev->cycles.mult = neg_adj ? mult - diff : mult + diff; in mlx4_en_phc_adjfreq()
142 write_sequnlock_irqrestore(&mdev->clock_lock, flags); in mlx4_en_phc_adjfreq()
148 * mlx4_en_phc_adjtime - Shift the time of the hardware clock
149 * @ptp: ptp clock structure
160 write_seqlock_irqsave(&mdev->clock_lock, flags); in mlx4_en_phc_adjtime()
161 timecounter_adjtime(&mdev->clock, delta); in mlx4_en_phc_adjtime()
162 write_sequnlock_irqrestore(&mdev->clock_lock, flags); in mlx4_en_phc_adjtime()
168 * mlx4_en_phc_gettime - Reads the current time from the hardware clock
169 * @ptp: ptp clock structure
183 write_seqlock_irqsave(&mdev->clock_lock, flags); in mlx4_en_phc_gettime()
184 ns = timecounter_read(&mdev->clock); in mlx4_en_phc_gettime()
185 write_sequnlock_irqrestore(&mdev->clock_lock, flags); in mlx4_en_phc_gettime()
193 * mlx4_en_phc_settime - Set the current time on the hardware clock
194 * @ptp: ptp clock structure
209 write_seqlock_irqsave(&mdev->clock_lock, flags); in mlx4_en_phc_settime()
210 timecounter_init(&mdev->clock, &mdev->cycles, ns); in mlx4_en_phc_settime()
211 write_sequnlock_irqrestore(&mdev->clock_lock, flags); in mlx4_en_phc_settime()
217 * mlx4_en_phc_enable - enable or disable an ancillary feature
218 * @ptp: ptp clock structure
229 return -EOPNOTSUPP; in mlx4_en_phc_enable()
255 u64 max_val_cycles_rounded = 1ULL << fls64(max_val_cycles - 1); in freq_to_shift()
265 struct mlx4_dev *dev = mdev->dev; in mlx4_en_init_timestamp()
269 * mdev->ptp_clock is common for all ports, skip initialization if in mlx4_en_init_timestamp()
272 if (mdev->ptp_clock) in mlx4_en_init_timestamp()
275 seqlock_init(&mdev->clock_lock); in mlx4_en_init_timestamp()
277 memset(&mdev->cycles, 0, sizeof(mdev->cycles)); in mlx4_en_init_timestamp()
278 mdev->cycles.read = mlx4_en_read_clock; in mlx4_en_init_timestamp()
279 mdev->cycles.mask = CLOCKSOURCE_MASK(48); in mlx4_en_init_timestamp()
280 mdev->cycles.shift = freq_to_shift(dev->caps.hca_core_clock); in mlx4_en_init_timestamp()
281 mdev->cycles.mult = in mlx4_en_init_timestamp()
282 clocksource_khz2mult(1000 * dev->caps.hca_core_clock, mdev->cycles.shift); in mlx4_en_init_timestamp()
283 mdev->nominal_c_mult = mdev->cycles.mult; in mlx4_en_init_timestamp()
285 write_seqlock_irqsave(&mdev->clock_lock, flags); in mlx4_en_init_timestamp()
286 timecounter_init(&mdev->clock, &mdev->cycles, in mlx4_en_init_timestamp()
288 write_sequnlock_irqrestore(&mdev->clock_lock, flags); in mlx4_en_init_timestamp()
291 mdev->ptp_clock_info = mlx4_en_ptp_clock_info; in mlx4_en_init_timestamp()
292 snprintf(mdev->ptp_clock_info.name, 16, "mlx4 ptp"); in mlx4_en_init_timestamp()
294 mdev->ptp_clock = ptp_clock_register(&mdev->ptp_clock_info, in mlx4_en_init_timestamp()
295 &mdev->pdev->dev); in mlx4_en_init_timestamp()
296 if (IS_ERR(mdev->ptp_clock)) { in mlx4_en_init_timestamp()
297 mdev->ptp_clock = NULL; in mlx4_en_init_timestamp()
299 } else if (mdev->ptp_clock) { in mlx4_en_init_timestamp()
300 mlx4_info(mdev, "registered PHC clock\n"); in mlx4_en_init_timestamp()