On 18/08/2020 23:47, Jacob Keller wrote:

On 8/18/2020 12:40 PM, Irene Kravets wrote:
I am using vendor kernel and a vendor-specific PTP driver 
(drivers/net/Ethernet/freescale/fec_ptp.c).  I see this driver in the mainline 
kernel as well.  What enables PPS output signal is the PTP_ENABLE_PPS ioctl 
sent from linuxptp stack (in phc2sys.c).
It's possible the driver assumes "PTP_ENABLE_PPS" is for enabling the
PPS output signal. I know I've had plenty of discussion with colleagues
trying to explain the difference between PTP_ENABLE_PPS and
PTP_PEROUT_REQUEST... So I would imagine other vendors might also get
this wrong sometimes.

Enabling the input and output pins should be done through the
PTP_PEROUT_REQUEST and PTP_PIN_SETFUNC ioctls.

That's not true for the fec_ptp driver. Looking to the driver code when the PTP_ENABLE_PPS ioctl is called the call stack is as follows:

ptp_chardev.c:ptp_ioctl() -> issues a PTP_CLK_REQ_PPS request to the underlying PTP driver (fec_ptp in this case)
fec_ptp.c:fec_ptp_enable() -> Checks for PTP_CLK_REQ_PPS
fec_ptp.c:fec_ptp_enable_pps() -> Sets up the output compare

PTP_PEROUT_REQUEST is not supported by the fec driver.

The IMX6 provides 4 output channels for IEEE1588 on different pads (ENET_1588_EVENTx_OUT) which can be used to output the PPS. But it looks like the fec driver is only using channel 0 hard-coded as output. The timer register is double-buffered, while the timer is running the next compare value can be written and it needs to the updated constantly before overflowing. What seems odd to me is that the driver is reading back the PTP timer to calculate the first compare match value. If the driver code gets interrupted by interrupt or other kernel threads in that instant the compare match (and so the PPS) will have a constant offset. Additionally, as Richard already pointed out, if there is applied a frequency adjustment on the PTP timer at the same time this doesn't look to work well. IMHO to implement the PPS setup correctly the timer would have to be stopped first.

Regards,
Hannes



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

Reply via email to