]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: Configure only the relevant bits for timestamping setup
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Tue, 12 Nov 2024 17:06:56 +0000 (18:06 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 Nov 2024 02:52:13 +0000 (18:52 -0800)
The PTP_TCR (Timestamp Control Register) is used to configure several
features related to packet timestamping.

On one hand, it configures the 1588 packet processing, to indicate what
types of frames should be timestamped (all, only 1588v1 or 1588v2, using
L2 or L4 timestamping, on IPv4 or IPv6, etc.). This is congfigured
usually through the ioctl / ndo dedicated for such setup. This
configuration is done by setting some fields in that register, that seem
to behave the same way on all dwmac variants, including DWMAC1000.

On the other hand, and only on DWMAC1000 apparently, some fields in that
register are used to configure external snapshots (bits 24/25).
On DWMAC4 and others, these fields are reserved and external
snapshots are configured through a dedicated register that simply
doesn't seem to exist on DWMAC1000.

This configuration is done in the dwmac1000-specific ptp_clock_info ops
(cf dwmac1000_ptp_enable()).

So to avoid the timestamping configuration interfering with the external
snapshots, this commit makes sure that the config_hw_tstamping only
configures the relevant bits in PTP_TCR, so that the DWMAC1000
timestamping can correctly rely on these otherwise reserved fields.

Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20241112170658.2388529-9-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c

index a94829ef8cfb4442be1576965ed69624f12cb8f1..0f59aa98260404bece530f505500f13d35884d0c 100644 (file)
 #include "dwmac4.h"
 #include "stmmac.h"
 
+#define STMMAC_HWTS_CFG_MASK   (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | \
+                                PTP_TCR_TSINIT | PTP_TCR_TSUPDT | \
+                                PTP_TCR_TSCTRLSSR | PTP_TCR_SNAPTYPSEL_1 | \
+                                PTP_TCR_TSIPV4ENA | PTP_TCR_TSIPV6ENA | \
+                                PTP_TCR_TSEVNTENA | PTP_TCR_TSMSTRENA | \
+                                PTP_TCR_TSVER2ENA | PTP_TCR_TSIPENA | \
+                                PTP_TCR_TSTRIG | PTP_TCR_TSENALL)
+
 static void config_hw_tstamping(void __iomem *ioaddr, u32 data)
 {
-       writel(data, ioaddr + PTP_TCR);
+       u32 regval = readl(ioaddr + PTP_TCR);
+
+       regval &= ~STMMAC_HWTS_CFG_MASK;
+       regval |= data;
+
+       writel(regval, ioaddr + PTP_TCR);
 }
 
 static void config_sub_second_increment(void __iomem *ioaddr,