1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019 Intel Corporation */
6 #include <linux/module.h>
7 #include <linux/device.h>
9 #include <linux/ptp_classify.h>
10 #include <linux/clocksource.h>
12 #define INCVALUE_MASK 0x7fffffff
13 #define ISGN 0x80000000
15 #define IGC_SYSTIM_OVERFLOW_PERIOD (HZ * 60 * 9)
16 #define IGC_PTP_TX_TIMEOUT (HZ * 15)
18 /* SYSTIM read access for I225 */
19 static void igc_ptp_read_i225(struct igc_adapter
*adapter
,
20 struct timespec64
*ts
)
22 struct igc_hw
*hw
= &adapter
->hw
;
25 /* The timestamp latches on lowest register read. For I210/I211, the
26 * lowest register is SYSTIMR. Since we only need to provide nanosecond
27 * resolution, we can ignore it.
30 nsec
= rd32(IGC_SYSTIML
);
31 sec
= rd32(IGC_SYSTIMH
);
37 static void igc_ptp_write_i225(struct igc_adapter
*adapter
,
38 const struct timespec64
*ts
)
40 struct igc_hw
*hw
= &adapter
->hw
;
42 /* Writing the SYSTIMR register is not necessary as it only
43 * provides sub-nanosecond resolution.
45 wr32(IGC_SYSTIML
, ts
->tv_nsec
);
46 wr32(IGC_SYSTIMH
, ts
->tv_sec
);
49 static int igc_ptp_adjfine_i225(struct ptp_clock_info
*ptp
, long scaled_ppm
)
51 struct igc_adapter
*igc
= container_of(ptp
, struct igc_adapter
,
53 struct igc_hw
*hw
= &igc
->hw
;
60 scaled_ppm
= -scaled_ppm
;
64 rate
= div_u64(rate
, 78125);
66 inca
= rate
& INCVALUE_MASK
;
70 wr32(IGC_TIMINCA
, inca
);
75 static int igc_ptp_adjtime_i225(struct ptp_clock_info
*ptp
, s64 delta
)
77 struct igc_adapter
*igc
= container_of(ptp
, struct igc_adapter
,
79 struct timespec64 now
, then
= ns_to_timespec64(delta
);
82 spin_lock_irqsave(&igc
->tmreg_lock
, flags
);
84 igc_ptp_read_i225(igc
, &now
);
85 now
= timespec64_add(now
, then
);
86 igc_ptp_write_i225(igc
, (const struct timespec64
*)&now
);
88 spin_unlock_irqrestore(&igc
->tmreg_lock
, flags
);
93 static int igc_ptp_gettimex64_i225(struct ptp_clock_info
*ptp
,
94 struct timespec64
*ts
,
95 struct ptp_system_timestamp
*sts
)
97 struct igc_adapter
*igc
= container_of(ptp
, struct igc_adapter
,
99 struct igc_hw
*hw
= &igc
->hw
;
102 spin_lock_irqsave(&igc
->tmreg_lock
, flags
);
104 ptp_read_system_prets(sts
);
106 ptp_read_system_postts(sts
);
107 ts
->tv_nsec
= rd32(IGC_SYSTIML
);
108 ts
->tv_sec
= rd32(IGC_SYSTIMH
);
110 spin_unlock_irqrestore(&igc
->tmreg_lock
, flags
);
115 static int igc_ptp_settime_i225(struct ptp_clock_info
*ptp
,
116 const struct timespec64
*ts
)
118 struct igc_adapter
*igc
= container_of(ptp
, struct igc_adapter
,
122 spin_lock_irqsave(&igc
->tmreg_lock
, flags
);
124 igc_ptp_write_i225(igc
, ts
);
126 spin_unlock_irqrestore(&igc
->tmreg_lock
, flags
);
131 static int igc_ptp_feature_enable_i225(struct ptp_clock_info
*ptp
,
132 struct ptp_clock_request
*rq
, int on
)
138 * igc_ptp_systim_to_hwtstamp - convert system time value to HW timestamp
139 * @adapter: board private structure
140 * @hwtstamps: timestamp structure to update
141 * @systim: unsigned 64bit system time value
143 * We need to convert the system time value stored in the RX/TXSTMP registers
144 * into a hwtstamp which can be used by the upper level timestamping functions.
146 static void igc_ptp_systim_to_hwtstamp(struct igc_adapter
*adapter
,
147 struct skb_shared_hwtstamps
*hwtstamps
,
150 switch (adapter
->hw
.mac
.type
) {
152 memset(hwtstamps
, 0, sizeof(*hwtstamps
));
153 /* Upper 32 bits contain s, lower 32 bits contain ns. */
154 hwtstamps
->hwtstamp
= ktime_set(systim
>> 32,
155 systim
& 0xFFFFFFFF);
163 * igc_ptp_rx_pktstamp - retrieve Rx per packet timestamp
164 * @q_vector: Pointer to interrupt specific structure
165 * @va: Pointer to address containing Rx buffer
166 * @skb: Buffer containing timestamp and packet
168 * This function is meant to retrieve the first timestamp from the
169 * first buffer of an incoming frame. The value is stored in little
170 * endian format starting on byte 0. There's a second timestamp
171 * starting on byte 8.
173 void igc_ptp_rx_pktstamp(struct igc_q_vector
*q_vector
, void *va
,
176 struct igc_adapter
*adapter
= q_vector
->adapter
;
177 __le64
*regval
= (__le64
*)va
;
180 /* The timestamp is recorded in little endian format.
181 * DWORD: | 0 | 1 | 2 | 3
182 * Field: | Timer0 Low | Timer0 High | Timer1 Low | Timer1 High
184 igc_ptp_systim_to_hwtstamp(adapter
, skb_hwtstamps(skb
),
185 le64_to_cpu(regval
[0]));
187 /* adjust timestamp for the RX latency based on link speed */
188 if (adapter
->hw
.mac
.type
== igc_i225
) {
189 switch (adapter
->link_speed
) {
191 adjust
= IGC_I225_RX_LATENCY_10
;
194 adjust
= IGC_I225_RX_LATENCY_100
;
197 adjust
= IGC_I225_RX_LATENCY_1000
;
200 adjust
= IGC_I225_RX_LATENCY_2500
;
204 skb_hwtstamps(skb
)->hwtstamp
=
205 ktime_sub_ns(skb_hwtstamps(skb
)->hwtstamp
, adjust
);
209 * igc_ptp_rx_rgtstamp - retrieve Rx timestamp stored in register
210 * @q_vector: Pointer to interrupt specific structure
211 * @skb: Buffer containing timestamp and packet
213 * This function is meant to retrieve a timestamp from the internal registers
214 * of the adapter and store it in the skb.
216 void igc_ptp_rx_rgtstamp(struct igc_q_vector
*q_vector
,
219 struct igc_adapter
*adapter
= q_vector
->adapter
;
220 struct igc_hw
*hw
= &adapter
->hw
;
223 /* If this bit is set, then the RX registers contain the time
224 * stamp. No other packet will be time stamped until we read
225 * these registers, so read the registers to make them
226 * available again. Because only one packet can be time
227 * stamped at a time, we know that the register values must
228 * belong to this one here and therefore we don't need to
229 * compare any of the additional attributes stored for it.
231 * If nothing went wrong, then it should have a shared
232 * tx_flags that we can turn into a skb_shared_hwtstamps.
234 if (!(rd32(IGC_TSYNCRXCTL
) & IGC_TSYNCRXCTL_VALID
))
237 regval
= rd32(IGC_RXSTMPL
);
238 regval
|= (u64
)rd32(IGC_RXSTMPH
) << 32;
240 igc_ptp_systim_to_hwtstamp(adapter
, skb_hwtstamps(skb
), regval
);
242 /* Update the last_rx_timestamp timer in order to enable watchdog check
243 * for error case of latched timestamp on a dropped packet.
245 adapter
->last_rx_timestamp
= jiffies
;
249 * igc_ptp_enable_tstamp_rxqueue - Enable RX timestamp for a queue
250 * @rx_ring: Pointer to RX queue
251 * @timer: Index for timer
253 * This function enables RX timestamping for a queue, and selects
254 * which 1588 timer will provide the timestamp.
256 static void igc_ptp_enable_tstamp_rxqueue(struct igc_adapter
*adapter
,
257 struct igc_ring
*rx_ring
, u8 timer
)
259 struct igc_hw
*hw
= &adapter
->hw
;
260 int reg_idx
= rx_ring
->reg_idx
;
261 u32 srrctl
= rd32(IGC_SRRCTL(reg_idx
));
263 srrctl
|= IGC_SRRCTL_TIMESTAMP
;
264 srrctl
|= IGC_SRRCTL_TIMER1SEL(timer
);
265 srrctl
|= IGC_SRRCTL_TIMER0SEL(timer
);
267 wr32(IGC_SRRCTL(reg_idx
), srrctl
);
270 static void igc_ptp_enable_tstamp_all_rxqueues(struct igc_adapter
*adapter
,
275 for (i
= 0; i
< adapter
->num_rx_queues
; i
++) {
276 struct igc_ring
*ring
= adapter
->rx_ring
[i
];
278 igc_ptp_enable_tstamp_rxqueue(adapter
, ring
, timer
);
283 * igc_ptp_set_timestamp_mode - setup hardware for timestamping
284 * @adapter: networking device structure
285 * @config: hwtstamp configuration
287 * Outgoing time stamping can be enabled and disabled. Play nice and
288 * disable it when requested, although it shouldn't case any overhead
289 * when no packet needs it. At most one packet in the queue may be
290 * marked for time stamping, otherwise it would be impossible to tell
291 * for sure to which packet the hardware time stamp belongs.
293 * Incoming time stamping has to be configured via the hardware
294 * filters. Not all combinations are supported, in particular event
295 * type has to be specified. Matching the kind of event packet is
296 * not supported, with the exception of "all V2 events regardless of
300 static int igc_ptp_set_timestamp_mode(struct igc_adapter
*adapter
,
301 struct hwtstamp_config
*config
)
303 u32 tsync_tx_ctl
= IGC_TSYNCTXCTL_ENABLED
;
304 u32 tsync_rx_ctl
= IGC_TSYNCRXCTL_ENABLED
;
305 struct igc_hw
*hw
= &adapter
->hw
;
306 u32 tsync_rx_cfg
= 0;
311 /* reserved for future extensions */
315 switch (config
->tx_type
) {
316 case HWTSTAMP_TX_OFF
:
324 switch (config
->rx_filter
) {
325 case HWTSTAMP_FILTER_NONE
:
328 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC
:
329 tsync_rx_ctl
|= IGC_TSYNCRXCTL_TYPE_L4_V1
;
330 tsync_rx_cfg
= IGC_TSYNCRXCFG_PTP_V1_SYNC_MESSAGE
;
333 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ
:
334 tsync_rx_ctl
|= IGC_TSYNCRXCTL_TYPE_L4_V1
;
335 tsync_rx_cfg
= IGC_TSYNCRXCFG_PTP_V1_DELAY_REQ_MESSAGE
;
338 case HWTSTAMP_FILTER_PTP_V2_EVENT
:
339 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT
:
340 case HWTSTAMP_FILTER_PTP_V2_L4_EVENT
:
341 case HWTSTAMP_FILTER_PTP_V2_SYNC
:
342 case HWTSTAMP_FILTER_PTP_V2_L2_SYNC
:
343 case HWTSTAMP_FILTER_PTP_V2_L4_SYNC
:
344 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ
:
345 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ
:
346 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ
:
347 tsync_rx_ctl
|= IGC_TSYNCRXCTL_TYPE_EVENT_V2
;
348 config
->rx_filter
= HWTSTAMP_FILTER_PTP_V2_EVENT
;
352 case HWTSTAMP_FILTER_PTP_V1_L4_EVENT
:
353 case HWTSTAMP_FILTER_NTP_ALL
:
354 case HWTSTAMP_FILTER_ALL
:
355 tsync_rx_ctl
|= IGC_TSYNCRXCTL_TYPE_ALL
;
356 config
->rx_filter
= HWTSTAMP_FILTER_ALL
;
360 config
->rx_filter
= HWTSTAMP_FILTER_NONE
;
364 /* Per-packet timestamping only works if all packets are
365 * timestamped, so enable timestamping in all packets as long
366 * as one Rx filter was configured.
369 tsync_rx_ctl
= IGC_TSYNCRXCTL_ENABLED
;
370 tsync_rx_ctl
|= IGC_TSYNCRXCTL_TYPE_ALL
;
371 tsync_rx_ctl
|= IGC_TSYNCRXCTL_RXSYNSIG
;
372 config
->rx_filter
= HWTSTAMP_FILTER_ALL
;
376 if (hw
->mac
.type
== igc_i225
) {
377 regval
= rd32(IGC_RXPBS
);
378 regval
|= IGC_RXPBS_CFG_TS_EN
;
379 wr32(IGC_RXPBS
, regval
);
381 /* FIXME: For now, only support retrieving RX
382 * timestamps from timer 0
384 igc_ptp_enable_tstamp_all_rxqueues(adapter
, 0);
389 tsync_tx_ctl
= IGC_TSYNCTXCTL_ENABLED
;
390 tsync_tx_ctl
|= IGC_TSYNCTXCTL_TXSYNSIG
;
393 /* enable/disable TX */
394 regval
= rd32(IGC_TSYNCTXCTL
);
395 regval
&= ~IGC_TSYNCTXCTL_ENABLED
;
396 regval
|= tsync_tx_ctl
;
397 wr32(IGC_TSYNCTXCTL
, regval
);
399 /* enable/disable RX */
400 regval
= rd32(IGC_TSYNCRXCTL
);
401 regval
&= ~(IGC_TSYNCRXCTL_ENABLED
| IGC_TSYNCRXCTL_TYPE_MASK
);
402 regval
|= tsync_rx_ctl
;
403 wr32(IGC_TSYNCRXCTL
, regval
);
405 /* define which PTP packets are time stamped */
406 wr32(IGC_TSYNCRXCFG
, tsync_rx_cfg
);
408 /* define ethertype filter for timestamped packets */
411 (IGC_ETQF_FILTER_ENABLE
| /* enable filter */
412 IGC_ETQF_1588
| /* enable timestamping */
413 ETH_P_1588
)); /* 1588 eth protocol type */
415 wr32(IGC_ETQF(3), 0);
417 /* L4 Queue Filter[3]: filter by destination port and protocol */
419 u32 ftqf
= (IPPROTO_UDP
/* UDP */
420 | IGC_FTQF_VF_BP
/* VF not compared */
421 | IGC_FTQF_1588_TIME_STAMP
/* Enable Timestamp */
422 | IGC_FTQF_MASK
); /* mask all inputs */
423 ftqf
&= ~IGC_FTQF_MASK_PROTO_BP
; /* enable protocol check */
425 wr32(IGC_IMIR(3), htons(PTP_EV_PORT
));
427 (IGC_IMIREXT_SIZE_BP
| IGC_IMIREXT_CTRL_BP
));
428 wr32(IGC_FTQF(3), ftqf
);
430 wr32(IGC_FTQF(3), IGC_FTQF_MASK
);
434 /* clear TX/RX time stamp registers, just to be sure */
435 regval
= rd32(IGC_TXSTMPL
);
436 regval
= rd32(IGC_TXSTMPH
);
437 regval
= rd32(IGC_RXSTMPL
);
438 regval
= rd32(IGC_RXSTMPH
);
443 void igc_ptp_tx_hang(struct igc_adapter
*adapter
)
445 bool timeout
= time_is_before_jiffies(adapter
->ptp_tx_start
+
447 struct igc_hw
*hw
= &adapter
->hw
;
449 if (!adapter
->ptp_tx_skb
)
452 if (!test_bit(__IGC_PTP_TX_IN_PROGRESS
, &adapter
->state
))
455 /* If we haven't received a timestamp within the timeout, it is
456 * reasonable to assume that it will never occur, so we can unlock the
457 * timestamp bit when this occurs.
460 cancel_work_sync(&adapter
->ptp_tx_work
);
461 dev_kfree_skb_any(adapter
->ptp_tx_skb
);
462 adapter
->ptp_tx_skb
= NULL
;
463 clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS
, &adapter
->state
);
464 adapter
->tx_hwtstamp_timeouts
++;
465 /* Clear the Tx valid bit in TSYNCTXCTL register to enable
469 dev_warn(&adapter
->pdev
->dev
, "clearing Tx timestamp hang\n");
474 * igc_ptp_tx_hwtstamp - utility function which checks for TX time stamp
475 * @adapter: Board private structure
477 * If we were asked to do hardware stamping and such a time stamp is
478 * available, then it must have been for this skb here because we only
479 * allow only one such packet into the queue.
481 static void igc_ptp_tx_hwtstamp(struct igc_adapter
*adapter
)
483 struct sk_buff
*skb
= adapter
->ptp_tx_skb
;
484 struct skb_shared_hwtstamps shhwtstamps
;
485 struct igc_hw
*hw
= &adapter
->hw
;
488 regval
= rd32(IGC_TXSTMPL
);
489 regval
|= (u64
)rd32(IGC_TXSTMPH
) << 32;
490 igc_ptp_systim_to_hwtstamp(adapter
, &shhwtstamps
, regval
);
492 /* Clear the lock early before calling skb_tstamp_tx so that
493 * applications are not woken up before the lock bit is clear. We use
494 * a copy of the skb pointer to ensure other threads can't change it
495 * while we're notifying the stack.
497 adapter
->ptp_tx_skb
= NULL
;
498 clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS
, &adapter
->state
);
500 /* Notify the stack and free the skb after we've unlocked */
501 skb_tstamp_tx(skb
, &shhwtstamps
);
502 dev_kfree_skb_any(skb
);
507 * @work: pointer to work struct
509 * This work function polls the TSYNCTXCTL valid bit to determine when a
510 * timestamp has been taken for the current stored skb.
512 static void igc_ptp_tx_work(struct work_struct
*work
)
514 struct igc_adapter
*adapter
= container_of(work
, struct igc_adapter
,
516 struct igc_hw
*hw
= &adapter
->hw
;
519 if (!adapter
->ptp_tx_skb
)
522 if (time_is_before_jiffies(adapter
->ptp_tx_start
+
523 IGC_PTP_TX_TIMEOUT
)) {
524 dev_kfree_skb_any(adapter
->ptp_tx_skb
);
525 adapter
->ptp_tx_skb
= NULL
;
526 clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS
, &adapter
->state
);
527 adapter
->tx_hwtstamp_timeouts
++;
528 /* Clear the tx valid bit in TSYNCTXCTL register to enable
532 dev_warn(&adapter
->pdev
->dev
, "clearing Tx timestamp hang\n");
536 tsynctxctl
= rd32(IGC_TSYNCTXCTL
);
537 if (tsynctxctl
& IGC_TSYNCTXCTL_VALID
)
538 igc_ptp_tx_hwtstamp(adapter
);
540 /* reschedule to check later */
541 schedule_work(&adapter
->ptp_tx_work
);
545 * igc_ptp_set_ts_config - set hardware time stamping config
546 * @netdev: network interface device structure
547 * @ifreq: interface request data
550 int igc_ptp_set_ts_config(struct net_device
*netdev
, struct ifreq
*ifr
)
552 struct igc_adapter
*adapter
= netdev_priv(netdev
);
553 struct hwtstamp_config config
;
556 if (copy_from_user(&config
, ifr
->ifr_data
, sizeof(config
)))
559 err
= igc_ptp_set_timestamp_mode(adapter
, &config
);
563 /* save these settings for future reference */
564 memcpy(&adapter
->tstamp_config
, &config
,
565 sizeof(adapter
->tstamp_config
));
567 return copy_to_user(ifr
->ifr_data
, &config
, sizeof(config
)) ?
572 * igc_ptp_get_ts_config - get hardware time stamping config
573 * @netdev: network interface device structure
574 * @ifreq: interface request data
576 * Get the hwtstamp_config settings to return to the user. Rather than attempt
577 * to deconstruct the settings from the registers, just return a shadow copy
578 * of the last known settings.
580 int igc_ptp_get_ts_config(struct net_device
*netdev
, struct ifreq
*ifr
)
582 struct igc_adapter
*adapter
= netdev_priv(netdev
);
583 struct hwtstamp_config
*config
= &adapter
->tstamp_config
;
585 return copy_to_user(ifr
->ifr_data
, config
, sizeof(*config
)) ?
590 * igc_ptp_init - Initialize PTP functionality
591 * @adapter: Board private structure
593 * This function is called at device probe to initialize the PTP
596 void igc_ptp_init(struct igc_adapter
*adapter
)
598 struct net_device
*netdev
= adapter
->netdev
;
599 struct igc_hw
*hw
= &adapter
->hw
;
601 switch (hw
->mac
.type
) {
603 snprintf(adapter
->ptp_caps
.name
, 16, "%pm", netdev
->dev_addr
);
604 adapter
->ptp_caps
.owner
= THIS_MODULE
;
605 adapter
->ptp_caps
.max_adj
= 62499999;
606 adapter
->ptp_caps
.adjfine
= igc_ptp_adjfine_i225
;
607 adapter
->ptp_caps
.adjtime
= igc_ptp_adjtime_i225
;
608 adapter
->ptp_caps
.gettimex64
= igc_ptp_gettimex64_i225
;
609 adapter
->ptp_caps
.settime64
= igc_ptp_settime_i225
;
610 adapter
->ptp_caps
.enable
= igc_ptp_feature_enable_i225
;
613 adapter
->ptp_clock
= NULL
;
617 spin_lock_init(&adapter
->tmreg_lock
);
618 INIT_WORK(&adapter
->ptp_tx_work
, igc_ptp_tx_work
);
620 adapter
->tstamp_config
.rx_filter
= HWTSTAMP_FILTER_NONE
;
621 adapter
->tstamp_config
.tx_type
= HWTSTAMP_TX_OFF
;
623 igc_ptp_reset(adapter
);
625 adapter
->ptp_clock
= ptp_clock_register(&adapter
->ptp_caps
,
626 &adapter
->pdev
->dev
);
627 if (IS_ERR(adapter
->ptp_clock
)) {
628 adapter
->ptp_clock
= NULL
;
629 dev_err(&adapter
->pdev
->dev
, "ptp_clock_register failed\n");
630 } else if (adapter
->ptp_clock
) {
631 dev_info(&adapter
->pdev
->dev
, "added PHC on %s\n",
632 adapter
->netdev
->name
);
633 adapter
->ptp_flags
|= IGC_PTP_ENABLED
;
638 * igc_ptp_suspend - Disable PTP work items and prepare for suspend
639 * @adapter: Board private structure
641 * This function stops the overflow check work and PTP Tx timestamp work, and
642 * will prepare the device for OS suspend.
644 void igc_ptp_suspend(struct igc_adapter
*adapter
)
646 if (!(adapter
->ptp_flags
& IGC_PTP_ENABLED
))
649 cancel_work_sync(&adapter
->ptp_tx_work
);
650 if (adapter
->ptp_tx_skb
) {
651 dev_kfree_skb_any(adapter
->ptp_tx_skb
);
652 adapter
->ptp_tx_skb
= NULL
;
653 clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS
, &adapter
->state
);
658 * igc_ptp_stop - Disable PTP device and stop the overflow check.
659 * @adapter: Board private structure.
661 * This function stops the PTP support and cancels the delayed work.
663 void igc_ptp_stop(struct igc_adapter
*adapter
)
665 igc_ptp_suspend(adapter
);
667 if (adapter
->ptp_clock
) {
668 ptp_clock_unregister(adapter
->ptp_clock
);
669 dev_info(&adapter
->pdev
->dev
, "removed PHC on %s\n",
670 adapter
->netdev
->name
);
671 adapter
->ptp_flags
&= ~IGC_PTP_ENABLED
;
676 * igc_ptp_reset - Re-enable the adapter for PTP following a reset.
677 * @adapter: Board private structure.
679 * This function handles the reset work required to re-enable the PTP device.
681 void igc_ptp_reset(struct igc_adapter
*adapter
)
683 struct igc_hw
*hw
= &adapter
->hw
;
686 /* reset the tstamp_config */
687 igc_ptp_set_timestamp_mode(adapter
, &adapter
->tstamp_config
);
689 spin_lock_irqsave(&adapter
->tmreg_lock
, flags
);
691 switch (adapter
->hw
.mac
.type
) {
693 wr32(IGC_TSAUXC
, 0x0);
694 wr32(IGC_TSSDP
, 0x0);
695 wr32(IGC_TSIM
, IGC_TSICR_INTERRUPTS
);
696 wr32(IGC_IMS
, IGC_IMS_TS
);
703 /* Re-initialize the timer. */
704 if (hw
->mac
.type
== igc_i225
) {
705 struct timespec64 ts64
= ktime_to_timespec64(ktime_get_real());
707 igc_ptp_write_i225(adapter
, &ts64
);
709 timecounter_init(&adapter
->tc
, &adapter
->cc
,
710 ktime_to_ns(ktime_get_real()));
713 spin_unlock_irqrestore(&adapter
->tmreg_lock
, flags
);