Some hardware like the ocelot/felix switch PHC can emit PPS signals but
not starting from arbitrary absolute times, but rather phase-aligned to
the beginning of a second.

For those, it was established that they should reject any other absolute
time for the PTP_PEROUT_REQUEST than 0.000000000 [1]. So currently
ts2phc would fail as below:

ts2phc -s /dev/ptp1 -f ts2phc.cfg -m
[242238.618012] mscc_felix 0000:00:00.5: Absolute start time not supported!
[242238.624878] mscc_felix 0000:00:00.5: Accept nsec for PPS phase adjustment, 
otherwise start time should be 0 0.
ts2phc[242238.506]: PTP_PEROUT_REQUEST2 failed: Invalid argument
failed to create master

Actually there's no good reason why ts2phc would specify an absolute
start time of (current time + 2 seconds, 0) for its most basic
operation. The (0, 0) start time should be accepted by all drivers, and
the behavior should be that some platform-level decision (hardware or
driver) is taken such that the requested time is advanced such that it
becomes a valid start time in the immediate future (based on the cycle
time, which is 1 second). This is similar to how other PTP-based
networking APIs work (such as tc-taprio, tc-gate). We can argue that
ocelot/felix supports this (and just this).

[1]: 
https://patchwork.ozlabs.org/project/netdev/patch/20200320103726.32559-7-yangbo...@nxp.com/

Quote below:

On Tue, 24 Mar 2020 at 15:19, Richard Cochran <richardcoch...@gmail.com> wrote:
>
> On Tue, Mar 24, 2020 at 05:21:27AM +0000, Y.b. Lu wrote:
> > In my one previous patch, I was suggested to implement PPS with
> > programmable pin periodic clock function.
> > But I didn’t find how should PPS be implemented with periodic clock
> > function after checking ptp driver.
> > https://patchwork.ozlabs.org/patch/1215464/
>
> Yes, for generating a 1-PPS output waveform, users call ioctl
> PTP_CLK_REQ_PEROUT with ptp_perout_request.period={1,0}.
>
> If your device can't control the start time, then it can accept an
> unspecified time of ptp_perout_request.start={0,0}.
>
> > Vladimir talked with me, for the special PPS case, we may consider,
> > if (req.perout.period.sec ==1 && req.perout.period.nsec == 0) and
> > configure WAVEFORM_LOW to be equal to req_perout.start.nsec.
> >
> > Richard, do you think is it ok?
>
> Sound okay to me (but I don't know about WAVEFORM_LOW).

Signed-off-by: Vladimir Oltean <olte...@gmail.com>
---
 ts2phc_phc_master.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ts2phc_phc_master.c b/ts2phc_phc_master.c
index 9f1837bc80eb..82f79820d9bf 100644
--- a/ts2phc_phc_master.c
+++ b/ts2phc_phc_master.c
@@ -47,7 +47,7 @@ static int ts2phc_phc_master_activate(struct config *cfg, 
const char *dev,
        }
        memset(&perout_request, 0, sizeof(perout_request));
        perout_request.index = master->channel;
-       perout_request.start.sec = ts.tv_sec + 2;
+       perout_request.start.sec = 0;
        perout_request.start.nsec = 0;
        perout_request.period.sec = 1;
        perout_request.period.nsec = 0;
-- 
2.25.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to