[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z4KnPlCtlhHjFI6z@hoboy.vegasvil.org>
Date: Sat, 11 Jan 2025 09:15:42 -0800
From: Richard Cochran <richardcochran@...il.com>
To: Jiawen Wu <jiawenwu@...stnetic.com>
Cc: andrew+netdev@...n.ch, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com, linux@...linux.org.uk,
horms@...nel.org, jacob.e.keller@...el.com, netdev@...r.kernel.org,
vadim.fedorenko@...ux.dev, mengyuanlou@...-swift.com
Subject: Re: [PATCH net-next v3 4/4] net: ngbe: Add support for 1PPS and TOD
On Fri, Jan 10, 2025 at 11:17:16AM +0800, Jiawen Wu wrote:
When I quickly scan the logic here...
> + /* Figure out how far past the next second we are */
> + div_u64_rem(ns, WX_NS_PER_SEC, &rem);
> +
> + /* Figure out how many nanoseconds to add to round the clock edge up
> + * to the next full second
> + */
> + rem = (WX_NS_PER_SEC - rem);
> +
> + /* Adjust the clock edge to align with the next full second. */
> + wx->pps_edge_start += div_u64(((u64)rem << cc->shift), cc->mult);
> + trgttiml0 = (u32)wx->pps_edge_start;
> + trgttimh0 = (u32)(wx->pps_edge_start >> 32);
> +
> + wx_set_pps(wx, wx->pps_enabled, ns + rem, wx->pps_edge_start);
> +
> + rem += wx->pps_width;
> + wx->pps_edge_end += div_u64(((u64)rem << cc->shift), cc->mult);
> + trgttiml1 = (u32)wx->pps_edge_end;
> + trgttimh1 = (u32)(wx->pps_edge_end >> 32);
> +
> + wr32ptp(wx, WX_TSC_1588_TRGT_L(0), trgttiml0);
> + wr32ptp(wx, WX_TSC_1588_TRGT_H(0), trgttimh0);
> + wr32ptp(wx, WX_TSC_1588_TRGT_L(1), trgttiml1);
> + wr32ptp(wx, WX_TSC_1588_TRGT_H(1), trgttimh1);
> + wr32ptp(wx, WX_TSC_1588_SDP(0), tssdp);
> + wr32ptp(wx, WX_TSC_1588_SDP(1), tssdp1);
> + wr32ptp(wx, WX_TSC_1588_AUX_CTL, tsauxc);
> + wr32ptp(wx, WX_TSC_1588_INT_EN, WX_TSC_1588_INT_EN_TT1);
> + WX_WRITE_FLUSH(wx);
> +
> + rem = WX_NS_PER_SEC;
> + /* Adjust the clock edge to align with the next full second. */
> + wx->sec_to_cc = div_u64(((u64)rem << cc->shift), cc->mult);
... that appears to be hard coding a period of one second?
> + wx->pps_width = rq->perout.period.nsec;
> + wx->ptp_setup_sdp(wx);
And this ^^^ is taking the dialed period and turning into the duty
cycle?
Thanks,
Richard
Powered by blists - more mailing lists