Lines Matching refs:ptp
79 struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); in ptp_clock_settime() local
81 if (ptp_clock_freerun(ptp)) { in ptp_clock_settime()
86 return ptp->info->settime64(ptp->info, tp); in ptp_clock_settime()
91 struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); in ptp_clock_gettime() local
94 if (ptp->info->gettimex64) in ptp_clock_gettime()
95 err = ptp->info->gettimex64(ptp->info, tp, NULL); in ptp_clock_gettime()
97 err = ptp->info->gettime64(ptp->info, tp); in ptp_clock_gettime()
103 struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); in ptp_clock_adjtime() local
107 if (ptp_clock_freerun(ptp)) { in ptp_clock_adjtime()
112 ops = ptp->info; in ptp_clock_adjtime()
136 ptp->dialed_frequency = tx->freq; in ptp_clock_adjtime()
151 tx->freq = ptp->dialed_frequency; in ptp_clock_adjtime()
172 struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); in ptp_clock_release() local
174 ptp_cleanup_pin_groups(ptp); in ptp_clock_release()
175 kfree(ptp->vclock_index); in ptp_clock_release()
176 mutex_destroy(&ptp->tsevq_mux); in ptp_clock_release()
177 mutex_destroy(&ptp->pincfg_mux); in ptp_clock_release()
178 mutex_destroy(&ptp->n_vclocks_mux); in ptp_clock_release()
179 ida_free(&ptp_clocks_map, ptp->index); in ptp_clock_release()
180 kfree(ptp); in ptp_clock_release()
193 struct ptp_clock *ptp = container_of(work, struct ptp_clock, in ptp_aux_kworker() local
195 struct ptp_clock_info *info = ptp->info; in ptp_aux_kworker()
201 kthread_queue_delayed_work(ptp->kworker, &ptp->aux_work, delay); in ptp_aux_kworker()
209 struct ptp_clock *ptp; in ptp_clock_register() local
218 ptp = kzalloc(sizeof(struct ptp_clock), GFP_KERNEL); in ptp_clock_register()
219 if (ptp == NULL) in ptp_clock_register()
228 ptp->clock.ops = ptp_clock_ops; in ptp_clock_register()
229 ptp->info = info; in ptp_clock_register()
230 ptp->devid = MKDEV(major, index); in ptp_clock_register()
231 ptp->index = index; in ptp_clock_register()
232 spin_lock_init(&ptp->tsevq.lock); in ptp_clock_register()
233 mutex_init(&ptp->tsevq_mux); in ptp_clock_register()
234 mutex_init(&ptp->pincfg_mux); in ptp_clock_register()
235 mutex_init(&ptp->n_vclocks_mux); in ptp_clock_register()
236 init_waitqueue_head(&ptp->tsev_wq); in ptp_clock_register()
238 if (ptp->info->getcycles64 || ptp->info->getcyclesx64) { in ptp_clock_register()
239 ptp->has_cycles = true; in ptp_clock_register()
240 if (!ptp->info->getcycles64 && ptp->info->getcyclesx64) in ptp_clock_register()
241 ptp->info->getcycles64 = ptp_getcycles64; in ptp_clock_register()
244 ptp->info->getcycles64 = ptp_getcycles64; in ptp_clock_register()
246 if (ptp->info->gettimex64) in ptp_clock_register()
247 ptp->info->getcyclesx64 = ptp->info->gettimex64; in ptp_clock_register()
249 if (ptp->info->getcrosststamp) in ptp_clock_register()
250 ptp->info->getcrosscycles = ptp->info->getcrosststamp; in ptp_clock_register()
253 if (ptp->info->do_aux_work) { in ptp_clock_register()
254 kthread_init_delayed_work(&ptp->aux_work, ptp_aux_kworker); in ptp_clock_register()
255 ptp->kworker = kthread_create_worker(0, "ptp%d", ptp->index); in ptp_clock_register()
256 if (IS_ERR(ptp->kworker)) { in ptp_clock_register()
257 err = PTR_ERR(ptp->kworker); in ptp_clock_register()
266 ptp->is_virtual_clock = true; in ptp_clock_register()
268 if (!ptp->is_virtual_clock) { in ptp_clock_register()
269 ptp->max_vclocks = PTP_DEFAULT_MAX_VCLOCKS; in ptp_clock_register()
271 size = sizeof(int) * ptp->max_vclocks; in ptp_clock_register()
272 ptp->vclock_index = kzalloc(size, GFP_KERNEL); in ptp_clock_register()
273 if (!ptp->vclock_index) { in ptp_clock_register()
279 err = ptp_populate_pin_groups(ptp); in ptp_clock_register()
290 ptp->pps_source = pps_register_source(&pps, PTP_PPS_DEFAULTS); in ptp_clock_register()
291 if (IS_ERR(ptp->pps_source)) { in ptp_clock_register()
292 err = PTR_ERR(ptp->pps_source); in ptp_clock_register()
296 ptp->pps_source->lookup_cookie = ptp; in ptp_clock_register()
300 device_initialize(&ptp->dev); in ptp_clock_register()
301 ptp->dev.devt = ptp->devid; in ptp_clock_register()
302 ptp->dev.class = ptp_class; in ptp_clock_register()
303 ptp->dev.parent = parent; in ptp_clock_register()
304 ptp->dev.groups = ptp->pin_attr_groups; in ptp_clock_register()
305 ptp->dev.release = ptp_clock_release; in ptp_clock_register()
306 dev_set_drvdata(&ptp->dev, ptp); in ptp_clock_register()
307 dev_set_name(&ptp->dev, "ptp%d", ptp->index); in ptp_clock_register()
310 err = posix_clock_register(&ptp->clock, &ptp->dev); in ptp_clock_register()
312 if (ptp->pps_source) in ptp_clock_register()
313 pps_unregister_source(ptp->pps_source); in ptp_clock_register()
315 if (ptp->kworker) in ptp_clock_register()
316 kthread_destroy_worker(ptp->kworker); in ptp_clock_register()
318 put_device(&ptp->dev); in ptp_clock_register()
324 return ptp; in ptp_clock_register()
327 ptp_cleanup_pin_groups(ptp); in ptp_clock_register()
329 kfree(ptp->vclock_index); in ptp_clock_register()
331 if (ptp->kworker) in ptp_clock_register()
332 kthread_destroy_worker(ptp->kworker); in ptp_clock_register()
334 mutex_destroy(&ptp->tsevq_mux); in ptp_clock_register()
335 mutex_destroy(&ptp->pincfg_mux); in ptp_clock_register()
336 mutex_destroy(&ptp->n_vclocks_mux); in ptp_clock_register()
339 kfree(ptp); in ptp_clock_register()
347 struct ptp_clock *ptp = dev_get_drvdata(dev); in unregister_vclock() local
349 ptp_vclock_unregister(info_to_vclock(ptp->info)); in unregister_vclock()
353 int ptp_clock_unregister(struct ptp_clock *ptp) in ptp_clock_unregister() argument
355 if (ptp_vclock_in_use(ptp)) { in ptp_clock_unregister()
356 device_for_each_child(&ptp->dev, NULL, unregister_vclock); in ptp_clock_unregister()
359 ptp->defunct = 1; in ptp_clock_unregister()
360 wake_up_interruptible(&ptp->tsev_wq); in ptp_clock_unregister()
362 if (ptp->kworker) { in ptp_clock_unregister()
363 kthread_cancel_delayed_work_sync(&ptp->aux_work); in ptp_clock_unregister()
364 kthread_destroy_worker(ptp->kworker); in ptp_clock_unregister()
368 if (ptp->pps_source) in ptp_clock_unregister()
369 pps_unregister_source(ptp->pps_source); in ptp_clock_unregister()
371 posix_clock_unregister(&ptp->clock); in ptp_clock_unregister()
377 void ptp_clock_event(struct ptp_clock *ptp, struct ptp_clock_event *event) in ptp_clock_event() argument
387 enqueue_external_timestamp(&ptp->tsevq, event); in ptp_clock_event()
388 wake_up_interruptible(&ptp->tsev_wq); in ptp_clock_event()
393 pps_event(ptp->pps_source, &evt, PTP_PPS_EVENT, NULL); in ptp_clock_event()
397 pps_event(ptp->pps_source, &event->pps_times, in ptp_clock_event()
404 int ptp_clock_index(struct ptp_clock *ptp) in ptp_clock_index() argument
406 return ptp->index; in ptp_clock_index()
410 int ptp_find_pin(struct ptp_clock *ptp, in ptp_find_pin() argument
416 for (i = 0; i < ptp->info->n_pins; i++) { in ptp_find_pin()
417 if (ptp->info->pin_config[i].func == func && in ptp_find_pin()
418 ptp->info->pin_config[i].chan == chan) { in ptp_find_pin()
419 pin = &ptp->info->pin_config[i]; in ptp_find_pin()
428 int ptp_find_pin_unlocked(struct ptp_clock *ptp, in ptp_find_pin_unlocked() argument
433 mutex_lock(&ptp->pincfg_mux); in ptp_find_pin_unlocked()
435 result = ptp_find_pin(ptp, func, chan); in ptp_find_pin_unlocked()
437 mutex_unlock(&ptp->pincfg_mux); in ptp_find_pin_unlocked()
443 int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay) in ptp_schedule_worker() argument
445 return kthread_mod_delayed_work(ptp->kworker, &ptp->aux_work, delay); in ptp_schedule_worker()
449 void ptp_cancel_worker_sync(struct ptp_clock *ptp) in ptp_cancel_worker_sync() argument
451 kthread_cancel_delayed_work_sync(&ptp->aux_work); in ptp_cancel_worker_sync()