blob: 519986c01e7809f831f65a4b0916a13cf46dbd78 [file] [log] [blame]
developerc3ac93d2018-12-20 16:12:53 +08001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2018 MediaTek Inc.
4 *
5 * Author: Weijie Gao <weijie.gao@mediatek.com>
6 * Author: Mark Lee <mark-mc.lee@mediatek.com>
7 */
8
9#ifndef _MTK_ETH_H_
10#define _MTK_ETH_H_
11
Simon Glass4dcacfc2020-05-10 11:40:13 -060012#include <linux/bitops.h>
developer65089f72022-09-09 19:59:24 +080013#include <linux/bitfield.h>
developer1d3b1f62022-09-09 19:59:21 +080014
15enum mkt_eth_capabilities {
16 MTK_TRGMII_BIT,
17 MTK_TRGMII_MT7621_CLK_BIT,
developera5d712a2023-07-19 17:17:22 +080018 MTK_U3_COPHY_V2_BIT,
19 MTK_INFRA_BIT,
developera7cdebf2022-09-09 19:59:26 +080020 MTK_NETSYS_V2_BIT,
developer1d3b1f62022-09-09 19:59:21 +080021
22 /* PATH BITS */
23 MTK_ETH_PATH_GMAC1_TRGMII_BIT,
developera5d712a2023-07-19 17:17:22 +080024 MTK_ETH_PATH_GMAC2_SGMII_BIT,
developer1d3b1f62022-09-09 19:59:21 +080025};
26
27#define MTK_TRGMII BIT(MTK_TRGMII_BIT)
28#define MTK_TRGMII_MT7621_CLK BIT(MTK_TRGMII_MT7621_CLK_BIT)
developera5d712a2023-07-19 17:17:22 +080029#define MTK_U3_COPHY_V2 BIT(MTK_U3_COPHY_V2_BIT)
30#define MTK_INFRA BIT(MTK_INFRA_BIT)
developera7cdebf2022-09-09 19:59:26 +080031#define MTK_NETSYS_V2 BIT(MTK_NETSYS_V2_BIT)
developer1d3b1f62022-09-09 19:59:21 +080032
33/* Supported path present on SoCs */
34#define MTK_ETH_PATH_GMAC1_TRGMII BIT(MTK_ETH_PATH_GMAC1_TRGMII_BIT)
35
developera5d712a2023-07-19 17:17:22 +080036#define MTK_ETH_PATH_GMAC2_SGMII BIT(MTK_ETH_PATH_GMAC2_SGMII_BIT)
37
developer1d3b1f62022-09-09 19:59:21 +080038#define MTK_GMAC1_TRGMII (MTK_ETH_PATH_GMAC1_TRGMII | MTK_TRGMII)
39
developera5d712a2023-07-19 17:17:22 +080040#define MTK_GMAC2_U3_QPHY (MTK_ETH_PATH_GMAC2_SGMII | MTK_U3_COPHY_V2 | MTK_INFRA)
41
developer1d3b1f62022-09-09 19:59:21 +080042#define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x))
43
44#define MT7621_CAPS (MTK_GMAC1_TRGMII | MTK_TRGMII_MT7621_CLK)
45
46#define MT7623_CAPS (MTK_GMAC1_TRGMII)
47
developera5d712a2023-07-19 17:17:22 +080048#define MT7981_CAPS (MTK_GMAC2_U3_QPHY | MTK_NETSYS_V2)
49
developer053929c2022-09-09 19:59:28 +080050#define MT7986_CAPS (MTK_NETSYS_V2)
51
developer1d3b1f62022-09-09 19:59:21 +080052/* Frame Engine Register Bases */
developera7cdebf2022-09-09 19:59:26 +080053#define PDMA_V1_BASE 0x0800
54#define PDMA_V2_BASE 0x6000
developerc3ac93d2018-12-20 16:12:53 +080055#define GDMA1_BASE 0x0500
56#define GDMA2_BASE 0x1500
57#define GMAC_BASE 0x10000
58
59/* Ethernet subsystem registers */
60
61#define ETHSYS_SYSCFG0_REG 0x14
62#define SYSCFG0_GE_MODE_S(n) (12 + ((n) * 2))
63#define SYSCFG0_GE_MODE_M 0x3
developer9a12c242020-01-21 19:31:57 +080064#define SYSCFG0_SGMII_SEL_M (0x3 << 8)
65#define SYSCFG0_SGMII_SEL(gmac) ((!(gmac)) ? BIT(9) : BIT(8))
developerc3ac93d2018-12-20 16:12:53 +080066
67#define ETHSYS_CLKCFG0_REG 0x2c
68#define ETHSYS_TRGMII_CLK_SEL362_5 BIT(11)
69
developera5d712a2023-07-19 17:17:22 +080070/* Top misc registers */
71#define USB_PHY_SWITCH_REG 0x218
72#define QPHY_SEL_MASK 0x3
73#define SGMII_QPHY_SEL 0x2
74
developerc3ac93d2018-12-20 16:12:53 +080075/* SYSCFG0_GE_MODE: GE Modes */
76#define GE_MODE_RGMII 0
77#define GE_MODE_MII 1
78#define GE_MODE_MII_PHY 2
79#define GE_MODE_RMII 3
80
developer9a12c242020-01-21 19:31:57 +080081/* SGMII subsystem config registers */
82#define SGMSYS_PCS_CONTROL_1 0x0
developerd5d73952020-02-18 16:49:37 +080083#define SGMII_LINK_STATUS BIT(18)
developer9a12c242020-01-21 19:31:57 +080084#define SGMII_AN_ENABLE BIT(12)
developerd5d73952020-02-18 16:49:37 +080085#define SGMII_AN_RESTART BIT(9)
developer9a12c242020-01-21 19:31:57 +080086
87#define SGMSYS_SGMII_MODE 0x20
developer4aafc992023-07-19 17:17:13 +080088#define SGMII_AN_MODE 0x31120103
developer9a12c242020-01-21 19:31:57 +080089#define SGMII_FORCE_MODE 0x31120019
90
91#define SGMSYS_QPHY_PWR_STATE_CTRL 0xe8
92#define SGMII_PHYA_PWD BIT(4)
93
developer053929c2022-09-09 19:59:28 +080094#define SGMSYS_QPHY_WRAP_CTRL 0xec
95#define SGMII_PN_SWAP_TX_RX 0x03
96
developer9a12c242020-01-21 19:31:57 +080097#define SGMSYS_GEN2_SPEED 0x2028
developerf6f0ccb2020-06-19 19:17:16 +080098#define SGMSYS_GEN2_SPEED_V2 0x128
developer9a12c242020-01-21 19:31:57 +080099#define SGMSYS_SPEED_2500 BIT(2)
100
developerc3ac93d2018-12-20 16:12:53 +0800101/* Frame Engine Registers */
developera7cdebf2022-09-09 19:59:26 +0800102#define FE_GLO_MISC_REG 0x124
103#define PDMA_VER_V2 BIT(4)
developerc3ac93d2018-12-20 16:12:53 +0800104
105/* PDMA */
106#define TX_BASE_PTR_REG(n) (0x000 + (n) * 0x10)
107#define TX_MAX_CNT_REG(n) (0x004 + (n) * 0x10)
108#define TX_CTX_IDX_REG(n) (0x008 + (n) * 0x10)
109#define TX_DTX_IDX_REG(n) (0x00c + (n) * 0x10)
110
111#define RX_BASE_PTR_REG(n) (0x100 + (n) * 0x10)
112#define RX_MAX_CNT_REG(n) (0x104 + (n) * 0x10)
113#define RX_CRX_IDX_REG(n) (0x108 + (n) * 0x10)
114#define RX_DRX_IDX_REG(n) (0x10c + (n) * 0x10)
115
116#define PDMA_GLO_CFG_REG 0x204
117#define TX_WB_DDONE BIT(6)
118#define RX_DMA_BUSY BIT(3)
119#define RX_DMA_EN BIT(2)
120#define TX_DMA_BUSY BIT(1)
121#define TX_DMA_EN BIT(0)
122
123#define PDMA_RST_IDX_REG 0x208
124#define RST_DRX_IDX0 BIT(16)
125#define RST_DTX_IDX0 BIT(0)
126
127/* GDMA */
128#define GDMA_IG_CTRL_REG 0x000
129#define GDM_ICS_EN BIT(22)
130#define GDM_TCS_EN BIT(21)
131#define GDM_UCS_EN BIT(20)
132#define STRP_CRC BIT(16)
133#define MYMAC_DP_S 12
134#define MYMAC_DP_M 0xf000
135#define BC_DP_S 8
136#define BC_DP_M 0xf00
137#define MC_DP_S 4
138#define MC_DP_M 0xf0
139#define UN_DP_S 0
140#define UN_DP_M 0x0f
141
142#define GDMA_MAC_LSB_REG 0x008
143
144#define GDMA_MAC_MSB_REG 0x00c
145
146/* MYMAC_DP/BC_DP/MC_DP/UN_DP: Destination ports */
147#define DP_PDMA 0
148#define DP_GDMA1 1
149#define DP_GDMA2 2
150#define DP_PPE 4
151#define DP_QDMA 5
152#define DP_DISCARD 7
153
154/* GMAC Registers */
155
156#define GMAC_PIAC_REG 0x0004
157#define PHY_ACS_ST BIT(31)
158#define MDIO_REG_ADDR_S 25
159#define MDIO_REG_ADDR_M 0x3e000000
160#define MDIO_PHY_ADDR_S 20
161#define MDIO_PHY_ADDR_M 0x1f00000
162#define MDIO_CMD_S 18
163#define MDIO_CMD_M 0xc0000
164#define MDIO_ST_S 16
165#define MDIO_ST_M 0x30000
166#define MDIO_RW_DATA_S 0
167#define MDIO_RW_DATA_M 0xffff
168
169/* MDIO_CMD: MDIO commands */
170#define MDIO_CMD_ADDR 0
171#define MDIO_CMD_WRITE 1
172#define MDIO_CMD_READ 2
173#define MDIO_CMD_READ_C45 3
174
175/* MDIO_ST: MDIO start field */
176#define MDIO_ST_C45 0
177#define MDIO_ST_C22 1
178
179#define GMAC_PORT_MCR(p) (0x0100 + (p) * 0x100)
180#define MAC_RX_PKT_LEN_S 24
181#define MAC_RX_PKT_LEN_M 0x3000000
182#define IPG_CFG_S 18
183#define IPG_CFG_M 0xc0000
184#define MAC_MODE BIT(16)
185#define FORCE_MODE BIT(15)
186#define MAC_TX_EN BIT(14)
187#define MAC_RX_EN BIT(13)
developer4aafc992023-07-19 17:17:13 +0800188#define DEL_RXFIFO_CLR BIT(12)
developerc3ac93d2018-12-20 16:12:53 +0800189#define BKOFF_EN BIT(9)
190#define BACKPR_EN BIT(8)
191#define FORCE_RX_FC BIT(5)
192#define FORCE_TX_FC BIT(4)
193#define FORCE_SPD_S 2
194#define FORCE_SPD_M 0x0c
195#define FORCE_DPX BIT(1)
196#define FORCE_LINK BIT(0)
197
developerd5d73952020-02-18 16:49:37 +0800198/* Values of IPG_CFG */
199#define IPG_96BIT 0
200#define IPG_96BIT_WITH_SHORT_IPG 1
201#define IPG_64BIT 2
202
developerc3ac93d2018-12-20 16:12:53 +0800203/* MAC_RX_PKT_LEN: Max RX packet length */
204#define MAC_RX_PKT_LEN_1518 0
205#define MAC_RX_PKT_LEN_1536 1
206#define MAC_RX_PKT_LEN_1552 2
207#define MAC_RX_PKT_LEN_JUMBO 3
208
209/* FORCE_SPD: Forced link speed */
210#define SPEED_10M 0
211#define SPEED_100M 1
212#define SPEED_1000M 2
213
214#define GMAC_TRGMII_RCK_CTRL 0x300
215#define RX_RST BIT(31)
216#define RXC_DQSISEL BIT(30)
217
218#define GMAC_TRGMII_TD_ODT(n) (0x354 + (n) * 8)
219#define TD_DM_DRVN_S 4
220#define TD_DM_DRVN_M 0xf0
221#define TD_DM_DRVP_S 0
222#define TD_DM_DRVP_M 0x0f
223
224/* MT7530 Registers */
225
226#define PCR_REG(p) (0x2004 + (p) * 0x100)
227#define PORT_MATRIX_S 16
228#define PORT_MATRIX_M 0xff0000
229
230#define PVC_REG(p) (0x2010 + (p) * 0x100)
231#define STAG_VPID_S 16
232#define STAG_VPID_M 0xffff0000
233#define VLAN_ATTR_S 6
234#define VLAN_ATTR_M 0xc0
235
236/* VLAN_ATTR: VLAN attributes */
237#define VLAN_ATTR_USER 0
238#define VLAN_ATTR_STACK 1
239#define VLAN_ATTR_TRANSLATION 2
240#define VLAN_ATTR_TRANSPARENT 3
241
developerd5d73952020-02-18 16:49:37 +0800242#define PMCR_REG(p) (0x3000 + (p) * 0x100)
243/* XXX: all fields of MT7530 are defined under GMAC_PORT_MCR
244 * MT7531 specific fields are defined below
245 */
246#define FORCE_MODE_EEE1G BIT(25)
247#define FORCE_MODE_EEE100 BIT(26)
248#define FORCE_MODE_TX_FC BIT(27)
249#define FORCE_MODE_RX_FC BIT(28)
250#define FORCE_MODE_DPX BIT(29)
251#define FORCE_MODE_SPD BIT(30)
252#define FORCE_MODE_LNK BIT(31)
253#define MT7531_FORCE_MODE FORCE_MODE_EEE1G | FORCE_MODE_EEE100 |\
254 FORCE_MODE_TX_FC | FORCE_MODE_RX_FC | \
255 FORCE_MODE_DPX | FORCE_MODE_SPD | \
256 FORCE_MODE_LNK
developerc3ac93d2018-12-20 16:12:53 +0800257
developerd5d73952020-02-18 16:49:37 +0800258/* MT7531 SGMII Registers */
259#define MT7531_SGMII_REG_BASE 0x5000
260#define MT7531_SGMII_REG_PORT_BASE 0x1000
261#define MT7531_SGMII_REG(p, r) (MT7531_SGMII_REG_BASE + \
262 (p) * MT7531_SGMII_REG_PORT_BASE + (r))
263#define MT7531_PCS_CONTROL_1(p) MT7531_SGMII_REG(((p) - 5), 0x00)
264#define MT7531_SGMII_MODE(p) MT7531_SGMII_REG(((p) - 5), 0x20)
265#define MT7531_QPHY_PWR_STATE_CTRL(p) MT7531_SGMII_REG(((p) - 5), 0xe8)
266#define MT7531_PHYA_CTRL_SIGNAL3(p) MT7531_SGMII_REG(((p) - 5), 0x128)
267/* XXX: all fields of MT7531 SGMII are defined under SGMSYS */
268
269/* MT753x System Control Register */
developerc3ac93d2018-12-20 16:12:53 +0800270#define SYS_CTRL_REG 0x7000
271#define SW_PHY_RST BIT(2)
272#define SW_SYS_RST BIT(1)
273#define SW_REG_RST BIT(0)
274
developerd5d73952020-02-18 16:49:37 +0800275/* MT7531 */
276#define MT7531_PHY_IAC 0x701c
277/* XXX: all fields are defined under GMAC_PIAC_REG */
278
279#define MT7531_CLKGEN_CTRL 0x7500
280#define CLK_SKEW_OUT_S 8
281#define CLK_SKEW_OUT_M 0x300
282#define CLK_SKEW_IN_S 6
283#define CLK_SKEW_IN_M 0xc0
284#define RXCLK_NO_DELAY BIT(5)
285#define TXCLK_NO_REVERSE BIT(4)
286#define GP_MODE_S 1
287#define GP_MODE_M 0x06
288#define GP_CLK_EN BIT(0)
289
290/* Values of GP_MODE */
291#define GP_MODE_RGMII 0
292#define GP_MODE_MII 1
293#define GP_MODE_REV_MII 2
294
295/* Values of CLK_SKEW_IN */
296#define CLK_SKEW_IN_NO_CHANGE 0
297#define CLK_SKEW_IN_DELAY_100PPS 1
298#define CLK_SKEW_IN_DELAY_200PPS 2
299#define CLK_SKEW_IN_REVERSE 3
300
301/* Values of CLK_SKEW_OUT */
302#define CLK_SKEW_OUT_NO_CHANGE 0
303#define CLK_SKEW_OUT_DELAY_100PPS 1
304#define CLK_SKEW_OUT_DELAY_200PPS 2
305#define CLK_SKEW_OUT_REVERSE 3
developerc3ac93d2018-12-20 16:12:53 +0800306
307#define HWTRAP_REG 0x7800
developerd5d73952020-02-18 16:49:37 +0800308/* MT7530 Modified Hardware Trap Status Registers */
developerc3ac93d2018-12-20 16:12:53 +0800309#define MHWTRAP_REG 0x7804
310#define CHG_TRAP BIT(16)
311#define LOOPDET_DIS BIT(14)
312#define P5_INTF_SEL_S 13
313#define P5_INTF_SEL_M 0x2000
314#define SMI_ADDR_S 11
315#define SMI_ADDR_M 0x1800
316#define XTAL_FSEL_S 9
317#define XTAL_FSEL_M 0x600
318#define P6_INTF_DIS BIT(8)
319#define P5_INTF_MODE_S 7
320#define P5_INTF_MODE_M 0x80
321#define P5_INTF_DIS BIT(6)
322#define C_MDIO_BPS BIT(5)
323#define CHIP_MODE_S 0
324#define CHIP_MODE_M 0x0f
325
326/* P5_INTF_SEL: Interface type of Port5 */
327#define P5_INTF_SEL_GPHY 0
328#define P5_INTF_SEL_GMAC5 1
329
330/* P5_INTF_MODE: Interface mode of Port5 */
331#define P5_INTF_MODE_GMII_MII 0
332#define P5_INTF_MODE_RGMII 1
333
334#define MT7530_P6ECR 0x7830
335#define P6_INTF_MODE_M 0x3
336#define P6_INTF_MODE_S 0
337
338/* P6_INTF_MODE: Interface mode of Port6 */
339#define P6_INTF_MODE_RGMII 0
340#define P6_INTF_MODE_TRGMII 1
341
developerd5d73952020-02-18 16:49:37 +0800342#define NUM_TRGMII_CTRL 5
343
developerc3ac93d2018-12-20 16:12:53 +0800344#define MT7530_TRGMII_RD(n) (0x7a10 + (n) * 8)
345#define RD_TAP_S 0
346#define RD_TAP_M 0x7f
347
348#define MT7530_TRGMII_TD_ODT(n) (0x7a54 + (n) * 8)
349/* XXX: all fields are defined under GMAC_TRGMII_TD_ODT */
350
developerd5d73952020-02-18 16:49:37 +0800351/* TOP Signals Status Register */
352#define MT7531_TOP_SIG_SR 0x780c
353#define PAD_MCM_SMI_EN BIT(0)
354#define PAD_DUAL_SGMII_EN BIT(1)
355
356/* MT7531 PLLGP Registers */
357#define MT7531_PLLGP_EN 0x7820
358#define EN_COREPLL BIT(2)
359#define SW_CLKSW BIT(1)
360#define SW_PLLGP BIT(0)
developerc3ac93d2018-12-20 16:12:53 +0800361
developerd5d73952020-02-18 16:49:37 +0800362#define MT7531_PLLGP_CR0 0x78a8
363#define RG_COREPLL_EN BIT(22)
364#define RG_COREPLL_POSDIV_S 23
365#define RG_COREPLL_POSDIV_M 0x3800000
366#define RG_COREPLL_SDM_PCW_S 1
367#define RG_COREPLL_SDM_PCW_M 0x3ffffe
368#define RG_COREPLL_SDM_PCW_CHG BIT(0)
369
370/* MT7531 RGMII and SGMII PLL clock */
371#define MT7531_ANA_PLLGP_CR2 0x78b0
372#define MT7531_ANA_PLLGP_CR5 0x78bc
373
374/* MT7531 GPIO GROUP IOLB SMT0 Control */
375#define MT7531_SMT0_IOLB 0x7f04
376#define SMT_IOLB_5_SMI_MDC_EN BIT(5)
377
378/* MT7530 GPHY MDIO Indirect Access Registers */
developerc3ac93d2018-12-20 16:12:53 +0800379#define MII_MMD_ACC_CTL_REG 0x0d
380#define MMD_CMD_S 14
381#define MMD_CMD_M 0xc000
382#define MMD_DEVAD_S 0
383#define MMD_DEVAD_M 0x1f
384
385/* MMD_CMD: MMD commands */
386#define MMD_ADDR 0
387#define MMD_DATA 1
388#define MMD_DATA_RW_POST_INC 2
389#define MMD_DATA_W_POST_INC 3
390
391#define MII_MMD_ADDR_DATA_REG 0x0e
392
393/* MT7530 GPHY MDIO MMD Registers */
developerc3ac93d2018-12-20 16:12:53 +0800394#define CORE_PLL_GROUP2 0x401
395#define RG_SYSPLL_EN_NORMAL BIT(15)
396#define RG_SYSPLL_VODEN BIT(14)
397#define RG_SYSPLL_POSDIV_S 5
398#define RG_SYSPLL_POSDIV_M 0x60
399
400#define CORE_PLL_GROUP4 0x403
developerd5d73952020-02-18 16:49:37 +0800401#define MT7531_BYPASS_MODE BIT(4)
402#define MT7531_POWER_ON_OFF BIT(5)
developerc3ac93d2018-12-20 16:12:53 +0800403#define RG_SYSPLL_DDSFBK_EN BIT(12)
404#define RG_SYSPLL_BIAS_EN BIT(11)
405#define RG_SYSPLL_BIAS_LPF_EN BIT(10)
406
407#define CORE_PLL_GROUP5 0x404
408#define RG_LCDDS_PCW_NCPO1_S 0
409#define RG_LCDDS_PCW_NCPO1_M 0xffff
410
411#define CORE_PLL_GROUP6 0x405
412#define RG_LCDDS_PCW_NCPO0_S 0
413#define RG_LCDDS_PCW_NCPO0_M 0xffff
414
415#define CORE_PLL_GROUP7 0x406
416#define RG_LCDDS_PWDB BIT(15)
417#define RG_LCDDS_ISO_EN BIT(13)
418#define RG_LCCDS_C_S 4
419#define RG_LCCDS_C_M 0x70
420#define RG_LCDDS_PCW_NCPO_CHG BIT(3)
421
422#define CORE_PLL_GROUP10 0x409
423#define RG_LCDDS_SSC_DELTA_S 0
424#define RG_LCDDS_SSC_DELTA_M 0xfff
425
426#define CORE_PLL_GROUP11 0x40a
427#define RG_LCDDS_SSC_DELTA1_S 0
428#define RG_LCDDS_SSC_DELTA1_M 0xfff
429
430#define CORE_GSWPLL_GRP1 0x40d
431#define RG_GSWPLL_POSDIV_200M_S 12
432#define RG_GSWPLL_POSDIV_200M_M 0x3000
433#define RG_GSWPLL_EN_PRE BIT(11)
434#define RG_GSWPLL_FBKDIV_200M_S 0
435#define RG_GSWPLL_FBKDIV_200M_M 0xff
436
437#define CORE_GSWPLL_GRP2 0x40e
438#define RG_GSWPLL_POSDIV_500M_S 8
439#define RG_GSWPLL_POSDIV_500M_M 0x300
440#define RG_GSWPLL_FBKDIV_500M_S 0
441#define RG_GSWPLL_FBKDIV_500M_M 0xff
442
443#define CORE_TRGMII_GSW_CLK_CG 0x410
444#define REG_GSWCK_EN BIT(0)
445#define REG_TRGMIICK_EN BIT(1)
446
developerd5d73952020-02-18 16:49:37 +0800447/* Extend PHY Control Register 3 */
448#define PHY_EXT_REG_14 0x14
449
450/* Fields of PHY_EXT_REG_14 */
451#define PHY_EN_DOWN_SHFIT BIT(4)
452
453/* Extend PHY Control Register 4 */
454#define PHY_EXT_REG_17 0x17
455
456/* Fields of PHY_EXT_REG_17 */
457#define PHY_LINKDOWN_POWER_SAVING_EN BIT(4)
458
459/* PHY RXADC Control Register 7 */
460#define PHY_DEV1E_REG_0C6 0x0c6
461
462/* Fields of PHY_DEV1E_REG_0C6 */
463#define PHY_POWER_SAVING_S 8
464#define PHY_POWER_SAVING_M 0x300
465#define PHY_POWER_SAVING_TX 0x0
466
developer65089f72022-09-09 19:59:24 +0800467/* PDMA descriptors */
468struct mtk_rx_dma {
469 unsigned int rxd1;
470 unsigned int rxd2;
471 unsigned int rxd3;
472 unsigned int rxd4;
473} __packed __aligned(4);
474
developera7cdebf2022-09-09 19:59:26 +0800475struct mtk_rx_dma_v2 {
476 unsigned int rxd1;
477 unsigned int rxd2;
478 unsigned int rxd3;
479 unsigned int rxd4;
480 unsigned int rxd5;
481 unsigned int rxd6;
482 unsigned int rxd7;
483 unsigned int rxd8;
484} __packed __aligned(4);
485
developer65089f72022-09-09 19:59:24 +0800486struct mtk_tx_dma {
487 unsigned int txd1;
488 unsigned int txd2;
489 unsigned int txd3;
490 unsigned int txd4;
491} __packed __aligned(4);
492
developera7cdebf2022-09-09 19:59:26 +0800493struct mtk_tx_dma_v2 {
494 unsigned int txd1;
495 unsigned int txd2;
496 unsigned int txd3;
497 unsigned int txd4;
498 unsigned int txd5;
499 unsigned int txd6;
500 unsigned int txd7;
501 unsigned int txd8;
502} __packed __aligned(4);
503
developer65089f72022-09-09 19:59:24 +0800504/* PDMA TXD fields */
505#define PDMA_TXD2_DDONE BIT(31)
506#define PDMA_TXD2_LS0 BIT(30)
developera7cdebf2022-09-09 19:59:26 +0800507#define PDMA_V1_TXD2_SDL0_M GENMASK(29, 16)
508#define PDMA_V1_TXD2_SDL0_SET(_v) FIELD_PREP(PDMA_V1_TXD2_SDL0_M, (_v))
509#define PDMA_V2_TXD2_SDL0_M GENMASK(23, 8)
510#define PDMA_V2_TXD2_SDL0_SET(_v) FIELD_PREP(PDMA_V2_TXD2_SDL0_M, (_v))
developer65089f72022-09-09 19:59:24 +0800511
developera7cdebf2022-09-09 19:59:26 +0800512#define PDMA_V1_TXD4_FPORT_M GENMASK(27, 25)
513#define PDMA_V1_TXD4_FPORT_SET(_v) FIELD_PREP(PDMA_V1_TXD4_FPORT_M, (_v))
514#define PDMA_V2_TXD4_FPORT_M GENMASK(27, 24)
515#define PDMA_V2_TXD4_FPORT_SET(_v) FIELD_PREP(PDMA_V2_TXD4_FPORT_M, (_v))
516
517#define PDMA_V2_TXD5_FPORT_M GENMASK(19, 16)
518#define PDMA_V2_TXD5_FPORT_SET(_v) FIELD_PREP(PDMA_V2_TXD5_FPORT_M, (_v))
developer65089f72022-09-09 19:59:24 +0800519
520/* PDMA RXD fields */
521#define PDMA_RXD2_DDONE BIT(31)
522#define PDMA_RXD2_LS0 BIT(30)
developera7cdebf2022-09-09 19:59:26 +0800523#define PDMA_V1_RXD2_PLEN0_M GENMASK(29, 16)
524#define PDMA_V1_RXD2_PLEN0_GET(_v) FIELD_GET(PDMA_V1_RXD2_PLEN0_M, (_v))
525#define PDMA_V1_RXD2_PLEN0_SET(_v) FIELD_PREP(PDMA_V1_RXD2_PLEN0_M, (_v))
526#define PDMA_V2_RXD2_PLEN0_M GENMASK(23, 8)
527#define PDMA_V2_RXD2_PLEN0_GET(_v) FIELD_GET(PDMA_V2_RXD2_PLEN0_M, (_v))
528#define PDMA_V2_RXD2_PLEN0_SET(_v) FIELD_PREP(PDMA_V2_RXD2_PLEN0_M, (_v))
developer65089f72022-09-09 19:59:24 +0800529
developerc3ac93d2018-12-20 16:12:53 +0800530#endif /* _MTK_ETH_H_ */