]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
net: dsa: sja1105: the PTP_CLK extts input reacts on both edges
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 6 May 2020 17:48:13 +0000 (20:48 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 May 2020 22:03:14 +0000 (15:03 -0700)
commit0ba83aa037da456bb73868e5cc20558c5a644414
treecb40fdf38cb7eb8d87f2bba4686946a83a7ef4f3
parenta84724178bd7081cf3bd5b558616dd6a9a4ca63b
net: dsa: sja1105: the PTP_CLK extts input reacts on both edges

It looks like the sja1105 external timestamping input is not as generic
as we thought. When fed a signal with 50% duty cycle, it will timestamp
both the rising and the falling edge. When fed a short pulse signal,
only the timestamp of the falling edge will be seen in the PTPSYNCTS
register, because that of the rising edge had been overwritten. So the
moral is: don't feed it short pulse inputs.

Luckily this is not a complete deal breaker, as we can still work with
1 Hz square waves. But the problem is that the extts polling period was
not dimensioned enough for this input signal. If we leave the period at
half a second, we risk losing timestamps due to jitter in the measuring
process. So we need to increase it to 4 times per second.

Also, the very least we can do to inform the user is to deny any other
flags combination than with PTP_RISING_EDGE and PTP_FALLING_EDGE both
set.

Fixes: 747e5eb31d59 ("net: dsa: sja1105: configure the PTP_CLK pin as EXT_TS or PER_OUT")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_ptp.c