xref: /linux/drivers/net/dsa/microchip/ksz_ptp_reg.h (revision 1f12ae5b67608f63596642774129abfafa95e9d8)
1eac1ea20SChristian Eggers /* SPDX-License-Identifier: GPL-2.0 */
2eac1ea20SChristian Eggers /* Microchip KSZ PTP register definitions
3eac1ea20SChristian Eggers  * Copyright (C) 2022 Microchip Technology Inc.
4eac1ea20SChristian Eggers  */
5eac1ea20SChristian Eggers 
6eac1ea20SChristian Eggers #ifndef __KSZ_PTP_REGS_H
7eac1ea20SChristian Eggers #define __KSZ_PTP_REGS_H
8eac1ea20SChristian Eggers 
9eac1ea20SChristian Eggers /* 5 - PTP Clock */
10eac1ea20SChristian Eggers #define REG_PTP_CLK_CTRL		0x0500
11eac1ea20SChristian Eggers 
12eac1ea20SChristian Eggers #define PTP_STEP_ADJ			BIT(6)
13eac1ea20SChristian Eggers #define PTP_STEP_DIR			BIT(5)
14eac1ea20SChristian Eggers #define PTP_READ_TIME			BIT(4)
15eac1ea20SChristian Eggers #define PTP_LOAD_TIME			BIT(3)
16eac1ea20SChristian Eggers #define PTP_CLK_ADJ_ENABLE		BIT(2)
17eac1ea20SChristian Eggers #define PTP_CLK_ENABLE			BIT(1)
18eac1ea20SChristian Eggers #define PTP_CLK_RESET			BIT(0)
19eac1ea20SChristian Eggers 
20eac1ea20SChristian Eggers #define REG_PTP_RTC_SUB_NANOSEC__2	0x0502
21eac1ea20SChristian Eggers 
22eac1ea20SChristian Eggers #define PTP_RTC_SUB_NANOSEC_M		0x0007
23eac1ea20SChristian Eggers #define PTP_RTC_0NS			0x00
24eac1ea20SChristian Eggers 
25eac1ea20SChristian Eggers #define REG_PTP_RTC_NANOSEC		0x0504
26eac1ea20SChristian Eggers 
27eac1ea20SChristian Eggers #define REG_PTP_RTC_SEC			0x0508
28eac1ea20SChristian Eggers 
29eac1ea20SChristian Eggers #define REG_PTP_SUBNANOSEC_RATE		0x050C
30eac1ea20SChristian Eggers 
31eac1ea20SChristian Eggers #define PTP_SUBNANOSEC_M		0x3FFFFFFF
32eac1ea20SChristian Eggers #define PTP_RATE_DIR			BIT(31)
33eac1ea20SChristian Eggers #define PTP_TMP_RATE_ENABLE		BIT(30)
34eac1ea20SChristian Eggers 
35eac1ea20SChristian Eggers #define REG_PTP_SUBNANOSEC_RATE_L	0x050E
36eac1ea20SChristian Eggers 
37eac1ea20SChristian Eggers #define REG_PTP_RATE_DURATION		0x0510
38eac1ea20SChristian Eggers #define REG_PTP_RATE_DURATION_H		0x0510
39eac1ea20SChristian Eggers #define REG_PTP_RATE_DURATION_L		0x0512
40eac1ea20SChristian Eggers 
41eac1ea20SChristian Eggers #define REG_PTP_MSG_CONF1		0x0514
42eac1ea20SChristian Eggers 
43eac1ea20SChristian Eggers #define PTP_802_1AS			BIT(7)
44eac1ea20SChristian Eggers #define PTP_ENABLE			BIT(6)
45eac1ea20SChristian Eggers #define PTP_ETH_ENABLE			BIT(5)
46eac1ea20SChristian Eggers #define PTP_IPV4_UDP_ENABLE		BIT(4)
47eac1ea20SChristian Eggers #define PTP_IPV6_UDP_ENABLE		BIT(3)
48eac1ea20SChristian Eggers #define PTP_TC_P2P			BIT(2)
49eac1ea20SChristian Eggers #define PTP_MASTER			BIT(1)
50eac1ea20SChristian Eggers #define PTP_1STEP			BIT(0)
51eac1ea20SChristian Eggers 
52*1f12ae5bSChristian Eggers #define REG_PTP_UNIT_INDEX__4		0x0520
53*1f12ae5bSChristian Eggers 
54*1f12ae5bSChristian Eggers #define PTP_GPIO_INDEX			GENMASK(19, 16)
55*1f12ae5bSChristian Eggers #define PTP_TSI_INDEX			BIT(8)
56*1f12ae5bSChristian Eggers #define PTP_TOU_INDEX			GENMASK(1, 0)
57*1f12ae5bSChristian Eggers 
58*1f12ae5bSChristian Eggers #define REG_PTP_TRIG_STATUS__4		0x0524
59*1f12ae5bSChristian Eggers 
60*1f12ae5bSChristian Eggers #define TRIG_ERROR_M			GENMASK(18, 16)
61*1f12ae5bSChristian Eggers #define TRIG_DONE_M			GENMASK(2, 0)
62*1f12ae5bSChristian Eggers 
63*1f12ae5bSChristian Eggers #define REG_PTP_INT_STATUS__4		0x0528
64*1f12ae5bSChristian Eggers 
65*1f12ae5bSChristian Eggers #define TRIG_INT_M			GENMASK(18, 16)
66*1f12ae5bSChristian Eggers #define TS_INT_M			GENMASK(1, 0)
67*1f12ae5bSChristian Eggers 
68*1f12ae5bSChristian Eggers #define REG_PTP_CTRL_STAT__4		0x052C
69*1f12ae5bSChristian Eggers 
70*1f12ae5bSChristian Eggers #define GPIO_IN			BIT(7)
71*1f12ae5bSChristian Eggers #define GPIO_OUT			BIT(6)
72*1f12ae5bSChristian Eggers #define TS_INT_ENABLE			BIT(5)
73*1f12ae5bSChristian Eggers #define TRIG_ACTIVE			BIT(4)
74*1f12ae5bSChristian Eggers #define TRIG_ENABLE			BIT(3)
75*1f12ae5bSChristian Eggers #define TRIG_RESET			BIT(2)
76*1f12ae5bSChristian Eggers #define TS_ENABLE			BIT(1)
77*1f12ae5bSChristian Eggers #define TS_RESET			BIT(0)
78*1f12ae5bSChristian Eggers 
79*1f12ae5bSChristian Eggers #define REG_TRIG_TARGET_NANOSEC	0x0530
80*1f12ae5bSChristian Eggers #define REG_TRIG_TARGET_SEC		0x0534
81*1f12ae5bSChristian Eggers 
82*1f12ae5bSChristian Eggers #define REG_TRIG_CTRL__4		0x0538
83*1f12ae5bSChristian Eggers 
84*1f12ae5bSChristian Eggers #define TRIG_CASCADE_ENABLE		BIT(31)
85*1f12ae5bSChristian Eggers #define TRIG_CASCADE_TAIL		BIT(30)
86*1f12ae5bSChristian Eggers #define TRIG_CASCADE_UPS_M		GENMASK(29, 26)
87*1f12ae5bSChristian Eggers #define TRIG_NOW			BIT(25)
88*1f12ae5bSChristian Eggers #define TRIG_NOTIFY			BIT(24)
89*1f12ae5bSChristian Eggers #define TRIG_EDGE			BIT(23)
90*1f12ae5bSChristian Eggers #define TRIG_PATTERN_M			GENMASK(22, 20)
91*1f12ae5bSChristian Eggers #define TRIG_NEG_EDGE			0
92*1f12ae5bSChristian Eggers #define TRIG_POS_EDGE			1
93*1f12ae5bSChristian Eggers #define TRIG_NEG_PULSE			2
94*1f12ae5bSChristian Eggers #define TRIG_POS_PULSE			3
95*1f12ae5bSChristian Eggers #define TRIG_NEG_PERIOD		4
96*1f12ae5bSChristian Eggers #define TRIG_POS_PERIOD		5
97*1f12ae5bSChristian Eggers #define TRIG_REG_OUTPUT		6
98*1f12ae5bSChristian Eggers #define TRIG_GPO_M			GENMASK(19, 16)
99*1f12ae5bSChristian Eggers #define TRIG_CASCADE_ITERATE_CNT_M	GENMASK(15, 0)
100*1f12ae5bSChristian Eggers 
101*1f12ae5bSChristian Eggers #define REG_TRIG_CYCLE_WIDTH		0x053C
102*1f12ae5bSChristian Eggers #define TRIG_CYCLE_WIDTH_M		GENMASK(31, 0)
103*1f12ae5bSChristian Eggers 
104*1f12ae5bSChristian Eggers #define REG_TRIG_CYCLE_CNT		0x0540
105*1f12ae5bSChristian Eggers 
106*1f12ae5bSChristian Eggers #define TRIG_CYCLE_CNT_M		GENMASK(31, 16)
107*1f12ae5bSChristian Eggers #define TRIG_BIT_PATTERN_M		GENMASK(15, 0)
108*1f12ae5bSChristian Eggers 
109*1f12ae5bSChristian Eggers #define REG_TRIG_ITERATE_TIME		0x0544
110*1f12ae5bSChristian Eggers 
111*1f12ae5bSChristian Eggers #define REG_TRIG_PULSE_WIDTH__4	0x0548
112*1f12ae5bSChristian Eggers 
113*1f12ae5bSChristian Eggers #define TRIG_PULSE_WIDTH_M		GENMASK(23, 0)
114*1f12ae5bSChristian Eggers 
115cc13ab18SArun Ramadoss /* Port PTP Register */
116cc13ab18SArun Ramadoss #define REG_PTP_PORT_RX_DELAY__2	0x0C00
117cc13ab18SArun Ramadoss #define REG_PTP_PORT_TX_DELAY__2	0x0C02
118cc13ab18SArun Ramadoss #define REG_PTP_PORT_ASYM_DELAY__2	0x0C04
119cc13ab18SArun Ramadoss 
120cc13ab18SArun Ramadoss #define REG_PTP_PORT_XDELAY_TS		0x0C08
121cc13ab18SArun Ramadoss #define REG_PTP_PORT_SYNC_TS		0x0C0C
122cc13ab18SArun Ramadoss #define REG_PTP_PORT_PDRESP_TS		0x0C10
123cc13ab18SArun Ramadoss 
124cc13ab18SArun Ramadoss #define REG_PTP_PORT_TX_INT_STATUS__2	0x0C14
125cc13ab18SArun Ramadoss #define REG_PTP_PORT_TX_INT_ENABLE__2	0x0C16
126cc13ab18SArun Ramadoss 
127cc13ab18SArun Ramadoss #define PTP_PORT_SYNC_INT		BIT(15)
128cc13ab18SArun Ramadoss #define PTP_PORT_XDELAY_REQ_INT		BIT(14)
129cc13ab18SArun Ramadoss #define PTP_PORT_PDELAY_RESP_INT	BIT(13)
130cc13ab18SArun Ramadoss #define KSZ_SYNC_MSG			2
131cc13ab18SArun Ramadoss #define KSZ_XDREQ_MSG			1
132cc13ab18SArun Ramadoss #define KSZ_PDRES_MSG			0
133cc13ab18SArun Ramadoss 
134eac1ea20SChristian Eggers #endif
135