Skip to content

Commit

Permalink
net: stmmac: Fix TX timestamp calculation
Browse files Browse the repository at this point in the history
When using GMAC4 the value written in PTP_SSIR should be shifted however
the shifted value is also used in subsequent calculations which results
in a bad timestamp value.

Signed-off-by: Fredrik Hallenberg <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
megahallon authored and davem330 committed Dec 19, 2017
1 parent 3db0960 commit 200922c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr,
{
u32 value = readl(ioaddr + PTP_TCR);
unsigned long data;
u32 reg_value;

/* For GMAC3.x, 4.x versions, convert the ptp_clock to nano second
* formula = (1/ptp_clock) * 1000000000
Expand All @@ -50,10 +51,11 @@ static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr,

data &= PTP_SSIR_SSINC_MASK;

reg_value = data;
if (gmac4)
data = data << GMAC4_PTP_SSIR_SSINC_SHIFT;
reg_value <<= GMAC4_PTP_SSIR_SSINC_SHIFT;

writel(data, ioaddr + PTP_SSIR);
writel(reg_value, ioaddr + PTP_SSIR);

return data;
}
Expand Down

0 comments on commit 200922c

Please sign in to comment.