@@ -275,17 +275,53 @@ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta)
275
275
return 0 ;
276
276
}
277
277
278
- static int igb_ptp_gettime_82576 (struct ptp_clock_info * ptp ,
279
- struct timespec64 * ts )
278
+ static int igb_ptp_gettimex_82576 (struct ptp_clock_info * ptp ,
279
+ struct timespec64 * ts ,
280
+ struct ptp_system_timestamp * sts )
280
281
{
281
282
struct igb_adapter * igb = container_of (ptp , struct igb_adapter ,
282
283
ptp_caps );
284
+ struct e1000_hw * hw = & igb -> hw ;
283
285
unsigned long flags ;
286
+ u32 lo , hi ;
284
287
u64 ns ;
285
288
286
289
spin_lock_irqsave (& igb -> tmreg_lock , flags );
287
290
288
- ns = timecounter_read (& igb -> tc );
291
+ ptp_read_system_prets (sts );
292
+ lo = rd32 (E1000_SYSTIML );
293
+ ptp_read_system_postts (sts );
294
+ hi = rd32 (E1000_SYSTIMH );
295
+
296
+ ns = timecounter_cyc2time (& igb -> tc , ((u64 )hi << 32 ) | lo );
297
+
298
+ spin_unlock_irqrestore (& igb -> tmreg_lock , flags );
299
+
300
+ * ts = ns_to_timespec64 (ns );
301
+
302
+ return 0 ;
303
+ }
304
+
305
+ static int igb_ptp_gettimex_82580 (struct ptp_clock_info * ptp ,
306
+ struct timespec64 * ts ,
307
+ struct ptp_system_timestamp * sts )
308
+ {
309
+ struct igb_adapter * igb = container_of (ptp , struct igb_adapter ,
310
+ ptp_caps );
311
+ struct e1000_hw * hw = & igb -> hw ;
312
+ unsigned long flags ;
313
+ u32 lo , hi ;
314
+ u64 ns ;
315
+
316
+ spin_lock_irqsave (& igb -> tmreg_lock , flags );
317
+
318
+ ptp_read_system_prets (sts );
319
+ rd32 (E1000_SYSTIMR );
320
+ ptp_read_system_postts (sts );
321
+ lo = rd32 (E1000_SYSTIML );
322
+ hi = rd32 (E1000_SYSTIMH );
323
+
324
+ ns = timecounter_cyc2time (& igb -> tc , ((u64 )hi << 32 ) | lo );
289
325
290
326
spin_unlock_irqrestore (& igb -> tmreg_lock , flags );
291
327
@@ -294,16 +330,22 @@ static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp,
294
330
return 0 ;
295
331
}
296
332
297
- static int igb_ptp_gettime_i210 (struct ptp_clock_info * ptp ,
298
- struct timespec64 * ts )
333
+ static int igb_ptp_gettimex_i210 (struct ptp_clock_info * ptp ,
334
+ struct timespec64 * ts ,
335
+ struct ptp_system_timestamp * sts )
299
336
{
300
337
struct igb_adapter * igb = container_of (ptp , struct igb_adapter ,
301
338
ptp_caps );
339
+ struct e1000_hw * hw = & igb -> hw ;
302
340
unsigned long flags ;
303
341
304
342
spin_lock_irqsave (& igb -> tmreg_lock , flags );
305
343
306
- igb_ptp_read_i210 (igb , ts );
344
+ ptp_read_system_prets (sts );
345
+ rd32 (E1000_SYSTIMR );
346
+ ptp_read_system_postts (sts );
347
+ ts -> tv_nsec = rd32 (E1000_SYSTIML );
348
+ ts -> tv_sec = rd32 (E1000_SYSTIMH );
307
349
308
350
spin_unlock_irqrestore (& igb -> tmreg_lock , flags );
309
351
@@ -656,9 +698,12 @@ static void igb_ptp_overflow_check(struct work_struct *work)
656
698
struct igb_adapter * igb =
657
699
container_of (work , struct igb_adapter , ptp_overflow_work .work );
658
700
struct timespec64 ts ;
701
+ u64 ns ;
659
702
660
- igb -> ptp_caps .gettime64 (& igb -> ptp_caps , & ts );
703
+ /* Update the timecounter */
704
+ ns = timecounter_read (& igb -> tc );
661
705
706
+ ts = ns_to_timespec64 (ns );
662
707
pr_debug ("igb overflow check at %lld.%09lu\n" ,
663
708
(long long ) ts .tv_sec , ts .tv_nsec );
664
709
@@ -1124,7 +1169,7 @@ void igb_ptp_init(struct igb_adapter *adapter)
1124
1169
adapter -> ptp_caps .pps = 0 ;
1125
1170
adapter -> ptp_caps .adjfreq = igb_ptp_adjfreq_82576 ;
1126
1171
adapter -> ptp_caps .adjtime = igb_ptp_adjtime_82576 ;
1127
- adapter -> ptp_caps .gettime64 = igb_ptp_gettime_82576 ;
1172
+ adapter -> ptp_caps .gettimex64 = igb_ptp_gettimex_82576 ;
1128
1173
adapter -> ptp_caps .settime64 = igb_ptp_settime_82576 ;
1129
1174
adapter -> ptp_caps .enable = igb_ptp_feature_enable ;
1130
1175
adapter -> cc .read = igb_ptp_read_82576 ;
@@ -1143,7 +1188,7 @@ void igb_ptp_init(struct igb_adapter *adapter)
1143
1188
adapter -> ptp_caps .pps = 0 ;
1144
1189
adapter -> ptp_caps .adjfine = igb_ptp_adjfine_82580 ;
1145
1190
adapter -> ptp_caps .adjtime = igb_ptp_adjtime_82576 ;
1146
- adapter -> ptp_caps .gettime64 = igb_ptp_gettime_82576 ;
1191
+ adapter -> ptp_caps .gettimex64 = igb_ptp_gettimex_82580 ;
1147
1192
adapter -> ptp_caps .settime64 = igb_ptp_settime_82576 ;
1148
1193
adapter -> ptp_caps .enable = igb_ptp_feature_enable ;
1149
1194
adapter -> cc .read = igb_ptp_read_82580 ;
@@ -1171,7 +1216,7 @@ void igb_ptp_init(struct igb_adapter *adapter)
1171
1216
adapter -> ptp_caps .pin_config = adapter -> sdp_config ;
1172
1217
adapter -> ptp_caps .adjfine = igb_ptp_adjfine_82580 ;
1173
1218
adapter -> ptp_caps .adjtime = igb_ptp_adjtime_i210 ;
1174
- adapter -> ptp_caps .gettime64 = igb_ptp_gettime_i210 ;
1219
+ adapter -> ptp_caps .gettimex64 = igb_ptp_gettimex_i210 ;
1175
1220
adapter -> ptp_caps .settime64 = igb_ptp_settime_i210 ;
1176
1221
adapter -> ptp_caps .enable = igb_ptp_feature_enable_i210 ;
1177
1222
adapter -> ptp_caps .verify = igb_ptp_verify_pin ;
0 commit comments