aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Abreu <Jose.Abreu@synopsys.com>2018-08-08 04:04:34 -0400
committerDavid S. Miller <davem@davemloft.net>2018-08-09 14:16:28 -0400
commit4bb7aff9e6d0f92483f27ec04683efc2fdd42d25 (patch)
tree59d1c38b19e49718964707d97ee5d066342df0c9
parent6fc21117b791b601362fd2240fab833cbdbfdc15 (diff)
net: stmmac: Add PTP support for XGMAC2
XGMAC2 uses the same engine of timestamping as GMAC4. Let's use the same callbacks. Signed-off-by: Jose Abreu <joabreu@synopsys.com> Cc: David S. Miller <davem@davemloft.net> Cc: Joao Pinto <jpinto@synopsys.com> Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com> Cc: Alexandre Torgue <alexandre.torgue@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/hwif.c4
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c6
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h1
3 files changed, 7 insertions, 4 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c
index 4b4ba1c8bad5..357309a6d6a5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.c
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c
@@ -193,13 +193,13 @@ static const struct stmmac_hwif_entry {
193 .xgmac = true, 193 .xgmac = true,
194 .min_id = DWXGMAC_CORE_2_10, 194 .min_id = DWXGMAC_CORE_2_10,
195 .regs = { 195 .regs = {
196 .ptp_off = 0, 196 .ptp_off = PTP_XGMAC_OFFSET,
197 .mmc_off = 0, 197 .mmc_off = 0,
198 }, 198 },
199 .desc = &dwxgmac210_desc_ops, 199 .desc = &dwxgmac210_desc_ops,
200 .dma = &dwxgmac210_dma_ops, 200 .dma = &dwxgmac210_dma_ops,
201 .mac = &dwxgmac210_ops, 201 .mac = &dwxgmac210_ops,
202 .hwtimestamp = NULL, 202 .hwtimestamp = &stmmac_ptp,
203 .mode = NULL, 203 .mode = NULL,
204 .tc = NULL, 204 .tc = NULL,
205 .setup = dwxgmac2_setup, 205 .setup = dwxgmac2_setup,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
index 0cb0e39a2be9..2293e21f789f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
@@ -71,6 +71,9 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
71 u32 sec, nsec; 71 u32 sec, nsec;
72 u32 quotient, reminder; 72 u32 quotient, reminder;
73 int neg_adj = 0; 73 int neg_adj = 0;
74 bool xmac;
75
76 xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;
74 77
75 if (delta < 0) { 78 if (delta < 0) {
76 neg_adj = 1; 79 neg_adj = 1;
@@ -82,8 +85,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
82 nsec = reminder; 85 nsec = reminder;
83 86
84 spin_lock_irqsave(&priv->ptp_lock, flags); 87 spin_lock_irqsave(&priv->ptp_lock, flags);
85 stmmac_adjust_systime(priv, priv->ptpaddr, sec, nsec, neg_adj, 88 stmmac_adjust_systime(priv, priv->ptpaddr, sec, nsec, neg_adj, xmac);
86 priv->plat->has_gmac4);
87 spin_unlock_irqrestore(&priv->ptp_lock, flags); 89 spin_unlock_irqrestore(&priv->ptp_lock, flags);
88 90
89 return 0; 91 return 0;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
index f4b31d69f60e..ecccf895fd7e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
@@ -21,6 +21,7 @@
21#ifndef __STMMAC_PTP_H__ 21#ifndef __STMMAC_PTP_H__
22#define __STMMAC_PTP_H__ 22#define __STMMAC_PTP_H__
23 23
24#define PTP_XGMAC_OFFSET 0xd00
24#define PTP_GMAC4_OFFSET 0xb00 25#define PTP_GMAC4_OFFSET 0xb00
25#define PTP_GMAC3_X_OFFSET 0x700 26#define PTP_GMAC3_X_OFFSET 0x700
26 27