[PATCH net-next 6/8] net: stmmac: introduce setter/getter for timestamp configuration
alexis.lothore at bootlin.com
alexis.lothore at bootlin.com
Fri Jun 16 03:04:07 PDT 2023
From: Alexis Lothoré <alexis.lothore at bootlin.com>
stmmac_hwtstamp_set currently writes the whole Timestamp Control register
when configuring hardware timestamping. It is done for all GMAC variants,
and leads to issues with DWMAC1000: this version also bears the Auxiliary
Snapshot Trigger bit in the same register. This field, which is set
independently with during PTP_CLK_REQ_EXTTS ioctl, is then overwritten when
stmmac_hwtstamp_set is called.
Introduce setter and getter to allow modifying only relevant parts of the
timestamp control register instead of overwriting it all.
Signed-off-by: Alexis Lothoré <alexis.lothore at bootlin.com>
---
drivers/net/ethernet/stmicro/stmmac/hwif.h | 9 ++++++---
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 10 ++++++++--
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index d0b2f13510aa..927324e3d748 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -534,7 +534,8 @@ struct stmmac_ops {
/* PTP and HW Timer helpers */
struct stmmac_hwtimestamp {
- void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data);
+ void (*config_hw_tstamping_set)(void __iomem *ioaddr, u32 data);
+ u32 (*config_hw_tstamping_get)(void __iomem *ioaddr);
void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock,
int gmac4, u32 *ssinc);
int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec);
@@ -546,8 +547,10 @@ struct stmmac_hwtimestamp {
void (*timestamp_interrupt)(struct stmmac_priv *priv);
};
-#define stmmac_config_hw_tstamping(__priv, __args...) \
- stmmac_do_void_callback(__priv, ptp, config_hw_tstamping, __args)
+#define stmmac_config_hw_tstamping_set(__priv, __args...) \
+ stmmac_do_void_callback(__priv, ptp, config_hw_tstamping_set, __args)
+#define stmmac_config_hw_tstamping_get(__priv, __args...) \
+ stmmac_do_callback(__priv, ptp, config_hw_tstamping_get, __args)
#define stmmac_config_sub_second_increment(__priv, __args...) \
stmmac_do_void_callback(__priv, ptp, config_sub_second_increment, __args)
#define stmmac_init_systime(__priv, __args...) \
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index 2cd0ec17f4c6..cbb94d3e0fa1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
@@ -18,11 +18,16 @@
#include "dwmac4.h"
#include "stmmac.h"
-static void config_hw_tstamping(void __iomem *ioaddr, u32 data)
+static void config_hw_tstamping_set(void __iomem *ioaddr, u32 data)
{
writel(data, ioaddr + PTP_TCR);
}
+static u32 config_hw_tstamping_get(void __iomem *ioaddr)
+{
+ return readl(ioaddr + PTP_TCR);
+}
+
static void config_sub_second_increment(void __iomem *ioaddr,
u32 ptp_clock, int gmac4, u32 *ssinc)
{
@@ -163,7 +168,8 @@ static void get_systime(void __iomem *ioaddr, u64 *systime)
}
const struct stmmac_hwtimestamp stmmac_ptp = {
- .config_hw_tstamping = config_hw_tstamping,
+ .config_hw_tstamping_set = config_hw_tstamping_set,
+ .config_hw_tstamping_get = config_hw_tstamping_get,
.init_systime = init_systime,
.config_sub_second_increment = config_sub_second_increment,
.config_addend = config_addend,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 4f0ef73d5121..528d2e010926 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -792,7 +792,7 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
ts_master_en | snap_type_sel;
}
- stmmac_config_hw_tstamping(priv, priv->ptpaddr, priv->systime_flags);
+ stmmac_config_hw_tstamping_set(priv, priv->ptpaddr, priv->systime_flags);
memcpy(&priv->tstamp_config, &config, sizeof(config));
@@ -841,7 +841,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags)
if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))
return -EOPNOTSUPP;
- stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags);
+ stmmac_config_hw_tstamping_set(priv, priv->ptpaddr, systime_flags);
priv->systime_flags = systime_flags;
/* program Sub Second Increment reg */
--
2.41.0
More information about the linux-arm-kernel
mailing list