Lines Matching +full:ns +full:- +full:config
1 // SPDX-License-Identifier: GPL-2.0+
14 /* The 82580 timesync updates the system timer every 8ns by 8ns,
38 * +--------------+ +---+---+------+
40 * +--------------+ +---+---+------+
43 * +----------+---+ +--------------+
45 * +----------+---+ +--------------+
50 * 2^45 * 10^-9 / 3600 = 9.77 hours.
53 * 2^40 * 10^-9 / 60 = 18.3 minutes.
67 #define INCVALUE_82576_MASK GENMASK(E1000_TIMINCA_16NS_SHIFT - 1, 0)
79 struct e1000_hw *hw = &igb->hw; in igb_ptp_read_82576()
96 struct e1000_hw *hw = &igb->hw; in igb_ptp_read_82580()
118 struct e1000_hw *hw = &adapter->hw; in igb_ptp_read_i210()
129 ts->tv_sec = sec; in igb_ptp_read_i210()
130 ts->tv_nsec = nsec; in igb_ptp_read_i210()
136 struct e1000_hw *hw = &adapter->hw; in igb_ptp_write_i210()
139 * sub-nanosecond resolution. in igb_ptp_write_i210()
141 wr32(E1000_SYSTIML, ts->tv_nsec); in igb_ptp_write_i210()
142 wr32(E1000_SYSTIMH, (u32)ts->tv_sec); in igb_ptp_write_i210()
146 * igb_ptp_systim_to_hwtstamp - convert system time value to hw timestamp
167 u64 ns; in igb_ptp_systim_to_hwtstamp() local
171 switch (adapter->hw.mac.type) { in igb_ptp_systim_to_hwtstamp()
176 spin_lock_irqsave(&adapter->tmreg_lock, flags); in igb_ptp_systim_to_hwtstamp()
177 ns = timecounter_cyc2time(&adapter->tc, systim); in igb_ptp_systim_to_hwtstamp()
178 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in igb_ptp_systim_to_hwtstamp()
180 hwtstamps->hwtstamp = ns_to_ktime(ns); in igb_ptp_systim_to_hwtstamp()
184 /* Upper 32 bits contain s, lower 32 bits contain ns. */ in igb_ptp_systim_to_hwtstamp()
185 hwtstamps->hwtstamp = ktime_set(systim >> 32, in igb_ptp_systim_to_hwtstamp()
198 struct e1000_hw *hw = &igb->hw; in igb_ptp_adjfine_82576()
212 struct e1000_hw *hw = &igb->hw; in igb_ptp_adjfine_82580()
234 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_adjtime_82576()
235 timecounter_adjtime(&igb->tc, delta); in igb_ptp_adjtime_82576()
236 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_adjtime_82576()
248 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_adjtime_i210()
254 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_adjtime_i210()
265 struct e1000_hw *hw = &igb->hw; in igb_ptp_gettimex_82576()
268 u64 ns; in igb_ptp_gettimex_82576() local
270 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_gettimex_82576()
277 ns = timecounter_cyc2time(&igb->tc, ((u64)hi << 32) | lo); in igb_ptp_gettimex_82576()
279 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_gettimex_82576()
281 *ts = ns_to_timespec64(ns); in igb_ptp_gettimex_82576()
292 struct e1000_hw *hw = &igb->hw; in igb_ptp_gettimex_82580()
295 u64 ns; in igb_ptp_gettimex_82580() local
297 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_gettimex_82580()
305 ns = timecounter_cyc2time(&igb->tc, ((u64)hi << 32) | lo); in igb_ptp_gettimex_82580()
307 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_gettimex_82580()
309 *ts = ns_to_timespec64(ns); in igb_ptp_gettimex_82580()
320 struct e1000_hw *hw = &igb->hw; in igb_ptp_gettimex_i210()
323 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_gettimex_i210()
328 ts->tv_nsec = rd32(E1000_SYSTIML); in igb_ptp_gettimex_i210()
329 ts->tv_sec = rd32(E1000_SYSTIMH); in igb_ptp_gettimex_i210()
331 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_gettimex_i210()
342 u64 ns; in igb_ptp_settime_82576() local
344 ns = timespec64_to_ns(ts); in igb_ptp_settime_82576()
346 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_settime_82576()
348 timecounter_init(&igb->tc, &igb->cc, ns); in igb_ptp_settime_82576()
350 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_settime_82576()
362 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_settime_i210()
366 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_settime_i210()
398 struct e1000_hw *hw = &igb->hw; in igb_pin_extts()
454 struct e1000_hw *hw = &igb->hw; in igb_pin_perout()
496 struct e1000_hw *hw = &igb->hw; in igb_ptp_feature_enable_82580()
500 int pin = -1; in igb_ptp_feature_enable_82580()
501 s64 ns; in igb_ptp_feature_enable_82580() local
503 switch (rq->type) { in igb_ptp_feature_enable_82580()
506 if (rq->extts.flags & PTP_STRICT_FLAGS && in igb_ptp_feature_enable_82580()
507 (rq->extts.flags & PTP_ENABLE_FEATURE) && in igb_ptp_feature_enable_82580()
508 (rq->extts.flags & PTP_EXTTS_EDGES) != PTP_EXTTS_EDGES) in igb_ptp_feature_enable_82580()
509 return -EOPNOTSUPP; in igb_ptp_feature_enable_82580()
512 pin = ptp_find_pin(igb->ptp_clock, PTP_PF_EXTTS, in igb_ptp_feature_enable_82580()
513 rq->extts.index); in igb_ptp_feature_enable_82580()
515 return -EBUSY; in igb_ptp_feature_enable_82580()
517 if (rq->extts.index == 1) { in igb_ptp_feature_enable_82580()
524 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_82580()
528 igb_pin_extts(igb, rq->extts.index, pin); in igb_ptp_feature_enable_82580()
537 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_82580()
542 if (rq->perout.flags) in igb_ptp_feature_enable_82580()
543 return -EOPNOTSUPP; in igb_ptp_feature_enable_82580()
546 pin = ptp_find_pin(igb->ptp_clock, PTP_PF_PEROUT, in igb_ptp_feature_enable_82580()
547 rq->perout.index); in igb_ptp_feature_enable_82580()
549 return -EBUSY; in igb_ptp_feature_enable_82580()
551 ts.tv_sec = rq->perout.period.sec; in igb_ptp_feature_enable_82580()
552 ts.tv_nsec = rq->perout.period.nsec; in igb_ptp_feature_enable_82580()
553 ns = timespec64_to_ns(&ts); in igb_ptp_feature_enable_82580()
554 ns = ns >> 1; in igb_ptp_feature_enable_82580()
555 if (on && ns < 8LL) in igb_ptp_feature_enable_82580()
556 return -EINVAL; in igb_ptp_feature_enable_82580()
557 ts = ns_to_timespec64(ns); in igb_ptp_feature_enable_82580()
558 if (rq->perout.index == 1) { in igb_ptp_feature_enable_82580()
569 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_82580()
572 if (rq->perout.index == 1) { in igb_ptp_feature_enable_82580()
580 int i = rq->perout.index; in igb_ptp_feature_enable_82580()
587 now = timecounter_cyc2time(&igb->tc, systim); in igb_ptp_feature_enable_82580()
597 div_u64_rem(now, ns, &rem); in igb_ptp_feature_enable_82580()
598 systim = systim + (ns - rem); in igb_ptp_feature_enable_82580()
601 div_u64_rem(now, ns << 1, &rem); in igb_ptp_feature_enable_82580()
602 if (rem < ns) { in igb_ptp_feature_enable_82580()
606 systim += ns; in igb_ptp_feature_enable_82580()
612 systim += ns; in igb_ptp_feature_enable_82580()
616 start = ns_to_timespec64(systim + (ns - rem)); in igb_ptp_feature_enable_82580()
618 igb->perout[i].start.tv_sec = start.tv_sec; in igb_ptp_feature_enable_82580()
619 igb->perout[i].start.tv_nsec = start.tv_nsec; in igb_ptp_feature_enable_82580()
620 igb->perout[i].period.tv_sec = ts.tv_sec; in igb_ptp_feature_enable_82580()
621 igb->perout[i].period.tv_nsec = ts.tv_nsec; in igb_ptp_feature_enable_82580()
630 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_82580()
634 return -EOPNOTSUPP; in igb_ptp_feature_enable_82580()
637 return -EOPNOTSUPP; in igb_ptp_feature_enable_82580()
645 struct e1000_hw *hw = &igb->hw; in igb_ptp_feature_enable_i210()
649 int use_freq = 0, pin = -1; in igb_ptp_feature_enable_i210()
650 s64 ns; in igb_ptp_feature_enable_i210() local
652 switch (rq->type) { in igb_ptp_feature_enable_i210()
655 if ((rq->extts.flags & PTP_STRICT_FLAGS) && in igb_ptp_feature_enable_i210()
656 (rq->extts.flags & PTP_ENABLE_FEATURE) && in igb_ptp_feature_enable_i210()
657 (rq->extts.flags & PTP_EXTTS_EDGES) != PTP_EXTTS_EDGES) in igb_ptp_feature_enable_i210()
658 return -EOPNOTSUPP; in igb_ptp_feature_enable_i210()
661 pin = ptp_find_pin(igb->ptp_clock, PTP_PF_EXTTS, in igb_ptp_feature_enable_i210()
662 rq->extts.index); in igb_ptp_feature_enable_i210()
664 return -EBUSY; in igb_ptp_feature_enable_i210()
666 if (rq->extts.index == 1) { in igb_ptp_feature_enable_i210()
673 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_i210()
677 igb_pin_extts(igb, rq->extts.index, pin); in igb_ptp_feature_enable_i210()
686 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_i210()
691 if (rq->perout.flags) in igb_ptp_feature_enable_i210()
692 return -EOPNOTSUPP; in igb_ptp_feature_enable_i210()
695 pin = ptp_find_pin(igb->ptp_clock, PTP_PF_PEROUT, in igb_ptp_feature_enable_i210()
696 rq->perout.index); in igb_ptp_feature_enable_i210()
698 return -EBUSY; in igb_ptp_feature_enable_i210()
700 ts.tv_sec = rq->perout.period.sec; in igb_ptp_feature_enable_i210()
701 ts.tv_nsec = rq->perout.period.nsec; in igb_ptp_feature_enable_i210()
702 ns = timespec64_to_ns(&ts); in igb_ptp_feature_enable_i210()
703 ns = ns >> 1; in igb_ptp_feature_enable_i210()
704 if (on && ((ns <= 70000000LL) || (ns == 125000000LL) || in igb_ptp_feature_enable_i210()
705 (ns == 250000000LL) || (ns == 500000000LL))) { in igb_ptp_feature_enable_i210()
706 if (ns < 8LL) in igb_ptp_feature_enable_i210()
707 return -EINVAL; in igb_ptp_feature_enable_i210()
710 ts = ns_to_timespec64(ns); in igb_ptp_feature_enable_i210()
711 if (rq->perout.index == 1) { in igb_ptp_feature_enable_i210()
734 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_i210()
737 if (rq->perout.index == 1) { in igb_ptp_feature_enable_i210()
745 int i = rq->perout.index; in igb_ptp_feature_enable_i210()
747 igb->perout[i].start.tv_sec = rq->perout.start.sec; in igb_ptp_feature_enable_i210()
748 igb->perout[i].start.tv_nsec = rq->perout.start.nsec; in igb_ptp_feature_enable_i210()
749 igb->perout[i].period.tv_sec = ts.tv_sec; in igb_ptp_feature_enable_i210()
750 igb->perout[i].period.tv_nsec = ts.tv_nsec; in igb_ptp_feature_enable_i210()
751 wr32(trgttimh, rq->perout.start.sec); in igb_ptp_feature_enable_i210()
752 wr32(trgttiml, rq->perout.start.nsec); in igb_ptp_feature_enable_i210()
754 wr32(freqout, ns); in igb_ptp_feature_enable_i210()
760 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_i210()
764 spin_lock_irqsave(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_i210()
770 igb->pps_sys_wrap_on = !!on; in igb_ptp_feature_enable_i210()
772 spin_unlock_irqrestore(&igb->tmreg_lock, flags); in igb_ptp_feature_enable_i210()
776 return -EOPNOTSUPP; in igb_ptp_feature_enable_i210()
782 return -EOPNOTSUPP; in igb_ptp_feature_enable()
794 return -1; in igb_ptp_verify_pin()
810 struct e1000_hw *hw = &adapter->hw; in igb_ptp_tx_work()
813 if (!adapter->ptp_tx_skb) in igb_ptp_tx_work()
816 if (time_is_before_jiffies(adapter->ptp_tx_start + in igb_ptp_tx_work()
818 dev_kfree_skb_any(adapter->ptp_tx_skb); in igb_ptp_tx_work()
819 adapter->ptp_tx_skb = NULL; in igb_ptp_tx_work()
820 clear_bit_unlock(__IGB_PTP_TX_IN_PROGRESS, &adapter->state); in igb_ptp_tx_work()
821 adapter->tx_hwtstamp_timeouts++; in igb_ptp_tx_work()
826 dev_warn(&adapter->pdev->dev, "clearing Tx timestamp hang\n"); in igb_ptp_tx_work()
835 schedule_work(&adapter->ptp_tx_work); in igb_ptp_tx_work()
843 u64 ns; in igb_ptp_overflow_check() local
846 ns = timecounter_read(&igb->tc); in igb_ptp_overflow_check()
848 ts = ns_to_timespec64(ns); in igb_ptp_overflow_check()
852 schedule_delayed_work(&igb->ptp_overflow_work, in igb_ptp_overflow_check()
857 * igb_ptp_rx_hang - detect error case when Rx timestamp registers latched
867 struct e1000_hw *hw = &adapter->hw; in igb_ptp_rx_hang()
871 /* Other hardware uses per-packet timestamps */ in igb_ptp_rx_hang()
872 if (hw->mac.type != e1000_82576) in igb_ptp_rx_hang()
879 adapter->last_rx_ptp_check = jiffies; in igb_ptp_rx_hang()
884 rx_event = adapter->last_rx_ptp_check; in igb_ptp_rx_hang()
885 if (time_after(adapter->last_rx_timestamp, rx_event)) in igb_ptp_rx_hang()
886 rx_event = adapter->last_rx_timestamp; in igb_ptp_rx_hang()
891 adapter->last_rx_ptp_check = jiffies; in igb_ptp_rx_hang()
892 adapter->rx_hwtstamp_cleared++; in igb_ptp_rx_hang()
893 dev_warn(&adapter->pdev->dev, "clearing Rx timestamp hang\n"); in igb_ptp_rx_hang()
898 * igb_ptp_tx_hang - detect error case where Tx timestamp never finishes
903 struct e1000_hw *hw = &adapter->hw; in igb_ptp_tx_hang()
904 bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + in igb_ptp_tx_hang()
907 if (!adapter->ptp_tx_skb) in igb_ptp_tx_hang()
910 if (!test_bit(__IGB_PTP_TX_IN_PROGRESS, &adapter->state)) in igb_ptp_tx_hang()
918 cancel_work_sync(&adapter->ptp_tx_work); in igb_ptp_tx_hang()
919 dev_kfree_skb_any(adapter->ptp_tx_skb); in igb_ptp_tx_hang()
920 adapter->ptp_tx_skb = NULL; in igb_ptp_tx_hang()
921 clear_bit_unlock(__IGB_PTP_TX_IN_PROGRESS, &adapter->state); in igb_ptp_tx_hang()
922 adapter->tx_hwtstamp_timeouts++; in igb_ptp_tx_hang()
927 dev_warn(&adapter->pdev->dev, "clearing Tx timestamp hang\n"); in igb_ptp_tx_hang()
932 * igb_ptp_tx_hwtstamp - utility function which checks for TX time stamp
941 struct sk_buff *skb = adapter->ptp_tx_skb; in igb_ptp_tx_hwtstamp()
942 struct e1000_hw *hw = &adapter->hw; in igb_ptp_tx_hwtstamp()
952 if (hw->mac.type == e1000_i210 || hw->mac.type == e1000_i211) { in igb_ptp_tx_hwtstamp()
953 switch (adapter->link_speed) { in igb_ptp_tx_hwtstamp()
974 adapter->ptp_tx_skb = NULL; in igb_ptp_tx_hwtstamp()
975 clear_bit_unlock(__IGB_PTP_TX_IN_PROGRESS, &adapter->state); in igb_ptp_tx_hwtstamp()
983 * igb_ptp_rx_pktstamp - retrieve Rx per packet timestamp
997 struct igb_adapter *adapter = q_vector->adapter; in igb_ptp_rx_pktstamp()
998 struct e1000_hw *hw = &adapter->hw; in igb_ptp_rx_pktstamp()
1003 if (!(adapter->ptp_flags & IGB_PTP_ENABLED)) in igb_ptp_rx_pktstamp()
1018 if (hw->mac.type == e1000_i210 || hw->mac.type == e1000_i211) { in igb_ptp_rx_pktstamp()
1019 switch (adapter->link_speed) { in igb_ptp_rx_pktstamp()
1038 * igb_ptp_rx_rgtstamp - retrieve Rx timestamp stored in register
1047 struct igb_adapter *adapter = q_vector->adapter; in igb_ptp_rx_rgtstamp()
1048 struct e1000_hw *hw = &adapter->hw; in igb_ptp_rx_rgtstamp()
1052 if (!(adapter->ptp_flags & IGB_PTP_ENABLED)) in igb_ptp_rx_rgtstamp()
1074 if (adapter->hw.mac.type == e1000_i210) { in igb_ptp_rx_rgtstamp()
1075 switch (adapter->link_speed) { in igb_ptp_rx_rgtstamp()
1087 skb_hwtstamps(skb)->hwtstamp = in igb_ptp_rx_rgtstamp()
1088 ktime_sub_ns(skb_hwtstamps(skb)->hwtstamp, adjust); in igb_ptp_rx_rgtstamp()
1093 adapter->last_rx_timestamp = jiffies; in igb_ptp_rx_rgtstamp()
1097 * igb_ptp_hwtstamp_get - get hardware time stamping config
1099 * @config: timestamping configuration structure
1106 struct kernel_hwtstamp_config *config) in igb_ptp_hwtstamp_get() argument
1110 *config = adapter->tstamp_config; in igb_ptp_hwtstamp_get()
1116 * igb_ptp_set_timestamp_mode - setup hardware for timestamping
1118 * @config: hwtstamp configuration
1133 struct kernel_hwtstamp_config *config) in igb_ptp_set_timestamp_mode() argument
1135 struct e1000_hw *hw = &adapter->hw; in igb_ptp_set_timestamp_mode()
1143 switch (config->tx_type) { in igb_ptp_set_timestamp_mode()
1150 return -ERANGE; in igb_ptp_set_timestamp_mode()
1153 switch (config->rx_filter) { in igb_ptp_set_timestamp_mode()
1177 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; in igb_ptp_set_timestamp_mode()
1187 if (hw->mac.type != e1000_82576) { in igb_ptp_set_timestamp_mode()
1189 config->rx_filter = HWTSTAMP_FILTER_ALL; in igb_ptp_set_timestamp_mode()
1194 config->rx_filter = HWTSTAMP_FILTER_NONE; in igb_ptp_set_timestamp_mode()
1195 return -ERANGE; in igb_ptp_set_timestamp_mode()
1198 if (hw->mac.type == e1000_82575) { in igb_ptp_set_timestamp_mode()
1200 return -EINVAL; in igb_ptp_set_timestamp_mode()
1204 /* Per-packet timestamping only works if all packets are in igb_ptp_set_timestamp_mode()
1208 if ((hw->mac.type >= e1000_82580) && tsync_rx_ctl) { in igb_ptp_set_timestamp_mode()
1211 config->rx_filter = HWTSTAMP_FILTER_ALL; in igb_ptp_set_timestamp_mode()
1215 if ((hw->mac.type == e1000_i210) || in igb_ptp_set_timestamp_mode()
1216 (hw->mac.type == e1000_i211)) { in igb_ptp_set_timestamp_mode()
1258 if (hw->mac.type == e1000_82576) { in igb_ptp_set_timestamp_mode()
1279 * igb_ptp_hwtstamp_set - set hardware time stamping config
1281 * @config: timestamping configuration structure
1285 struct kernel_hwtstamp_config *config, in igb_ptp_hwtstamp_set() argument
1291 err = igb_ptp_set_timestamp_mode(adapter, config); in igb_ptp_hwtstamp_set()
1296 adapter->tstamp_config = *config; in igb_ptp_hwtstamp_set()
1302 * igb_ptp_init - Initialize PTP functionality
1310 struct e1000_hw *hw = &adapter->hw; in igb_ptp_init()
1311 struct net_device *netdev = adapter->netdev; in igb_ptp_init()
1313 switch (hw->mac.type) { in igb_ptp_init()
1315 snprintf(adapter->ptp_caps.name, 16, "%pm", netdev->dev_addr); in igb_ptp_init()
1316 adapter->ptp_caps.owner = THIS_MODULE; in igb_ptp_init()
1317 adapter->ptp_caps.max_adj = 999999881; in igb_ptp_init()
1318 adapter->ptp_caps.n_ext_ts = 0; in igb_ptp_init()
1319 adapter->ptp_caps.pps = 0; in igb_ptp_init()
1320 adapter->ptp_caps.adjfine = igb_ptp_adjfine_82576; in igb_ptp_init()
1321 adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576; in igb_ptp_init()
1322 adapter->ptp_caps.gettimex64 = igb_ptp_gettimex_82576; in igb_ptp_init()
1323 adapter->ptp_caps.settime64 = igb_ptp_settime_82576; in igb_ptp_init()
1324 adapter->ptp_caps.enable = igb_ptp_feature_enable; in igb_ptp_init()
1325 adapter->cc.read = igb_ptp_read_82576; in igb_ptp_init()
1326 adapter->cc.mask = CYCLECOUNTER_MASK(64); in igb_ptp_init()
1327 adapter->cc.mult = 1; in igb_ptp_init()
1328 adapter->cc.shift = IGB_82576_TSYNC_SHIFT; in igb_ptp_init()
1329 adapter->ptp_flags |= IGB_PTP_OVERFLOW_CHECK; in igb_ptp_init()
1335 snprintf(adapter->ptp_caps.name, 16, "%pm", netdev->dev_addr); in igb_ptp_init()
1336 adapter->ptp_caps.owner = THIS_MODULE; in igb_ptp_init()
1337 adapter->ptp_caps.max_adj = 62499999; in igb_ptp_init()
1338 adapter->ptp_caps.n_ext_ts = IGB_N_EXTTS; in igb_ptp_init()
1339 adapter->ptp_caps.n_per_out = IGB_N_PEROUT; in igb_ptp_init()
1340 adapter->ptp_caps.n_pins = IGB_N_SDP; in igb_ptp_init()
1341 adapter->ptp_caps.pps = 0; in igb_ptp_init()
1342 adapter->ptp_caps.supported_extts_flags = PTP_RISING_EDGE | in igb_ptp_init()
1345 adapter->ptp_caps.pin_config = adapter->sdp_config; in igb_ptp_init()
1346 adapter->ptp_caps.adjfine = igb_ptp_adjfine_82580; in igb_ptp_init()
1347 adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576; in igb_ptp_init()
1348 adapter->ptp_caps.gettimex64 = igb_ptp_gettimex_82580; in igb_ptp_init()
1349 adapter->ptp_caps.settime64 = igb_ptp_settime_82576; in igb_ptp_init()
1350 adapter->ptp_caps.enable = igb_ptp_feature_enable_82580; in igb_ptp_init()
1351 adapter->ptp_caps.verify = igb_ptp_verify_pin; in igb_ptp_init()
1352 adapter->cc.read = igb_ptp_read_82580; in igb_ptp_init()
1353 adapter->cc.mask = CYCLECOUNTER_MASK(IGB_NBITS_82580); in igb_ptp_init()
1354 adapter->cc.mult = 1; in igb_ptp_init()
1355 adapter->cc.shift = 0; in igb_ptp_init()
1356 adapter->ptp_flags |= IGB_PTP_OVERFLOW_CHECK; in igb_ptp_init()
1361 snprintf(adapter->ptp_caps.name, 16, "%pm", netdev->dev_addr); in igb_ptp_init()
1362 adapter->ptp_caps.owner = THIS_MODULE; in igb_ptp_init()
1363 adapter->ptp_caps.max_adj = 62499999; in igb_ptp_init()
1364 adapter->ptp_caps.n_ext_ts = IGB_N_EXTTS; in igb_ptp_init()
1365 adapter->ptp_caps.n_per_out = IGB_N_PEROUT; in igb_ptp_init()
1366 adapter->ptp_caps.n_pins = IGB_N_SDP; in igb_ptp_init()
1367 adapter->ptp_caps.supported_extts_flags = PTP_RISING_EDGE | in igb_ptp_init()
1370 adapter->ptp_caps.pps = 1; in igb_ptp_init()
1371 adapter->ptp_caps.pin_config = adapter->sdp_config; in igb_ptp_init()
1372 adapter->ptp_caps.adjfine = igb_ptp_adjfine_82580; in igb_ptp_init()
1373 adapter->ptp_caps.adjtime = igb_ptp_adjtime_i210; in igb_ptp_init()
1374 adapter->ptp_caps.gettimex64 = igb_ptp_gettimex_i210; in igb_ptp_init()
1375 adapter->ptp_caps.settime64 = igb_ptp_settime_i210; in igb_ptp_init()
1376 adapter->ptp_caps.enable = igb_ptp_feature_enable_i210; in igb_ptp_init()
1377 adapter->ptp_caps.verify = igb_ptp_verify_pin; in igb_ptp_init()
1380 adapter->ptp_clock = NULL; in igb_ptp_init()
1384 adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps, in igb_ptp_init()
1385 &adapter->pdev->dev); in igb_ptp_init()
1386 if (IS_ERR(adapter->ptp_clock)) { in igb_ptp_init()
1387 adapter->ptp_clock = NULL; in igb_ptp_init()
1388 dev_err(&adapter->pdev->dev, "ptp_clock_register failed\n"); in igb_ptp_init()
1389 } else if (adapter->ptp_clock) { in igb_ptp_init()
1390 dev_info(&adapter->pdev->dev, "added PHC on %s\n", in igb_ptp_init()
1391 adapter->netdev->name); in igb_ptp_init()
1392 adapter->ptp_flags |= IGB_PTP_ENABLED; in igb_ptp_init()
1394 spin_lock_init(&adapter->tmreg_lock); in igb_ptp_init()
1395 INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work); in igb_ptp_init()
1397 if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK) in igb_ptp_init()
1398 INIT_DELAYED_WORK(&adapter->ptp_overflow_work, in igb_ptp_init()
1401 adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in igb_ptp_init()
1402 adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF; in igb_ptp_init()
1409 * igb_ptp_sdp_init - utility function which inits the SDP config structs
1417 struct ptp_pin_desc *ppd = &adapter->sdp_config[i]; in igb_ptp_sdp_init()
1419 snprintf(ppd->name, sizeof(ppd->name), "SDP%d", i); in igb_ptp_sdp_init()
1420 ppd->index = i; in igb_ptp_sdp_init()
1421 ppd->func = PTP_PF_NONE; in igb_ptp_sdp_init()
1426 * igb_ptp_suspend - Disable PTP work items and prepare for suspend
1434 if (!(adapter->ptp_flags & IGB_PTP_ENABLED)) in igb_ptp_suspend()
1437 if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK) in igb_ptp_suspend()
1438 cancel_delayed_work_sync(&adapter->ptp_overflow_work); in igb_ptp_suspend()
1440 cancel_work_sync(&adapter->ptp_tx_work); in igb_ptp_suspend()
1441 if (adapter->ptp_tx_skb) { in igb_ptp_suspend()
1442 dev_kfree_skb_any(adapter->ptp_tx_skb); in igb_ptp_suspend()
1443 adapter->ptp_tx_skb = NULL; in igb_ptp_suspend()
1444 clear_bit_unlock(__IGB_PTP_TX_IN_PROGRESS, &adapter->state); in igb_ptp_suspend()
1449 * igb_ptp_stop - Disable PTP device and stop the overflow check.
1458 if (adapter->ptp_clock) { in igb_ptp_stop()
1459 ptp_clock_unregister(adapter->ptp_clock); in igb_ptp_stop()
1460 dev_info(&adapter->pdev->dev, "removed PHC on %s\n", in igb_ptp_stop()
1461 adapter->netdev->name); in igb_ptp_stop()
1462 adapter->ptp_flags &= ~IGB_PTP_ENABLED; in igb_ptp_stop()
1467 * igb_ptp_reset - Re-enable the adapter for PTP following a reset.
1470 * This function handles the reset work required to re-enable the PTP device.
1474 struct e1000_hw *hw = &adapter->hw; in igb_ptp_reset()
1478 igb_ptp_set_timestamp_mode(adapter, &adapter->tstamp_config); in igb_ptp_reset()
1480 spin_lock_irqsave(&adapter->tmreg_lock, flags); in igb_ptp_reset()
1482 switch (adapter->hw.mac.type) { in igb_ptp_reset()
1496 (adapter->pps_sys_wrap_on ? TSINTR_SYS_WRAP : 0)); in igb_ptp_reset()
1504 /* Re-initialize the timer. */ in igb_ptp_reset()
1505 if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) { in igb_ptp_reset()
1510 timecounter_init(&adapter->tc, &adapter->cc, in igb_ptp_reset()
1514 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in igb_ptp_reset()
1518 if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK) in igb_ptp_reset()
1519 schedule_delayed_work(&adapter->ptp_overflow_work, in igb_ptp_reset()