Lines Matching full:adapter
20 static bool lan743x_ptp_is_enabled(struct lan743x_adapter *adapter);
21 static void lan743x_ptp_enable(struct lan743x_adapter *adapter);
22 static void lan743x_ptp_disable(struct lan743x_adapter *adapter);
23 static void lan743x_ptp_reset(struct lan743x_adapter *adapter);
24 static void lan743x_ptp_clock_set(struct lan743x_adapter *adapter,
40 int lan743x_gpio_init(struct lan743x_adapter *adapter) in lan743x_gpio_init() argument
42 struct lan743x_gpio *gpio = &adapter->gpio; in lan743x_gpio_init()
50 lan743x_csr_write(adapter, GPIO_CFG0, gpio->gpio_cfg0); in lan743x_gpio_init()
51 lan743x_csr_write(adapter, GPIO_CFG1, gpio->gpio_cfg1); in lan743x_gpio_init()
52 lan743x_csr_write(adapter, GPIO_CFG2, gpio->gpio_cfg2); in lan743x_gpio_init()
53 lan743x_csr_write(adapter, GPIO_CFG3, gpio->gpio_cfg3); in lan743x_gpio_init()
58 static void lan743x_ptp_wait_till_cmd_done(struct lan743x_adapter *adapter, in lan743x_ptp_wait_till_cmd_done() argument
65 (data = (lan743x_csr_read(adapter, PTP_CMD_CTL) & in lan743x_ptp_wait_till_cmd_done()
71 netif_err(adapter, drv, adapter->netdev, in lan743x_ptp_wait_till_cmd_done()
77 static void lan743x_ptp_tx_ts_enqueue_ts(struct lan743x_adapter *adapter, in lan743x_ptp_tx_ts_enqueue_ts() argument
81 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_tx_ts_enqueue_ts()
90 netif_err(adapter, drv, adapter->netdev, in lan743x_ptp_tx_ts_enqueue_ts()
96 static void lan743x_ptp_tx_ts_complete(struct lan743x_adapter *adapter) in lan743x_ptp_tx_ts_complete() argument
98 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_tx_ts_complete()
156 static int lan743x_ptp_reserve_event_ch(struct lan743x_adapter *adapter, in lan743x_ptp_reserve_event_ch() argument
159 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_reserve_event_ch()
167 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_reserve_event_ch()
175 static void lan743x_ptp_release_event_ch(struct lan743x_adapter *adapter, in lan743x_ptp_release_event_ch() argument
178 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_release_event_ch()
184 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_release_event_ch()
191 static void lan743x_ptp_clock_get(struct lan743x_adapter *adapter,
194 static void lan743x_ptp_io_clock_get(struct lan743x_adapter *adapter,
196 static void lan743x_ptp_clock_step(struct lan743x_adapter *adapter,
199 static void lan743x_led_mux_enable(struct lan743x_adapter *adapter, in lan743x_led_mux_enable() argument
202 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_led_mux_enable()
206 u32 val = lan743x_csr_read(adapter, HW_CFG); in lan743x_led_mux_enable()
213 lan743x_csr_write(adapter, HW_CFG, val); in lan743x_led_mux_enable()
217 static void lan743x_led_mux_save(struct lan743x_adapter *adapter) in lan743x_led_mux_save() argument
219 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_led_mux_save()
220 u32 id_rev = adapter->csr.id_rev & ID_REV_ID_MASK_; in lan743x_led_mux_save()
224 u32 val = lan743x_csr_read(adapter, HW_CFG); in lan743x_led_mux_save()
237 static void lan743x_led_mux_restore(struct lan743x_adapter *adapter) in lan743x_led_mux_restore() argument
239 u32 id_rev = adapter->csr.id_rev & ID_REV_ID_MASK_; in lan743x_led_mux_restore()
245 lan743x_led_mux_enable(adapter, i, true); in lan743x_led_mux_restore()
249 static int lan743x_gpio_rsrv_ptp_out(struct lan743x_adapter *adapter, in lan743x_gpio_rsrv_ptp_out() argument
252 struct lan743x_gpio *gpio = &adapter->gpio; in lan743x_gpio_rsrv_ptp_out()
265 lan743x_led_mux_enable(adapter, pin, false); in lan743x_gpio_rsrv_ptp_out()
270 lan743x_csr_write(adapter, GPIO_CFG0, gpio->gpio_cfg0); in lan743x_gpio_rsrv_ptp_out()
275 lan743x_csr_write(adapter, GPIO_CFG1, gpio->gpio_cfg1); in lan743x_gpio_rsrv_ptp_out()
279 lan743x_csr_write(adapter, GPIO_CFG2, gpio->gpio_cfg2); in lan743x_gpio_rsrv_ptp_out()
289 lan743x_csr_write(adapter, GPIO_CFG3, gpio->gpio_cfg3); in lan743x_gpio_rsrv_ptp_out()
297 static void lan743x_gpio_release(struct lan743x_adapter *adapter, int pin) in lan743x_gpio_release() argument
299 struct lan743x_gpio *gpio = &adapter->gpio; in lan743x_gpio_release()
313 lan743x_csr_write(adapter, GPIO_CFG3, in lan743x_gpio_release()
321 lan743x_csr_write(adapter, GPIO_CFG1, gpio->gpio_cfg1); in lan743x_gpio_release()
326 lan743x_csr_write(adapter, GPIO_CFG0, gpio->gpio_cfg0); in lan743x_gpio_release()
329 lan743x_led_mux_enable(adapter, pin, true); in lan743x_gpio_release()
339 struct lan743x_adapter *adapter = in lan743x_ptpci_adjfine() local
355 lan743x_csr_write(adapter, PTP_CLOCK_RATE_ADJ, in lan743x_ptpci_adjfine()
365 struct lan743x_adapter *adapter = in lan743x_ptpci_adjtime() local
368 lan743x_ptp_clock_step(adapter, delta); in lan743x_ptpci_adjtime()
378 struct lan743x_adapter *adapter = in lan743x_ptpci_gettime64() local
383 if (adapter->is_pci11x1x) in lan743x_ptpci_gettime64()
384 lan743x_ptp_io_clock_get(adapter, &seconds, &nano_seconds, in lan743x_ptpci_gettime64()
387 lan743x_ptp_clock_get(adapter, &seconds, &nano_seconds, NULL); in lan743x_ptpci_gettime64()
399 struct lan743x_adapter *adapter = in lan743x_ptpci_settime64() local
405 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptpci_settime64()
411 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptpci_settime64()
418 lan743x_ptp_clock_set(adapter, seconds, nano_seconds, 0); in lan743x_ptpci_settime64()
423 static void lan743x_ptp_perout_off(struct lan743x_adapter *adapter, in lan743x_ptp_perout_off() argument
426 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_perout_off()
431 lan743x_gpio_release(adapter, perout->gpio_pin); in lan743x_ptp_perout_off()
437 lan743x_csr_write(adapter, in lan743x_ptp_perout_off()
440 lan743x_csr_write(adapter, in lan743x_ptp_perout_off()
444 general_config = lan743x_csr_read(adapter, PTP_GENERAL_CONFIG); in lan743x_ptp_perout_off()
447 lan743x_csr_write(adapter, PTP_GENERAL_CONFIG, general_config); in lan743x_ptp_perout_off()
448 lan743x_ptp_release_event_ch(adapter, perout->event_ch); in lan743x_ptp_perout_off()
453 static int lan743x_ptp_perout(struct lan743x_adapter *adapter, int on, in lan743x_ptp_perout() argument
456 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_perout()
476 lan743x_ptp_perout_off(adapter, index); in lan743x_ptp_perout()
483 lan743x_ptp_perout_off(adapter, index); in lan743x_ptp_perout()
486 perout->event_ch = lan743x_ptp_reserve_event_ch(adapter, index); in lan743x_ptp_perout()
489 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_perout()
496 perout->gpio_pin = lan743x_gpio_rsrv_ptp_out(adapter, in lan743x_ptp_perout()
501 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_perout()
529 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_perout()
535 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_perout()
573 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_perout()
593 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_perout()
605 lan743x_csr_write(adapter, in lan743x_ptp_perout()
608 lan743x_csr_write(adapter, in lan743x_ptp_perout()
612 general_config = lan743x_csr_read(adapter, PTP_GENERAL_CONFIG); in lan743x_ptp_perout()
619 lan743x_csr_write(adapter, PTP_GENERAL_CONFIG, general_config); in lan743x_ptp_perout()
622 lan743x_csr_write(adapter, in lan743x_ptp_perout()
625 lan743x_csr_write(adapter, in lan743x_ptp_perout()
630 lan743x_csr_write(adapter, in lan743x_ptp_perout()
633 lan743x_csr_write(adapter, in lan743x_ptp_perout()
640 lan743x_ptp_perout_off(adapter, index); in lan743x_ptp_perout()
644 static void lan743x_ptp_io_perout_off(struct lan743x_adapter *adapter, in lan743x_ptp_io_perout_off() argument
647 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_perout_off()
656 lan743x_csr_write(adapter, in lan743x_ptp_io_perout_off()
659 lan743x_csr_write(adapter, in lan743x_ptp_io_perout_off()
663 gen_cfg = lan743x_csr_read(adapter, HS_PTP_GENERAL_CONFIG); in lan743x_ptp_io_perout_off()
668 lan743x_csr_write(adapter, HS_PTP_GENERAL_CONFIG, gen_cfg); in lan743x_ptp_io_perout_off()
670 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptp_io_perout_off()
673 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptp_io_perout_off()
675 lan743x_ptp_release_event_ch(adapter, event_ch); in lan743x_ptp_io_perout_off()
682 val = lan743x_csr_read(adapter, PTP_IO_EVENT_OUTPUT_CFG); in lan743x_ptp_io_perout_off()
686 lan743x_csr_write(adapter, PTP_IO_EVENT_OUTPUT_CFG, val); in lan743x_ptp_io_perout_off()
689 val = lan743x_csr_read(adapter, PTP_IO_PIN_CFG); in lan743x_ptp_io_perout_off()
691 lan743x_csr_write(adapter, PTP_IO_PIN_CFG, val); in lan743x_ptp_io_perout_off()
693 val = lan743x_csr_read(adapter, PTP_IO_PIN_CFG); in lan743x_ptp_io_perout_off()
696 static int lan743x_ptp_io_perout(struct lan743x_adapter *adapter, int on, in lan743x_ptp_io_perout() argument
699 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_perout()
718 lan743x_ptp_io_perout_off(adapter, index); in lan743x_ptp_io_perout()
724 lan743x_ptp_io_perout_off(adapter, index); in lan743x_ptp_io_perout()
727 event_ch = lan743x_ptp_reserve_event_ch(adapter, index); in lan743x_ptp_io_perout()
729 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_io_perout()
776 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_io_perout()
785 lan743x_csr_write(adapter, in lan743x_ptp_io_perout()
788 lan743x_csr_write(adapter, in lan743x_ptp_io_perout()
792 gen_cfg = lan743x_csr_read(adapter, HS_PTP_GENERAL_CONFIG); in lan743x_ptp_io_perout()
798 lan743x_csr_write(adapter, HS_PTP_GENERAL_CONFIG, gen_cfg); in lan743x_ptp_io_perout()
804 lan743x_csr_write(adapter, in lan743x_ptp_io_perout()
807 lan743x_csr_write(adapter, in lan743x_ptp_io_perout()
816 lan743x_csr_write(adapter, in lan743x_ptp_io_perout()
819 lan743x_csr_write(adapter, in lan743x_ptp_io_perout()
824 val = lan743x_csr_read(adapter, PTP_CMD_CTL); in lan743x_ptp_io_perout()
826 lan743x_csr_write(adapter, PTP_CMD_CTL, val); in lan743x_ptp_io_perout()
829 val = lan743x_csr_read(adapter, PTP_IO_PIN_CFG); in lan743x_ptp_io_perout()
831 lan743x_csr_write(adapter, PTP_IO_PIN_CFG, val); in lan743x_ptp_io_perout()
834 val = lan743x_csr_read(adapter, PTP_IO_EVENT_OUTPUT_CFG); in lan743x_ptp_io_perout()
844 lan743x_csr_write(adapter, PTP_IO_EVENT_OUTPUT_CFG, val); in lan743x_ptp_io_perout()
849 lan743x_ptp_io_perout_off(adapter, index); in lan743x_ptp_io_perout()
853 static void lan743x_ptp_io_extts_off(struct lan743x_adapter *adapter, in lan743x_ptp_io_extts_off() argument
856 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_extts_off()
866 lan743x_csr_write(adapter, PTP_INT_EN_CLR, val); in lan743x_ptp_io_extts_off()
869 val = lan743x_csr_read(adapter, PTP_IO_CAP_CONFIG); in lan743x_ptp_io_extts_off()
877 lan743x_csr_write(adapter, PTP_IO_CAP_CONFIG, val); in lan743x_ptp_io_extts_off()
880 val = lan743x_csr_read(adapter, PTP_IO_SEL); in lan743x_ptp_io_extts_off()
882 lan743x_csr_write(adapter, PTP_IO_SEL, val); in lan743x_ptp_io_extts_off()
889 static int lan743x_ptp_io_event_cap_en(struct lan743x_adapter *adapter, in lan743x_ptp_io_event_cap_en() argument
892 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_event_cap_en()
900 val = lan743x_csr_read(adapter, PTP_IO_CAP_CONFIG); in lan743x_ptp_io_event_cap_en()
913 lan743x_csr_write(adapter, PTP_IO_CAP_CONFIG, val); in lan743x_ptp_io_event_cap_en()
916 val = lan743x_csr_read(adapter, PTP_IO_SEL); in lan743x_ptp_io_event_cap_en()
919 lan743x_csr_write(adapter, PTP_IO_SEL, val); in lan743x_ptp_io_event_cap_en()
926 lan743x_csr_write(adapter, PTP_INT_EN_SET, val); in lan743x_ptp_io_event_cap_en()
933 static int lan743x_ptp_io_extts(struct lan743x_adapter *adapter, int on, in lan743x_ptp_io_extts() argument
936 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_extts()
950 ret = lan743x_ptp_io_event_cap_en(adapter, flags, index); in lan743x_ptp_io_extts()
954 lan743x_ptp_io_extts_off(adapter, index); in lan743x_ptp_io_extts()
965 struct lan743x_adapter *adapter = in lan743x_ptpci_enable() local
972 return lan743x_ptp_io_extts(adapter, on, in lan743x_ptpci_enable()
977 if (adapter->is_pci11x1x) in lan743x_ptpci_enable()
978 return lan743x_ptp_io_perout(adapter, on, in lan743x_ptpci_enable()
981 return lan743x_ptp_perout(adapter, on, in lan743x_ptpci_enable()
988 netif_err(adapter, drv, adapter->netdev, in lan743x_ptpci_enable()
994 netif_err(adapter, drv, adapter->netdev, "request == NULL\n"); in lan743x_ptpci_enable()
1006 struct lan743x_adapter *adapter = in lan743x_ptpci_verify_pin_config() local
1018 if (!adapter->is_pci11x1x) in lan743x_ptpci_verify_pin_config()
1029 static void lan743x_ptp_io_event_clock_get(struct lan743x_adapter *adapter, in lan743x_ptp_io_event_clock_get() argument
1033 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_event_clock_get()
1039 sec = lan743x_csr_read(adapter, PTP_IO_FE_LTC_SEC_CAP_X); in lan743x_ptp_io_event_clock_get()
1040 nsec = lan743x_csr_read(adapter, PTP_IO_FE_LTC_NS_CAP_X); in lan743x_ptp_io_event_clock_get()
1042 sec = lan743x_csr_read(adapter, PTP_IO_RE_LTC_SEC_CAP_X); in lan743x_ptp_io_event_clock_get()
1043 nsec = lan743x_csr_read(adapter, PTP_IO_RE_LTC_NS_CAP_X); in lan743x_ptp_io_event_clock_get()
1060 struct lan743x_adapter *adapter = in lan743x_ptpci_do_aux_work() local
1071 ptp_int_sts = lan743x_csr_read(adapter, PTP_INT_STS); in lan743x_ptpci_do_aux_work()
1076 cap_info = lan743x_csr_read(adapter, PTP_CAP_INFO); in lan743x_ptpci_do_aux_work()
1079 seconds = lan743x_csr_read(adapter, in lan743x_ptpci_do_aux_work()
1081 nsec = lan743x_csr_read(adapter, in lan743x_ptpci_do_aux_work()
1085 header = lan743x_csr_read(adapter, in lan743x_ptpci_do_aux_work()
1091 lan743x_ptp_tx_ts_enqueue_ts(adapter, in lan743x_ptpci_do_aux_work()
1098 netif_err(adapter, drv, adapter->netdev, in lan743x_ptpci_do_aux_work()
1101 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptpci_do_aux_work()
1105 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptpci_do_aux_work()
1108 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptpci_do_aux_work()
1119 lan743x_ptp_io_event_clock_get(adapter, in lan743x_ptpci_do_aux_work()
1130 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptpci_do_aux_work()
1138 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptpci_do_aux_work()
1152 lan743x_ptp_io_event_clock_get(adapter, in lan743x_ptpci_do_aux_work()
1163 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptpci_do_aux_work()
1171 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptpci_do_aux_work()
1178 ptp_int_sts = lan743x_csr_read(adapter, PTP_INT_STS); in lan743x_ptpci_do_aux_work()
1182 lan743x_ptp_tx_ts_complete(adapter); in lan743x_ptpci_do_aux_work()
1184 lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_1588_); in lan743x_ptpci_do_aux_work()
1189 static void lan743x_ptp_clock_get(struct lan743x_adapter *adapter, in lan743x_ptp_clock_get() argument
1193 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_clock_get()
1197 lan743x_csr_write(adapter, PTP_CMD_CTL, PTP_CMD_CTL_PTP_CLOCK_READ_); in lan743x_ptp_clock_get()
1198 lan743x_ptp_wait_till_cmd_done(adapter, PTP_CMD_CTL_PTP_CLOCK_READ_); in lan743x_ptp_clock_get()
1201 (*seconds) = lan743x_csr_read(adapter, PTP_CLOCK_SEC); in lan743x_ptp_clock_get()
1204 (*nano_seconds) = lan743x_csr_read(adapter, PTP_CLOCK_NS); in lan743x_ptp_clock_get()
1208 lan743x_csr_read(adapter, PTP_CLOCK_SUBNS); in lan743x_ptp_clock_get()
1213 static void lan743x_ptp_io_clock_get(struct lan743x_adapter *adapter, in lan743x_ptp_io_clock_get() argument
1216 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_io_clock_get()
1219 lan743x_csr_write(adapter, PTP_CMD_CTL, PTP_CMD_CTL_PTP_CLOCK_READ_); in lan743x_ptp_io_clock_get()
1220 lan743x_ptp_wait_till_cmd_done(adapter, PTP_CMD_CTL_PTP_CLOCK_READ_); in lan743x_ptp_io_clock_get()
1223 (*sec) = lan743x_csr_read(adapter, PTP_LTC_RD_SEC_LO); in lan743x_ptp_io_clock_get()
1226 (*nsec) = lan743x_csr_read(adapter, PTP_LTC_RD_NS); in lan743x_ptp_io_clock_get()
1230 lan743x_csr_read(adapter, PTP_LTC_RD_SUBNS); in lan743x_ptp_io_clock_get()
1235 static void lan743x_ptp_clock_step(struct lan743x_adapter *adapter, in lan743x_ptp_clock_step() argument
1238 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_clock_step()
1248 if (adapter->is_pci11x1x) in lan743x_ptp_clock_step()
1249 lan743x_ptp_io_clock_get(adapter, &unsigned_seconds, in lan743x_ptp_clock_step()
1252 lan743x_ptp_clock_get(adapter, &unsigned_seconds, in lan743x_ptp_clock_step()
1261 lan743x_ptp_clock_set(adapter, unsigned_seconds, in lan743x_ptp_clock_step()
1268 if (adapter->is_pci11x1x) { in lan743x_ptp_clock_step()
1269 lan743x_ptp_io_clock_get(adapter, &unsigned_seconds, in lan743x_ptp_clock_step()
1272 lan743x_ptp_clock_get(adapter, &unsigned_seconds, in lan743x_ptp_clock_step()
1283 lan743x_ptp_clock_set(adapter, unsigned_seconds, in lan743x_ptp_clock_step()
1327 lan743x_csr_write(adapter, PTP_CLOCK_STEP_ADJ, in lan743x_ptp_clock_step()
1336 lan743x_csr_write(adapter, PTP_CLOCK_STEP_ADJ, in lan743x_ptp_clock_step()
1340 lan743x_csr_write(adapter, PTP_CMD_CTL, in lan743x_ptp_clock_step()
1342 lan743x_ptp_wait_till_cmd_done(adapter, in lan743x_ptp_clock_step()
1348 lan743x_csr_write(adapter, PTP_CLOCK_STEP_ADJ, in lan743x_ptp_clock_step()
1352 lan743x_csr_write(adapter, PTP_CMD_CTL, in lan743x_ptp_clock_step()
1354 lan743x_ptp_wait_till_cmd_done(adapter, in lan743x_ptp_clock_step()
1362 struct lan743x_adapter *adapter = (struct lan743x_adapter *)context; in lan743x_ptp_isr() local
1367 ptp = &adapter->ptp; in lan743x_ptp_isr()
1369 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_1588_); in lan743x_ptp_isr()
1371 ptp_int_sts = lan743x_csr_read(adapter, PTP_INT_STS); in lan743x_ptp_isr()
1372 ptp_int_sts &= lan743x_csr_read(adapter, PTP_INT_EN_SET); in lan743x_ptp_isr()
1379 netif_err(adapter, drv, adapter->netdev, in lan743x_ptp_isr()
1382 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptp_isr()
1387 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptp_isr()
1392 lan743x_csr_write(adapter, PTP_INT_STS, in lan743x_ptp_isr()
1398 lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_1588_); in lan743x_ptp_isr()
1402 static void lan743x_ptp_tx_ts_enqueue_skb(struct lan743x_adapter *adapter, in lan743x_ptp_tx_ts_enqueue_skb() argument
1405 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_tx_ts_enqueue_skb()
1419 netif_err(adapter, drv, adapter->netdev, in lan743x_ptp_tx_ts_enqueue_skb()
1426 static void lan743x_ptp_sync_to_system_clock(struct lan743x_adapter *adapter) in lan743x_ptp_sync_to_system_clock() argument
1432 lan743x_ptp_clock_set(adapter, ts.tv_sec, ts.tv_nsec, 0); in lan743x_ptp_sync_to_system_clock()
1435 void lan743x_ptp_update_latency(struct lan743x_adapter *adapter, in lan743x_ptp_update_latency() argument
1440 lan743x_csr_write(adapter, PTP_LATENCY, in lan743x_ptp_update_latency()
1445 lan743x_csr_write(adapter, PTP_LATENCY, in lan743x_ptp_update_latency()
1450 lan743x_csr_write(adapter, PTP_LATENCY, in lan743x_ptp_update_latency()
1457 int lan743x_ptp_init(struct lan743x_adapter *adapter) in lan743x_ptp_init() argument
1459 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_init()
1471 lan743x_led_mux_save(adapter); in lan743x_ptp_init()
1476 int lan743x_ptp_open(struct lan743x_adapter *adapter) in lan743x_ptp_open() argument
1478 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_open()
1484 lan743x_ptp_reset(adapter); in lan743x_ptp_open()
1485 lan743x_ptp_sync_to_system_clock(adapter); in lan743x_ptp_open()
1486 temp = lan743x_csr_read(adapter, PTP_TX_MOD2); in lan743x_ptp_open()
1488 lan743x_csr_write(adapter, PTP_TX_MOD2, temp); in lan743x_ptp_open()
1491 lan743x_rx_set_tstamp_mode(adapter, HWTSTAMP_FILTER_NONE); in lan743x_ptp_open()
1493 lan743x_ptp_enable(adapter); in lan743x_ptp_open()
1494 lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_1588_); in lan743x_ptp_open()
1495 lan743x_csr_write(adapter, PTP_INT_EN_SET, in lan743x_ptp_open()
1502 switch (adapter->csr.id_rev & ID_REV_ID_MASK_) { in lan743x_ptp_open()
1512 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_open()
1514 adapter->csr.id_rev); in lan743x_ptp_open()
1533 adapter->netdev->dev_addr); in lan743x_ptp_open()
1551 &adapter->pdev->dev); in lan743x_ptp_open()
1554 netif_err(adapter, ifup, adapter->netdev, in lan743x_ptp_open()
1559 netif_info(adapter, ifup, adapter->netdev, in lan743x_ptp_open()
1564 lan743x_ptp_close(adapter); in lan743x_ptp_open()
1568 void lan743x_ptp_close(struct lan743x_adapter *adapter) in lan743x_ptp_close() argument
1570 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_close()
1578 netif_info(adapter, drv, adapter->netdev, in lan743x_ptp_close()
1583 lan743x_csr_write(adapter, PTP_INT_EN_CLR, in lan743x_ptp_close()
1586 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_1588_); in lan743x_ptp_close()
1591 lan743x_ptp_tx_ts_complete(adapter); in lan743x_ptp_close()
1608 lan743x_led_mux_restore(adapter); in lan743x_ptp_close()
1610 lan743x_ptp_disable(adapter); in lan743x_ptp_close()
1613 static void lan743x_ptp_set_sync_ts_insert(struct lan743x_adapter *adapter, in lan743x_ptp_set_sync_ts_insert() argument
1616 u32 ptp_tx_mod = lan743x_csr_read(adapter, PTP_TX_MOD); in lan743x_ptp_set_sync_ts_insert()
1623 lan743x_csr_write(adapter, PTP_TX_MOD, ptp_tx_mod); in lan743x_ptp_set_sync_ts_insert()
1626 static bool lan743x_ptp_is_enabled(struct lan743x_adapter *adapter) in lan743x_ptp_is_enabled() argument
1628 if (lan743x_csr_read(adapter, PTP_CMD_CTL) & PTP_CMD_CTL_PTP_ENABLE_) in lan743x_ptp_is_enabled()
1633 static void lan743x_ptp_enable(struct lan743x_adapter *adapter) in lan743x_ptp_enable() argument
1635 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_enable()
1639 if (lan743x_ptp_is_enabled(adapter)) { in lan743x_ptp_enable()
1640 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_enable()
1644 lan743x_csr_write(adapter, PTP_CMD_CTL, PTP_CMD_CTL_PTP_ENABLE_); in lan743x_ptp_enable()
1649 static void lan743x_ptp_disable(struct lan743x_adapter *adapter) in lan743x_ptp_disable() argument
1651 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_disable()
1654 lan743x_rx_set_tstamp_mode(adapter, HWTSTAMP_FILTER_NONE); in lan743x_ptp_disable()
1657 if (!lan743x_ptp_is_enabled(adapter)) { in lan743x_ptp_disable()
1658 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_disable()
1662 lan743x_csr_write(adapter, PTP_CMD_CTL, PTP_CMD_CTL_PTP_DISABLE_); in lan743x_ptp_disable()
1663 lan743x_ptp_wait_till_cmd_done(adapter, PTP_CMD_CTL_PTP_ENABLE_); in lan743x_ptp_disable()
1668 static void lan743x_ptp_reset(struct lan743x_adapter *adapter) in lan743x_ptp_reset() argument
1670 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_reset()
1674 if (lan743x_ptp_is_enabled(adapter)) { in lan743x_ptp_reset()
1675 netif_err(adapter, drv, adapter->netdev, in lan743x_ptp_reset()
1680 lan743x_csr_write(adapter, PTP_CMD_CTL, PTP_CMD_CTL_PTP_RESET_); in lan743x_ptp_reset()
1681 lan743x_ptp_wait_till_cmd_done(adapter, PTP_CMD_CTL_PTP_RESET_); in lan743x_ptp_reset()
1686 static void lan743x_ptp_clock_set(struct lan743x_adapter *adapter, in lan743x_ptp_clock_set() argument
1690 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_clock_set()
1694 lan743x_csr_write(adapter, PTP_CLOCK_SEC, seconds); in lan743x_ptp_clock_set()
1695 lan743x_csr_write(adapter, PTP_CLOCK_NS, nano_seconds); in lan743x_ptp_clock_set()
1696 lan743x_csr_write(adapter, PTP_CLOCK_SUBNS, sub_nano_seconds); in lan743x_ptp_clock_set()
1698 lan743x_csr_write(adapter, PTP_CMD_CTL, PTP_CMD_CTL_PTP_CLOCK_LOAD_); in lan743x_ptp_clock_set()
1699 lan743x_ptp_wait_till_cmd_done(adapter, PTP_CMD_CTL_PTP_CLOCK_LOAD_); in lan743x_ptp_clock_set()
1703 bool lan743x_ptp_request_tx_timestamp(struct lan743x_adapter *adapter) in lan743x_ptp_request_tx_timestamp() argument
1705 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_request_tx_timestamp()
1718 void lan743x_ptp_unrequest_tx_timestamp(struct lan743x_adapter *adapter) in lan743x_ptp_unrequest_tx_timestamp() argument
1720 struct lan743x_ptp *ptp = &adapter->ptp; in lan743x_ptp_unrequest_tx_timestamp()
1726 netif_err(adapter, drv, adapter->netdev, in lan743x_ptp_unrequest_tx_timestamp()
1731 void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter, in lan743x_ptp_tx_timestamp_skb() argument
1734 lan743x_ptp_tx_ts_enqueue_skb(adapter, skb, ignore_sync); in lan743x_ptp_tx_timestamp_skb()
1736 lan743x_ptp_tx_ts_complete(adapter); in lan743x_ptp_tx_timestamp_skb()
1741 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_ptp_ioctl() local
1747 netif_err(adapter, drv, adapter->netdev, in lan743x_ptp_ioctl()
1757 for (index = 0; index < adapter->used_tx_channels; in lan743x_ptp_ioctl()
1759 lan743x_tx_set_timestamping_mode(&adapter->tx[index], in lan743x_ptp_ioctl()
1761 lan743x_ptp_set_sync_ts_insert(adapter, false); in lan743x_ptp_ioctl()
1764 for (index = 0; index < adapter->used_tx_channels; in lan743x_ptp_ioctl()
1766 lan743x_tx_set_timestamping_mode(&adapter->tx[index], in lan743x_ptp_ioctl()
1768 lan743x_ptp_set_sync_ts_insert(adapter, false); in lan743x_ptp_ioctl()
1771 for (index = 0; index < adapter->used_tx_channels; in lan743x_ptp_ioctl()
1773 lan743x_tx_set_timestamping_mode(&adapter->tx[index], in lan743x_ptp_ioctl()
1776 lan743x_ptp_set_sync_ts_insert(adapter, true); in lan743x_ptp_ioctl()
1782 netif_warn(adapter, drv, adapter->netdev, in lan743x_ptp_ioctl()
1788 ret = lan743x_rx_set_tstamp_mode(adapter, config.rx_filter); in lan743x_ptp_ioctl()