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