1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (C) 2018 Microchip Technology Inc. */
8 #include "lan743x_ptp.h"
10 #define DRIVER_AUTHOR "Bryan Whitehead <Bryan.Whitehead@microchip.com>"
11 #define DRIVER_DESC "LAN743x PCIe Gigabit Ethernet Driver"
12 #define DRIVER_NAME "lan743x"
14 /* Register Definitions */
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)
30 #define FPGA_REV (0x04)
31 #define FPGA_REV_GET_MINOR_(fpga_rev) (((fpga_rev) >> 8) & 0x000000FF)
32 #define FPGA_REV_GET_MAJOR_(fpga_rev) ((fpga_rev) & 0x000000FF)
33 #define FPGA_SGMII_OP BIT(24)
35 #define STRAP_READ (0x0C)
36 #define STRAP_READ_USE_SGMII_EN_ BIT(22)
37 #define STRAP_READ_SGMII_EN_ BIT(6)
38 #define STRAP_READ_SGMII_REFCLK_ BIT(5)
39 #define STRAP_READ_SGMII_2_5G_ BIT(4)
40 #define STRAP_READ_BASE_X_ BIT(3)
41 #define STRAP_READ_RGMII_TXC_DELAY_EN_ BIT(2)
42 #define STRAP_READ_RGMII_RXC_DELAY_EN_ BIT(1)
43 #define STRAP_READ_ADV_PM_DISABLE_ BIT(0)
45 #define HW_CFG (0x010)
46 #define HW_CFG_RST_PROTECT_PCIE_ BIT(19)
47 #define HW_CFG_HOT_RESET_DIS_ BIT(15)
48 #define HW_CFG_D3_VAUX_OVR_ BIT(14)
49 #define HW_CFG_D3_RESET_DIS_ BIT(13)
50 #define HW_CFG_RST_PROTECT_ BIT(12)
51 #define HW_CFG_RELOAD_TYPE_ALL_ (0x00000FC0)
52 #define HW_CFG_EE_OTP_RELOAD_ BIT(4)
53 #define HW_CFG_LRST_ BIT(1)
55 #define PMT_CTL (0x014)
56 #define PMT_CTL_ETH_PHY_D3_COLD_OVR_ BIT(27)
57 #define PMT_CTL_MAC_D3_RX_CLK_OVR_ BIT(25)
58 #define PMT_CTL_ETH_PHY_EDPD_PLL_CTL_ BIT(24)
59 #define PMT_CTL_ETH_PHY_D3_OVR_ BIT(23)
60 #define PMT_CTL_RX_FCT_RFE_D3_CLK_OVR_ BIT(18)
61 #define PMT_CTL_GPIO_WAKEUP_EN_ BIT(15)
62 #define PMT_CTL_EEE_WAKEUP_EN_ BIT(13)
63 #define PMT_CTL_READY_ BIT(7)
64 #define PMT_CTL_ETH_PHY_RST_ BIT(4)
65 #define PMT_CTL_WOL_EN_ BIT(3)
66 #define PMT_CTL_ETH_PHY_WAKE_EN_ BIT(2)
67 #define PMT_CTL_WUPS_MASK_ (0x00000003)
69 #define DP_SEL (0x024)
70 #define DP_SEL_DPRDY_ BIT(31)
71 #define DP_SEL_MASK_ (0x0000001F)
72 #define DP_SEL_RFE_RAM (0x00000001)
74 #define DP_SEL_VHF_HASH_LEN (16)
75 #define DP_SEL_VHF_VLAN_LEN (128)
77 #define DP_CMD (0x028)
78 #define DP_CMD_WRITE_ (0x00000001)
80 #define DP_ADDR (0x02C)
82 #define DP_DATA_0 (0x030)
84 #define E2P_CMD (0x040)
85 #define E2P_CMD_EPC_BUSY_ BIT(31)
86 #define E2P_CMD_EPC_CMD_WRITE_ (0x30000000)
87 #define E2P_CMD_EPC_CMD_EWEN_ (0x20000000)
88 #define E2P_CMD_EPC_CMD_READ_ (0x00000000)
89 #define E2P_CMD_EPC_TIMEOUT_ BIT(10)
90 #define E2P_CMD_EPC_ADDR_MASK_ (0x000001FF)
92 #define E2P_DATA (0x044)
94 /* Hearthstone top level & System Reg Addresses */
95 #define ETH_CTRL_REG_ADDR_BASE (0x0000)
96 #define ETH_SYS_REG_ADDR_BASE (0x4000)
97 #define CONFIG_REG_ADDR_BASE (0x0000)
98 #define ETH_EEPROM_REG_ADDR_BASE (0x0E00)
99 #define ETH_OTP_REG_ADDR_BASE (0x1000)
100 #define SYS_LOCK_REG (0x00A0)
101 #define SYS_LOCK_REG_MAIN_LOCK_ BIT(7)
102 #define SYS_LOCK_REG_GEN_PERI_LOCK_ BIT(5)
103 #define SYS_LOCK_REG_SPI_PERI_LOCK_ BIT(4)
104 #define SYS_LOCK_REG_SMBUS_PERI_LOCK_ BIT(3)
105 #define SYS_LOCK_REG_UART_SS_LOCK_ BIT(2)
106 #define SYS_LOCK_REG_ENET_SS_LOCK_ BIT(1)
107 #define SYS_LOCK_REG_USB_SS_LOCK_ BIT(0)
108 #define ETH_SYSTEM_SYS_LOCK_REG (ETH_SYS_REG_ADDR_BASE + \
109 CONFIG_REG_ADDR_BASE + \
111 #define HS_EEPROM_REG_ADDR_BASE (ETH_SYS_REG_ADDR_BASE + \
112 ETH_EEPROM_REG_ADDR_BASE)
113 #define HS_E2P_CMD (HS_EEPROM_REG_ADDR_BASE + 0x0000)
114 #define HS_E2P_CMD_EPC_BUSY_ BIT(31)
115 #define HS_E2P_CMD_EPC_CMD_WRITE_ GENMASK(29, 28)
116 #define HS_E2P_CMD_EPC_CMD_READ_ (0x0)
117 #define HS_E2P_CMD_EPC_TIMEOUT_ BIT(17)
118 #define HS_E2P_CMD_EPC_ADDR_MASK_ GENMASK(15, 0)
119 #define HS_E2P_DATA (HS_EEPROM_REG_ADDR_BASE + 0x0004)
120 #define HS_E2P_DATA_MASK_ GENMASK(7, 0)
121 #define HS_E2P_CFG (HS_EEPROM_REG_ADDR_BASE + 0x0008)
122 #define HS_E2P_CFG_I2C_PULSE_MASK_ GENMASK(19, 16)
123 #define HS_E2P_CFG_EEPROM_SIZE_SEL_ BIT(12)
124 #define HS_E2P_CFG_I2C_BAUD_RATE_MASK_ GENMASK(9, 8)
125 #define HS_E2P_CFG_TEST_EEPR_TO_BYP_ BIT(0)
126 #define HS_E2P_PAD_CTL (HS_EEPROM_REG_ADDR_BASE + 0x000C)
128 #define GPIO_CFG0 (0x050)
129 #define GPIO_CFG0_GPIO_DIR_BIT_(bit) BIT(16 + (bit))
130 #define GPIO_CFG0_GPIO_DATA_BIT_(bit) BIT(0 + (bit))
132 #define GPIO_CFG1 (0x054)
133 #define GPIO_CFG1_GPIOEN_BIT_(bit) BIT(16 + (bit))
134 #define GPIO_CFG1_GPIOBUF_BIT_(bit) BIT(0 + (bit))
136 #define GPIO_CFG2 (0x058)
137 #define GPIO_CFG2_1588_POL_BIT_(bit) BIT(0 + (bit))
139 #define GPIO_CFG3 (0x05C)
140 #define GPIO_CFG3_1588_CH_SEL_BIT_(bit) BIT(16 + (bit))
141 #define GPIO_CFG3_1588_OE_BIT_(bit) BIT(0 + (bit))
143 #define FCT_RX_CTL (0xAC)
144 #define FCT_RX_CTL_EN_(channel) BIT(28 + (channel))
145 #define FCT_RX_CTL_DIS_(channel) BIT(24 + (channel))
146 #define FCT_RX_CTL_RESET_(channel) BIT(20 + (channel))
148 #define FCT_TX_CTL (0xC4)
149 #define FCT_TX_CTL_EN_(channel) BIT(28 + (channel))
150 #define FCT_TX_CTL_DIS_(channel) BIT(24 + (channel))
151 #define FCT_TX_CTL_RESET_(channel) BIT(20 + (channel))
153 #define FCT_FLOW(rx_channel) (0xE0 + ((rx_channel) << 2))
154 #define FCT_FLOW_CTL_OFF_THRESHOLD_ (0x00007F00)
155 #define FCT_FLOW_CTL_OFF_THRESHOLD_SET_(value) \
156 ((value << 8) & FCT_FLOW_CTL_OFF_THRESHOLD_)
157 #define FCT_FLOW_CTL_REQ_EN_ BIT(7)
158 #define FCT_FLOW_CTL_ON_THRESHOLD_ (0x0000007F)
159 #define FCT_FLOW_CTL_ON_THRESHOLD_SET_(value) \
160 ((value << 0) & FCT_FLOW_CTL_ON_THRESHOLD_)
162 #define MAC_CR (0x100)
163 #define MAC_CR_MII_EN_ BIT(19)
164 #define MAC_CR_EEE_EN_ BIT(17)
165 #define MAC_CR_ADD_ BIT(12)
166 #define MAC_CR_ASD_ BIT(11)
167 #define MAC_CR_CNTR_RST_ BIT(5)
168 #define MAC_CR_DPX_ BIT(3)
169 #define MAC_CR_CFG_H_ BIT(2)
170 #define MAC_CR_CFG_L_ BIT(1)
171 #define MAC_CR_RST_ BIT(0)
173 #define MAC_RX (0x104)
174 #define MAC_RX_MAX_SIZE_SHIFT_ (16)
175 #define MAC_RX_MAX_SIZE_MASK_ (0x3FFF0000)
176 #define MAC_RX_RXD_ BIT(1)
177 #define MAC_RX_RXEN_ BIT(0)
179 #define MAC_TX (0x108)
180 #define MAC_TX_TXD_ BIT(1)
181 #define MAC_TX_TXEN_ BIT(0)
183 #define MAC_FLOW (0x10C)
184 #define MAC_FLOW_CR_TX_FCEN_ BIT(30)
185 #define MAC_FLOW_CR_RX_FCEN_ BIT(29)
186 #define MAC_FLOW_CR_FCPT_MASK_ (0x0000FFFF)
188 #define MAC_RX_ADDRH (0x118)
190 #define MAC_RX_ADDRL (0x11C)
192 #define MAC_MII_ACC (0x120)
193 #define MAC_MII_ACC_MDC_CYCLE_SHIFT_ (16)
194 #define MAC_MII_ACC_MDC_CYCLE_MASK_ (0x00070000)
195 #define MAC_MII_ACC_MDC_CYCLE_2_5MHZ_ (0)
196 #define MAC_MII_ACC_MDC_CYCLE_5MHZ_ (1)
197 #define MAC_MII_ACC_MDC_CYCLE_12_5MHZ_ (2)
198 #define MAC_MII_ACC_MDC_CYCLE_25MHZ_ (3)
199 #define MAC_MII_ACC_MDC_CYCLE_1_25MHZ_ (4)
200 #define MAC_MII_ACC_PHY_ADDR_SHIFT_ (11)
201 #define MAC_MII_ACC_PHY_ADDR_MASK_ (0x0000F800)
202 #define MAC_MII_ACC_MIIRINDA_SHIFT_ (6)
203 #define MAC_MII_ACC_MIIRINDA_MASK_ (0x000007C0)
204 #define MAC_MII_ACC_MII_READ_ (0x00000000)
205 #define MAC_MII_ACC_MII_WRITE_ (0x00000002)
206 #define MAC_MII_ACC_MII_BUSY_ BIT(0)
208 #define MAC_MII_ACC_MIIMMD_SHIFT_ (6)
209 #define MAC_MII_ACC_MIIMMD_MASK_ (0x000007C0)
210 #define MAC_MII_ACC_MIICL45_ BIT(3)
211 #define MAC_MII_ACC_MIICMD_MASK_ (0x00000006)
212 #define MAC_MII_ACC_MIICMD_ADDR_ (0x00000000)
213 #define MAC_MII_ACC_MIICMD_WRITE_ (0x00000002)
214 #define MAC_MII_ACC_MIICMD_READ_ (0x00000004)
215 #define MAC_MII_ACC_MIICMD_READ_INC_ (0x00000006)
217 #define MAC_MII_DATA (0x124)
219 #define MAC_EEE_TX_LPI_REQ_DLY_CNT (0x130)
221 #define MAC_WUCSR (0x140)
222 #define MAC_MP_SO_EN_ BIT(21)
223 #define MAC_WUCSR_RFE_WAKE_EN_ BIT(14)
224 #define MAC_WUCSR_PFDA_EN_ BIT(3)
225 #define MAC_WUCSR_WAKE_EN_ BIT(2)
226 #define MAC_WUCSR_MPEN_ BIT(1)
227 #define MAC_WUCSR_BCST_EN_ BIT(0)
229 #define MAC_WK_SRC (0x144)
230 #define MAC_MP_SO_HI (0x148)
231 #define MAC_MP_SO_LO (0x14C)
233 #define MAC_WUF_CFG0 (0x150)
234 #define MAC_NUM_OF_WUF_CFG (32)
235 #define MAC_WUF_CFG_BEGIN (MAC_WUF_CFG0)
236 #define MAC_WUF_CFG(index) (MAC_WUF_CFG_BEGIN + (4 * (index)))
237 #define MAC_WUF_CFG_EN_ BIT(31)
238 #define MAC_WUF_CFG_TYPE_MCAST_ (0x02000000)
239 #define MAC_WUF_CFG_TYPE_ALL_ (0x01000000)
240 #define MAC_WUF_CFG_OFFSET_SHIFT_ (16)
241 #define MAC_WUF_CFG_CRC16_MASK_ (0x0000FFFF)
243 #define MAC_WUF_MASK0_0 (0x200)
244 #define MAC_WUF_MASK0_1 (0x204)
245 #define MAC_WUF_MASK0_2 (0x208)
246 #define MAC_WUF_MASK0_3 (0x20C)
247 #define MAC_WUF_MASK0_BEGIN (MAC_WUF_MASK0_0)
248 #define MAC_WUF_MASK1_BEGIN (MAC_WUF_MASK0_1)
249 #define MAC_WUF_MASK2_BEGIN (MAC_WUF_MASK0_2)
250 #define MAC_WUF_MASK3_BEGIN (MAC_WUF_MASK0_3)
251 #define MAC_WUF_MASK0(index) (MAC_WUF_MASK0_BEGIN + (0x10 * (index)))
252 #define MAC_WUF_MASK1(index) (MAC_WUF_MASK1_BEGIN + (0x10 * (index)))
253 #define MAC_WUF_MASK2(index) (MAC_WUF_MASK2_BEGIN + (0x10 * (index)))
254 #define MAC_WUF_MASK3(index) (MAC_WUF_MASK3_BEGIN + (0x10 * (index)))
256 /* offset 0x400 - 0x500, x may range from 0 to 32, for a total of 33 entries */
257 #define RFE_ADDR_FILT_HI(x) (0x400 + (8 * (x)))
258 #define RFE_ADDR_FILT_HI_VALID_ BIT(31)
260 /* offset 0x404 - 0x504, x may range from 0 to 32, for a total of 33 entries */
261 #define RFE_ADDR_FILT_LO(x) (0x404 + (8 * (x)))
263 #define RFE_CTL (0x508)
264 #define RFE_CTL_AB_ BIT(10)
265 #define RFE_CTL_AM_ BIT(9)
266 #define RFE_CTL_AU_ BIT(8)
267 #define RFE_CTL_MCAST_HASH_ BIT(3)
268 #define RFE_CTL_DA_PERFECT_ BIT(1)
270 #define RFE_RSS_CFG (0x554)
271 #define RFE_RSS_CFG_UDP_IPV6_EX_ BIT(16)
272 #define RFE_RSS_CFG_TCP_IPV6_EX_ BIT(15)
273 #define RFE_RSS_CFG_IPV6_EX_ BIT(14)
274 #define RFE_RSS_CFG_UDP_IPV6_ BIT(13)
275 #define RFE_RSS_CFG_TCP_IPV6_ BIT(12)
276 #define RFE_RSS_CFG_IPV6_ BIT(11)
277 #define RFE_RSS_CFG_UDP_IPV4_ BIT(10)
278 #define RFE_RSS_CFG_TCP_IPV4_ BIT(9)
279 #define RFE_RSS_CFG_IPV4_ BIT(8)
280 #define RFE_RSS_CFG_VALID_HASH_BITS_ (0x000000E0)
281 #define RFE_RSS_CFG_RSS_QUEUE_ENABLE_ BIT(2)
282 #define RFE_RSS_CFG_RSS_HASH_STORE_ BIT(1)
283 #define RFE_RSS_CFG_RSS_ENABLE_ BIT(0)
285 #define RFE_HASH_KEY(index) (0x558 + (index << 2))
287 #define RFE_INDX(index) (0x580 + (index << 2))
289 #define MAC_WUCSR2 (0x600)
291 #define SGMII_CTL (0x728)
292 #define SGMII_CTL_SGMII_ENABLE_ BIT(31)
293 #define SGMII_CTL_LINK_STATUS_SOURCE_ BIT(8)
294 #define SGMII_CTL_SGMII_POWER_DN_ BIT(1)
296 #define INT_STS (0x780)
297 #define INT_BIT_DMA_RX_(channel) BIT(24 + (channel))
298 #define INT_BIT_ALL_RX_ (0x0F000000)
299 #define INT_BIT_DMA_TX_(channel) BIT(16 + (channel))
300 #define INT_BIT_ALL_TX_ (0x000F0000)
301 #define INT_BIT_SW_GP_ BIT(9)
302 #define INT_BIT_1588_ BIT(7)
303 #define INT_BIT_ALL_OTHER_ (INT_BIT_SW_GP_ | INT_BIT_1588_)
304 #define INT_BIT_MAS_ BIT(0)
306 #define INT_SET (0x784)
308 #define INT_EN_SET (0x788)
310 #define INT_EN_CLR (0x78C)
312 #define INT_STS_R2C (0x790)
314 #define INT_VEC_EN_SET (0x794)
315 #define INT_VEC_EN_CLR (0x798)
316 #define INT_VEC_EN_AUTO_CLR (0x79C)
317 #define INT_VEC_EN_(vector_index) BIT(0 + vector_index)
319 #define INT_VEC_MAP0 (0x7A0)
320 #define INT_VEC_MAP0_RX_VEC_(channel, vector) \
321 (((u32)(vector)) << ((channel) << 2))
323 #define INT_VEC_MAP1 (0x7A4)
324 #define INT_VEC_MAP1_TX_VEC_(channel, vector) \
325 (((u32)(vector)) << ((channel) << 2))
327 #define INT_VEC_MAP2 (0x7A8)
329 #define INT_MOD_MAP0 (0x7B0)
331 #define INT_MOD_MAP1 (0x7B4)
333 #define INT_MOD_MAP2 (0x7B8)
335 #define INT_MOD_CFG0 (0x7C0)
336 #define INT_MOD_CFG1 (0x7C4)
337 #define INT_MOD_CFG2 (0x7C8)
338 #define INT_MOD_CFG3 (0x7CC)
339 #define INT_MOD_CFG4 (0x7D0)
340 #define INT_MOD_CFG5 (0x7D4)
341 #define INT_MOD_CFG6 (0x7D8)
342 #define INT_MOD_CFG7 (0x7DC)
343 #define INT_MOD_CFG8 (0x7E0)
344 #define INT_MOD_CFG9 (0x7E4)
346 #define PTP_CMD_CTL (0x0A00)
347 #define PTP_CMD_CTL_PTP_LTC_TARGET_READ_ BIT(13)
348 #define PTP_CMD_CTL_PTP_CLK_STP_NSEC_ BIT(6)
349 #define PTP_CMD_CTL_PTP_CLOCK_STEP_SEC_ BIT(5)
350 #define PTP_CMD_CTL_PTP_CLOCK_LOAD_ BIT(4)
351 #define PTP_CMD_CTL_PTP_CLOCK_READ_ BIT(3)
352 #define PTP_CMD_CTL_PTP_ENABLE_ BIT(2)
353 #define PTP_CMD_CTL_PTP_DISABLE_ BIT(1)
354 #define PTP_CMD_CTL_PTP_RESET_ BIT(0)
355 #define PTP_GENERAL_CONFIG (0x0A04)
356 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_X_MASK_(channel) \
357 (0x7 << (1 + ((channel) << 2)))
358 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_100NS_ (0)
359 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_10US_ (1)
360 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_100US_ (2)
361 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_1MS_ (3)
362 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_10MS_ (4)
363 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_200MS_ (5)
364 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_TOGGLE_ (6)
365 #define PTP_GENERAL_CONFIG_CLOCK_EVENT_X_SET_(channel, value) \
366 (((value) & 0x7) << (1 + ((channel) << 2)))
367 #define PTP_GENERAL_CONFIG_RELOAD_ADD_X_(channel) (BIT((channel) << 2))
369 #define HS_PTP_GENERAL_CONFIG (0x0A04)
370 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_X_MASK_(channel) \
371 (0xf << (4 + ((channel) << 2)))
372 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_100NS_ (0)
373 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_500NS_ (1)
374 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_1US_ (2)
375 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_5US_ (3)
376 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_10US_ (4)
377 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_50US_ (5)
378 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_100US_ (6)
379 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_500US_ (7)
380 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_1MS_ (8)
381 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_5MS_ (9)
382 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_10MS_ (10)
383 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_50MS_ (11)
384 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_100MS_ (12)
385 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_200MS_ (13)
386 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_TOGG_ (14)
387 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_INT_ (15)
388 #define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_X_SET_(channel, value) \
389 (((value) & 0xf) << (4 + ((channel) << 2)))
390 #define HS_PTP_GENERAL_CONFIG_EVENT_POL_X_(channel) (BIT(1 + ((channel) * 2)))
391 #define HS_PTP_GENERAL_CONFIG_RELOAD_ADD_X_(channel) (BIT((channel) * 2))
393 #define PTP_INT_STS (0x0A08)
394 #define PTP_INT_IO_FE_MASK_ GENMASK(31, 24)
395 #define PTP_INT_IO_FE_SHIFT_ (24)
396 #define PTP_INT_IO_FE_SET_(channel) BIT(24 + (channel))
397 #define PTP_INT_IO_RE_MASK_ GENMASK(23, 16)
398 #define PTP_INT_IO_RE_SHIFT_ (16)
399 #define PTP_INT_IO_RE_SET_(channel) BIT(16 + (channel))
400 #define PTP_INT_TX_TS_OVRFL_INT_ BIT(14)
401 #define PTP_INT_TX_SWTS_ERR_INT_ BIT(13)
402 #define PTP_INT_TX_TS_INT_ BIT(12)
403 #define PTP_INT_RX_TS_OVRFL_INT_ BIT(9)
404 #define PTP_INT_RX_TS_INT_ BIT(8)
405 #define PTP_INT_TIMER_INT_B_ BIT(1)
406 #define PTP_INT_TIMER_INT_A_ BIT(0)
407 #define PTP_INT_EN_SET (0x0A0C)
408 #define PTP_INT_EN_FE_EN_SET_(channel) BIT(24 + (channel))
409 #define PTP_INT_EN_RE_EN_SET_(channel) BIT(16 + (channel))
410 #define PTP_INT_EN_TIMER_SET_(channel) BIT(channel)
411 #define PTP_INT_EN_CLR (0x0A10)
412 #define PTP_INT_EN_FE_EN_CLR_(channel) BIT(24 + (channel))
413 #define PTP_INT_EN_RE_EN_CLR_(channel) BIT(16 + (channel))
414 #define PTP_INT_BIT_TX_SWTS_ERR_ BIT(13)
415 #define PTP_INT_BIT_TX_TS_ BIT(12)
416 #define PTP_INT_BIT_TIMER_B_ BIT(1)
417 #define PTP_INT_BIT_TIMER_A_ BIT(0)
419 #define PTP_CLOCK_SEC (0x0A14)
420 #define PTP_CLOCK_NS (0x0A18)
421 #define PTP_CLOCK_SUBNS (0x0A1C)
422 #define PTP_CLOCK_RATE_ADJ (0x0A20)
423 #define PTP_CLOCK_RATE_ADJ_DIR_ BIT(31)
424 #define PTP_CLOCK_STEP_ADJ (0x0A2C)
425 #define PTP_CLOCK_STEP_ADJ_DIR_ BIT(31)
426 #define PTP_CLOCK_STEP_ADJ_VALUE_MASK_ (0x3FFFFFFF)
427 #define PTP_CLOCK_TARGET_SEC_X(channel) (0x0A30 + ((channel) << 4))
428 #define PTP_CLOCK_TARGET_NS_X(channel) (0x0A34 + ((channel) << 4))
429 #define PTP_CLOCK_TARGET_RELOAD_SEC_X(channel) (0x0A38 + ((channel) << 4))
430 #define PTP_CLOCK_TARGET_RELOAD_NS_X(channel) (0x0A3C + ((channel) << 4))
431 #define PTP_LTC_SET_SEC_HI (0x0A50)
432 #define PTP_LTC_SET_SEC_HI_SEC_47_32_MASK_ GENMASK(15, 0)
433 #define PTP_VERSION (0x0A54)
434 #define PTP_VERSION_TX_UP_MASK_ GENMASK(31, 24)
435 #define PTP_VERSION_TX_LO_MASK_ GENMASK(23, 16)
436 #define PTP_VERSION_RX_UP_MASK_ GENMASK(15, 8)
437 #define PTP_VERSION_RX_LO_MASK_ GENMASK(7, 0)
438 #define PTP_IO_SEL (0x0A58)
439 #define PTP_IO_SEL_MASK_ GENMASK(10, 8)
440 #define PTP_IO_SEL_SHIFT_ (8)
441 #define PTP_LATENCY (0x0A5C)
442 #define PTP_LATENCY_TX_SET_(tx_latency) (((u32)(tx_latency)) << 16)
443 #define PTP_LATENCY_RX_SET_(rx_latency) \
444 (((u32)(rx_latency)) & 0x0000FFFF)
445 #define PTP_CAP_INFO (0x0A60)
446 #define PTP_CAP_INFO_TX_TS_CNT_GET_(reg_val) (((reg_val) & 0x00000070) >> 4)
448 #define PTP_TX_MOD (0x0AA4)
449 #define PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_ (0x10000000)
451 #define PTP_TX_MOD2 (0x0AA8)
452 #define PTP_TX_MOD2_TX_PTP_CLR_UDPV4_CHKSUM_ (0x00000001)
454 #define PTP_TX_EGRESS_SEC (0x0AAC)
455 #define PTP_TX_EGRESS_NS (0x0AB0)
456 #define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_MASK_ (0xC0000000)
457 #define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_AUTO_ (0x00000000)
458 #define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_SW_ (0x40000000)
459 #define PTP_TX_EGRESS_NS_TS_NS_MASK_ (0x3FFFFFFF)
461 #define PTP_TX_MSG_HEADER (0x0AB4)
462 #define PTP_TX_MSG_HEADER_MSG_TYPE_ (0x000F0000)
463 #define PTP_TX_MSG_HEADER_MSG_TYPE_SYNC_ (0x00000000)
465 #define PTP_TX_CAP_INFO (0x0AB8)
466 #define PTP_TX_CAP_INFO_TX_CH_MASK_ GENMASK(1, 0)
467 #define PTP_TX_DOMAIN (0x0ABC)
468 #define PTP_TX_DOMAIN_MASK_ GENMASK(23, 16)
469 #define PTP_TX_DOMAIN_RANGE_EN_ BIT(15)
470 #define PTP_TX_DOMAIN_RANGE_MASK_ GENMASK(7, 0)
471 #define PTP_TX_SDOID (0x0AC0)
472 #define PTP_TX_SDOID_MASK_ GENMASK(23, 16)
473 #define PTP_TX_SDOID_RANGE_EN_ BIT(15)
474 #define PTP_TX_SDOID_11_0_MASK_ GENMASK(7, 0)
475 #define PTP_IO_CAP_CONFIG (0x0AC4)
476 #define PTP_IO_CAP_CONFIG_LOCK_FE_(channel) BIT(24 + (channel))
477 #define PTP_IO_CAP_CONFIG_LOCK_RE_(channel) BIT(16 + (channel))
478 #define PTP_IO_CAP_CONFIG_FE_CAP_EN_(channel) BIT(8 + (channel))
479 #define PTP_IO_CAP_CONFIG_RE_CAP_EN_(channel) BIT(0 + (channel))
480 #define PTP_IO_RE_LTC_SEC_CAP_X (0x0AC8)
481 #define PTP_IO_RE_LTC_NS_CAP_X (0x0ACC)
482 #define PTP_IO_FE_LTC_SEC_CAP_X (0x0AD0)
483 #define PTP_IO_FE_LTC_NS_CAP_X (0x0AD4)
484 #define PTP_IO_EVENT_OUTPUT_CFG (0x0AD8)
485 #define PTP_IO_EVENT_OUTPUT_CFG_SEL_(channel) BIT(16 + (channel))
486 #define PTP_IO_EVENT_OUTPUT_CFG_EN_(channel) BIT(0 + (channel))
487 #define PTP_IO_PIN_CFG (0x0ADC)
488 #define PTP_IO_PIN_CFG_OBUF_TYPE_(channel) BIT(0 + (channel))
489 #define PTP_LTC_RD_SEC_HI (0x0AF0)
490 #define PTP_LTC_RD_SEC_HI_SEC_47_32_MASK_ GENMASK(15, 0)
491 #define PTP_LTC_RD_SEC_LO (0x0AF4)
492 #define PTP_LTC_RD_NS (0x0AF8)
493 #define PTP_LTC_RD_NS_29_0_MASK_ GENMASK(29, 0)
494 #define PTP_LTC_RD_SUBNS (0x0AFC)
495 #define PTP_RX_USER_MAC_HI (0x0B00)
496 #define PTP_RX_USER_MAC_HI_47_32_MASK_ GENMASK(15, 0)
497 #define PTP_RX_USER_MAC_LO (0x0B04)
498 #define PTP_RX_USER_IP_ADDR_0 (0x0B20)
499 #define PTP_RX_USER_IP_ADDR_1 (0x0B24)
500 #define PTP_RX_USER_IP_ADDR_2 (0x0B28)
501 #define PTP_RX_USER_IP_ADDR_3 (0x0B2C)
502 #define PTP_RX_USER_IP_MASK_0 (0x0B30)
503 #define PTP_RX_USER_IP_MASK_1 (0x0B34)
504 #define PTP_RX_USER_IP_MASK_2 (0x0B38)
505 #define PTP_RX_USER_IP_MASK_3 (0x0B3C)
506 #define PTP_TX_USER_MAC_HI (0x0B40)
507 #define PTP_TX_USER_MAC_HI_47_32_MASK_ GENMASK(15, 0)
508 #define PTP_TX_USER_MAC_LO (0x0B44)
509 #define PTP_TX_USER_IP_ADDR_0 (0x0B60)
510 #define PTP_TX_USER_IP_ADDR_1 (0x0B64)
511 #define PTP_TX_USER_IP_ADDR_2 (0x0B68)
512 #define PTP_TX_USER_IP_ADDR_3 (0x0B6C)
513 #define PTP_TX_USER_IP_MASK_0 (0x0B70)
514 #define PTP_TX_USER_IP_MASK_1 (0x0B74)
515 #define PTP_TX_USER_IP_MASK_2 (0x0B78)
516 #define PTP_TX_USER_IP_MASK_3 (0x0B7C)
518 #define DMAC_CFG (0xC00)
519 #define DMAC_CFG_COAL_EN_ BIT(16)
520 #define DMAC_CFG_CH_ARB_SEL_RX_HIGH_ (0x00000000)
521 #define DMAC_CFG_MAX_READ_REQ_MASK_ (0x00000070)
522 #define DMAC_CFG_MAX_READ_REQ_SET_(val) \
523 ((((u32)(val)) << 4) & DMAC_CFG_MAX_READ_REQ_MASK_)
524 #define DMAC_CFG_MAX_DSPACE_16_ (0x00000000)
525 #define DMAC_CFG_MAX_DSPACE_32_ (0x00000001)
526 #define DMAC_CFG_MAX_DSPACE_64_ BIT(1)
527 #define DMAC_CFG_MAX_DSPACE_128_ (0x00000003)
529 #define DMAC_COAL_CFG (0xC04)
530 #define DMAC_COAL_CFG_TIMER_LIMIT_MASK_ (0xFFF00000)
531 #define DMAC_COAL_CFG_TIMER_LIMIT_SET_(val) \
532 ((((u32)(val)) << 20) & DMAC_COAL_CFG_TIMER_LIMIT_MASK_)
533 #define DMAC_COAL_CFG_TIMER_TX_START_ BIT(19)
534 #define DMAC_COAL_CFG_FLUSH_INTS_ BIT(18)
535 #define DMAC_COAL_CFG_INT_EXIT_COAL_ BIT(17)
536 #define DMAC_COAL_CFG_CSR_EXIT_COAL_ BIT(16)
537 #define DMAC_COAL_CFG_TX_THRES_MASK_ (0x0000FF00)
538 #define DMAC_COAL_CFG_TX_THRES_SET_(val) \
539 ((((u32)(val)) << 8) & DMAC_COAL_CFG_TX_THRES_MASK_)
540 #define DMAC_COAL_CFG_RX_THRES_MASK_ (0x000000FF)
541 #define DMAC_COAL_CFG_RX_THRES_SET_(val) \
542 (((u32)(val)) & DMAC_COAL_CFG_RX_THRES_MASK_)
544 #define DMAC_OBFF_CFG (0xC08)
545 #define DMAC_OBFF_TX_THRES_MASK_ (0x0000FF00)
546 #define DMAC_OBFF_TX_THRES_SET_(val) \
547 ((((u32)(val)) << 8) & DMAC_OBFF_TX_THRES_MASK_)
548 #define DMAC_OBFF_RX_THRES_MASK_ (0x000000FF)
549 #define DMAC_OBFF_RX_THRES_SET_(val) \
550 (((u32)(val)) & DMAC_OBFF_RX_THRES_MASK_)
552 #define DMAC_CMD (0xC0C)
553 #define DMAC_CMD_SWR_ BIT(31)
554 #define DMAC_CMD_TX_SWR_(channel) BIT(24 + (channel))
555 #define DMAC_CMD_START_T_(channel) BIT(20 + (channel))
556 #define DMAC_CMD_STOP_T_(channel) BIT(16 + (channel))
557 #define DMAC_CMD_RX_SWR_(channel) BIT(8 + (channel))
558 #define DMAC_CMD_START_R_(channel) BIT(4 + (channel))
559 #define DMAC_CMD_STOP_R_(channel) BIT(0 + (channel))
561 #define DMAC_INT_STS (0xC10)
562 #define DMAC_INT_EN_SET (0xC14)
563 #define DMAC_INT_EN_CLR (0xC18)
564 #define DMAC_INT_BIT_RXFRM_(channel) BIT(16 + (channel))
565 #define DMAC_INT_BIT_TX_IOC_(channel) BIT(0 + (channel))
567 #define RX_CFG_A(channel) (0xC40 + ((channel) << 6))
568 #define RX_CFG_A_RX_WB_ON_INT_TMR_ BIT(30)
569 #define RX_CFG_A_RX_WB_THRES_MASK_ (0x1F000000)
570 #define RX_CFG_A_RX_WB_THRES_SET_(val) \
571 ((((u32)(val)) << 24) & RX_CFG_A_RX_WB_THRES_MASK_)
572 #define RX_CFG_A_RX_PF_THRES_MASK_ (0x001F0000)
573 #define RX_CFG_A_RX_PF_THRES_SET_(val) \
574 ((((u32)(val)) << 16) & RX_CFG_A_RX_PF_THRES_MASK_)
575 #define RX_CFG_A_RX_PF_PRI_THRES_MASK_ (0x00001F00)
576 #define RX_CFG_A_RX_PF_PRI_THRES_SET_(val) \
577 ((((u32)(val)) << 8) & RX_CFG_A_RX_PF_PRI_THRES_MASK_)
578 #define RX_CFG_A_RX_HP_WB_EN_ BIT(5)
580 #define RX_CFG_B(channel) (0xC44 + ((channel) << 6))
581 #define RX_CFG_B_TS_ALL_RX_ BIT(29)
582 #define RX_CFG_B_RX_PAD_MASK_ (0x03000000)
583 #define RX_CFG_B_RX_PAD_0_ (0x00000000)
584 #define RX_CFG_B_RX_PAD_2_ (0x02000000)
585 #define RX_CFG_B_RDMABL_512_ (0x00040000)
586 #define RX_CFG_B_RX_RING_LEN_MASK_ (0x0000FFFF)
588 #define RX_BASE_ADDRH(channel) (0xC48 + ((channel) << 6))
590 #define RX_BASE_ADDRL(channel) (0xC4C + ((channel) << 6))
592 #define RX_HEAD_WRITEBACK_ADDRH(channel) (0xC50 + ((channel) << 6))
594 #define RX_HEAD_WRITEBACK_ADDRL(channel) (0xC54 + ((channel) << 6))
596 #define RX_HEAD(channel) (0xC58 + ((channel) << 6))
598 #define RX_TAIL(channel) (0xC5C + ((channel) << 6))
599 #define RX_TAIL_SET_TOP_INT_EN_ BIT(30)
600 #define RX_TAIL_SET_TOP_INT_VEC_EN_ BIT(29)
602 #define RX_CFG_C(channel) (0xC64 + ((channel) << 6))
603 #define RX_CFG_C_RX_TOP_INT_EN_AUTO_CLR_ BIT(6)
604 #define RX_CFG_C_RX_INT_EN_R2C_ BIT(4)
605 #define RX_CFG_C_RX_DMA_INT_STS_AUTO_CLR_ BIT(3)
606 #define RX_CFG_C_RX_INT_STS_R2C_MODE_MASK_ (0x00000007)
608 #define TX_CFG_A(channel) (0xD40 + ((channel) << 6))
609 #define TX_CFG_A_TX_HP_WB_ON_INT_TMR_ BIT(30)
610 #define TX_CFG_A_TX_TMR_HPWB_SEL_IOC_ (0x10000000)
611 #define TX_CFG_A_TX_PF_THRES_MASK_ (0x001F0000)
612 #define TX_CFG_A_TX_PF_THRES_SET_(value) \
613 ((((u32)(value)) << 16) & TX_CFG_A_TX_PF_THRES_MASK_)
614 #define TX_CFG_A_TX_PF_PRI_THRES_MASK_ (0x00001F00)
615 #define TX_CFG_A_TX_PF_PRI_THRES_SET_(value) \
616 ((((u32)(value)) << 8) & TX_CFG_A_TX_PF_PRI_THRES_MASK_)
617 #define TX_CFG_A_TX_HP_WB_EN_ BIT(5)
618 #define TX_CFG_A_TX_HP_WB_THRES_MASK_ (0x0000000F)
619 #define TX_CFG_A_TX_HP_WB_THRES_SET_(value) \
620 (((u32)(value)) & TX_CFG_A_TX_HP_WB_THRES_MASK_)
622 #define TX_CFG_B(channel) (0xD44 + ((channel) << 6))
623 #define TX_CFG_B_TDMABL_512_ (0x00040000)
624 #define TX_CFG_B_TX_RING_LEN_MASK_ (0x0000FFFF)
626 #define TX_BASE_ADDRH(channel) (0xD48 + ((channel) << 6))
628 #define TX_BASE_ADDRL(channel) (0xD4C + ((channel) << 6))
630 #define TX_HEAD_WRITEBACK_ADDRH(channel) (0xD50 + ((channel) << 6))
632 #define TX_HEAD_WRITEBACK_ADDRL(channel) (0xD54 + ((channel) << 6))
634 #define TX_HEAD(channel) (0xD58 + ((channel) << 6))
636 #define TX_TAIL(channel) (0xD5C + ((channel) << 6))
637 #define TX_TAIL_SET_DMAC_INT_EN_ BIT(31)
638 #define TX_TAIL_SET_TOP_INT_EN_ BIT(30)
639 #define TX_TAIL_SET_TOP_INT_VEC_EN_ BIT(29)
641 #define TX_CFG_C(channel) (0xD64 + ((channel) << 6))
642 #define TX_CFG_C_TX_TOP_INT_EN_AUTO_CLR_ BIT(6)
643 #define TX_CFG_C_TX_DMA_INT_EN_AUTO_CLR_ BIT(5)
644 #define TX_CFG_C_TX_INT_EN_R2C_ BIT(4)
645 #define TX_CFG_C_TX_DMA_INT_STS_AUTO_CLR_ BIT(3)
646 #define TX_CFG_C_TX_INT_STS_R2C_MODE_MASK_ (0x00000007)
648 #define OTP_PWR_DN (0x1000)
649 #define OTP_PWR_DN_PWRDN_N_ BIT(0)
651 #define OTP_ADDR_HIGH (0x1004)
652 #define OTP_ADDR_LOW (0x1008)
654 #define OTP_PRGM_DATA (0x1010)
656 #define OTP_PRGM_MODE (0x1014)
657 #define OTP_PRGM_MODE_BYTE_ BIT(0)
659 #define OTP_READ_DATA (0x1018)
661 #define OTP_FUNC_CMD (0x1020)
662 #define OTP_FUNC_CMD_READ_ BIT(0)
664 #define OTP_TST_CMD (0x1024)
665 #define OTP_TST_CMD_PRGVRFY_ BIT(3)
667 #define OTP_CMD_GO (0x1028)
668 #define OTP_CMD_GO_GO_ BIT(0)
670 #define OTP_STATUS (0x1030)
671 #define OTP_STATUS_BUSY_ BIT(0)
673 /* Hearthstone OTP block registers */
674 #define HS_OTP_BLOCK_BASE (ETH_SYS_REG_ADDR_BASE + \
675 ETH_OTP_REG_ADDR_BASE)
676 #define HS_OTP_PWR_DN (HS_OTP_BLOCK_BASE + 0x0)
677 #define HS_OTP_ADDR_HIGH (HS_OTP_BLOCK_BASE + 0x4)
678 #define HS_OTP_ADDR_LOW (HS_OTP_BLOCK_BASE + 0x8)
679 #define HS_OTP_PRGM_DATA (HS_OTP_BLOCK_BASE + 0x10)
680 #define HS_OTP_PRGM_MODE (HS_OTP_BLOCK_BASE + 0x14)
681 #define HS_OTP_READ_DATA (HS_OTP_BLOCK_BASE + 0x18)
682 #define HS_OTP_FUNC_CMD (HS_OTP_BLOCK_BASE + 0x20)
683 #define HS_OTP_TST_CMD (HS_OTP_BLOCK_BASE + 0x24)
684 #define HS_OTP_CMD_GO (HS_OTP_BLOCK_BASE + 0x28)
685 #define HS_OTP_STATUS (HS_OTP_BLOCK_BASE + 0x30)
687 /* MAC statistics registers */
688 #define STAT_RX_FCS_ERRORS (0x1200)
689 #define STAT_RX_ALIGNMENT_ERRORS (0x1204)
690 #define STAT_RX_FRAGMENT_ERRORS (0x1208)
691 #define STAT_RX_JABBER_ERRORS (0x120C)
692 #define STAT_RX_UNDERSIZE_FRAME_ERRORS (0x1210)
693 #define STAT_RX_OVERSIZE_FRAME_ERRORS (0x1214)
694 #define STAT_RX_DROPPED_FRAMES (0x1218)
695 #define STAT_RX_UNICAST_BYTE_COUNT (0x121C)
696 #define STAT_RX_BROADCAST_BYTE_COUNT (0x1220)
697 #define STAT_RX_MULTICAST_BYTE_COUNT (0x1224)
698 #define STAT_RX_UNICAST_FRAMES (0x1228)
699 #define STAT_RX_BROADCAST_FRAMES (0x122C)
700 #define STAT_RX_MULTICAST_FRAMES (0x1230)
701 #define STAT_RX_PAUSE_FRAMES (0x1234)
702 #define STAT_RX_64_BYTE_FRAMES (0x1238)
703 #define STAT_RX_65_127_BYTE_FRAMES (0x123C)
704 #define STAT_RX_128_255_BYTE_FRAMES (0x1240)
705 #define STAT_RX_256_511_BYTES_FRAMES (0x1244)
706 #define STAT_RX_512_1023_BYTE_FRAMES (0x1248)
707 #define STAT_RX_1024_1518_BYTE_FRAMES (0x124C)
708 #define STAT_RX_GREATER_1518_BYTE_FRAMES (0x1250)
709 #define STAT_RX_TOTAL_FRAMES (0x1254)
710 #define STAT_EEE_RX_LPI_TRANSITIONS (0x1258)
711 #define STAT_EEE_RX_LPI_TIME (0x125C)
712 #define STAT_RX_COUNTER_ROLLOVER_STATUS (0x127C)
714 #define STAT_TX_FCS_ERRORS (0x1280)
715 #define STAT_TX_EXCESS_DEFERRAL_ERRORS (0x1284)
716 #define STAT_TX_CARRIER_ERRORS (0x1288)
717 #define STAT_TX_BAD_BYTE_COUNT (0x128C)
718 #define STAT_TX_SINGLE_COLLISIONS (0x1290)
719 #define STAT_TX_MULTIPLE_COLLISIONS (0x1294)
720 #define STAT_TX_EXCESSIVE_COLLISION (0x1298)
721 #define STAT_TX_LATE_COLLISIONS (0x129C)
722 #define STAT_TX_UNICAST_BYTE_COUNT (0x12A0)
723 #define STAT_TX_BROADCAST_BYTE_COUNT (0x12A4)
724 #define STAT_TX_MULTICAST_BYTE_COUNT (0x12A8)
725 #define STAT_TX_UNICAST_FRAMES (0x12AC)
726 #define STAT_TX_BROADCAST_FRAMES (0x12B0)
727 #define STAT_TX_MULTICAST_FRAMES (0x12B4)
728 #define STAT_TX_PAUSE_FRAMES (0x12B8)
729 #define STAT_TX_64_BYTE_FRAMES (0x12BC)
730 #define STAT_TX_65_127_BYTE_FRAMES (0x12C0)
731 #define STAT_TX_128_255_BYTE_FRAMES (0x12C4)
732 #define STAT_TX_256_511_BYTES_FRAMES (0x12C8)
733 #define STAT_TX_512_1023_BYTE_FRAMES (0x12CC)
734 #define STAT_TX_1024_1518_BYTE_FRAMES (0x12D0)
735 #define STAT_TX_GREATER_1518_BYTE_FRAMES (0x12D4)
736 #define STAT_TX_TOTAL_FRAMES (0x12D8)
737 #define STAT_EEE_TX_LPI_TRANSITIONS (0x12DC)
738 #define STAT_EEE_TX_LPI_TIME (0x12E0)
739 #define STAT_TX_COUNTER_ROLLOVER_STATUS (0x12FC)
741 /* End of Register definitions */
743 #define LAN743X_MAX_RX_CHANNELS (4)
744 #define LAN743X_MAX_TX_CHANNELS (1)
745 #define PCI11X1X_MAX_TX_CHANNELS (4)
746 struct lan743x_adapter;
748 #define LAN743X_USED_RX_CHANNELS (4)
749 #define LAN743X_USED_TX_CHANNELS (1)
750 #define PCI11X1X_USED_TX_CHANNELS (4)
751 #define LAN743X_INT_MOD (400)
753 #if (LAN743X_USED_RX_CHANNELS > LAN743X_MAX_RX_CHANNELS)
754 #error Invalid LAN743X_USED_RX_CHANNELS
756 #if (LAN743X_USED_TX_CHANNELS > LAN743X_MAX_TX_CHANNELS)
757 #error Invalid LAN743X_USED_TX_CHANNELS
759 #if (PCI11X1X_USED_TX_CHANNELS > PCI11X1X_MAX_TX_CHANNELS)
760 #error Invalid PCI11X1X_USED_TX_CHANNELS
764 /* SMSC acquired EFAR late 1990's, MCHP acquired SMSC 2012 */
765 #define PCI_VENDOR_ID_SMSC PCI_VENDOR_ID_EFAR
766 #define PCI_DEVICE_ID_SMSC_LAN7430 (0x7430)
767 #define PCI_DEVICE_ID_SMSC_LAN7431 (0x7431)
768 #define PCI_DEVICE_ID_SMSC_A011 (0xA011)
769 #define PCI_DEVICE_ID_SMSC_A041 (0xA041)
771 #define PCI_CONFIG_LENGTH (0x1000)
774 #define CSR_LENGTH (0x2000)
776 #define LAN743X_CSR_FLAG_IS_A0 BIT(0)
777 #define LAN743X_CSR_FLAG_IS_B0 BIT(1)
778 #define LAN743X_CSR_FLAG_SUPPORTS_INTR_AUTO_SET_CLR BIT(8)
782 u8 __iomem *csr_address;
788 typedef void(*lan743x_vector_handler)(void *context, u32 int_sts, u32 flags);
790 #define LAN743X_VECTOR_FLAG_IRQ_SHARED BIT(0)
791 #define LAN743X_VECTOR_FLAG_SOURCE_STATUS_READ BIT(1)
792 #define LAN743X_VECTOR_FLAG_SOURCE_STATUS_R2C BIT(2)
793 #define LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C BIT(3)
794 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CHECK BIT(4)
795 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CLEAR BIT(5)
796 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_R2C BIT(6)
797 #define LAN743X_VECTOR_FLAG_MASTER_ENABLE_CLEAR BIT(7)
798 #define LAN743X_VECTOR_FLAG_MASTER_ENABLE_SET BIT(8)
799 #define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_ISR_CLEAR BIT(9)
800 #define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_ISR_SET BIT(10)
801 #define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_CLEAR BIT(11)
802 #define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET BIT(12)
803 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_CLEAR BIT(13)
804 #define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET BIT(14)
805 #define LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR BIT(15)
807 struct lan743x_vector {
810 struct lan743x_adapter *adapter;
813 lan743x_vector_handler handler;
817 #define LAN743X_MAX_VECTOR_COUNT (8)
818 #define PCI11X1X_MAX_VECTOR_COUNT (16)
820 struct lan743x_intr {
825 struct lan743x_vector vector_list[PCI11X1X_MAX_VECTOR_COUNT];
826 int number_of_vectors;
829 bool software_isr_flag;
830 wait_queue_head_t software_isr_wq;
833 #define LAN743X_MAX_FRAME_SIZE (9 * 1024)
838 u8 fc_request_control;
842 struct lan743x_tx_descriptor;
843 struct lan743x_tx_buffer_info;
845 #define GPIO_QUEUE_STARTED (0)
846 #define GPIO_TX_FUNCTION (1)
847 #define GPIO_TX_COMPLETION (2)
848 #define GPIO_TX_FRAGMENT (3)
850 #define TX_FRAME_FLAG_IN_PROGRESS BIT(0)
852 #define TX_TS_FLAG_TIMESTAMPING_ENABLED BIT(0)
853 #define TX_TS_FLAG_ONE_STEP_SYNC BIT(1)
856 struct lan743x_adapter *adapter;
862 size_t ring_allocation_size;
863 struct lan743x_tx_descriptor *ring_cpu_ptr;
864 dma_addr_t ring_dma_ptr;
865 /* ring_lock: used to prevent concurrent access to tx ring */
866 spinlock_t ring_lock;
872 struct lan743x_tx_buffer_info *buffer_info;
874 __le32 *head_cpu_ptr;
875 dma_addr_t head_dma_ptr;
879 struct napi_struct napi;
882 struct sk_buff *overflow_skb;
885 void lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx,
886 bool enable_timestamping,
887 bool enable_onestep_sync);
890 struct lan743x_rx_descriptor;
891 struct lan743x_rx_buffer_info;
894 struct lan743x_adapter *adapter;
899 size_t ring_allocation_size;
900 struct lan743x_rx_descriptor *ring_cpu_ptr;
901 dma_addr_t ring_dma_ptr;
903 struct lan743x_rx_buffer_info *buffer_info;
905 __le32 *head_cpu_ptr;
906 dma_addr_t head_dma_ptr;
910 struct napi_struct napi;
914 struct sk_buff *skb_head, *skb_tail;
917 struct lan743x_adapter {
918 struct net_device *netdev;
919 struct mii_bus *mdiobus;
923 u8 sopass[SOPASS_MAX];
925 struct pci_dev *pdev;
926 struct lan743x_csr csr;
927 struct lan743x_intr intr;
929 struct lan743x_gpio gpio;
930 struct lan743x_ptp ptp;
932 u8 mac_address[ETH_ALEN];
934 struct lan743x_phy phy;
935 struct lan743x_tx tx[PCI11X1X_USED_TX_CHANNELS];
936 struct lan743x_rx rx[LAN743X_USED_RX_CHANNELS];
939 /* protect ethernet syslock */
940 spinlock_t eth_syslock_spinlock;
942 u32 eth_syslock_acquire_cnt;
947 #define LAN743X_ADAPTER_FLAG_OTP BIT(0)
952 #define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel))
954 #define INTR_FLAG_IRQ_REQUESTED(vector_index) BIT(0 + vector_index)
955 #define INTR_FLAG_MSI_ENABLED BIT(8)
956 #define INTR_FLAG_MSIX_ENABLED BIT(9)
958 #define MAC_MII_READ 1
959 #define MAC_MII_WRITE 0
961 #define PHY_FLAG_OPENED BIT(0)
962 #define PHY_FLAG_ATTACHED BIT(1)
964 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
965 #define DMA_ADDR_HIGH32(dma_addr) ((u32)(((dma_addr) >> 32) & 0xFFFFFFFF))
967 #define DMA_ADDR_HIGH32(dma_addr) ((u32)(0))
969 #define DMA_ADDR_LOW32(dma_addr) ((u32)((dma_addr) & 0xFFFFFFFF))
970 #define DMA_DESCRIPTOR_SPACING_16 (16)
971 #define DMA_DESCRIPTOR_SPACING_32 (32)
972 #define DMA_DESCRIPTOR_SPACING_64 (64)
973 #define DMA_DESCRIPTOR_SPACING_128 (128)
974 #define DEFAULT_DMA_DESCRIPTOR_SPACING (L1_CACHE_BYTES)
976 #define DMAC_CHANNEL_STATE_SET(start_bit, stop_bit) \
977 (((start_bit) ? 2 : 0) | ((stop_bit) ? 1 : 0))
978 #define DMAC_CHANNEL_STATE_INITIAL DMAC_CHANNEL_STATE_SET(0, 0)
979 #define DMAC_CHANNEL_STATE_STARTED DMAC_CHANNEL_STATE_SET(1, 0)
980 #define DMAC_CHANNEL_STATE_STOP_PENDING DMAC_CHANNEL_STATE_SET(1, 1)
981 #define DMAC_CHANNEL_STATE_STOPPED DMAC_CHANNEL_STATE_SET(0, 1)
983 /* TX Descriptor bits */
984 #define TX_DESC_DATA0_DTYPE_MASK_ (0xC0000000)
985 #define TX_DESC_DATA0_DTYPE_DATA_ (0x00000000)
986 #define TX_DESC_DATA0_DTYPE_EXT_ (0x40000000)
987 #define TX_DESC_DATA0_FS_ (0x20000000)
988 #define TX_DESC_DATA0_LS_ (0x10000000)
989 #define TX_DESC_DATA0_EXT_ (0x08000000)
990 #define TX_DESC_DATA0_IOC_ (0x04000000)
991 #define TX_DESC_DATA0_ICE_ (0x00400000)
992 #define TX_DESC_DATA0_IPE_ (0x00200000)
993 #define TX_DESC_DATA0_TPE_ (0x00100000)
994 #define TX_DESC_DATA0_FCS_ (0x00020000)
995 #define TX_DESC_DATA0_TSE_ (0x00010000)
996 #define TX_DESC_DATA0_BUF_LENGTH_MASK_ (0x0000FFFF)
997 #define TX_DESC_DATA0_EXT_LSO_ (0x00200000)
998 #define TX_DESC_DATA0_EXT_PAY_LENGTH_MASK_ (0x000FFFFF)
999 #define TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_ (0x3FFF0000)
1001 struct lan743x_tx_descriptor {
1006 } __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING);
1008 #define TX_BUFFER_INFO_FLAG_ACTIVE BIT(0)
1009 #define TX_BUFFER_INFO_FLAG_TIMESTAMP_REQUESTED BIT(1)
1010 #define TX_BUFFER_INFO_FLAG_IGNORE_SYNC BIT(2)
1011 #define TX_BUFFER_INFO_FLAG_SKB_FRAGMENT BIT(3)
1012 struct lan743x_tx_buffer_info {
1014 struct sk_buff *skb;
1016 unsigned int buffer_length;
1019 #define LAN743X_TX_RING_SIZE (50)
1021 /* OWN bit is set. ie, Descs are owned by RX DMAC */
1022 #define RX_DESC_DATA0_OWN_ (0x00008000)
1023 /* OWN bit is clear. ie, Descs are owned by host */
1024 #define RX_DESC_DATA0_FS_ (0x80000000)
1025 #define RX_DESC_DATA0_LS_ (0x40000000)
1026 #define RX_DESC_DATA0_FRAME_LENGTH_MASK_ (0x3FFF0000)
1027 #define RX_DESC_DATA0_FRAME_LENGTH_GET_(data0) \
1028 (((data0) & RX_DESC_DATA0_FRAME_LENGTH_MASK_) >> 16)
1029 #define RX_DESC_DATA0_EXT_ (0x00004000)
1030 #define RX_DESC_DATA0_BUF_LENGTH_MASK_ (0x00003FFF)
1031 #define RX_DESC_DATA2_TS_NS_MASK_ (0x3FFFFFFF)
1033 #if ((NET_IP_ALIGN != 0) && (NET_IP_ALIGN != 2))
1034 #error NET_IP_ALIGN must be 0 or 2
1037 #define RX_HEAD_PADDING NET_IP_ALIGN
1039 struct lan743x_rx_descriptor {
1044 } __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING);
1046 #define RX_BUFFER_INFO_FLAG_ACTIVE BIT(0)
1047 struct lan743x_rx_buffer_info {
1049 struct sk_buff *skb;
1052 unsigned int buffer_length;
1055 #define LAN743X_RX_RING_SIZE (128)
1057 #define RX_PROCESS_RESULT_NOTHING_TO_DO (0)
1058 #define RX_PROCESS_RESULT_BUFFER_RECEIVED (1)
1060 u32 lan743x_csr_read(struct lan743x_adapter *adapter, int offset);
1061 void lan743x_csr_write(struct lan743x_adapter *adapter, int offset, u32 data);
1063 #endif /* _LAN743X_H */