Lines Matching full:ptp
13 static bool is_tstmp_atomic_update_supported(struct otx2_ptp *ptp) in is_tstmp_atomic_update_supported() argument
19 if (!ptp->nic) in is_tstmp_atomic_update_supported()
22 mutex_lock(&ptp->nic->mbox.lock); in is_tstmp_atomic_update_supported()
23 req = otx2_mbox_alloc_msg_ptp_get_cap(&ptp->nic->mbox); in is_tstmp_atomic_update_supported()
25 mutex_unlock(&ptp->nic->mbox.lock); in is_tstmp_atomic_update_supported()
29 err = otx2_sync_mbox_msg(&ptp->nic->mbox); in is_tstmp_atomic_update_supported()
31 mutex_unlock(&ptp->nic->mbox.lock); in is_tstmp_atomic_update_supported()
34 rsp = (struct ptp_get_cap_rsp *)otx2_mbox_get_rsp(&ptp->nic->mbox.mbox, 0, in is_tstmp_atomic_update_supported()
36 mutex_unlock(&ptp->nic->mbox.lock); in is_tstmp_atomic_update_supported()
49 struct otx2_ptp *ptp = container_of(ptp_info, struct otx2_ptp, in otx2_ptp_hw_adjtime() local
51 struct otx2_nic *pfvf = ptp->nic; in otx2_ptp_hw_adjtime()
55 if (!ptp->nic) in otx2_ptp_hw_adjtime()
59 req = otx2_mbox_alloc_msg_ptp_op(&ptp->nic->mbox); in otx2_ptp_hw_adjtime()
66 rc = otx2_sync_mbox_msg(&ptp->nic->mbox); in otx2_ptp_hw_adjtime()
72 static u64 otx2_ptp_get_clock(struct otx2_ptp *ptp) in otx2_ptp_get_clock() argument
78 if (!ptp->nic) in otx2_ptp_get_clock()
81 req = otx2_mbox_alloc_msg_ptp_op(&ptp->nic->mbox); in otx2_ptp_get_clock()
87 err = otx2_sync_mbox_msg(&ptp->nic->mbox); in otx2_ptp_get_clock()
91 rsp = (struct ptp_rsp *)otx2_mbox_get_rsp(&ptp->nic->mbox.mbox, 0, in otx2_ptp_get_clock()
102 struct otx2_ptp *ptp = container_of(ptp_info, struct otx2_ptp, in otx2_ptp_hw_gettime() local
106 tstamp = otx2_ptp_get_clock(ptp); in otx2_ptp_hw_gettime()
115 struct otx2_ptp *ptp = container_of(ptp_info, struct otx2_ptp, in otx2_ptp_hw_settime() local
117 struct otx2_nic *pfvf = ptp->nic; in otx2_ptp_hw_settime()
122 if (!ptp->nic) in otx2_ptp_hw_settime()
128 req = otx2_mbox_alloc_msg_ptp_op(&ptp->nic->mbox); in otx2_ptp_hw_settime()
136 rc = otx2_sync_mbox_msg(&ptp->nic->mbox); in otx2_ptp_hw_settime()
144 struct otx2_ptp *ptp = container_of(ptp_info, struct otx2_ptp, in otx2_ptp_adjfine() local
148 if (!ptp->nic) in otx2_ptp_adjfine()
151 req = otx2_mbox_alloc_msg_ptp_op(&ptp->nic->mbox); in otx2_ptp_adjfine()
158 return otx2_sync_mbox_msg(&ptp->nic->mbox); in otx2_ptp_adjfine()
161 static int ptp_set_thresh(struct otx2_ptp *ptp, u64 thresh) in ptp_set_thresh() argument
165 if (!ptp->nic) in ptp_set_thresh()
168 req = otx2_mbox_alloc_msg_ptp_op(&ptp->nic->mbox); in ptp_set_thresh()
175 return otx2_sync_mbox_msg(&ptp->nic->mbox); in ptp_set_thresh()
178 static int ptp_pps_on(struct otx2_ptp *ptp, int on, u64 period) in ptp_pps_on() argument
182 if (!ptp->nic) in ptp_pps_on()
185 req = otx2_mbox_alloc_msg_ptp_op(&ptp->nic->mbox); in ptp_pps_on()
193 return otx2_sync_mbox_msg(&ptp->nic->mbox); in ptp_pps_on()
198 struct otx2_ptp *ptp = container_of(cc, struct otx2_ptp, cycle_counter); in ptp_cc_read() local
200 return otx2_ptp_get_clock(ptp); in ptp_cc_read()
203 static u64 ptp_tstmp_read(struct otx2_ptp *ptp) in ptp_tstmp_read() argument
209 if (!ptp->nic) in ptp_tstmp_read()
212 req = otx2_mbox_alloc_msg_ptp_op(&ptp->nic->mbox); in ptp_tstmp_read()
218 err = otx2_sync_mbox_msg(&ptp->nic->mbox); in ptp_tstmp_read()
222 rsp = (struct ptp_rsp *)otx2_mbox_get_rsp(&ptp->nic->mbox.mbox, 0, in ptp_tstmp_read()
232 struct otx2_ptp *ptp = container_of(ptp_info, struct otx2_ptp, in otx2_ptp_tc_adjtime() local
234 struct otx2_nic *pfvf = ptp->nic; in otx2_ptp_tc_adjtime()
237 timecounter_adjtime(&ptp->time_counter, delta); in otx2_ptp_tc_adjtime()
246 struct otx2_ptp *ptp = container_of(ptp_info, struct otx2_ptp, in otx2_ptp_tc_gettime() local
250 mutex_lock(&ptp->nic->mbox.lock); in otx2_ptp_tc_gettime()
251 tstamp = timecounter_read(&ptp->time_counter); in otx2_ptp_tc_gettime()
252 mutex_unlock(&ptp->nic->mbox.lock); in otx2_ptp_tc_gettime()
261 struct otx2_ptp *ptp = container_of(ptp_info, struct otx2_ptp, in otx2_ptp_tc_settime() local
267 mutex_lock(&ptp->nic->mbox.lock); in otx2_ptp_tc_settime()
268 timecounter_init(&ptp->time_counter, &ptp->cycle_counter, nsec); in otx2_ptp_tc_settime()
269 mutex_unlock(&ptp->nic->mbox.lock); in otx2_ptp_tc_settime()
274 static int otx2_ptp_verify_pin(struct ptp_clock_info *ptp, unsigned int pin, in otx2_ptp_verify_pin() argument
296 struct otx2_ptp *ptp = container_of(work, struct otx2_ptp, in otx2_ptp_extts_check() local
301 mutex_lock(&ptp->nic->mbox.lock); in otx2_ptp_extts_check()
302 tstmp = ptp_tstmp_read(ptp); in otx2_ptp_extts_check()
303 mutex_unlock(&ptp->nic->mbox.lock); in otx2_ptp_extts_check()
305 if (tstmp != ptp->last_extts) { in otx2_ptp_extts_check()
308 event.timestamp = ptp->ptp_tstamp2nsec(&ptp->time_counter, tstmp); in otx2_ptp_extts_check()
309 ptp_clock_event(ptp->ptp_clock, &event); in otx2_ptp_extts_check()
311 if (ptp->thresh != new_thresh) { in otx2_ptp_extts_check()
312 mutex_lock(&ptp->nic->mbox.lock); in otx2_ptp_extts_check()
313 ptp_set_thresh(ptp, new_thresh); in otx2_ptp_extts_check()
314 mutex_unlock(&ptp->nic->mbox.lock); in otx2_ptp_extts_check()
315 ptp->thresh = new_thresh; in otx2_ptp_extts_check()
317 ptp->last_extts = tstmp; in otx2_ptp_extts_check()
319 schedule_delayed_work(&ptp->extts_work, msecs_to_jiffies(200)); in otx2_ptp_extts_check()
324 struct otx2_ptp *ptp = container_of(work, struct otx2_ptp, in otx2_sync_tstamp() local
326 struct otx2_nic *pfvf = ptp->nic; in otx2_sync_tstamp()
330 tstamp = otx2_ptp_get_clock(ptp); in otx2_sync_tstamp()
333 ptp->tstamp = ptp->ptp_tstamp2nsec(&ptp->time_counter, tstamp); in otx2_sync_tstamp()
334 ptp->base_ns = tstamp % NSEC_PER_SEC; in otx2_sync_tstamp()
336 schedule_delayed_work(&ptp->synctstamp_work, msecs_to_jiffies(250)); in otx2_sync_tstamp()
342 struct otx2_ptp *ptp = container_of(ptp_info, struct otx2_ptp, in otx2_ptp_enable() local
347 if (!ptp->nic) in otx2_ptp_enable()
352 pin = ptp_find_pin(ptp->ptp_clock, PTP_PF_EXTTS, in otx2_ptp_enable()
357 schedule_delayed_work(&ptp->extts_work, msecs_to_jiffies(200)); in otx2_ptp_enable()
359 cancel_delayed_work_sync(&ptp->extts_work); in otx2_ptp_enable()
371 ptp_pps_on(ptp, on, period); in otx2_ptp_enable()
373 ptp_pps_on(ptp, on, period); in otx2_ptp_enable()
390 pfvf->ptp = NULL; in otx2_ptp_init()
395 /* check if PTP block is available */ in otx2_ptp_init()
425 .name = "OcteonTX2 PTP", in otx2_ptp_init()
480 pfvf->ptp = ptp_ptr; in otx2_ptp_init()
489 struct otx2_ptp *ptp = pfvf->ptp; in otx2_ptp_destroy() local
491 if (!ptp) in otx2_ptp_destroy()
494 cancel_delayed_work(&pfvf->ptp->synctstamp_work); in otx2_ptp_destroy()
496 ptp_clock_unregister(ptp->ptp_clock); in otx2_ptp_destroy()
497 kfree(ptp); in otx2_ptp_destroy()
498 pfvf->ptp = NULL; in otx2_ptp_destroy()
504 if (!pfvf->ptp) in otx2_ptp_clock_index()
507 return ptp_clock_index(pfvf->ptp->ptp_clock); in otx2_ptp_clock_index()
513 if (!pfvf->ptp) in otx2_ptp_tstamp2time()
516 *tsns = pfvf->ptp->ptp_tstamp2nsec(&pfvf->ptp->time_counter, tstamp); in otx2_ptp_tstamp2time()
523 MODULE_DESCRIPTION("Marvell RVU NIC PTP Driver");