18
18
19
19
#define MV88E6XXX_MAX_ADJ_PPB 1000000
20
20
21
+ struct mv88e6xxx_cc_coeffs {
22
+ u32 cc_shift ;
23
+ u32 cc_mult ;
24
+ u32 cc_mult_num ;
25
+ u32 cc_mult_dem ;
26
+ };
27
+
21
28
/* Family MV88E6250:
22
29
* Raw timestamps are in units of 10-ns clock periods.
23
30
*
24
31
* clkadj = scaled_ppm * 10*2^28 / (10^6 * 2^16)
25
32
* simplifies to
26
33
* clkadj = scaled_ppm * 2^7 / 5^5
27
34
*/
28
- #define MV88E6250_CC_SHIFT 28
29
- #define MV88E6250_CC_MULT (10 << MV88E6250_CC_SHIFT)
30
- #define MV88E6250_CC_MULT_NUM (1 << 7)
31
- #define MV88E6250_CC_MULT_DEM 3125ULL
35
+ #define MV88E6250_CC_SHIFT 28
36
+ static const struct mv88e6xxx_cc_coeffs mv88e6250_cc_coeffs = {
37
+ .cc_shift = MV88E6250_CC_SHIFT ,
38
+ .cc_mult = 10 << MV88E6250_CC_SHIFT ,
39
+ .cc_mult_num = 1 << 7 ,
40
+ .cc_mult_dem = 3125ULL ,
41
+ };
32
42
33
43
/* Other families:
34
44
* Raw timestamps are in units of 8-ns clock periods.
37
47
* simplifies to
38
48
* clkadj = scaled_ppm * 2^9 / 5^6
39
49
*/
40
- #define MV88E6XXX_CC_SHIFT 28
41
- #define MV88E6XXX_CC_MULT (8 << MV88E6XXX_CC_SHIFT)
42
- #define MV88E6XXX_CC_MULT_NUM (1 << 9)
43
- #define MV88E6XXX_CC_MULT_DEM 15625ULL
50
+ #define MV88E6XXX_CC_SHIFT 28
51
+ static const struct mv88e6xxx_cc_coeffs mv88e6xxx_cc_coeffs = {
52
+ .cc_shift = MV88E6XXX_CC_SHIFT ,
53
+ .cc_mult = 8 << MV88E6XXX_CC_SHIFT ,
54
+ .cc_mult_num = 1 << 9 ,
55
+ .cc_mult_dem = 15625ULL
56
+ };
44
57
45
58
#define TAI_EVENT_WORK_INTERVAL msecs_to_jiffies(100)
46
59
@@ -214,10 +227,10 @@ static int mv88e6xxx_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
214
227
scaled_ppm = - scaled_ppm ;
215
228
}
216
229
217
- mult = ptp_ops -> cc_mult ;
218
- adj = ptp_ops -> cc_mult_num ;
230
+ mult = ptp_ops -> cc_coeffs -> cc_mult ;
231
+ adj = ptp_ops -> cc_coeffs -> cc_mult_num ;
219
232
adj *= scaled_ppm ;
220
- diff = div_u64 (adj , ptp_ops -> cc_mult_dem );
233
+ diff = div_u64 (adj , ptp_ops -> cc_coeffs -> cc_mult_dem );
221
234
222
235
mv88e6xxx_reg_lock (chip );
223
236
@@ -364,10 +377,7 @@ const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops = {
364
377
(1 << HWTSTAMP_FILTER_PTP_V2_EVENT ) |
365
378
(1 << HWTSTAMP_FILTER_PTP_V2_SYNC ) |
366
379
(1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ ),
367
- .cc_shift = MV88E6XXX_CC_SHIFT ,
368
- .cc_mult = MV88E6XXX_CC_MULT ,
369
- .cc_mult_num = MV88E6XXX_CC_MULT_NUM ,
370
- .cc_mult_dem = MV88E6XXX_CC_MULT_DEM ,
380
+ .cc_coeffs = & mv88e6xxx_cc_coeffs
371
381
};
372
382
373
383
const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops = {
@@ -391,10 +401,7 @@ const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops = {
391
401
(1 << HWTSTAMP_FILTER_PTP_V2_EVENT ) |
392
402
(1 << HWTSTAMP_FILTER_PTP_V2_SYNC ) |
393
403
(1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ ),
394
- .cc_shift = MV88E6250_CC_SHIFT ,
395
- .cc_mult = MV88E6250_CC_MULT ,
396
- .cc_mult_num = MV88E6250_CC_MULT_NUM ,
397
- .cc_mult_dem = MV88E6250_CC_MULT_DEM ,
404
+ .cc_coeffs = & mv88e6250_cc_coeffs ,
398
405
};
399
406
400
407
const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {
@@ -418,10 +425,7 @@ const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {
418
425
(1 << HWTSTAMP_FILTER_PTP_V2_EVENT ) |
419
426
(1 << HWTSTAMP_FILTER_PTP_V2_SYNC ) |
420
427
(1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ ),
421
- .cc_shift = MV88E6XXX_CC_SHIFT ,
422
- .cc_mult = MV88E6XXX_CC_MULT ,
423
- .cc_mult_num = MV88E6XXX_CC_MULT_NUM ,
424
- .cc_mult_dem = MV88E6XXX_CC_MULT_DEM ,
428
+ .cc_coeffs = & mv88e6xxx_cc_coeffs ,
425
429
};
426
430
427
431
const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = {
@@ -446,10 +450,7 @@ const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = {
446
450
(1 << HWTSTAMP_FILTER_PTP_V2_EVENT ) |
447
451
(1 << HWTSTAMP_FILTER_PTP_V2_SYNC ) |
448
452
(1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ ),
449
- .cc_shift = MV88E6XXX_CC_SHIFT ,
450
- .cc_mult = MV88E6XXX_CC_MULT ,
451
- .cc_mult_num = MV88E6XXX_CC_MULT_NUM ,
452
- .cc_mult_dem = MV88E6XXX_CC_MULT_DEM ,
453
+ .cc_coeffs = & mv88e6xxx_cc_coeffs ,
453
454
};
454
455
455
456
static u64 mv88e6xxx_ptp_clock_read (const struct cyclecounter * cc )
@@ -487,8 +488,8 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip)
487
488
memset (& chip -> tstamp_cc , 0 , sizeof (chip -> tstamp_cc ));
488
489
chip -> tstamp_cc .read = mv88e6xxx_ptp_clock_read ;
489
490
chip -> tstamp_cc .mask = CYCLECOUNTER_MASK (32 );
490
- chip -> tstamp_cc .mult = ptp_ops -> cc_mult ;
491
- chip -> tstamp_cc .shift = ptp_ops -> cc_shift ;
491
+ chip -> tstamp_cc .mult = ptp_ops -> cc_coeffs -> cc_mult ;
492
+ chip -> tstamp_cc .shift = ptp_ops -> cc_coeffs -> cc_shift ;
492
493
493
494
timecounter_init (& chip -> tstamp_tc , & chip -> tstamp_cc ,
494
495
ktime_to_ns (ktime_get_real ()));
0 commit comments