@@ -541,9 +541,12 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
netdev_dbg(priv->dev, "%s config flags:0x%x, tx_type:0x%x, rx_filter:0x%x\n",
__func__, config.flags, config.tx_type, config.rx_filter);
- /* reserved for future extensions */
- if (config.flags)
- return -EINVAL;
+ if (config.flags != HWTSTAMP_FLAGS_ADJ_COARSE) {
+ /* Defaulting to fine adjustment for compatibility */
+ netdev_dbg(priv->dev, "%s defaulting to fine adjustment mode\n",
+ __func__);
+ config.flags = HWTSTAMP_FLAGS_ADJ_FINE;
+ }
if (config.tx_type != HWTSTAMP_TX_OFF &&
config.tx_type != HWTSTAMP_TX_ON)
@@ -689,10 +692,16 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
stmmac_set_hw_tstamping(priv, priv->ptpaddr, 0);
else {
stmmac_get_hw_tstamping(priv, priv->ptpaddr, &value);
- value |= (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | PTP_TCR_TSCTRLSSR |
+ value |= (PTP_TCR_TSENA | PTP_TCR_TSCTRLSSR |
tstamp_all | ptp_v2 | ptp_over_ethernet |
ptp_over_ipv6_udp | ptp_over_ipv4_udp | ts_event_en |
ts_master_en | snap_type_sel);
+
+ if (config.flags == HWTSTAMP_FLAGS_ADJ_FINE)
+ value |= PTP_TCR_TSCFUPDT;
+ else
+ value &= ~PTP_TCR_TSCFUPDT;
+
stmmac_set_hw_tstamping(priv, priv->ptpaddr, value);
/* program Sub Second Increment reg */
@@ -27,6 +27,9 @@ static int stmmac_adjust_freq(struct ptp_clock_info *ptp, s32 ppb)
int neg_adj = 0;
u64 adj;
+ if (priv->tstamp_config.flags != HWTSTAMP_FLAGS_ADJ_FINE)
+ return -EPERM;
+
if (ppb < 0) {
neg_adj = 1;
ppb = -ppb;
This commit enables coarse correction mode for stmmac driver. The coarse mode allows to update the system time in one process. The required time adjustment is written in the Timestamp Update registers while the Sub-second increment register is programmed with the period of the clock, which is the precision of our correction. The fine adjutment mode is always the default behavior of the driver. One should use the HWTSAMP_FLAG_ADJ_COARSE flag while calling SIOCGHWTSTAMP ioctl to enable coarse mode for stmmac driver. Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.com> --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++++++++++++---- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-)