Lines Matching refs:ptp_data

20 #define ptp_data_to_ksz_dev(d) container_of((d), struct ksz_device, ptp_data)
181 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_enable_perout() local
192 if (ptp_data->tou_mode != KSZ_PTP_TOU_PEROUT && in ksz_ptp_enable_perout()
193 ptp_data->tou_mode != KSZ_PTP_TOU_IDLE) in ksz_ptp_enable_perout()
196 pin = ptp_find_pin(ptp_data->clock, PTP_PF_PEROUT, request->index); in ksz_ptp_enable_perout()
212 ptp_data->tou_mode = KSZ_PTP_TOU_IDLE; in ksz_ptp_enable_perout()
216 ptp_data->perout_target_time_first.tv_sec = request->start.sec; in ksz_ptp_enable_perout()
217 ptp_data->perout_target_time_first.tv_nsec = request->start.nsec; in ksz_ptp_enable_perout()
219 ptp_data->perout_period.tv_sec = request->period.sec; in ksz_ptp_enable_perout()
220 ptp_data->perout_period.tv_nsec = request->period.nsec; in ksz_ptp_enable_perout()
222 cycle_width_ns = timespec64_to_ns(&ptp_data->perout_period); in ksz_ptp_enable_perout()
244 &ptp_data->perout_target_time_first, in ksz_ptp_enable_perout()
257 ptp_data->tou_mode = KSZ_PTP_TOU_PEROUT; in ksz_ptp_enable_perout()
265 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_enable_mode() local
280 ret = ptp_schedule_worker(ptp_data->clock, 0); in ksz_ptp_enable_mode()
284 ptp_cancel_worker_sync(ptp_data->clock); in ksz_ptp_enable_mode()
299 struct ksz_ptp_data *ptp_data; in ksz_get_ts_info() local
301 ptp_data = &dev->ptp_data; in ksz_get_ts_info()
303 if (!ptp_data->clock) in ksz_get_ts_info()
320 ts->phc_index = ptp_clock_index(ptp_data->clock); in ksz_get_ts_info()
437 struct ksz_ptp_data *ptp_data; in ksz_tstamp_reconstruct() local
441 ptp_data = &dev->ptp_data; in ksz_tstamp_reconstruct()
444 spin_lock_bh(&ptp_data->clock_lock); in ksz_tstamp_reconstruct()
445 ptp_clock_time = ptp_data->clock_time; in ksz_tstamp_reconstruct()
446 spin_unlock_bh(&ptp_data->clock_lock); in ksz_tstamp_reconstruct()
627 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_gettime() local
628 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_gettime()
631 mutex_lock(&ptp_data->lock); in ksz_ptp_gettime()
633 mutex_unlock(&ptp_data->lock); in ksz_ptp_gettime()
640 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_restart_perout() local
655 first_ns = timespec64_to_ns(&ptp_data->perout_target_time_first); in ksz_ptp_restart_perout()
658 period_ns = timespec64_to_ns(&ptp_data->perout_period); in ksz_ptp_restart_perout()
675 request.period.sec = ptp_data->perout_period.tv_sec; in ksz_ptp_restart_perout()
676 request.period.nsec = ptp_data->perout_period.tv_nsec; in ksz_ptp_restart_perout()
686 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_settime() local
687 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_settime()
690 mutex_lock(&ptp_data->lock); in ksz_ptp_settime()
709 switch (ptp_data->tou_mode) { in ksz_ptp_settime()
721 spin_lock_bh(&ptp_data->clock_lock); in ksz_ptp_settime()
722 ptp_data->clock_time = *ts; in ksz_ptp_settime()
723 spin_unlock_bh(&ptp_data->clock_lock); in ksz_ptp_settime()
726 mutex_unlock(&ptp_data->lock); in ksz_ptp_settime()
733 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_adjfine() local
734 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_adjfine()
740 mutex_lock(&ptp_data->lock); in ksz_ptp_adjfine()
766 mutex_unlock(&ptp_data->lock); in ksz_ptp_adjfine()
772 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_adjtime() local
773 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_adjtime()
779 mutex_lock(&ptp_data->lock); in ksz_ptp_adjtime()
810 switch (ptp_data->tou_mode) { in ksz_ptp_adjtime()
822 spin_lock_bh(&ptp_data->clock_lock); in ksz_ptp_adjtime()
823 ptp_data->clock_time = timespec64_add(ptp_data->clock_time, delta64); in ksz_ptp_adjtime()
824 spin_unlock_bh(&ptp_data->clock_lock); in ksz_ptp_adjtime()
827 mutex_unlock(&ptp_data->lock); in ksz_ptp_adjtime()
834 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_enable() local
835 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_enable()
840 mutex_lock(&ptp_data->lock); in ksz_ptp_enable()
842 mutex_unlock(&ptp_data->lock); in ksz_ptp_enable()
871 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_do_aux_work() local
872 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_do_aux_work()
876 mutex_lock(&ptp_data->lock); in ksz_ptp_do_aux_work()
881 spin_lock_bh(&ptp_data->clock_lock); in ksz_ptp_do_aux_work()
882 ptp_data->clock_time = ts; in ksz_ptp_do_aux_work()
883 spin_unlock_bh(&ptp_data->clock_lock); in ksz_ptp_do_aux_work()
886 mutex_unlock(&ptp_data->lock); in ksz_ptp_do_aux_work()
893 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_start_clock() local
900 ptp_data->clock_time.tv_sec = 0; in ksz_ptp_start_clock()
901 ptp_data->clock_time.tv_nsec = 0; in ksz_ptp_start_clock()
909 struct ksz_ptp_data *ptp_data; in ksz_ptp_clock_register() local
913 ptp_data = &dev->ptp_data; in ksz_ptp_clock_register()
914 mutex_init(&ptp_data->lock); in ksz_ptp_clock_register()
915 spin_lock_init(&ptp_data->clock_lock); in ksz_ptp_clock_register()
917 ptp_data->caps.owner = THIS_MODULE; in ksz_ptp_clock_register()
918 snprintf(ptp_data->caps.name, 16, "Microchip Clock"); in ksz_ptp_clock_register()
919 ptp_data->caps.max_adj = KSZ_MAX_DRIFT_CORR; in ksz_ptp_clock_register()
920 ptp_data->caps.gettime64 = ksz_ptp_gettime; in ksz_ptp_clock_register()
921 ptp_data->caps.settime64 = ksz_ptp_settime; in ksz_ptp_clock_register()
922 ptp_data->caps.adjfine = ksz_ptp_adjfine; in ksz_ptp_clock_register()
923 ptp_data->caps.adjtime = ksz_ptp_adjtime; in ksz_ptp_clock_register()
924 ptp_data->caps.do_aux_work = ksz_ptp_do_aux_work; in ksz_ptp_clock_register()
925 ptp_data->caps.enable = ksz_ptp_enable; in ksz_ptp_clock_register()
926 ptp_data->caps.verify = ksz_ptp_verify_pin; in ksz_ptp_clock_register()
927 ptp_data->caps.n_pins = KSZ_PTP_N_GPIO; in ksz_ptp_clock_register()
928 ptp_data->caps.n_per_out = 3; in ksz_ptp_clock_register()
935 struct ptp_pin_desc *ptp_pin = &ptp_data->pin_config[i]; in ksz_ptp_clock_register()
943 ptp_data->caps.pin_config = ptp_data->pin_config; in ksz_ptp_clock_register()
953 ptp_data->clock = ptp_clock_register(&ptp_data->caps, dev->dev); in ksz_ptp_clock_register()
954 if (IS_ERR_OR_NULL(ptp_data->clock)) in ksz_ptp_clock_register()
955 return PTR_ERR(ptp_data->clock); in ksz_ptp_clock_register()
963 struct ksz_ptp_data *ptp_data; in ksz_ptp_clock_unregister() local
965 ptp_data = &dev->ptp_data; in ksz_ptp_clock_unregister()
967 if (ptp_data->clock) in ksz_ptp_clock_unregister()
968 ptp_clock_unregister(ptp_data->clock); in ksz_ptp_clock_unregister()