|
16 | 16 | #include <linux/if_hsr.h>
|
17 | 17 | #include <linux/if_vlan.h>
|
18 | 18 | #include <linux/interrupt.h>
|
| 19 | +#include <linux/io-64-nonatomic-hi-lo.h> |
19 | 20 | #include <linux/kernel.h>
|
20 | 21 | #include <linux/mfd/syscon.h>
|
21 | 22 | #include <linux/module.h>
|
@@ -411,6 +412,8 @@ static int prueth_perout_enable(void *clockops_data,
|
411 | 412 | struct prueth_emac *emac = clockops_data;
|
412 | 413 | u32 reduction_factor = 0, offset = 0;
|
413 | 414 | struct timespec64 ts;
|
| 415 | + u64 current_cycle; |
| 416 | + u64 start_offset; |
414 | 417 | u64 ns_period;
|
415 | 418 |
|
416 | 419 | if (!on)
|
@@ -449,8 +452,14 @@ static int prueth_perout_enable(void *clockops_data,
|
449 | 452 | writel(reduction_factor, emac->prueth->shram.va +
|
450 | 453 | TIMESYNC_FW_WC_SYNCOUT_REDUCTION_FACTOR_OFFSET);
|
451 | 454 |
|
452 |
| - writel(0, emac->prueth->shram.va + |
453 |
| - TIMESYNC_FW_WC_SYNCOUT_START_TIME_CYCLECOUNT_OFFSET); |
| 455 | + current_cycle = icssg_read_time(emac->prueth->shram.va + |
| 456 | + TIMESYNC_FW_WC_CYCLECOUNT_OFFSET); |
| 457 | + |
| 458 | + /* Rounding of current_cycle count to next second */ |
| 459 | + start_offset = roundup(current_cycle, MSEC_PER_SEC); |
| 460 | + |
| 461 | + hi_lo_writeq(start_offset, emac->prueth->shram.va + |
| 462 | + TIMESYNC_FW_WC_SYNCOUT_START_TIME_CYCLECOUNT_OFFSET); |
454 | 463 |
|
455 | 464 | return 0;
|
456 | 465 | }
|
|
0 commit comments