• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /******************************************************************************
3   PTP Header file
4 
5   Copyright (C) 2013  Vayavya Labs Pvt Ltd
6 
7 
8   Author: Rayagond Kokatanur <rayagond@vayavyalabs.com>
9 ******************************************************************************/
10 
11 #ifndef	__STMMAC_PTP_H__
12 #define	__STMMAC_PTP_H__
13 
14 #define PTP_XGMAC_OFFSET	0xd00
15 #define	PTP_GMAC4_OFFSET	0xb00
16 #define	PTP_GMAC3_X_OFFSET	0x700
17 
18 /* IEEE 1588 PTP register offsets */
19 #define	PTP_TCR		0x00	/* Timestamp Control Reg */
20 #define	PTP_SSIR	0x04	/* Sub-Second Increment Reg */
21 #define	PTP_STSR	0x08	/* System Time – Seconds Regr */
22 #define	PTP_STNSR	0x0c	/* System Time – Nanoseconds Reg */
23 #define	PTP_STSUR	0x10	/* System Time – Seconds Update Reg */
24 #define	PTP_STNSUR	0x14	/* System Time – Nanoseconds Update Reg */
25 #define	PTP_TAR		0x18	/* Timestamp Addend Reg */
26 
27 #define	PTP_STNSUR_ADDSUB_SHIFT	31
28 #define	PTP_DIGITAL_ROLLOVER_MODE	0x3B9ACA00	/* 10e9-1 ns */
29 #define	PTP_BINARY_ROLLOVER_MODE	0x80000000	/* ~0.466 ns */
30 
31 /* PTP Timestamp control register defines */
32 #define	PTP_TCR_TSENA		BIT(0)	/* Timestamp Enable */
33 #define	PTP_TCR_TSCFUPDT	BIT(1)	/* Timestamp Fine/Coarse Update */
34 #define	PTP_TCR_TSINIT		BIT(2)	/* Timestamp Initialize */
35 #define	PTP_TCR_TSUPDT		BIT(3)	/* Timestamp Update */
36 #define	PTP_TCR_TSTRIG		BIT(4)	/* Timestamp Interrupt Trigger Enable */
37 #define	PTP_TCR_TSADDREG	BIT(5)	/* Addend Reg Update */
38 #define	PTP_TCR_TSENALL		BIT(8)	/* Enable Timestamp for All Frames */
39 #define	PTP_TCR_TSCTRLSSR	BIT(9)	/* Digital or Binary Rollover Control */
40 /* Enable PTP packet Processing for Version 2 Format */
41 #define	PTP_TCR_TSVER2ENA	BIT(10)
42 /* Enable Processing of PTP over Ethernet Frames */
43 #define	PTP_TCR_TSIPENA		BIT(11)
44 /* Enable Processing of PTP Frames Sent over IPv6-UDP */
45 #define	PTP_TCR_TSIPV6ENA	BIT(12)
46 /* Enable Processing of PTP Frames Sent over IPv4-UDP */
47 #define	PTP_TCR_TSIPV4ENA	BIT(13)
48 /* Enable Timestamp Snapshot for Event Messages */
49 #define	PTP_TCR_TSEVNTENA	BIT(14)
50 /* Enable Snapshot for Messages Relevant to Master */
51 #define	PTP_TCR_TSMSTRENA	BIT(15)
52 /* Select PTP packets for Taking Snapshots
53  * On gmac4 specifically:
54  * Enable SYNC, Pdelay_Req, Pdelay_Resp when TSEVNTENA is enabled.
55  * or
56  * Enable  SYNC, Follow_Up, Delay_Req, Delay_Resp, Pdelay_Req, Pdelay_Resp,
57  * Pdelay_Resp_Follow_Up if TSEVNTENA is disabled
58  */
59 #define	PTP_TCR_SNAPTYPSEL_1	BIT(16)
60 /* Enable MAC address for PTP Frame Filtering */
61 #define	PTP_TCR_TSENMACADDR	BIT(18)
62 
63 /* SSIR defines */
64 #define	PTP_SSIR_SSINC_MAX		0xff
65 #define	GMAC4_PTP_SSIR_SSINC_SHIFT	16
66 
67 #endif	/* __STMMAC_PTP_H__ */
68