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
279 ptp_schedule_worker(ptp_data->clock, 0); in ksz_ptp_enable_mode()
281 ptp_cancel_worker_sync(ptp_data->clock); in ksz_ptp_enable_mode()
296 struct ksz_ptp_data *ptp_data; in ksz_get_ts_info() local
298 ptp_data = &dev->ptp_data; in ksz_get_ts_info()
300 if (!ptp_data->clock) in ksz_get_ts_info()
317 ts->phc_index = ptp_clock_index(ptp_data->clock); in ksz_get_ts_info()
434 struct ksz_ptp_data *ptp_data; in ksz_tstamp_reconstruct() local
438 ptp_data = &dev->ptp_data; in ksz_tstamp_reconstruct()
441 spin_lock_bh(&ptp_data->clock_lock); in ksz_tstamp_reconstruct()
442 ptp_clock_time = ptp_data->clock_time; in ksz_tstamp_reconstruct()
443 spin_unlock_bh(&ptp_data->clock_lock); in ksz_tstamp_reconstruct()
624 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_gettime() local
625 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_gettime()
628 mutex_lock(&ptp_data->lock); in ksz_ptp_gettime()
630 mutex_unlock(&ptp_data->lock); in ksz_ptp_gettime()
637 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_restart_perout() local
652 first_ns = timespec64_to_ns(&ptp_data->perout_target_time_first); in ksz_ptp_restart_perout()
655 period_ns = timespec64_to_ns(&ptp_data->perout_period); in ksz_ptp_restart_perout()
672 request.period.sec = ptp_data->perout_period.tv_sec; in ksz_ptp_restart_perout()
673 request.period.nsec = ptp_data->perout_period.tv_nsec; in ksz_ptp_restart_perout()
683 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_settime() local
684 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_settime()
687 mutex_lock(&ptp_data->lock); in ksz_ptp_settime()
706 switch (ptp_data->tou_mode) { in ksz_ptp_settime()
718 spin_lock_bh(&ptp_data->clock_lock); in ksz_ptp_settime()
719 ptp_data->clock_time = *ts; in ksz_ptp_settime()
720 spin_unlock_bh(&ptp_data->clock_lock); in ksz_ptp_settime()
723 mutex_unlock(&ptp_data->lock); in ksz_ptp_settime()
730 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_adjfine() local
731 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_adjfine()
737 mutex_lock(&ptp_data->lock); in ksz_ptp_adjfine()
763 mutex_unlock(&ptp_data->lock); in ksz_ptp_adjfine()
769 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_adjtime() local
770 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_adjtime()
776 mutex_lock(&ptp_data->lock); in ksz_ptp_adjtime()
807 switch (ptp_data->tou_mode) { in ksz_ptp_adjtime()
819 spin_lock_bh(&ptp_data->clock_lock); in ksz_ptp_adjtime()
820 ptp_data->clock_time = timespec64_add(ptp_data->clock_time, delta64); in ksz_ptp_adjtime()
821 spin_unlock_bh(&ptp_data->clock_lock); in ksz_ptp_adjtime()
824 mutex_unlock(&ptp_data->lock); in ksz_ptp_adjtime()
831 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_enable() local
832 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_enable()
837 mutex_lock(&ptp_data->lock); in ksz_ptp_enable()
839 mutex_unlock(&ptp_data->lock); in ksz_ptp_enable()
868 struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp); in ksz_ptp_do_aux_work() local
869 struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data); in ksz_ptp_do_aux_work()
873 mutex_lock(&ptp_data->lock); in ksz_ptp_do_aux_work()
878 spin_lock_bh(&ptp_data->clock_lock); in ksz_ptp_do_aux_work()
879 ptp_data->clock_time = ts; in ksz_ptp_do_aux_work()
880 spin_unlock_bh(&ptp_data->clock_lock); in ksz_ptp_do_aux_work()
883 mutex_unlock(&ptp_data->lock); in ksz_ptp_do_aux_work()
890 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_start_clock() local
897 ptp_data->clock_time.tv_sec = 0; in ksz_ptp_start_clock()
898 ptp_data->clock_time.tv_nsec = 0; in ksz_ptp_start_clock()
906 struct ksz_ptp_data *ptp_data; in ksz_ptp_clock_register() local
910 ptp_data = &dev->ptp_data; in ksz_ptp_clock_register()
911 mutex_init(&ptp_data->lock); in ksz_ptp_clock_register()
912 spin_lock_init(&ptp_data->clock_lock); in ksz_ptp_clock_register()
914 ptp_data->caps.owner = THIS_MODULE; in ksz_ptp_clock_register()
915 snprintf(ptp_data->caps.name, 16, "Microchip Clock"); in ksz_ptp_clock_register()
916 ptp_data->caps.max_adj = KSZ_MAX_DRIFT_CORR; in ksz_ptp_clock_register()
917 ptp_data->caps.gettime64 = ksz_ptp_gettime; in ksz_ptp_clock_register()
918 ptp_data->caps.settime64 = ksz_ptp_settime; in ksz_ptp_clock_register()
919 ptp_data->caps.adjfine = ksz_ptp_adjfine; in ksz_ptp_clock_register()
920 ptp_data->caps.adjtime = ksz_ptp_adjtime; in ksz_ptp_clock_register()
921 ptp_data->caps.do_aux_work = ksz_ptp_do_aux_work; in ksz_ptp_clock_register()
922 ptp_data->caps.enable = ksz_ptp_enable; in ksz_ptp_clock_register()
923 ptp_data->caps.verify = ksz_ptp_verify_pin; in ksz_ptp_clock_register()
924 ptp_data->caps.n_pins = KSZ_PTP_N_GPIO; in ksz_ptp_clock_register()
925 ptp_data->caps.n_per_out = 3; in ksz_ptp_clock_register()
932 struct ptp_pin_desc *ptp_pin = &ptp_data->pin_config[i]; in ksz_ptp_clock_register()
940 ptp_data->caps.pin_config = ptp_data->pin_config; in ksz_ptp_clock_register()
950 ptp_data->clock = ptp_clock_register(&ptp_data->caps, dev->dev); in ksz_ptp_clock_register()
951 if (IS_ERR_OR_NULL(ptp_data->clock)) in ksz_ptp_clock_register()
952 return PTR_ERR(ptp_data->clock); in ksz_ptp_clock_register()
960 struct ksz_ptp_data *ptp_data; in ksz_ptp_clock_unregister() local
962 ptp_data = &dev->ptp_data; in ksz_ptp_clock_unregister()
964 if (ptp_data->clock) in ksz_ptp_clock_unregister()
965 ptp_clock_unregister(ptp_data->clock); in ksz_ptp_clock_unregister()