blob: 733da633f0e00419d3ccc57e079c331f8373e682 [file] [log] [blame]
developerfd40db22021-04-29 10:08:25 +08001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (c) 2018 MediaTek Inc.
4 * Author: Weijie Gao <weijie.gao@mediatek.com>
5 */
6
7#ifndef _MT753X_REGS_H_
8#define _MT753X_REGS_H_
9
10#include <linux/bitops.h>
11
developer2cdaeb12022-10-04 20:25:05 +080012/* ethernet wrap register */
13#define ETH_RESET 0x8
14
developerfd40db22021-04-29 10:08:25 +080015/* Values of Egress TAG Control */
16#define ETAG_CTRL_UNTAG 0
17#define ETAG_CTRL_TAG 2
18#define ETAG_CTRL_SWAP 1
19#define ETAG_CTRL_STACK 3
20
21#define VTCR 0x90
22#define VAWD1 0x94
23#define VAWD2 0x98
24
25/* Fields of VTCR */
26#define VTCR_BUSY BIT(31)
27#define IDX_INVLD BIT(16)
28#define VTCR_FUNC_S 12
29#define VTCR_FUNC_M 0xf000
30#define VTCR_VID_S 0
31#define VTCR_VID_M 0xfff
32
33/* Values of VTCR_FUNC */
34#define VTCR_READ_VLAN_ENTRY 0
35#define VTCR_WRITE_VLAN_ENTRY 1
36#define VTCR_INVD_VLAN_ENTRY 2
37#define VTCR_ENABLE_VLAN_ENTRY 3
38#define VTCR_READ_ACL_ENTRY 4
39#define VTCR_WRITE_ACL_ENTRY 5
40#define VTCR_READ_TRTCM_TABLE 6
41#define VTCR_WRITE_TRTCM_TABLE 7
42#define VTCR_READ_ACL_MASK_ENTRY 8
43#define VTCR_WRITE_ACL_MASK_ENTRY 9
44#define VTCR_READ_ACL_RULE_ENTRY 10
45#define VTCR_WRITE_ACL_RULE_ENTRY 11
46#define VTCR_READ_ACL_RATE_ENTRY 12
47#define VTCR_WRITE_ACL_RATE_ENTRY 13
48
49/* VLAN entry fields */
50/* VAWD1 */
51#define PORT_STAG BIT(31)
52#define IVL_MAC BIT(30)
53#define EG_CON BIT(29)
54#define VTAG_EN BIT(28)
55#define COPY_PRI BIT(27)
56#define USER_PRI_S 24
57#define USER_PRI_M 0x7000000
58#define PORT_MEM_S 16
59#define PORT_MEM_M 0xff0000
60#define S_TAG1_S 4
61#define S_TAG1_M 0xfff0
62#define FID_S 1
63#define FID_M 0x0e
64#define VENTRY_VALID BIT(0)
65
66/* VAWD2 */
67#define S_TAG2_S 16
68#define S_TAG2_M 0xffff0000
69#define PORT_ETAG_S(p) ((p) * 2)
70#define PORT_ETAG_M 0x03
71
72#define PORT_CTRL_BASE 0x2000
73#define PORT_CTRL_PORT_OFFSET 0x100
74#define PORT_CTRL_REG(p, r) (PORT_CTRL_BASE + \
75 (p) * PORT_CTRL_PORT_OFFSET + (r))
76#define CKGCR(p) PORT_CTRL_REG(p, 0x00)
77#define PCR(p) PORT_CTRL_REG(p, 0x04)
78#define PIC(p) PORT_CTRL_REG(p, 0x08)
79#define PSC(p) PORT_CTRL_REG(p, 0x0c)
80#define PVC(p) PORT_CTRL_REG(p, 0x10)
81#define PPBV1(p) PORT_CTRL_REG(p, 0x14)
82#define PPBV2(p) PORT_CTRL_REG(p, 0x18)
83#define BSR(p) PORT_CTRL_REG(p, 0x1c)
84#define STAG01 PORT_CTRL_REG(p, 0x20)
85#define STAG23 PORT_CTRL_REG(p, 0x24)
86#define STAG45 PORT_CTRL_REG(p, 0x28)
87#define STAG67 PORT_CTRL_REG(p, 0x2c)
88
89#define PPBV(p, g) (PPBV1(p) + ((g) / 2) * 4)
90
91/* Fields of PCR */
92#define MLDV2_EN BIT(30)
93#define EG_TAG_S 28
94#define EG_TAG_M 0x30000000
95#define PORT_PRI_S 24
96#define PORT_PRI_M 0x7000000
97#define PORT_MATRIX_S 16
98#define PORT_MATRIX_M 0xff0000
99#define UP2DSCP_EN BIT(12)
100#define UP2TAG_EN BIT(11)
101#define ACL_EN BIT(10)
102#define PORT_TX_MIR BIT(9)
103#define PORT_RX_MIR BIT(8)
104#define ACL_MIR BIT(7)
105#define MIS_PORT_FW_S 4
106#define MIS_PORT_FW_M 0x70
107#define VLAN_MIS BIT(2)
108#define PORT_VLAN_S 0
109#define PORT_VLAN_M 0x03
110
111/* Values of PORT_VLAN */
112#define PORT_MATRIX_MODE 0
113#define FALLBACK_MODE 1
114#define CHECK_MODE 2
115#define SECURITY_MODE 3
116
117/* Fields of PVC */
118#define STAG_VPID_S 16
119#define STAG_VPID_M 0xffff0000
120#define DIS_PVID BIT(15)
121#define FORCE_PVID BIT(14)
122#define PT_VPM BIT(12)
123#define PT_OPTION BIT(11)
124#define PVC_EG_TAG_S 8
125#define PVC_EG_TAG_M 0x700
126#define VLAN_ATTR_S 6
127#define VLAN_ATTR_M 0xc0
128#define PVC_PORT_STAG BIT(5)
129#define BC_LKYV_EN BIT(4)
130#define MC_LKYV_EN BIT(3)
131#define UC_LKYV_EN BIT(2)
132#define ACC_FRM_S 0
133#define ACC_FRM_M 0x03
134
135/* Values of VLAN_ATTR */
136#define VA_USER_PORT 0
137#define VA_STACK_PORT 1
138#define VA_TRANSLATION_PORT 2
139#define VA_TRANSPARENT_PORT 3
140
141/* Fields of PPBV */
142#define GRP_PORT_PRI_S(g) (((g) % 2) * 16 + 13)
143#define GRP_PORT_PRI_M 0x07
144#define GRP_PORT_VID_S(g) (((g) % 2) * 16)
145#define GRP_PORT_VID_M 0xfff
146
147#define PORT_MAC_CTRL_BASE 0x3000
148#define PORT_MAC_CTRL_PORT_OFFSET 0x100
149#define PORT_MAC_CTRL_REG(p, r) (PORT_MAC_CTRL_BASE + \
150 (p) * PORT_MAC_CTRL_PORT_OFFSET + (r))
151#define PMCR(p) PORT_MAC_CTRL_REG(p, 0x00)
152#define PMEEECR(p) PORT_MAC_CTRL_REG(p, 0x04)
153#define PMSR(p) PORT_MAC_CTRL_REG(p, 0x08)
154#define PINT_EN(p) PORT_MAC_CTRL_REG(p, 0x10)
155#define PINT_STS(p) PORT_MAC_CTRL_REG(p, 0x14)
156
157#define GMACCR (PORT_MAC_CTRL_BASE + 0xe0)
158#define TXCRC_EN BIT(19)
159#define RXCRC_EN BIT(18)
160#define PRMBL_LMT_EN BIT(17)
161#define MTCC_LMT_S 9
162#define MTCC_LMT_M 0x1e00
163#define MAX_RX_JUMBO_S 2
164#define MAX_RX_JUMBO_M 0x3c
165#define MAX_RX_PKT_LEN_S 0
166#define MAX_RX_PKT_LEN_M 0x3
167
168/* Values of MAX_RX_PKT_LEN */
169#define RX_PKT_LEN_1518 0
170#define RX_PKT_LEN_1536 1
171#define RX_PKT_LEN_1522 2
172#define RX_PKT_LEN_MAX_JUMBO 3
173
174/* Fields of PMCR */
175#define IPG_CFG_S 18
176#define IPG_CFG_M 0xc0000
177#define EXT_PHY BIT(17)
178#define MAC_MODE BIT(16)
179#define MAC_TX_EN BIT(14)
180#define MAC_RX_EN BIT(13)
181#define MAC_PRE BIT(11)
182#define BKOFF_EN BIT(9)
183#define BACKPR_EN BIT(8)
184#define FORCE_EEE1G BIT(7)
185#define FORCE_EEE1000 BIT(6)
186#define FORCE_RX_FC BIT(5)
187#define FORCE_TX_FC BIT(4)
188#define FORCE_SPD_S 2
189#define FORCE_SPD_M 0x0c
190#define FORCE_DPX BIT(1)
191#define FORCE_LINK BIT(0)
192
193/* Fields of PMSR */
194#define EEE1G_STS BIT(7)
195#define EEE100_STS BIT(6)
196#define RX_FC_STS BIT(5)
197#define TX_FC_STS BIT(4)
198#define MAC_SPD_STS_S 2
199#define MAC_SPD_STS_M 0x0c
200#define MAC_DPX_STS BIT(1)
201#define MAC_LNK_STS BIT(0)
202
203/* Values of MAC_SPD_STS */
204#define MAC_SPD_10 0
205#define MAC_SPD_100 1
206#define MAC_SPD_1000 2
207#define MAC_SPD_2500 3
208
209/* Values of IPG_CFG */
210#define IPG_96BIT 0
211#define IPG_96BIT_WITH_SHORT_IPG 1
212#define IPG_64BIT 2
213
214#define MIB_COUNTER_BASE 0x4000
215#define MIB_COUNTER_PORT_OFFSET 0x100
216#define MIB_COUNTER_REG(p, r) (MIB_COUNTER_BASE + \
217 (p) * MIB_COUNTER_PORT_OFFSET + (r))
218#define STATS_TDPC 0x00
219#define STATS_TCRC 0x04
220#define STATS_TUPC 0x08
221#define STATS_TMPC 0x0C
222#define STATS_TBPC 0x10
223#define STATS_TCEC 0x14
224#define STATS_TSCEC 0x18
225#define STATS_TMCEC 0x1C
226#define STATS_TDEC 0x20
227#define STATS_TLCEC 0x24
228#define STATS_TXCEC 0x28
229#define STATS_TPPC 0x2C
230#define STATS_TL64PC 0x30
231#define STATS_TL65PC 0x34
232#define STATS_TL128PC 0x38
233#define STATS_TL256PC 0x3C
234#define STATS_TL512PC 0x40
235#define STATS_TL1024PC 0x44
236#define STATS_TOC 0x48
237#define STATS_RDPC 0x60
238#define STATS_RFPC 0x64
239#define STATS_RUPC 0x68
240#define STATS_RMPC 0x6C
241#define STATS_RBPC 0x70
242#define STATS_RAEPC 0x74
243#define STATS_RCEPC 0x78
244#define STATS_RUSPC 0x7C
245#define STATS_RFEPC 0x80
246#define STATS_ROSPC 0x84
247#define STATS_RJEPC 0x88
248#define STATS_RPPC 0x8C
249#define STATS_RL64PC 0x90
250#define STATS_RL65PC 0x94
251#define STATS_RL128PC 0x98
252#define STATS_RL256PC 0x9C
253#define STATS_RL512PC 0xA0
254#define STATS_RL1024PC 0xA4
255#define STATS_ROC 0xA8
256#define STATS_RDPC_CTRL 0xB0
257#define STATS_RDPC_ING 0xB4
258#define STATS_RDPC_ARL 0xB8
259
260#define SYS_CTRL 0x7000
261#define SW_PHY_RST BIT(2)
262#define SW_SYS_RST BIT(1)
263#define SW_REG_RST BIT(0)
264
265#define SYS_INT_EN 0x7008
266#define SYS_INT_STS 0x700c
267#define MAC_PC_INT BIT(16)
268#define PHY_INT(p) BIT((p) + 8)
269#define PHY_LC_INT(p) BIT(p)
270
271#define PHY_IAC 0x701c
272#define PHY_ACS_ST BIT(31)
273#define MDIO_REG_ADDR_S 25
274#define MDIO_REG_ADDR_M 0x3e000000
275#define MDIO_PHY_ADDR_S 20
276#define MDIO_PHY_ADDR_M 0x1f00000
277#define MDIO_CMD_S 18
278#define MDIO_CMD_M 0xc0000
279#define MDIO_ST_S 16
280#define MDIO_ST_M 0x30000
281#define MDIO_RW_DATA_S 0
282#define MDIO_RW_DATA_M 0xffff
283
284/* MDIO_CMD: MDIO commands */
285#define MDIO_CMD_ADDR 0
286#define MDIO_CMD_WRITE 1
287#define MDIO_CMD_READ 2
288#define MDIO_CMD_READ_C45 3
289
290/* MDIO_ST: MDIO start field */
291#define MDIO_ST_C45 0
292#define MDIO_ST_C22 1
293
294#define HWSTRAP 0x7800
295#define MHWSTRAP 0x7804
296
297/* Internal GPHY Page Control Register */
298#define PHY_CL22_PAGE_CTRL 0x1f
299#define PHY_TR_PAGE 0x52b5
300
301/* Internal GPHY Token Ring Access Registers */
302#define PHY_TR_CTRL 0x10
303#define PHY_TR_LOW_DATA 0x11
304#define PHY_TR_HIGH_DATA 0x12
305
306/* Fields of PHY_TR_CTRL */
307#define PHY_TR_PKT_XMT_STA BIT(15)
308#define PHY_TR_WR_S 13
309#define PHY_TR_CH_ADDR_S 11
310#define PHY_TR_NODE_ADDR_S 7
311#define PHY_TR_DATA_ADDR_S 1
312
313enum phy_tr_wr {
314 PHY_TR_WRITE = 0,
315 PHY_TR_READ = 1,
316};
317
318/* Helper macro for GPHY Token Ring Access */
319#define PHY_TR_LOW_VAL(x) ((x) & 0xffff)
320#define PHY_TR_HIGH_VAL(x) (((x) & 0xff0000) >> 16)
321
322/* Token Ring Channels */
323#define PMA_CH 0x1
324#define DSP_CH 0x2
325
326/* Token Ring Nodes */
327#define PMA_NOD 0xf
328#define DSP_NOD 0xd
329
330/* Token Ring register range */
331enum tr_pma_reg_addr {
332 PMA_MIN = 0x0,
333 PMA_01 = 0x1,
334 PMA_17 = 0x17,
335 PMA_18 = 0x18,
336 PMA_MAX = 0x3d,
337};
338
339enum tr_dsp_reg_addr {
340 DSP_MIN = 0x0,
341 DSP_06 = 0x6,
342 DSP_08 = 0x8,
343 DSP_0f = 0xf,
344 DSP_10 = 0x10,
345 DSP_MAX = 0x3e,
346};
347#endif /* _MT753X_REGS_H_ */