Lines Matching full:ptp

81 	struct lan743x_ptp *ptp = &adapter->ptp;  in lan743x_ptp_tx_ts_enqueue_ts()  local
83 spin_lock_bh(&ptp->tx_ts_lock); in lan743x_ptp_tx_ts_enqueue_ts()
84 if (ptp->tx_ts_queue_size < LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS) { in lan743x_ptp_tx_ts_enqueue_ts()
85 ptp->tx_ts_seconds_queue[ptp->tx_ts_queue_size] = seconds; in lan743x_ptp_tx_ts_enqueue_ts()
86 ptp->tx_ts_nseconds_queue[ptp->tx_ts_queue_size] = nano_seconds; in lan743x_ptp_tx_ts_enqueue_ts()
87 ptp->tx_ts_header_queue[ptp->tx_ts_queue_size] = header; in lan743x_ptp_tx_ts_enqueue_ts()
88 ptp->tx_ts_queue_size++; in lan743x_ptp_tx_ts_enqueue_ts()
93 spin_unlock_bh(&ptp->tx_ts_lock); in lan743x_ptp_tx_ts_enqueue_ts()
98 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_tx_ts_complete() local
105 spin_lock_bh(&ptp->tx_ts_lock); in lan743x_ptp_tx_ts_complete()
106 c = ptp->tx_ts_skb_queue_size; in lan743x_ptp_tx_ts_complete()
108 if (c > ptp->tx_ts_queue_size) in lan743x_ptp_tx_ts_complete()
109 c = ptp->tx_ts_queue_size; in lan743x_ptp_tx_ts_complete()
114 ignore_sync = ((ptp->tx_ts_ignore_sync_queue & in lan743x_ptp_tx_ts_complete()
116 skb = ptp->tx_ts_skb_queue[i]; in lan743x_ptp_tx_ts_complete()
117 nseconds = ptp->tx_ts_nseconds_queue[i]; in lan743x_ptp_tx_ts_complete()
118 seconds = ptp->tx_ts_seconds_queue[i]; in lan743x_ptp_tx_ts_complete()
119 header = ptp->tx_ts_header_queue[i]; in lan743x_ptp_tx_ts_complete()
130 ptp->tx_ts_skb_queue[i] = NULL; in lan743x_ptp_tx_ts_complete()
131 ptp->tx_ts_seconds_queue[i] = 0; in lan743x_ptp_tx_ts_complete()
132 ptp->tx_ts_nseconds_queue[i] = 0; in lan743x_ptp_tx_ts_complete()
133 ptp->tx_ts_header_queue[i] = 0; in lan743x_ptp_tx_ts_complete()
137 ptp->tx_ts_ignore_sync_queue >>= c; in lan743x_ptp_tx_ts_complete()
139 ptp->tx_ts_skb_queue[i - c] = ptp->tx_ts_skb_queue[i]; in lan743x_ptp_tx_ts_complete()
140 ptp->tx_ts_seconds_queue[i - c] = ptp->tx_ts_seconds_queue[i]; in lan743x_ptp_tx_ts_complete()
141 ptp->tx_ts_nseconds_queue[i - c] = ptp->tx_ts_nseconds_queue[i]; in lan743x_ptp_tx_ts_complete()
142 ptp->tx_ts_header_queue[i - c] = ptp->tx_ts_header_queue[i]; in lan743x_ptp_tx_ts_complete()
144 ptp->tx_ts_skb_queue[i] = NULL; in lan743x_ptp_tx_ts_complete()
145 ptp->tx_ts_seconds_queue[i] = 0; in lan743x_ptp_tx_ts_complete()
146 ptp->tx_ts_nseconds_queue[i] = 0; in lan743x_ptp_tx_ts_complete()
147 ptp->tx_ts_header_queue[i] = 0; in lan743x_ptp_tx_ts_complete()
149 ptp->tx_ts_skb_queue_size -= c; in lan743x_ptp_tx_ts_complete()
150 ptp->tx_ts_queue_size -= c; in lan743x_ptp_tx_ts_complete()
152 ptp->pending_tx_timestamps -= c; in lan743x_ptp_tx_ts_complete()
153 spin_unlock_bh(&ptp->tx_ts_lock); in lan743x_ptp_tx_ts_complete()
159 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_reserve_event_ch() local
162 mutex_lock(&ptp->command_lock); in lan743x_ptp_reserve_event_ch()
163 if (!(test_bit(event_channel, &ptp->used_event_ch))) { in lan743x_ptp_reserve_event_ch()
164 ptp->used_event_ch |= BIT(event_channel); in lan743x_ptp_reserve_event_ch()
171 mutex_unlock(&ptp->command_lock); in lan743x_ptp_reserve_event_ch()
178 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_release_event_ch() local
180 mutex_lock(&ptp->command_lock); in lan743x_ptp_release_event_ch()
181 if (test_bit(event_channel, &ptp->used_event_ch)) { in lan743x_ptp_release_event_ch()
182 ptp->used_event_ch &= ~BIT(event_channel); in lan743x_ptp_release_event_ch()
188 mutex_unlock(&ptp->command_lock); in lan743x_ptp_release_event_ch()
202 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_led_mux_enable() local
204 if (ptp->leds_multiplexed && in lan743x_led_mux_enable()
205 ptp->led_enabled[pin]) { in lan743x_led_mux_enable()
219 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_led_mux_save() local
229 ptp->led_enabled[i] = led_enabled; in lan743x_led_mux_save()
231 ptp->leds_multiplexed = true; in lan743x_led_mux_save()
233 ptp->leds_multiplexed = false; in lan743x_led_mux_save()
311 /* disable ptp output */ in lan743x_gpio_release()
337 struct lan743x_ptp *ptp = in lan743x_ptpci_adjfine() local
340 container_of(ptp, struct lan743x_adapter, ptp); in lan743x_ptpci_adjfine()
363 struct lan743x_ptp *ptp = in lan743x_ptpci_adjtime() local
366 container_of(ptp, struct lan743x_adapter, ptp); in lan743x_ptpci_adjtime()
376 struct lan743x_ptp *ptp = in lan743x_ptpci_gettime64() local
379 container_of(ptp, struct lan743x_adapter, ptp); in lan743x_ptpci_gettime64()
397 struct lan743x_ptp *ptp = in lan743x_ptpci_settime64() local
400 container_of(ptp, struct lan743x_adapter, ptp); in lan743x_ptpci_settime64()
426 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_perout_off() local
428 struct lan743x_ptp_perout *perout = &ptp->perout[index]; in lan743x_ptp_perout_off()
456 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_perout() local
463 struct lan743x_ptp_perout *perout = &ptp->perout[index]; in lan743x_ptp_perout()
471 perout_pin = ptp_find_pin(ptp->ptp_clock, PTP_PF_PEROUT, in lan743x_ptp_perout()
647 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_perout_off() local
653 event_ch = ptp->ptp_io_perout[index]; in lan743x_ptp_io_perout_off()
676 ptp->ptp_io_perout[index] = -1; in lan743x_ptp_io_perout_off()
679 perout_pin = ptp_find_pin(ptp->ptp_clock, PTP_PF_PEROUT, index); in lan743x_ptp_io_perout_off()
699 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_perout() local
711 event_ch = ptp->ptp_io_perout[index]; in lan743x_ptp_io_perout()
714 perout_pin = ptp_find_pin(ptp->ptp_clock, PTP_PF_PEROUT, index); in lan743x_ptp_io_perout()
734 ptp->ptp_io_perout[index] = event_ch; in lan743x_ptp_io_perout()
856 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_extts_off() local
860 extts = &ptp->extts[index]; in lan743x_ptp_io_extts_off()
861 /* PTP Interrupt Enable Clear Register */ in lan743x_ptp_io_extts_off()
868 /* Disables PTP-IO edge lock */ in lan743x_ptp_io_extts_off()
879 /* PTP-IO De-select register */ in lan743x_ptp_io_extts_off()
892 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_event_cap_en() local
898 mutex_lock(&ptp->command_lock); in lan743x_ptp_io_event_cap_en()
899 /* PTP-IO Event Capture Enable */ in lan743x_ptp_io_event_cap_en()
915 /* PTP-IO Select */ in lan743x_ptp_io_event_cap_en()
921 /* PTP Interrupt Enable Register */ in lan743x_ptp_io_event_cap_en()
928 mutex_unlock(&ptp->command_lock); in lan743x_ptp_io_event_cap_en()
936 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_extts() local
943 extts = &ptp->extts[index]; in lan743x_ptp_io_extts()
946 extts_pin = ptp_find_pin(ptp->ptp_clock, PTP_PF_EXTTS, index); in lan743x_ptp_io_extts()
963 struct lan743x_ptp *ptp = in lan743x_ptpci_enable() local
966 container_of(ptp, struct lan743x_adapter, ptp); in lan743x_ptpci_enable()
999 static int lan743x_ptpci_verify_pin_config(struct ptp_clock_info *ptp, in lan743x_ptpci_verify_pin_config() argument
1005 container_of(ptp, struct lan743x_ptp, ptp_clock_info); in lan743x_ptpci_verify_pin_config()
1007 container_of(lan_ptp, struct lan743x_adapter, ptp); in lan743x_ptpci_verify_pin_config()
1033 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_event_clock_get() local
1037 mutex_lock(&ptp->command_lock); in lan743x_ptp_io_event_clock_get()
1046 mutex_unlock(&ptp->command_lock); in lan743x_ptp_io_event_clock_get()
1049 extts = &ptp->extts[channel]; in lan743x_ptp_io_event_clock_get()
1058 struct lan743x_ptp *ptp = in lan743x_ptpci_do_aux_work() local
1061 container_of(ptp, struct lan743x_adapter, ptp); in lan743x_ptpci_do_aux_work()
1123 /* PTP Falling Event post */ in lan743x_ptpci_do_aux_work()
1128 ptp_clock_event(ptp->ptp_clock, in lan743x_ptpci_do_aux_work()
1156 /* PTP Rising Event post */ in lan743x_ptpci_do_aux_work()
1161 ptp_clock_event(ptp->ptp_clock, in lan743x_ptpci_do_aux_work()
1193 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_clock_get() local
1195 mutex_lock(&ptp->command_lock); in lan743x_ptp_clock_get()
1210 mutex_unlock(&ptp->command_lock); in lan743x_ptp_clock_get()
1216 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_clock_get() local
1218 mutex_lock(&ptp->command_lock); in lan743x_ptp_io_clock_get()
1232 mutex_unlock(&ptp->command_lock); in lan743x_ptp_io_clock_get()
1238 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_clock_step() local
1321 mutex_lock(&ptp->command_lock); in lan743x_ptp_clock_step()
1344 mutex_unlock(&ptp->command_lock); in lan743x_ptp_clock_step()
1347 mutex_lock(&ptp->command_lock); in lan743x_ptp_clock_step()
1356 mutex_unlock(&ptp->command_lock); in lan743x_ptp_clock_step()
1363 struct lan743x_ptp *ptp = NULL; in lan743x_ptp_isr() local
1367 ptp = &adapter->ptp; in lan743x_ptp_isr()
1375 ptp_schedule_worker(ptp->ptp_clock, 0); in lan743x_ptp_isr()
1380 "PTP TX Software Timestamp Error\n"); in lan743x_ptp_isr()
1405 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_tx_ts_enqueue_skb() local
1407 spin_lock_bh(&ptp->tx_ts_lock); in lan743x_ptp_tx_ts_enqueue_skb()
1408 if (ptp->tx_ts_skb_queue_size < LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS) { in lan743x_ptp_tx_ts_enqueue_skb()
1409 ptp->tx_ts_skb_queue[ptp->tx_ts_skb_queue_size] = skb; in lan743x_ptp_tx_ts_enqueue_skb()
1411 ptp->tx_ts_ignore_sync_queue |= in lan743x_ptp_tx_ts_enqueue_skb()
1412 BIT(ptp->tx_ts_skb_queue_size); in lan743x_ptp_tx_ts_enqueue_skb()
1413 ptp->tx_ts_skb_queue_size++; in lan743x_ptp_tx_ts_enqueue_skb()
1423 spin_unlock_bh(&ptp->tx_ts_lock); in lan743x_ptp_tx_ts_enqueue_skb()
1459 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_init() local
1462 mutex_init(&ptp->command_lock); in lan743x_ptp_init()
1463 spin_lock_init(&ptp->tx_ts_lock); in lan743x_ptp_init()
1464 ptp->used_event_ch = 0; in lan743x_ptp_init()
1467 ptp->perout[i].event_ch = -1; in lan743x_ptp_init()
1468 ptp->perout[i].gpio_pin = -1; in lan743x_ptp_init()
1478 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_open() local
1497 ptp->flags |= PTP_FLAG_ISR_ENABLED; in lan743x_ptp_open()
1523 struct ptp_pin_desc *ptp_pin = &ptp->pin_config[i]; in lan743x_ptp_open()
1531 ptp->ptp_clock_info.owner = THIS_MODULE; in lan743x_ptp_open()
1532 snprintf(ptp->ptp_clock_info.name, 16, "%pm", in lan743x_ptp_open()
1534 ptp->ptp_clock_info.max_adj = LAN743X_PTP_MAX_FREQ_ADJ_IN_PPB; in lan743x_ptp_open()
1535 ptp->ptp_clock_info.n_alarm = 0; in lan743x_ptp_open()
1536 ptp->ptp_clock_info.n_ext_ts = LAN743X_PTP_N_EXTTS; in lan743x_ptp_open()
1537 ptp->ptp_clock_info.n_per_out = LAN743X_PTP_N_EVENT_CHAN; in lan743x_ptp_open()
1538 ptp->ptp_clock_info.n_pins = n_pins; in lan743x_ptp_open()
1539 ptp->ptp_clock_info.pps = LAN743X_PTP_N_PPS; in lan743x_ptp_open()
1540 ptp->ptp_clock_info.pin_config = ptp->pin_config; in lan743x_ptp_open()
1541 ptp->ptp_clock_info.adjfine = lan743x_ptpci_adjfine; in lan743x_ptp_open()
1542 ptp->ptp_clock_info.adjtime = lan743x_ptpci_adjtime; in lan743x_ptp_open()
1543 ptp->ptp_clock_info.gettime64 = lan743x_ptpci_gettime64; in lan743x_ptp_open()
1544 ptp->ptp_clock_info.getcrosststamp = NULL; in lan743x_ptp_open()
1545 ptp->ptp_clock_info.settime64 = lan743x_ptpci_settime64; in lan743x_ptp_open()
1546 ptp->ptp_clock_info.enable = lan743x_ptpci_enable; in lan743x_ptp_open()
1547 ptp->ptp_clock_info.do_aux_work = lan743x_ptpci_do_aux_work; in lan743x_ptp_open()
1548 ptp->ptp_clock_info.verify = lan743x_ptpci_verify_pin_config; in lan743x_ptp_open()
1550 ptp->ptp_clock = ptp_clock_register(&ptp->ptp_clock_info, in lan743x_ptp_open()
1553 if (IS_ERR(ptp->ptp_clock)) { in lan743x_ptp_open()
1558 ptp->flags |= PTP_FLAG_PTP_CLOCK_REGISTERED; in lan743x_ptp_open()
1560 "successfully registered ptp clock\n"); in lan743x_ptp_open()
1570 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_close() local
1574 (ptp->flags & PTP_FLAG_PTP_CLOCK_REGISTERED)) { in lan743x_ptp_close()
1575 ptp_clock_unregister(ptp->ptp_clock); in lan743x_ptp_close()
1576 ptp->ptp_clock = NULL; in lan743x_ptp_close()
1577 ptp->flags &= ~PTP_FLAG_PTP_CLOCK_REGISTERED; in lan743x_ptp_close()
1579 "ptp clock unregister\n"); in lan743x_ptp_close()
1582 if (ptp->flags & PTP_FLAG_ISR_ENABLED) { in lan743x_ptp_close()
1587 ptp->flags &= ~PTP_FLAG_ISR_ENABLED; in lan743x_ptp_close()
1592 spin_lock_bh(&ptp->tx_ts_lock); in lan743x_ptp_close()
1596 struct sk_buff *skb = ptp->tx_ts_skb_queue[index]; in lan743x_ptp_close()
1599 ptp->tx_ts_skb_queue[index] = NULL; in lan743x_ptp_close()
1600 ptp->tx_ts_seconds_queue[index] = 0; in lan743x_ptp_close()
1601 ptp->tx_ts_nseconds_queue[index] = 0; in lan743x_ptp_close()
1603 ptp->tx_ts_skb_queue_size = 0; in lan743x_ptp_close()
1604 ptp->tx_ts_queue_size = 0; in lan743x_ptp_close()
1605 ptp->pending_tx_timestamps = 0; in lan743x_ptp_close()
1606 spin_unlock_bh(&ptp->tx_ts_lock); in lan743x_ptp_close()
1635 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_enable() local
1637 mutex_lock(&ptp->command_lock); in lan743x_ptp_enable()
1641 "PTP already enabled\n"); in lan743x_ptp_enable()
1646 mutex_unlock(&ptp->command_lock); in lan743x_ptp_enable()
1651 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_disable() local
1656 mutex_lock(&ptp->command_lock); in lan743x_ptp_disable()
1659 "PTP already disabled\n"); in lan743x_ptp_disable()
1665 mutex_unlock(&ptp->command_lock); in lan743x_ptp_disable()
1670 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_reset() local
1672 mutex_lock(&ptp->command_lock); in lan743x_ptp_reset()
1683 mutex_unlock(&ptp->command_lock); in lan743x_ptp_reset()
1690 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_clock_set() local
1692 mutex_lock(&ptp->command_lock); in lan743x_ptp_clock_set()
1700 mutex_unlock(&ptp->command_lock); in lan743x_ptp_clock_set()
1705 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_request_tx_timestamp() local
1708 spin_lock(&ptp->tx_ts_lock); in lan743x_ptp_request_tx_timestamp()
1709 if (ptp->pending_tx_timestamps < LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS) { in lan743x_ptp_request_tx_timestamp()
1711 ptp->pending_tx_timestamps++; in lan743x_ptp_request_tx_timestamp()
1714 spin_unlock(&ptp->tx_ts_lock); in lan743x_ptp_request_tx_timestamp()
1720 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_unrequest_tx_timestamp() local
1722 spin_lock_bh(&ptp->tx_ts_lock); in lan743x_ptp_unrequest_tx_timestamp()
1723 if (ptp->pending_tx_timestamps > 0) in lan743x_ptp_unrequest_tx_timestamp()
1724 ptp->pending_tx_timestamps--; in lan743x_ptp_unrequest_tx_timestamp()
1728 spin_unlock_bh(&ptp->tx_ts_lock); in lan743x_ptp_unrequest_tx_timestamp()