xref: /linux/drivers/net/ethernet/microchip/lan743x_main.h (revision 6af91e3d2cfc8bb579b1aa2d22cd91f8c34acdf6)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (C) 2018 Microchip Technology Inc. */
3 
4 #ifndef _LAN743X_H
5 #define _LAN743X_H
6 
7 #include <linux/phy.h>
8 #include "lan743x_ptp.h"
9 
10 #define DRIVER_AUTHOR   "Bryan Whitehead <Bryan.Whitehead@microchip.com>"
11 #define DRIVER_DESC "LAN743x PCIe Gigabit Ethernet Driver"
12 #define DRIVER_NAME "lan743x"
13 
14 /* Register Definitions */
15 #define ID_REV				(0x00)
16 #define ID_REV_ID_MASK_			(0xFFFF0000)
17 #define ID_REV_ID_LAN7430_		(0x74300000)
18 #define ID_REV_ID_LAN7431_		(0x74310000)
19 #define ID_REV_ID_LAN743X_		(0x74300000)
20 #define ID_REV_ID_A011_			(0xA0110000)	// PCI11010
21 #define ID_REV_ID_A041_			(0xA0410000)	// PCI11414
22 #define ID_REV_ID_A0X1_			(0xA0010000)
23 #define ID_REV_IS_VALID_CHIP_ID_(id_rev)	    \
24 	((((id_rev) & 0xFFF00000) == ID_REV_ID_LAN743X_) || \
25 	 (((id_rev) & 0xFF0F0000) == ID_REV_ID_A0X1_))
26 #define ID_REV_CHIP_REV_MASK_		(0x0000FFFF)
27 #define ID_REV_CHIP_REV_A0_		(0x00000000)
28 #define ID_REV_CHIP_REV_B0_		(0x00000010)
29 #define ID_REV_CHIP_REV_PCI11X1X_B0_	(0x000000B0)
30 
31 #define FPGA_REV			(0x04)
32 #define FPGA_REV_GET_MINOR_(fpga_rev)	(((fpga_rev) >> 8) & 0x000000FF)
33 #define FPGA_REV_GET_MAJOR_(fpga_rev)	((fpga_rev) & 0x000000FF)
34 #define FPGA_SGMII_OP			BIT(24)
35 
36 #define STRAP_READ			(0x0C)
37 #define STRAP_READ_USE_SGMII_EN_	BIT(22)
38 #define STRAP_READ_SGMII_EN_		BIT(6)
39 #define STRAP_READ_SGMII_REFCLK_	BIT(5)
40 #define STRAP_READ_SGMII_2_5G_		BIT(4)
41 #define STRAP_READ_BASE_X_		BIT(3)
42 #define STRAP_READ_RGMII_TXC_DELAY_EN_	BIT(2)
43 #define STRAP_READ_RGMII_RXC_DELAY_EN_	BIT(1)
44 #define STRAP_READ_ADV_PM_DISABLE_	BIT(0)
45 
46 #define HW_CFG					(0x010)
47 #define HW_CFG_RST_PROTECT_PCIE_		BIT(19)
48 #define HW_CFG_HOT_RESET_DIS_			BIT(15)
49 #define HW_CFG_D3_VAUX_OVR_			BIT(14)
50 #define HW_CFG_D3_RESET_DIS_			BIT(13)
51 #define HW_CFG_RST_PROTECT_			BIT(12)
52 #define HW_CFG_RELOAD_TYPE_ALL_			(0x00000FC0)
53 #define HW_CFG_EE_OTP_RELOAD_			BIT(4)
54 #define HW_CFG_LRST_				BIT(1)
55 
56 #define PMT_CTL					(0x014)
57 #define PMT_CTL_ETH_PHY_D3_COLD_OVR_		BIT(27)
58 #define PMT_CTL_MAC_D3_RX_CLK_OVR_		BIT(25)
59 #define PMT_CTL_ETH_PHY_EDPD_PLL_CTL_		BIT(24)
60 #define PMT_CTL_ETH_PHY_D3_OVR_			BIT(23)
61 #define PMT_CTL_RX_FCT_RFE_D3_CLK_OVR_		BIT(18)
62 #define PMT_CTL_GPIO_WAKEUP_EN_			BIT(15)
63 #define PMT_CTL_EEE_WAKEUP_EN_			BIT(13)
64 #define PMT_CTL_RES_CLR_WKP_MASK_		GENMASK(9, 8)
65 #define PMT_CTL_READY_				BIT(7)
66 #define PMT_CTL_ETH_PHY_RST_			BIT(4)
67 #define PMT_CTL_WOL_EN_				BIT(3)
68 #define PMT_CTL_ETH_PHY_WAKE_EN_		BIT(2)
69 #define PMT_CTL_WUPS_MASK_			(0x00000003)
70 
71 #define DP_SEL				(0x024)
72 #define DP_SEL_DPRDY_			BIT(31)
73 #define DP_SEL_MASK_			(0x0000001F)
74 #define DP_SEL_RFE_RAM			(0x00000001)
75 
76 #define DP_SEL_VHF_HASH_LEN		(16)
77 #define DP_SEL_VHF_VLAN_LEN		(128)
78 
79 #define DP_CMD				(0x028)
80 #define DP_CMD_WRITE_			(0x00000001)
81 
82 #define DP_ADDR				(0x02C)
83 
84 #define DP_DATA_0			(0x030)
85 
86 #define E2P_CMD				(0x040)
87 #define E2P_CMD_EPC_BUSY_		BIT(31)
88 #define E2P_CMD_EPC_CMD_WRITE_		(0x30000000)
89 #define E2P_CMD_EPC_CMD_EWEN_		(0x20000000)
90 #define E2P_CMD_EPC_CMD_READ_		(0x00000000)
91 #define E2P_CMD_EPC_TIMEOUT_		BIT(10)
92 #define E2P_CMD_EPC_ADDR_MASK_		(0x000001FF)
93 
94 #define E2P_DATA			(0x044)
95 
96 /* Hearthstone top level & System Reg Addresses */
97 #define ETH_CTRL_REG_ADDR_BASE		(0x0000)
98 #define ETH_SYS_REG_ADDR_BASE		(0x4000)
99 #define CONFIG_REG_ADDR_BASE		(0x0000)
100 #define ETH_EEPROM_REG_ADDR_BASE	(0x0E00)
101 #define ETH_OTP_REG_ADDR_BASE		(0x1000)
102 #define GEN_SYS_CONFIG_LOAD_STARTED_REG	(0x0078)
103 #define ETH_SYS_CONFIG_LOAD_STARTED_REG (ETH_SYS_REG_ADDR_BASE + \
104 					 CONFIG_REG_ADDR_BASE + \
105 					 GEN_SYS_CONFIG_LOAD_STARTED_REG)
106 #define GEN_SYS_LOAD_STARTED_REG_ETH_	BIT(4)
107 #define SYS_LOCK_REG			(0x00A0)
108 #define SYS_LOCK_REG_MAIN_LOCK_		BIT(7)
109 #define SYS_LOCK_REG_GEN_PERI_LOCK_	BIT(5)
110 #define SYS_LOCK_REG_SPI_PERI_LOCK_	BIT(4)
111 #define SYS_LOCK_REG_SMBUS_PERI_LOCK_	BIT(3)
112 #define SYS_LOCK_REG_UART_SS_LOCK_	BIT(2)
113 #define SYS_LOCK_REG_ENET_SS_LOCK_	BIT(1)
114 #define SYS_LOCK_REG_USB_SS_LOCK_	BIT(0)
115 #define ETH_SYSTEM_SYS_LOCK_REG		(ETH_SYS_REG_ADDR_BASE + \
116 					 CONFIG_REG_ADDR_BASE + \
117 					 SYS_LOCK_REG)
118 #define HS_EEPROM_REG_ADDR_BASE		(ETH_SYS_REG_ADDR_BASE + \
119 					 ETH_EEPROM_REG_ADDR_BASE)
120 #define HS_E2P_CMD			(HS_EEPROM_REG_ADDR_BASE + 0x0000)
121 #define HS_E2P_CMD_EPC_BUSY_		BIT(31)
122 #define HS_E2P_CMD_EPC_CMD_WRITE_	GENMASK(29, 28)
123 #define HS_E2P_CMD_EPC_CMD_READ_	(0x0)
124 #define HS_E2P_CMD_EPC_TIMEOUT_		BIT(17)
125 #define HS_E2P_CMD_EPC_ADDR_MASK_	GENMASK(15, 0)
126 #define HS_E2P_DATA			(HS_EEPROM_REG_ADDR_BASE + 0x0004)
127 #define HS_E2P_DATA_MASK_		GENMASK(7, 0)
128 #define HS_E2P_CFG			(HS_EEPROM_REG_ADDR_BASE + 0x0008)
129 #define HS_E2P_CFG_I2C_PULSE_MASK_	GENMASK(19, 16)
130 #define HS_E2P_CFG_EEPROM_SIZE_SEL_	BIT(12)
131 #define HS_E2P_CFG_I2C_BAUD_RATE_MASK_	GENMASK(9, 8)
132 #define HS_E2P_CFG_TEST_EEPR_TO_BYP_	BIT(0)
133 #define HS_E2P_PAD_CTL			(HS_EEPROM_REG_ADDR_BASE + 0x000C)
134 
135 #define GPIO_CFG0			(0x050)
136 #define GPIO_CFG0_GPIO_DIR_BIT_(bit)	BIT(16 + (bit))
137 #define GPIO_CFG0_GPIO_DATA_BIT_(bit)	BIT(0 + (bit))
138 
139 #define GPIO_CFG1			(0x054)
140 #define GPIO_CFG1_GPIOEN_BIT_(bit)	BIT(16 + (bit))
141 #define GPIO_CFG1_GPIOBUF_BIT_(bit)	BIT(0 + (bit))
142 
143 #define GPIO_CFG2			(0x058)
144 #define GPIO_CFG2_1588_POL_BIT_(bit)	BIT(0 + (bit))
145 
146 #define GPIO_CFG3			(0x05C)
147 #define GPIO_CFG3_1588_CH_SEL_BIT_(bit)	BIT(16 + (bit))
148 #define GPIO_CFG3_1588_OE_BIT_(bit)	BIT(0 + (bit))
149 
150 #define FCT_RX_CTL			(0xAC)
151 #define FCT_RX_CTL_EN_(channel)		BIT(28 + (channel))
152 #define FCT_RX_CTL_DIS_(channel)	BIT(24 + (channel))
153 #define FCT_RX_CTL_RESET_(channel)	BIT(20 + (channel))
154 
155 #define FCT_TX_CTL			(0xC4)
156 #define FCT_TX_CTL_EN_(channel)		BIT(28 + (channel))
157 #define FCT_TX_CTL_DIS_(channel)	BIT(24 + (channel))
158 #define FCT_TX_CTL_RESET_(channel)	BIT(20 + (channel))
159 
160 #define FCT_FLOW(rx_channel)			(0xE0 + ((rx_channel) << 2))
161 #define FCT_FLOW_CTL_OFF_THRESHOLD_		(0x00007F00)
162 #define FCT_FLOW_CTL_OFF_THRESHOLD_SET_(value)	\
163 	((value << 8) & FCT_FLOW_CTL_OFF_THRESHOLD_)
164 #define FCT_FLOW_CTL_REQ_EN_			BIT(7)
165 #define FCT_FLOW_CTL_ON_THRESHOLD_		(0x0000007F)
166 #define FCT_FLOW_CTL_ON_THRESHOLD_SET_(value)	\
167 	((value << 0) & FCT_FLOW_CTL_ON_THRESHOLD_)
168 
169 #define MAC_CR				(0x100)
170 #define MAC_CR_MII_EN_			BIT(19)
171 #define MAC_CR_EEE_EN_			BIT(17)
172 #define MAC_CR_ADD_			BIT(12)
173 #define MAC_CR_ASD_			BIT(11)
174 #define MAC_CR_CNTR_RST_		BIT(5)
175 #define MAC_CR_DPX_			BIT(3)
176 #define MAC_CR_CFG_H_			BIT(2)
177 #define MAC_CR_CFG_L_			BIT(1)
178 #define MAC_CR_RST_			BIT(0)
179 
180 #define MAC_RX				(0x104)
181 #define MAC_RX_MAX_SIZE_SHIFT_		(16)
182 #define MAC_RX_MAX_SIZE_MASK_		(0x3FFF0000)
183 #define MAC_RX_RXD_			BIT(1)
184 #define MAC_RX_RXEN_			BIT(0)
185 
186 #define MAC_TX				(0x108)
187 #define MAC_TX_TXD_			BIT(1)
188 #define MAC_TX_TXEN_			BIT(0)
189 
190 #define MAC_FLOW			(0x10C)
191 #define MAC_FLOW_CR_TX_FCEN_		BIT(30)
192 #define MAC_FLOW_CR_RX_FCEN_		BIT(29)
193 #define MAC_FLOW_CR_FCPT_MASK_		(0x0000FFFF)
194 
195 #define MAC_RX_ADDRH			(0x118)
196 
197 #define MAC_RX_ADDRL			(0x11C)
198 
199 #define MAC_MII_ACC			(0x120)
200 #define MAC_MII_ACC_MDC_CYCLE_SHIFT_	(16)
201 #define MAC_MII_ACC_MDC_CYCLE_MASK_	(0x00070000)
202 #define MAC_MII_ACC_MDC_CYCLE_2_5MHZ_	(0)
203 #define MAC_MII_ACC_MDC_CYCLE_5MHZ_	(1)
204 #define MAC_MII_ACC_MDC_CYCLE_12_5MHZ_	(2)
205 #define MAC_MII_ACC_MDC_CYCLE_25MHZ_	(3)
206 #define MAC_MII_ACC_MDC_CYCLE_1_25MHZ_	(4)
207 #define MAC_MII_ACC_PHY_ADDR_SHIFT_	(11)
208 #define MAC_MII_ACC_PHY_ADDR_MASK_	(0x0000F800)
209 #define MAC_MII_ACC_MIIRINDA_SHIFT_	(6)
210 #define MAC_MII_ACC_MIIRINDA_MASK_	(0x000007C0)
211 #define MAC_MII_ACC_MII_READ_		(0x00000000)
212 #define MAC_MII_ACC_MII_WRITE_		(0x00000002)
213 #define MAC_MII_ACC_MII_BUSY_		BIT(0)
214 
215 #define MAC_MII_ACC_MIIMMD_SHIFT_	(6)
216 #define MAC_MII_ACC_MIIMMD_MASK_	(0x000007C0)
217 #define MAC_MII_ACC_MIICL45_		BIT(3)
218 #define MAC_MII_ACC_MIICMD_MASK_	(0x00000006)
219 #define MAC_MII_ACC_MIICMD_ADDR_	(0x00000000)
220 #define MAC_MII_ACC_MIICMD_WRITE_	(0x00000002)
221 #define MAC_MII_ACC_MIICMD_READ_	(0x00000004)
222 #define MAC_MII_ACC_MIICMD_READ_INC_	(0x00000006)
223 
224 #define MAC_MII_DATA			(0x124)
225 
226 #define MAC_EEE_TX_LPI_REQ_DLY_CNT		(0x130)
227 
228 #define MAC_WUCSR				(0x140)
229 #define MAC_MP_SO_EN_				BIT(21)
230 #define MAC_WUCSR_RFE_WAKE_EN_			BIT(14)
231 #define MAC_WUCSR_EEE_TX_WAKE_			BIT(13)
232 #define MAC_WUCSR_EEE_RX_WAKE_			BIT(11)
233 #define MAC_WUCSR_RFE_WAKE_FR_			BIT(9)
234 #define MAC_WUCSR_PFDA_FR_			BIT(7)
235 #define MAC_WUCSR_WUFR_				BIT(6)
236 #define MAC_WUCSR_MPR_				BIT(5)
237 #define MAC_WUCSR_BCAST_FR_			BIT(4)
238 #define MAC_WUCSR_PFDA_EN_			BIT(3)
239 #define MAC_WUCSR_WAKE_EN_			BIT(2)
240 #define MAC_WUCSR_MPEN_				BIT(1)
241 #define MAC_WUCSR_BCST_EN_			BIT(0)
242 
243 #define MAC_WK_SRC				(0x144)
244 #define MAC_WK_SRC_ETH_PHY_WK_			BIT(17)
245 #define MAC_WK_SRC_IPV6_TCPSYN_RCD_WK_		BIT(16)
246 #define MAC_WK_SRC_IPV4_TCPSYN_RCD_WK_		BIT(15)
247 #define MAC_WK_SRC_EEE_TX_WK_			BIT(14)
248 #define MAC_WK_SRC_EEE_RX_WK_			BIT(13)
249 #define MAC_WK_SRC_RFE_FR_WK_			BIT(12)
250 #define MAC_WK_SRC_PFDA_FR_WK_			BIT(11)
251 #define MAC_WK_SRC_MP_FR_WK_			BIT(10)
252 #define MAC_WK_SRC_BCAST_FR_WK_			BIT(9)
253 #define MAC_WK_SRC_WU_FR_WK_			BIT(8)
254 #define MAC_WK_SRC_WK_FR_SAVED_			BIT(7)
255 
256 #define MAC_MP_SO_HI				(0x148)
257 #define MAC_MP_SO_LO				(0x14C)
258 
259 #define MAC_WUF_CFG0			(0x150)
260 #define MAC_NUM_OF_WUF_CFG		(32)
261 #define MAC_WUF_CFG_BEGIN		(MAC_WUF_CFG0)
262 #define MAC_WUF_CFG(index)		(MAC_WUF_CFG_BEGIN + (4 * (index)))
263 #define MAC_WUF_CFG_EN_			BIT(31)
264 #define MAC_WUF_CFG_TYPE_MCAST_		(0x02000000)
265 #define MAC_WUF_CFG_TYPE_ALL_		(0x01000000)
266 #define MAC_WUF_CFG_OFFSET_SHIFT_	(16)
267 #define MAC_WUF_CFG_CRC16_MASK_		(0x0000FFFF)
268 
269 #define MAC_WUF_MASK0_0			(0x200)
270 #define MAC_WUF_MASK0_1			(0x204)
271 #define MAC_WUF_MASK0_2			(0x208)
272 #define MAC_WUF_MASK0_3			(0x20C)
273 #define MAC_WUF_MASK0_BEGIN		(MAC_WUF_MASK0_0)
274 #define MAC_WUF_MASK1_BEGIN		(MAC_WUF_MASK0_1)
275 #define MAC_WUF_MASK2_BEGIN		(MAC_WUF_MASK0_2)
276 #define MAC_WUF_MASK3_BEGIN		(MAC_WUF_MASK0_3)
277 #define MAC_WUF_MASK0(index)		(MAC_WUF_MASK0_BEGIN + (0x10 * (index)))
278 #define MAC_WUF_MASK1(index)		(MAC_WUF_MASK1_BEGIN + (0x10 * (index)))
279 #define MAC_WUF_MASK2(index)		(MAC_WUF_MASK2_BEGIN + (0x10 * (index)))
280 #define MAC_WUF_MASK3(index)		(MAC_WUF_MASK3_BEGIN + (0x10 * (index)))
281 
282 /* offset 0x400 - 0x500, x may range from 0 to 32, for a total of 33 entries */
283 #define RFE_ADDR_FILT_HI(x)		(0x400 + (8 * (x)))
284 #define RFE_ADDR_FILT_HI_VALID_		BIT(31)
285 
286 /* offset 0x404 - 0x504, x may range from 0 to 32, for a total of 33 entries */
287 #define RFE_ADDR_FILT_LO(x)		(0x404 + (8 * (x)))
288 
289 #define RFE_CTL				(0x508)
290 #define RFE_CTL_TCP_UDP_COE_		BIT(12)
291 #define RFE_CTL_IP_COE_			BIT(11)
292 #define RFE_CTL_AB_			BIT(10)
293 #define RFE_CTL_AM_			BIT(9)
294 #define RFE_CTL_AU_			BIT(8)
295 #define RFE_CTL_MCAST_HASH_		BIT(3)
296 #define RFE_CTL_DA_PERFECT_		BIT(1)
297 
298 #define RFE_RSS_CFG			(0x554)
299 #define RFE_RSS_CFG_UDP_IPV6_EX_	BIT(16)
300 #define RFE_RSS_CFG_TCP_IPV6_EX_	BIT(15)
301 #define RFE_RSS_CFG_IPV6_EX_		BIT(14)
302 #define RFE_RSS_CFG_UDP_IPV6_		BIT(13)
303 #define RFE_RSS_CFG_TCP_IPV6_		BIT(12)
304 #define RFE_RSS_CFG_IPV6_		BIT(11)
305 #define RFE_RSS_CFG_UDP_IPV4_		BIT(10)
306 #define RFE_RSS_CFG_TCP_IPV4_		BIT(9)
307 #define RFE_RSS_CFG_IPV4_		BIT(8)
308 #define RFE_RSS_CFG_VALID_HASH_BITS_	(0x000000E0)
309 #define RFE_RSS_CFG_RSS_QUEUE_ENABLE_	BIT(2)
310 #define RFE_RSS_CFG_RSS_HASH_STORE_	BIT(1)
311 #define RFE_RSS_CFG_RSS_ENABLE_		BIT(0)
312 
313 #define RFE_HASH_KEY(index)		(0x558 + (index << 2))
314 
315 #define RFE_INDX(index)			(0x580 + (index << 2))
316 
317 #define MAC_WUCSR2			(0x600)
318 #define MAC_WUCSR2_NS_RCD_		BIT(7)
319 #define MAC_WUCSR2_ARP_RCD_		BIT(6)
320 #define MAC_WUCSR2_IPV6_TCPSYN_RCD_	BIT(5)
321 #define MAC_WUCSR2_IPV4_TCPSYN_RCD_	BIT(4)
322 
323 #define SGMII_ACC			(0x720)
324 #define SGMII_ACC_SGMII_BZY_		BIT(31)
325 #define SGMII_ACC_SGMII_WR_		BIT(30)
326 #define SGMII_ACC_SGMII_MMD_SHIFT_	(16)
327 #define SGMII_ACC_SGMII_MMD_MASK_	GENMASK(20, 16)
328 #define SGMII_ACC_SGMII_MMD_VSR_	BIT(15)
329 #define SGMII_ACC_SGMII_ADDR_SHIFT_	(0)
330 #define SGMII_ACC_SGMII_ADDR_MASK_	GENMASK(15, 0)
331 #define SGMII_DATA			(0x724)
332 #define SGMII_DATA_SHIFT_		(0)
333 #define SGMII_DATA_MASK_		GENMASK(15, 0)
334 #define SGMII_CTL			(0x728)
335 #define SGMII_CTL_SGMII_ENABLE_		BIT(31)
336 #define SGMII_CTL_LINK_STATUS_SOURCE_	BIT(8)
337 #define SGMII_CTL_SGMII_POWER_DN_	BIT(1)
338 
339 #define MISC_CTL_0			(0x920)
340 #define MISC_CTL_0_RFE_READ_FIFO_MASK_	GENMASK(6, 4)
341 
342 /* Vendor Specific SGMII MMD details */
343 #define SR_VSMMD_PCS_ID1		0x0004
344 #define SR_VSMMD_PCS_ID2		0x0005
345 #define SR_VSMMD_STS			0x0008
346 #define SR_VSMMD_CTRL			0x0009
347 
348 #define VR_MII_DIG_CTRL1			0x8000
349 #define VR_MII_DIG_CTRL1_VR_RST_		BIT(15)
350 #define VR_MII_DIG_CTRL1_R2TLBE_		BIT(14)
351 #define VR_MII_DIG_CTRL1_EN_VSMMD1_		BIT(13)
352 #define VR_MII_DIG_CTRL1_CS_EN_			BIT(10)
353 #define VR_MII_DIG_CTRL1_MAC_AUTO_SW_		BIT(9)
354 #define VR_MII_DIG_CTRL1_INIT_			BIT(8)
355 #define VR_MII_DIG_CTRL1_DTXLANED_0_		BIT(4)
356 #define VR_MII_DIG_CTRL1_CL37_TMR_OVR_RIDE_	BIT(3)
357 #define VR_MII_DIG_CTRL1_EN_2_5G_MODE_		BIT(2)
358 #define VR_MII_DIG_CTRL1_BYP_PWRUP_		BIT(1)
359 #define VR_MII_DIG_CTRL1_PHY_MODE_CTRL_		BIT(0)
360 #define VR_MII_AN_CTRL				0x8001
361 #define VR_MII_AN_CTRL_MII_CTRL_		BIT(8)
362 #define VR_MII_AN_CTRL_SGMII_LINK_STS_		BIT(4)
363 #define VR_MII_AN_CTRL_TX_CONFIG_		BIT(3)
364 #define VR_MII_AN_CTRL_1000BASE_X_		(0)
365 #define VR_MII_AN_CTRL_SGMII_MODE_		(2)
366 #define VR_MII_AN_CTRL_QSGMII_MODE_		(3)
367 #define VR_MII_AN_CTRL_PCS_MODE_SHIFT_		(1)
368 #define VR_MII_AN_CTRL_PCS_MODE_MASK_		GENMASK(2, 1)
369 #define VR_MII_AN_CTRL_MII_AN_INTR_EN_		BIT(0)
370 #define VR_MII_AN_INTR_STS			0x8002
371 #define VR_MII_AN_INTR_STS_LINK_UP_		BIT(4)
372 #define VR_MII_AN_INTR_STS_SPEED_MASK_		GENMASK(3, 2)
373 #define VR_MII_AN_INTR_STS_1000_MBPS_		BIT(3)
374 #define VR_MII_AN_INTR_STS_100_MBPS_		BIT(2)
375 #define VR_MII_AN_INTR_STS_10_MBPS_		(0)
376 #define VR_MII_AN_INTR_STS_FDX_			BIT(1)
377 #define VR_MII_AN_INTR_STS_CL37_ANCMPLT_INTR_	BIT(0)
378 
379 #define VR_MII_LINK_TIMER_CTRL			0x800A
380 #define VR_MII_DIG_STS                          0x8010
381 #define VR_MII_DIG_STS_PSEQ_STATE_MASK_         GENMASK(4, 2)
382 #define VR_MII_DIG_STS_PSEQ_STATE_POS_          (2)
383 #define VR_MII_GEN2_4_MPLL_CTRL0		0x8078
384 #define VR_MII_MPLL_CTRL0_REF_CLK_DIV2_		BIT(12)
385 #define VR_MII_MPLL_CTRL0_USE_REFCLK_PAD_	BIT(4)
386 #define VR_MII_GEN2_4_MPLL_CTRL1		0x8079
387 #define VR_MII_MPLL_CTRL1_MPLL_MULTIPLIER_	GENMASK(6, 0)
388 #define VR_MII_BAUD_RATE_3P125GBPS		(3125)
389 #define VR_MII_BAUD_RATE_1P25GBPS		(1250)
390 #define VR_MII_MPLL_MULTIPLIER_125		(125)
391 #define VR_MII_MPLL_MULTIPLIER_100		(100)
392 #define VR_MII_MPLL_MULTIPLIER_50		(50)
393 #define VR_MII_MPLL_MULTIPLIER_40		(40)
394 #define VR_MII_GEN2_4_MISC_CTRL1		0x809A
395 #define VR_MII_CTRL1_RX_RATE_0_MASK_		GENMASK(3, 2)
396 #define VR_MII_CTRL1_RX_RATE_0_SHIFT_		(2)
397 #define VR_MII_CTRL1_TX_RATE_0_MASK_		GENMASK(1, 0)
398 #define VR_MII_MPLL_BAUD_CLK			(0)
399 #define VR_MII_MPLL_BAUD_CLK_DIV_2		(1)
400 #define VR_MII_MPLL_BAUD_CLK_DIV_4		(2)
401 
402 #define INT_STS				(0x780)
403 #define INT_BIT_DMA_RX_(channel)	BIT(24 + (channel))
404 #define INT_BIT_ALL_RX_			(0x0F000000)
405 #define INT_BIT_DMA_TX_(channel)	BIT(16 + (channel))
406 #define INT_BIT_ALL_TX_			(0x000F0000)
407 #define INT_BIT_SW_GP_			BIT(9)
408 #define INT_BIT_1588_			BIT(7)
409 #define INT_BIT_ALL_OTHER_		(INT_BIT_SW_GP_ | INT_BIT_1588_)
410 #define INT_BIT_MAS_			BIT(0)
411 
412 #define INT_SET				(0x784)
413 
414 #define INT_EN_SET			(0x788)
415 
416 #define INT_EN_CLR			(0x78C)
417 
418 #define INT_STS_R2C			(0x790)
419 
420 #define INT_VEC_EN_SET			(0x794)
421 #define INT_VEC_EN_CLR			(0x798)
422 #define INT_VEC_EN_AUTO_CLR		(0x79C)
423 #define INT_VEC_EN_(vector_index)	BIT(0 + vector_index)
424 
425 #define INT_VEC_MAP0			(0x7A0)
426 #define INT_VEC_MAP0_RX_VEC_(channel, vector)	\
427 	(((u32)(vector)) << ((channel) << 2))
428 
429 #define INT_VEC_MAP1			(0x7A4)
430 #define INT_VEC_MAP1_TX_VEC_(channel, vector)	\
431 	(((u32)(vector)) << ((channel) << 2))
432 
433 #define INT_VEC_MAP2			(0x7A8)
434 
435 #define INT_MOD_MAP0			(0x7B0)
436 
437 #define INT_MOD_MAP1			(0x7B4)
438 
439 #define INT_MOD_MAP2			(0x7B8)
440 
441 #define INT_MOD_CFG0			(0x7C0)
442 #define INT_MOD_CFG1			(0x7C4)
443 #define INT_MOD_CFG2			(0x7C8)
444 #define INT_MOD_CFG3			(0x7CC)
445 #define INT_MOD_CFG4			(0x7D0)
446 #define INT_MOD_CFG5			(0x7D4)
447 #define INT_MOD_CFG6			(0x7D8)
448 #define INT_MOD_CFG7			(0x7DC)
449 #define INT_MOD_CFG8			(0x7E0)
450 #define INT_MOD_CFG9			(0x7E4)
451 
452 #define PTP_CMD_CTL					(0x0A00)
453 #define PTP_CMD_CTL_PTP_LTC_TARGET_READ_		BIT(13)
454 #define PTP_CMD_CTL_PTP_CLK_STP_NSEC_			BIT(6)
455 #define PTP_CMD_CTL_PTP_CLOCK_STEP_SEC_			BIT(5)
456 #define PTP_CMD_CTL_PTP_CLOCK_LOAD_			BIT(4)
457 #define PTP_CMD_CTL_PTP_CLOCK_READ_			BIT(3)
458 #define PTP_CMD_CTL_PTP_ENABLE_				BIT(2)
459 #define PTP_CMD_CTL_PTP_DISABLE_			BIT(1)
460 #define PTP_CMD_CTL_PTP_RESET_				BIT(0)
461 #define PTP_GENERAL_CONFIG				(0x0A04)
462 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_X_MASK_(channel) \
463 	(0x7 << (1 + ((channel) << 2)))
464 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_100NS_	(0)
465 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_10US_	(1)
466 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_100US_	(2)
467 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_1MS_	(3)
468 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_10MS_	(4)
469 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_200MS_	(5)
470 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_TOGGLE_	(6)
471 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_X_SET_(channel, value) \
472 	(((value) & 0x7) << (1 + ((channel) << 2)))
473 #define PTP_GENERAL_CONFIG_RELOAD_ADD_X_(channel)	(BIT((channel) << 2))
474 
475 #define HS_PTP_GENERAL_CONFIG				(0x0A04)
476 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_X_MASK_(channel) \
477 	(0xf << (4 + ((channel) << 2)))
478 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_100NS_	(0)
479 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_500NS_	(1)
480 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_1US_		(2)
481 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_5US_		(3)
482 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_10US_		(4)
483 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_50US_		(5)
484 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_100US_	(6)
485 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_500US_	(7)
486 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_1MS_		(8)
487 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_5MS_		(9)
488 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_10MS_		(10)
489 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_50MS_		(11)
490 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_100MS_	(12)
491 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_200MS_	(13)
492 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_TOGG_		(14)
493 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_INT_		(15)
494 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_X_SET_(channel, value) \
495 	(((value) & 0xf) << (4 + ((channel) << 2)))
496 #define HS_PTP_GENERAL_CONFIG_EVENT_POL_X_(channel)	(BIT(1 + ((channel) * 2)))
497 #define HS_PTP_GENERAL_CONFIG_RELOAD_ADD_X_(channel)	(BIT((channel) * 2))
498 
499 #define PTP_INT_STS				(0x0A08)
500 #define PTP_INT_IO_FE_MASK_			GENMASK(31, 24)
501 #define PTP_INT_IO_FE_SHIFT_			(24)
502 #define PTP_INT_IO_FE_SET_(channel)		BIT(24 + (channel))
503 #define PTP_INT_IO_RE_MASK_			GENMASK(23, 16)
504 #define PTP_INT_IO_RE_SHIFT_			(16)
505 #define PTP_INT_IO_RE_SET_(channel)		BIT(16 + (channel))
506 #define PTP_INT_TX_TS_OVRFL_INT_		BIT(14)
507 #define PTP_INT_TX_SWTS_ERR_INT_		BIT(13)
508 #define PTP_INT_TX_TS_INT_			BIT(12)
509 #define PTP_INT_RX_TS_OVRFL_INT_		BIT(9)
510 #define PTP_INT_RX_TS_INT_			BIT(8)
511 #define PTP_INT_TIMER_INT_B_			BIT(1)
512 #define PTP_INT_TIMER_INT_A_			BIT(0)
513 #define PTP_INT_EN_SET				(0x0A0C)
514 #define PTP_INT_EN_FE_EN_SET_(channel)		BIT(24 + (channel))
515 #define PTP_INT_EN_RE_EN_SET_(channel)		BIT(16 + (channel))
516 #define PTP_INT_EN_TIMER_SET_(channel)		BIT(channel)
517 #define PTP_INT_EN_CLR				(0x0A10)
518 #define PTP_INT_EN_FE_EN_CLR_(channel)		BIT(24 + (channel))
519 #define PTP_INT_EN_RE_EN_CLR_(channel)		BIT(16 + (channel))
520 #define PTP_INT_BIT_TX_SWTS_ERR_		BIT(13)
521 #define PTP_INT_BIT_TX_TS_			BIT(12)
522 #define PTP_INT_BIT_TIMER_B_			BIT(1)
523 #define PTP_INT_BIT_TIMER_A_			BIT(0)
524 
525 #define PTP_CLOCK_SEC				(0x0A14)
526 #define PTP_CLOCK_NS				(0x0A18)
527 #define PTP_CLOCK_SUBNS				(0x0A1C)
528 #define PTP_CLOCK_RATE_ADJ			(0x0A20)
529 #define PTP_CLOCK_RATE_ADJ_DIR_			BIT(31)
530 #define PTP_CLOCK_STEP_ADJ			(0x0A2C)
531 #define PTP_CLOCK_STEP_ADJ_DIR_			BIT(31)
532 #define PTP_CLOCK_STEP_ADJ_VALUE_MASK_		(0x3FFFFFFF)
533 #define PTP_CLOCK_TARGET_SEC_X(channel)		(0x0A30 + ((channel) << 4))
534 #define PTP_CLOCK_TARGET_NS_X(channel)		(0x0A34 + ((channel) << 4))
535 #define PTP_CLOCK_TARGET_RELOAD_SEC_X(channel)	(0x0A38 + ((channel) << 4))
536 #define PTP_CLOCK_TARGET_RELOAD_NS_X(channel)	(0x0A3C + ((channel) << 4))
537 #define PTP_LTC_SET_SEC_HI			(0x0A50)
538 #define PTP_LTC_SET_SEC_HI_SEC_47_32_MASK_	GENMASK(15, 0)
539 #define PTP_VERSION				(0x0A54)
540 #define PTP_VERSION_TX_UP_MASK_			GENMASK(31, 24)
541 #define PTP_VERSION_TX_LO_MASK_			GENMASK(23, 16)
542 #define PTP_VERSION_RX_UP_MASK_			GENMASK(15, 8)
543 #define PTP_VERSION_RX_LO_MASK_			GENMASK(7, 0)
544 #define PTP_IO_SEL				(0x0A58)
545 #define PTP_IO_SEL_MASK_			GENMASK(10, 8)
546 #define PTP_IO_SEL_SHIFT_			(8)
547 #define PTP_LATENCY				(0x0A5C)
548 #define PTP_LATENCY_TX_SET_(tx_latency)		(((u32)(tx_latency)) << 16)
549 #define PTP_LATENCY_RX_SET_(rx_latency)		\
550 	(((u32)(rx_latency)) & 0x0000FFFF)
551 #define PTP_CAP_INFO				(0x0A60)
552 #define PTP_CAP_INFO_TX_TS_CNT_GET_(reg_val)	(((reg_val) & 0x00000070) >> 4)
553 #define PTP_RX_TS_CFG				(0x0A68)
554 #define PTP_RX_TS_CFG_EVENT_MSGS_               GENMASK(3, 0)
555 
556 #define PTP_TX_MOD				(0x0AA4)
557 #define PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_	(0x10000000)
558 
559 #define PTP_TX_MOD2				(0x0AA8)
560 #define PTP_TX_MOD2_TX_PTP_CLR_UDPV4_CHKSUM_	(0x00000001)
561 
562 #define PTP_TX_EGRESS_SEC			(0x0AAC)
563 #define PTP_TX_EGRESS_NS			(0x0AB0)
564 #define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_MASK_	(0xC0000000)
565 #define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_AUTO_	(0x00000000)
566 #define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_SW_	(0x40000000)
567 #define PTP_TX_EGRESS_NS_TS_NS_MASK_		(0x3FFFFFFF)
568 
569 #define PTP_TX_MSG_HEADER			(0x0AB4)
570 #define PTP_TX_MSG_HEADER_MSG_TYPE_		(0x000F0000)
571 #define PTP_TX_MSG_HEADER_MSG_TYPE_SYNC_	(0x00000000)
572 
573 #define PTP_TX_CAP_INFO				(0x0AB8)
574 #define PTP_TX_CAP_INFO_TX_CH_MASK_		GENMASK(1, 0)
575 #define PTP_TX_DOMAIN				(0x0ABC)
576 #define PTP_TX_DOMAIN_MASK_			GENMASK(23, 16)
577 #define PTP_TX_DOMAIN_RANGE_EN_			BIT(15)
578 #define PTP_TX_DOMAIN_RANGE_MASK_		GENMASK(7, 0)
579 #define PTP_TX_SDOID				(0x0AC0)
580 #define PTP_TX_SDOID_MASK_			GENMASK(23, 16)
581 #define PTP_TX_SDOID_RANGE_EN_			BIT(15)
582 #define PTP_TX_SDOID_11_0_MASK_			GENMASK(7, 0)
583 #define PTP_IO_CAP_CONFIG			(0x0AC4)
584 #define PTP_IO_CAP_CONFIG_LOCK_FE_(channel)	BIT(24 + (channel))
585 #define PTP_IO_CAP_CONFIG_LOCK_RE_(channel)	BIT(16 + (channel))
586 #define PTP_IO_CAP_CONFIG_FE_CAP_EN_(channel)	BIT(8 + (channel))
587 #define PTP_IO_CAP_CONFIG_RE_CAP_EN_(channel)	BIT(0 + (channel))
588 #define PTP_IO_RE_LTC_SEC_CAP_X			(0x0AC8)
589 #define PTP_IO_RE_LTC_NS_CAP_X			(0x0ACC)
590 #define PTP_IO_FE_LTC_SEC_CAP_X			(0x0AD0)
591 #define PTP_IO_FE_LTC_NS_CAP_X			(0x0AD4)
592 #define PTP_IO_EVENT_OUTPUT_CFG			(0x0AD8)
593 #define PTP_IO_EVENT_OUTPUT_CFG_SEL_(channel)	BIT(16 + (channel))
594 #define PTP_IO_EVENT_OUTPUT_CFG_EN_(channel)	BIT(0 + (channel))
595 #define PTP_IO_PIN_CFG				(0x0ADC)
596 #define PTP_IO_PIN_CFG_OBUF_TYPE_(channel)	BIT(0 + (channel))
597 #define PTP_LTC_RD_SEC_HI			(0x0AF0)
598 #define PTP_LTC_RD_SEC_HI_SEC_47_32_MASK_	GENMASK(15, 0)
599 #define PTP_LTC_RD_SEC_LO			(0x0AF4)
600 #define PTP_LTC_RD_NS				(0x0AF8)
601 #define PTP_LTC_RD_NS_29_0_MASK_		GENMASK(29, 0)
602 #define PTP_LTC_RD_SUBNS			(0x0AFC)
603 #define PTP_RX_USER_MAC_HI			(0x0B00)
604 #define PTP_RX_USER_MAC_HI_47_32_MASK_		GENMASK(15, 0)
605 #define PTP_RX_USER_MAC_LO			(0x0B04)
606 #define PTP_RX_USER_IP_ADDR_0			(0x0B20)
607 #define PTP_RX_USER_IP_ADDR_1			(0x0B24)
608 #define PTP_RX_USER_IP_ADDR_2			(0x0B28)
609 #define PTP_RX_USER_IP_ADDR_3			(0x0B2C)
610 #define PTP_RX_USER_IP_MASK_0			(0x0B30)
611 #define PTP_RX_USER_IP_MASK_1			(0x0B34)
612 #define PTP_RX_USER_IP_MASK_2			(0x0B38)
613 #define PTP_RX_USER_IP_MASK_3			(0x0B3C)
614 #define PTP_TX_USER_MAC_HI			(0x0B40)
615 #define PTP_TX_USER_MAC_HI_47_32_MASK_		GENMASK(15, 0)
616 #define PTP_TX_USER_MAC_LO			(0x0B44)
617 #define PTP_TX_USER_IP_ADDR_0			(0x0B60)
618 #define PTP_TX_USER_IP_ADDR_1			(0x0B64)
619 #define PTP_TX_USER_IP_ADDR_2			(0x0B68)
620 #define PTP_TX_USER_IP_ADDR_3			(0x0B6C)
621 #define PTP_TX_USER_IP_MASK_0			(0x0B70)
622 #define PTP_TX_USER_IP_MASK_1			(0x0B74)
623 #define PTP_TX_USER_IP_MASK_2			(0x0B78)
624 #define PTP_TX_USER_IP_MASK_3			(0x0B7C)
625 
626 #define DMAC_CFG				(0xC00)
627 #define DMAC_CFG_COAL_EN_			BIT(16)
628 #define DMAC_CFG_CH_ARB_SEL_RX_HIGH_		(0x00000000)
629 #define DMAC_CFG_MAX_READ_REQ_MASK_		(0x00000070)
630 #define DMAC_CFG_MAX_READ_REQ_SET_(val)	\
631 	((((u32)(val)) << 4) & DMAC_CFG_MAX_READ_REQ_MASK_)
632 #define DMAC_CFG_MAX_DSPACE_16_			(0x00000000)
633 #define DMAC_CFG_MAX_DSPACE_32_			(0x00000001)
634 #define DMAC_CFG_MAX_DSPACE_64_			BIT(1)
635 #define DMAC_CFG_MAX_DSPACE_128_		(0x00000003)
636 
637 #define DMAC_COAL_CFG				(0xC04)
638 #define DMAC_COAL_CFG_TIMER_LIMIT_MASK_		(0xFFF00000)
639 #define DMAC_COAL_CFG_TIMER_LIMIT_SET_(val)	\
640 	((((u32)(val)) << 20) & DMAC_COAL_CFG_TIMER_LIMIT_MASK_)
641 #define DMAC_COAL_CFG_TIMER_TX_START_		BIT(19)
642 #define DMAC_COAL_CFG_FLUSH_INTS_		BIT(18)
643 #define DMAC_COAL_CFG_INT_EXIT_COAL_		BIT(17)
644 #define DMAC_COAL_CFG_CSR_EXIT_COAL_		BIT(16)
645 #define DMAC_COAL_CFG_TX_THRES_MASK_		(0x0000FF00)
646 #define DMAC_COAL_CFG_TX_THRES_SET_(val)	\
647 	((((u32)(val)) << 8) & DMAC_COAL_CFG_TX_THRES_MASK_)
648 #define DMAC_COAL_CFG_RX_THRES_MASK_		(0x000000FF)
649 #define DMAC_COAL_CFG_RX_THRES_SET_(val)	\
650 	(((u32)(val)) & DMAC_COAL_CFG_RX_THRES_MASK_)
651 
652 #define DMAC_OBFF_CFG				(0xC08)
653 #define DMAC_OBFF_TX_THRES_MASK_		(0x0000FF00)
654 #define DMAC_OBFF_TX_THRES_SET_(val)	\
655 	((((u32)(val)) << 8) & DMAC_OBFF_TX_THRES_MASK_)
656 #define DMAC_OBFF_RX_THRES_MASK_		(0x000000FF)
657 #define DMAC_OBFF_RX_THRES_SET_(val)	\
658 	(((u32)(val)) & DMAC_OBFF_RX_THRES_MASK_)
659 
660 #define DMAC_CMD				(0xC0C)
661 #define DMAC_CMD_SWR_				BIT(31)
662 #define DMAC_CMD_TX_SWR_(channel)		BIT(24 + (channel))
663 #define DMAC_CMD_START_T_(channel)		BIT(20 + (channel))
664 #define DMAC_CMD_STOP_T_(channel)		BIT(16 + (channel))
665 #define DMAC_CMD_RX_SWR_(channel)		BIT(8 + (channel))
666 #define DMAC_CMD_START_R_(channel)		BIT(4 + (channel))
667 #define DMAC_CMD_STOP_R_(channel)		BIT(0 + (channel))
668 
669 #define DMAC_INT_STS				(0xC10)
670 #define DMAC_INT_EN_SET				(0xC14)
671 #define DMAC_INT_EN_CLR				(0xC18)
672 #define DMAC_INT_BIT_RXFRM_(channel)		BIT(16 + (channel))
673 #define DMAC_INT_BIT_TX_IOC_(channel)		BIT(0 + (channel))
674 
675 #define RX_CFG_A(channel)			(0xC40 + ((channel) << 6))
676 #define RX_CFG_A_RX_WB_ON_INT_TMR_		BIT(30)
677 #define RX_CFG_A_RX_WB_THRES_MASK_		(0x1F000000)
678 #define RX_CFG_A_RX_WB_THRES_SET_(val)	\
679 	((((u32)(val)) << 24) & RX_CFG_A_RX_WB_THRES_MASK_)
680 #define RX_CFG_A_RX_PF_THRES_MASK_		(0x001F0000)
681 #define RX_CFG_A_RX_PF_THRES_SET_(val)	\
682 	((((u32)(val)) << 16) & RX_CFG_A_RX_PF_THRES_MASK_)
683 #define RX_CFG_A_RX_PF_PRI_THRES_MASK_		(0x00001F00)
684 #define RX_CFG_A_RX_PF_PRI_THRES_SET_(val)	\
685 	((((u32)(val)) << 8) & RX_CFG_A_RX_PF_PRI_THRES_MASK_)
686 #define RX_CFG_A_RX_HP_WB_EN_			BIT(5)
687 
688 #define RX_CFG_B(channel)			(0xC44 + ((channel) << 6))
689 #define RX_CFG_B_TS_ALL_RX_			BIT(29)
690 #define RX_CFG_B_TS_DESCR_EN_			BIT(28)
691 #define RX_CFG_B_TS_NONE_			0
692 #define RX_CFG_B_TS_MASK_			(0xCFFFFFFF)
693 #define RX_CFG_B_RX_PAD_MASK_			(0x03000000)
694 #define RX_CFG_B_RX_PAD_0_			(0x00000000)
695 #define RX_CFG_B_RX_PAD_2_			(0x02000000)
696 #define RX_CFG_B_RDMABL_512_			(0x00040000)
697 #define RX_CFG_B_RX_RING_LEN_MASK_		(0x0000FFFF)
698 
699 #define RX_BASE_ADDRH(channel)			(0xC48 + ((channel) << 6))
700 
701 #define RX_BASE_ADDRL(channel)			(0xC4C + ((channel) << 6))
702 
703 #define RX_HEAD_WRITEBACK_ADDRH(channel)	(0xC50 + ((channel) << 6))
704 
705 #define RX_HEAD_WRITEBACK_ADDRL(channel)	(0xC54 + ((channel) << 6))
706 
707 #define RX_HEAD(channel)			(0xC58 + ((channel) << 6))
708 
709 #define RX_TAIL(channel)			(0xC5C + ((channel) << 6))
710 #define RX_TAIL_SET_TOP_INT_EN_			BIT(30)
711 #define RX_TAIL_SET_TOP_INT_VEC_EN_		BIT(29)
712 
713 #define RX_CFG_C(channel)			(0xC64 + ((channel) << 6))
714 #define RX_CFG_C_RX_TOP_INT_EN_AUTO_CLR_	BIT(6)
715 #define RX_CFG_C_RX_INT_EN_R2C_			BIT(4)
716 #define RX_CFG_C_RX_DMA_INT_STS_AUTO_CLR_	BIT(3)
717 #define RX_CFG_C_RX_INT_STS_R2C_MODE_MASK_	(0x00000007)
718 
719 #define TX_CFG_A(channel)			(0xD40 + ((channel) << 6))
720 #define TX_CFG_A_TX_HP_WB_ON_INT_TMR_		BIT(30)
721 #define TX_CFG_A_TX_TMR_HPWB_SEL_IOC_		(0x10000000)
722 #define TX_CFG_A_TX_PF_THRES_MASK_		(0x001F0000)
723 #define TX_CFG_A_TX_PF_THRES_SET_(value)	\
724 	((((u32)(value)) << 16) & TX_CFG_A_TX_PF_THRES_MASK_)
725 #define TX_CFG_A_TX_PF_PRI_THRES_MASK_		(0x00001F00)
726 #define TX_CFG_A_TX_PF_PRI_THRES_SET_(value)	\
727 	((((u32)(value)) << 8) & TX_CFG_A_TX_PF_PRI_THRES_MASK_)
728 #define TX_CFG_A_TX_HP_WB_EN_			BIT(5)
729 #define TX_CFG_A_TX_HP_WB_THRES_MASK_		(0x0000000F)
730 #define TX_CFG_A_TX_HP_WB_THRES_SET_(value)	\
731 	(((u32)(value)) & TX_CFG_A_TX_HP_WB_THRES_MASK_)
732 
733 #define TX_CFG_B(channel)			(0xD44 + ((channel) << 6))
734 #define TX_CFG_B_TDMABL_512_			(0x00040000)
735 #define TX_CFG_B_TX_RING_LEN_MASK_		(0x0000FFFF)
736 
737 #define TX_BASE_ADDRH(channel)			(0xD48 + ((channel) << 6))
738 
739 #define TX_BASE_ADDRL(channel)			(0xD4C + ((channel) << 6))
740 
741 #define TX_HEAD_WRITEBACK_ADDRH(channel)	(0xD50 + ((channel) << 6))
742 
743 #define TX_HEAD_WRITEBACK_ADDRL(channel)	(0xD54 + ((channel) << 6))
744 
745 #define TX_HEAD(channel)			(0xD58 + ((channel) << 6))
746 
747 #define TX_TAIL(channel)			(0xD5C + ((channel) << 6))
748 #define TX_TAIL_SET_DMAC_INT_EN_		BIT(31)
749 #define TX_TAIL_SET_TOP_INT_EN_			BIT(30)
750 #define TX_TAIL_SET_TOP_INT_VEC_EN_		BIT(29)
751 
752 #define TX_CFG_C(channel)			(0xD64 + ((channel) << 6))
753 #define TX_CFG_C_TX_TOP_INT_EN_AUTO_CLR_	BIT(6)
754 #define TX_CFG_C_TX_DMA_INT_EN_AUTO_CLR_	BIT(5)
755 #define TX_CFG_C_TX_INT_EN_R2C_			BIT(4)
756 #define TX_CFG_C_TX_DMA_INT_STS_AUTO_CLR_	BIT(3)
757 #define TX_CFG_C_TX_INT_STS_R2C_MODE_MASK_	(0x00000007)
758 
759 #define OTP_PWR_DN				(0x1000)
760 #define OTP_PWR_DN_PWRDN_N_			BIT(0)
761 
762 #define OTP_ADDR_HIGH				(0x1004)
763 #define OTP_ADDR_LOW				(0x1008)
764 
765 #define OTP_PRGM_DATA				(0x1010)
766 
767 #define OTP_PRGM_MODE				(0x1014)
768 #define OTP_PRGM_MODE_BYTE_			BIT(0)
769 
770 #define OTP_READ_DATA				(0x1018)
771 
772 #define OTP_FUNC_CMD				(0x1020)
773 #define OTP_FUNC_CMD_READ_			BIT(0)
774 
775 #define OTP_TST_CMD				(0x1024)
776 #define OTP_TST_CMD_PRGVRFY_			BIT(3)
777 
778 #define OTP_CMD_GO				(0x1028)
779 #define OTP_CMD_GO_GO_				BIT(0)
780 
781 #define OTP_STATUS				(0x1030)
782 #define OTP_STATUS_BUSY_			BIT(0)
783 
784 /* Hearthstone OTP block registers */
785 #define HS_OTP_BLOCK_BASE			(ETH_SYS_REG_ADDR_BASE + \
786 						 ETH_OTP_REG_ADDR_BASE)
787 #define HS_OTP_PWR_DN				(HS_OTP_BLOCK_BASE + 0x0)
788 #define HS_OTP_ADDR_HIGH			(HS_OTP_BLOCK_BASE + 0x4)
789 #define HS_OTP_ADDR_LOW				(HS_OTP_BLOCK_BASE + 0x8)
790 #define HS_OTP_PRGM_DATA			(HS_OTP_BLOCK_BASE + 0x10)
791 #define HS_OTP_PRGM_MODE			(HS_OTP_BLOCK_BASE + 0x14)
792 #define HS_OTP_READ_DATA			(HS_OTP_BLOCK_BASE + 0x18)
793 #define HS_OTP_FUNC_CMD				(HS_OTP_BLOCK_BASE + 0x20)
794 #define HS_OTP_TST_CMD				(HS_OTP_BLOCK_BASE + 0x24)
795 #define HS_OTP_CMD_GO				(HS_OTP_BLOCK_BASE + 0x28)
796 #define HS_OTP_STATUS				(HS_OTP_BLOCK_BASE + 0x30)
797 
798 /* MAC statistics registers */
799 #define STAT_RX_FCS_ERRORS			(0x1200)
800 #define STAT_RX_ALIGNMENT_ERRORS		(0x1204)
801 #define STAT_RX_FRAGMENT_ERRORS			(0x1208)
802 #define STAT_RX_JABBER_ERRORS			(0x120C)
803 #define STAT_RX_UNDERSIZE_FRAME_ERRORS		(0x1210)
804 #define STAT_RX_OVERSIZE_FRAME_ERRORS		(0x1214)
805 #define STAT_RX_DROPPED_FRAMES			(0x1218)
806 #define STAT_RX_UNICAST_BYTE_COUNT		(0x121C)
807 #define STAT_RX_BROADCAST_BYTE_COUNT		(0x1220)
808 #define STAT_RX_MULTICAST_BYTE_COUNT		(0x1224)
809 #define STAT_RX_UNICAST_FRAMES			(0x1228)
810 #define STAT_RX_BROADCAST_FRAMES		(0x122C)
811 #define STAT_RX_MULTICAST_FRAMES		(0x1230)
812 #define STAT_RX_PAUSE_FRAMES			(0x1234)
813 #define STAT_RX_64_BYTE_FRAMES			(0x1238)
814 #define STAT_RX_65_127_BYTE_FRAMES		(0x123C)
815 #define STAT_RX_128_255_BYTE_FRAMES		(0x1240)
816 #define STAT_RX_256_511_BYTES_FRAMES		(0x1244)
817 #define STAT_RX_512_1023_BYTE_FRAMES		(0x1248)
818 #define STAT_RX_1024_1518_BYTE_FRAMES		(0x124C)
819 #define STAT_RX_GREATER_1518_BYTE_FRAMES	(0x1250)
820 #define STAT_RX_TOTAL_FRAMES			(0x1254)
821 #define STAT_EEE_RX_LPI_TRANSITIONS		(0x1258)
822 #define STAT_EEE_RX_LPI_TIME			(0x125C)
823 #define STAT_RX_COUNTER_ROLLOVER_STATUS		(0x127C)
824 
825 #define STAT_TX_FCS_ERRORS			(0x1280)
826 #define STAT_TX_EXCESS_DEFERRAL_ERRORS		(0x1284)
827 #define STAT_TX_CARRIER_ERRORS			(0x1288)
828 #define STAT_TX_BAD_BYTE_COUNT			(0x128C)
829 #define STAT_TX_SINGLE_COLLISIONS		(0x1290)
830 #define STAT_TX_MULTIPLE_COLLISIONS		(0x1294)
831 #define STAT_TX_EXCESSIVE_COLLISION		(0x1298)
832 #define STAT_TX_LATE_COLLISIONS			(0x129C)
833 #define STAT_TX_UNICAST_BYTE_COUNT		(0x12A0)
834 #define STAT_TX_BROADCAST_BYTE_COUNT		(0x12A4)
835 #define STAT_TX_MULTICAST_BYTE_COUNT		(0x12A8)
836 #define STAT_TX_UNICAST_FRAMES			(0x12AC)
837 #define STAT_TX_BROADCAST_FRAMES		(0x12B0)
838 #define STAT_TX_MULTICAST_FRAMES		(0x12B4)
839 #define STAT_TX_PAUSE_FRAMES			(0x12B8)
840 #define STAT_TX_64_BYTE_FRAMES			(0x12BC)
841 #define STAT_TX_65_127_BYTE_FRAMES		(0x12C0)
842 #define STAT_TX_128_255_BYTE_FRAMES		(0x12C4)
843 #define STAT_TX_256_511_BYTES_FRAMES		(0x12C8)
844 #define STAT_TX_512_1023_BYTE_FRAMES		(0x12CC)
845 #define STAT_TX_1024_1518_BYTE_FRAMES		(0x12D0)
846 #define STAT_TX_GREATER_1518_BYTE_FRAMES	(0x12D4)
847 #define STAT_TX_TOTAL_FRAMES			(0x12D8)
848 #define STAT_EEE_TX_LPI_TRANSITIONS		(0x12DC)
849 #define STAT_EEE_TX_LPI_TIME			(0x12E0)
850 #define STAT_TX_COUNTER_ROLLOVER_STATUS		(0x12FC)
851 
852 /* End of Register definitions */
853 
854 #define LAN743X_MAX_RX_CHANNELS		(4)
855 #define LAN743X_MAX_TX_CHANNELS		(1)
856 #define PCI11X1X_MAX_TX_CHANNELS	(4)
857 struct lan743x_adapter;
858 
859 #define LAN743X_USED_RX_CHANNELS	(4)
860 #define LAN743X_USED_TX_CHANNELS	(1)
861 #define PCI11X1X_USED_TX_CHANNELS	(4)
862 #define LAN743X_INT_MOD	(400)
863 
864 #if (LAN743X_USED_RX_CHANNELS > LAN743X_MAX_RX_CHANNELS)
865 #error Invalid LAN743X_USED_RX_CHANNELS
866 #endif
867 #if (LAN743X_USED_TX_CHANNELS > LAN743X_MAX_TX_CHANNELS)
868 #error Invalid LAN743X_USED_TX_CHANNELS
869 #endif
870 #if (PCI11X1X_USED_TX_CHANNELS > PCI11X1X_MAX_TX_CHANNELS)
871 #error Invalid PCI11X1X_USED_TX_CHANNELS
872 #endif
873 
874 /* PCI */
875 /* SMSC acquired EFAR late 1990's, MCHP acquired SMSC 2012 */
876 #define PCI_VENDOR_ID_SMSC		PCI_VENDOR_ID_EFAR
877 #define PCI_DEVICE_ID_SMSC_LAN7430	(0x7430)
878 #define PCI_DEVICE_ID_SMSC_LAN7431	(0x7431)
879 #define PCI_DEVICE_ID_SMSC_A011		(0xA011)
880 #define PCI_DEVICE_ID_SMSC_A041		(0xA041)
881 
882 #define PCI_CONFIG_LENGTH		(0x1000)
883 
884 /* CSR */
885 #define CSR_LENGTH					(0x2000)
886 
887 #define LAN743X_CSR_FLAG_IS_A0				BIT(0)
888 #define LAN743X_CSR_FLAG_IS_B0				BIT(1)
889 #define LAN743X_CSR_FLAG_SUPPORTS_INTR_AUTO_SET_CLR	BIT(8)
890 
891 struct lan743x_csr {
892 	u32 flags;
893 	u8 __iomem *csr_address;
894 	u32 id_rev;
895 	u32 fpga_rev;
896 };
897 
898 /* INTERRUPTS */
899 typedef void(*lan743x_vector_handler)(void *context, u32 int_sts, u32 flags);
900 
901 #define LAN743X_VECTOR_FLAG_IRQ_SHARED			BIT(0)
902 #define LAN743X_VECTOR_FLAG_SOURCE_STATUS_READ		BIT(1)
903 #define LAN743X_VECTOR_FLAG_SOURCE_STATUS_R2C		BIT(2)
904 #define LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C		BIT(3)
905 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CHECK		BIT(4)
906 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CLEAR		BIT(5)
907 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_R2C		BIT(6)
908 #define LAN743X_VECTOR_FLAG_MASTER_ENABLE_CLEAR		BIT(7)
909 #define LAN743X_VECTOR_FLAG_MASTER_ENABLE_SET		BIT(8)
910 #define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_ISR_CLEAR	BIT(9)
911 #define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_ISR_SET	BIT(10)
912 #define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_CLEAR	BIT(11)
913 #define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET	BIT(12)
914 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_CLEAR	BIT(13)
915 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET	BIT(14)
916 #define LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR	BIT(15)
917 
918 struct lan743x_vector {
919 	int			irq;
920 	u32			flags;
921 	struct lan743x_adapter	*adapter;
922 	int			vector_index;
923 	u32			int_mask;
924 	lan743x_vector_handler	handler;
925 	void			*context;
926 };
927 
928 #define LAN743X_MAX_VECTOR_COUNT	(8)
929 #define PCI11X1X_MAX_VECTOR_COUNT	(16)
930 
931 struct lan743x_intr {
932 	int			flags;
933 
934 	unsigned int		irq;
935 
936 	struct lan743x_vector	vector_list[PCI11X1X_MAX_VECTOR_COUNT];
937 	int			number_of_vectors;
938 	bool			using_vectors;
939 
940 	bool			software_isr_flag;
941 	wait_queue_head_t	software_isr_wq;
942 };
943 
944 #define LAN743X_MAX_FRAME_SIZE			(9 * 1024)
945 
946 /* PHY */
947 struct lan743x_phy {
948 	bool	fc_autoneg;
949 	u8	fc_request_control;
950 };
951 
952 /* TX */
953 struct lan743x_tx_descriptor;
954 struct lan743x_tx_buffer_info;
955 
956 #define GPIO_QUEUE_STARTED		(0)
957 #define GPIO_TX_FUNCTION		(1)
958 #define GPIO_TX_COMPLETION		(2)
959 #define GPIO_TX_FRAGMENT		(3)
960 
961 #define TX_FRAME_FLAG_IN_PROGRESS	BIT(0)
962 
963 #define TX_TS_FLAG_TIMESTAMPING_ENABLED	BIT(0)
964 #define TX_TS_FLAG_ONE_STEP_SYNC	BIT(1)
965 
966 struct lan743x_tx {
967 	struct lan743x_adapter *adapter;
968 	u32	ts_flags;
969 	u32	vector_flags;
970 	int	channel_number;
971 
972 	int	ring_size;
973 	size_t	ring_allocation_size;
974 	struct lan743x_tx_descriptor *ring_cpu_ptr;
975 	dma_addr_t ring_dma_ptr;
976 	/* ring_lock: used to prevent concurrent access to tx ring */
977 	spinlock_t ring_lock;
978 	u32		frame_flags;
979 	u32		frame_first;
980 	u32		frame_data0;
981 	u32		frame_tail;
982 
983 	struct lan743x_tx_buffer_info *buffer_info;
984 
985 	__le32		*head_cpu_ptr;
986 	dma_addr_t	head_dma_ptr;
987 	int		last_head;
988 	int		last_tail;
989 
990 	struct napi_struct napi;
991 	u32 frame_count;
992 	u32 rqd_descriptors;
993 };
994 
995 void lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx,
996 				      bool enable_timestamping,
997 				      bool enable_onestep_sync);
998 
999 /* RX */
1000 struct lan743x_rx_descriptor;
1001 struct lan743x_rx_buffer_info;
1002 
1003 struct lan743x_rx {
1004 	struct lan743x_adapter *adapter;
1005 	u32	vector_flags;
1006 	int	channel_number;
1007 
1008 	int	ring_size;
1009 	size_t	ring_allocation_size;
1010 	struct lan743x_rx_descriptor *ring_cpu_ptr;
1011 	dma_addr_t ring_dma_ptr;
1012 
1013 	struct lan743x_rx_buffer_info *buffer_info;
1014 
1015 	__le32		*head_cpu_ptr;
1016 	dma_addr_t	head_dma_ptr;
1017 	u32		last_head;
1018 	u32		last_tail;
1019 
1020 	struct napi_struct napi;
1021 
1022 	u32		frame_count;
1023 
1024 	struct sk_buff *skb_head, *skb_tail;
1025 };
1026 
1027 int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter,
1028 			       int rx_filter);
1029 
1030 /* SGMII Link Speed Duplex status */
1031 enum lan743x_sgmii_lsd {
1032 	POWER_DOWN = 0,
1033 	LINK_DOWN,
1034 	ANEG_BUSY,
1035 	LINK_10HD,
1036 	LINK_10FD,
1037 	LINK_100HD,
1038 	LINK_100FD,
1039 	LINK_1000_MASTER,
1040 	LINK_1000_SLAVE,
1041 	LINK_2500_MASTER,
1042 	LINK_2500_SLAVE
1043 };
1044 
1045 #define MAC_SUPPORTED_WAKES  (WAKE_BCAST | WAKE_UCAST | WAKE_MCAST | \
1046 			      WAKE_MAGIC | WAKE_ARP)
1047 struct lan743x_adapter {
1048 	struct net_device       *netdev;
1049 	struct mii_bus		*mdiobus;
1050 	int                     msg_enable;
1051 #ifdef CONFIG_PM
1052 	u32			wolopts;
1053 	u8			sopass[SOPASS_MAX];
1054 	u32			phy_wolopts;
1055 	u32			phy_wol_supported;
1056 #endif
1057 	struct pci_dev		*pdev;
1058 	struct lan743x_csr      csr;
1059 	struct lan743x_intr     intr;
1060 
1061 	struct lan743x_gpio	gpio;
1062 	struct lan743x_ptp	ptp;
1063 
1064 	u8			mac_address[ETH_ALEN];
1065 
1066 	struct lan743x_phy      phy;
1067 	struct lan743x_tx       tx[PCI11X1X_USED_TX_CHANNELS];
1068 	struct lan743x_rx       rx[LAN743X_USED_RX_CHANNELS];
1069 	bool			is_pci11x1x;
1070 	bool			is_sgmii_en;
1071 	/* protect ethernet syslock */
1072 	spinlock_t		eth_syslock_spinlock;
1073 	bool			eth_syslock_en;
1074 	u32			eth_syslock_acquire_cnt;
1075 	struct mutex		sgmii_rw_lock;
1076 	/* SGMII Link Speed & Duplex status */
1077 	enum			lan743x_sgmii_lsd sgmii_lsd;
1078 	u8			max_tx_channels;
1079 	u8			used_tx_channels;
1080 	u8			max_vector_count;
1081 
1082 #define LAN743X_ADAPTER_FLAG_OTP		BIT(0)
1083 	u32			flags;
1084 	u32			hw_cfg;
1085 	phy_interface_t		phy_interface;
1086 };
1087 
1088 #define LAN743X_COMPONENT_FLAG_RX(channel)  BIT(20 + (channel))
1089 
1090 #define INTR_FLAG_IRQ_REQUESTED(vector_index)	BIT(0 + vector_index)
1091 #define INTR_FLAG_MSI_ENABLED			BIT(8)
1092 #define INTR_FLAG_MSIX_ENABLED			BIT(9)
1093 
1094 #define MAC_MII_READ            1
1095 #define MAC_MII_WRITE           0
1096 
1097 #define PHY_FLAG_OPENED     BIT(0)
1098 #define PHY_FLAG_ATTACHED   BIT(1)
1099 
1100 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
1101 #define DMA_ADDR_HIGH32(dma_addr)   ((u32)(((dma_addr) >> 32) & 0xFFFFFFFF))
1102 #else
1103 #define DMA_ADDR_HIGH32(dma_addr)   ((u32)(0))
1104 #endif
1105 #define DMA_ADDR_LOW32(dma_addr) ((u32)((dma_addr) & 0xFFFFFFFF))
1106 #define DMA_DESCRIPTOR_SPACING_16       (16)
1107 #define DMA_DESCRIPTOR_SPACING_32       (32)
1108 #define DMA_DESCRIPTOR_SPACING_64       (64)
1109 #define DMA_DESCRIPTOR_SPACING_128      (128)
1110 #define DEFAULT_DMA_DESCRIPTOR_SPACING  (DMA_DESCRIPTOR_SPACING_16)
1111 
1112 #define DMAC_CHANNEL_STATE_SET(start_bit, stop_bit) \
1113 	(((start_bit) ? 2 : 0) | ((stop_bit) ? 1 : 0))
1114 #define DMAC_CHANNEL_STATE_INITIAL      DMAC_CHANNEL_STATE_SET(0, 0)
1115 #define DMAC_CHANNEL_STATE_STARTED      DMAC_CHANNEL_STATE_SET(1, 0)
1116 #define DMAC_CHANNEL_STATE_STOP_PENDING DMAC_CHANNEL_STATE_SET(1, 1)
1117 #define DMAC_CHANNEL_STATE_STOPPED      DMAC_CHANNEL_STATE_SET(0, 1)
1118 
1119 /* TX Descriptor bits */
1120 #define TX_DESC_DATA0_DTYPE_MASK_		(0xC0000000)
1121 #define TX_DESC_DATA0_DTYPE_DATA_		(0x00000000)
1122 #define TX_DESC_DATA0_DTYPE_EXT_		(0x40000000)
1123 #define TX_DESC_DATA0_FS_			(0x20000000)
1124 #define TX_DESC_DATA0_LS_			(0x10000000)
1125 #define TX_DESC_DATA0_EXT_			(0x08000000)
1126 #define TX_DESC_DATA0_IOC_			(0x04000000)
1127 #define TX_DESC_DATA0_ICE_			(0x00400000)
1128 #define TX_DESC_DATA0_IPE_			(0x00200000)
1129 #define TX_DESC_DATA0_TPE_			(0x00100000)
1130 #define TX_DESC_DATA0_FCS_			(0x00020000)
1131 #define TX_DESC_DATA0_TSE_			(0x00010000)
1132 #define TX_DESC_DATA0_BUF_LENGTH_MASK_		(0x0000FFFF)
1133 #define TX_DESC_DATA0_EXT_LSO_			(0x00200000)
1134 #define TX_DESC_DATA0_EXT_PAY_LENGTH_MASK_	(0x000FFFFF)
1135 #define TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_	(0x3FFF0000)
1136 
1137 struct lan743x_tx_descriptor {
1138 	__le32     data0;
1139 	__le32     data1;
1140 	__le32     data2;
1141 	__le32     data3;
1142 } __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING);
1143 
1144 #define TX_BUFFER_INFO_FLAG_ACTIVE		BIT(0)
1145 #define TX_BUFFER_INFO_FLAG_TIMESTAMP_REQUESTED	BIT(1)
1146 #define TX_BUFFER_INFO_FLAG_IGNORE_SYNC		BIT(2)
1147 #define TX_BUFFER_INFO_FLAG_SKB_FRAGMENT	BIT(3)
1148 struct lan743x_tx_buffer_info {
1149 	int flags;
1150 	struct sk_buff *skb;
1151 	dma_addr_t      dma_ptr;
1152 	unsigned int    buffer_length;
1153 };
1154 
1155 #define LAN743X_TX_RING_SIZE    (128)
1156 
1157 /* OWN bit is set. ie, Descs are owned by RX DMAC */
1158 #define RX_DESC_DATA0_OWN_                (0x00008000)
1159 /* OWN bit is clear. ie, Descs are owned by host */
1160 #define RX_DESC_DATA0_FS_                 (0x80000000)
1161 #define RX_DESC_DATA0_LS_                 (0x40000000)
1162 #define RX_DESC_DATA0_FRAME_LENGTH_MASK_  (0x3FFF0000)
1163 #define RX_DESC_DATA0_FRAME_LENGTH_GET_(data0)	\
1164 	(((data0) & RX_DESC_DATA0_FRAME_LENGTH_MASK_) >> 16)
1165 #define RX_DESC_DATA0_EXT_                (0x00004000)
1166 #define RX_DESC_DATA0_BUF_LENGTH_MASK_    (0x00003FFF)
1167 #define RX_DESC_DATA1_STATUS_ICE_         (0x00020000)
1168 #define RX_DESC_DATA1_STATUS_TCE_         (0x00010000)
1169 #define RX_DESC_DATA1_STATUS_ICSM_        (0x00000001)
1170 #define RX_DESC_DATA2_TS_NS_MASK_         (0x3FFFFFFF)
1171 
1172 #if ((NET_IP_ALIGN != 0) && (NET_IP_ALIGN != 2))
1173 #error NET_IP_ALIGN must be 0 or 2
1174 #endif
1175 
1176 #define RX_HEAD_PADDING		NET_IP_ALIGN
1177 
1178 struct lan743x_rx_descriptor {
1179 	__le32     data0;
1180 	__le32     data1;
1181 	__le32     data2;
1182 	__le32     data3;
1183 } __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING);
1184 
1185 #define RX_BUFFER_INFO_FLAG_ACTIVE      BIT(0)
1186 struct lan743x_rx_buffer_info {
1187 	int flags;
1188 	struct sk_buff *skb;
1189 
1190 	dma_addr_t      dma_ptr;
1191 	unsigned int    buffer_length;
1192 };
1193 
1194 #define LAN743X_RX_RING_SIZE        (128)
1195 
1196 #define RX_PROCESS_RESULT_NOTHING_TO_DO     (0)
1197 #define RX_PROCESS_RESULT_BUFFER_RECEIVED   (1)
1198 
1199 u32 lan743x_csr_read(struct lan743x_adapter *adapter, int offset);
1200 void lan743x_csr_write(struct lan743x_adapter *adapter, int offset, u32 data);
1201 int lan743x_hs_syslock_acquire(struct lan743x_adapter *adapter, u16 timeout);
1202 void lan743x_hs_syslock_release(struct lan743x_adapter *adapter);
1203 void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter,
1204 				       bool tx_enable, bool rx_enable);
1205 int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr);
1206 
1207 #endif /* _LAN743X_H */
1208