* [PATCH net-next 1/1] net: fec: ptp: correct the ENET_ATCOR value
@ 2015-06-05 9:22 Fugang Duan
2015-06-07 22:31 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Fugang Duan @ 2015-06-05 9:22 UTC (permalink / raw)
To: richardcochran, davem; +Cc: netdev, B20596, b38611
From: Fugang Duan <b38611@freescale.com>
The current driver adjust freq formula is:
fe * diff = ppb * pc
Note:
fe: ENET ref clock frequency in Hz
diff = inc_corr - inc: difference between default increment and correction increment
ppb: parts per billion adjustment from base
pc: correction period (in number of fe clock cycles)
The correction increment will be used after N cycles of regular increments,
not every N cycles (with N being the correction period). For example, set ENET_ATCOR=4,
INC=8, INC_CORR=9, there will be 4 increments of 8 (ENET_ATINC[INC]) , followed by 1
increment of 9 (ENET_ATINC[INC_CORR]).
So, the correct formula is:
fe * diff = ppb * (pc + 1)
For ENET_ATCOR, a value 0 disables the correction counter and no corrections occur.
So base on the origin formula, set pc = pc > 1 ? pc - 1 : pc.
Signed-off-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: Frank Li <Frank.Li@freescale.com>
---
drivers/net/ethernet/freescale/fec_ptp.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index 2daf42e..9eb81fa 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -353,6 +353,7 @@ static int fec_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
tmp = readl(fep->hwp + FEC_ATIME_INC) & FEC_T_INC_MASK;
tmp |= corr_ns << FEC_T_INC_CORR_OFFSET;
writel(tmp, fep->hwp + FEC_ATIME_INC);
+ corr_period = corr_period > 1 ? corr_period - 1 : corr_period;
writel(corr_period, fep->hwp + FEC_ATIME_CORR);
/* dummy read to update the timer. */
timecounter_read(&fep->tc);
--
1.7.8
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next 1/1] net: fec: ptp: correct the ENET_ATCOR value
2015-06-05 9:22 [PATCH net-next 1/1] net: fec: ptp: correct the ENET_ATCOR value Fugang Duan
@ 2015-06-07 22:31 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-06-07 22:31 UTC (permalink / raw)
To: B38611; +Cc: richardcochran, netdev, B20596
From: Fugang Duan <B38611@freescale.com>
Date: Fri, 5 Jun 2015 17:22:08 +0800
> From: Fugang Duan <b38611@freescale.com>
>
> The current driver adjust freq formula is:
> fe * diff = ppb * pc
> Note:
> fe: ENET ref clock frequency in Hz
> diff = inc_corr - inc: difference between default increment and correction increment
> ppb: parts per billion adjustment from base
> pc: correction period (in number of fe clock cycles)
>
> The correction increment will be used after N cycles of regular increments,
> not every N cycles (with N being the correction period). For example, set ENET_ATCOR=4,
> INC=8, INC_CORR=9, there will be 4 increments of 8 (ENET_ATINC[INC]) , followed by 1
> increment of 9 (ENET_ATINC[INC_CORR]).
>
> So, the correct formula is:
> fe * diff = ppb * (pc + 1)
>
> For ENET_ATCOR, a value 0 disables the correction counter and no corrections occur.
> So base on the origin formula, set pc = pc > 1 ? pc - 1 : pc.
>
> Signed-off-by: Fugang Duan <B38611@freescale.com>
> Signed-off-by: Frank Li <Frank.Li@freescale.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-07 22:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-05 9:22 [PATCH net-next 1/1] net: fec: ptp: correct the ENET_ATCOR value Fugang Duan
2015-06-07 22:31 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).