diff options
author | Fredrik Hallenberg <megahallon@gmail.com> | 2017-12-18 17:33:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-12-19 14:12:14 -0500 |
commit | 200922c93f008e03ddc804c6dacdf26ca1ba86d7 (patch) | |
tree | f836da0bbbb4a3095dd7f52cc44be1ecf066014a | |
parent | 3db096011722fd8717e57687ae94b6917a11c9cc (diff) |
net: stmmac: Fix TX timestamp calculation
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 <megahallon@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 721b61655261..08c19ebd5306 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | |||
@@ -34,6 +34,7 @@ static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr, | |||
34 | { | 34 | { |
35 | u32 value = readl(ioaddr + PTP_TCR); | 35 | u32 value = readl(ioaddr + PTP_TCR); |
36 | unsigned long data; | 36 | unsigned long data; |
37 | u32 reg_value; | ||
37 | 38 | ||
38 | /* For GMAC3.x, 4.x versions, convert the ptp_clock to nano second | 39 | /* For GMAC3.x, 4.x versions, convert the ptp_clock to nano second |
39 | * formula = (1/ptp_clock) * 1000000000 | 40 | * formula = (1/ptp_clock) * 1000000000 |
@@ -50,10 +51,11 @@ static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr, | |||
50 | 51 | ||
51 | data &= PTP_SSIR_SSINC_MASK; | 52 | data &= PTP_SSIR_SSINC_MASK; |
52 | 53 | ||
54 | reg_value = data; | ||
53 | if (gmac4) | 55 | if (gmac4) |
54 | data = data << GMAC4_PTP_SSIR_SSINC_SHIFT; | 56 | reg_value <<= GMAC4_PTP_SSIR_SSINC_SHIFT; |
55 | 57 | ||
56 | writel(data, ioaddr + PTP_SSIR); | 58 | writel(reg_value, ioaddr + PTP_SSIR); |
57 | 59 | ||
58 | return data; | 60 | return data; |
59 | } | 61 | } |