7b8f539be00053eafbe761c387c88dddf4ba9a11
[openwrt.git] / target / linux / generic / files / drivers / net / phy / b53 / b53_regs.h
1 /*
2  * B53 register definitions
3  *
4  * Copyright (C) 2004 Broadcom Corporation
5  * Copyright (C) 2011-2013 Jonas Gorski <jogo@openwrt.org>
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19
20 #ifndef __B53_REGS_H
21 #define __B53_REGS_H
22
23 /* Management Port (SMP) Page offsets */
24 #define B53_CTRL_PAGE                   0x00 /* Control */
25 #define B53_STAT_PAGE                   0x01 /* Status */
26 #define B53_MGMT_PAGE                   0x02 /* Management Mode */
27 #define B53_MIB_AC_PAGE                 0x03 /* MIB Autocast */
28 #define B53_ARLCTRL_PAGE                0x04 /* ARL Control */
29 #define B53_ARLIO_PAGE                  0x05 /* ARL Access */
30 #define B53_FRAMEBUF_PAGE               0x06 /* Management frame access */
31 #define B53_MEM_ACCESS_PAGE             0x08 /* Memory access */
32
33 /* PHY Registers */
34 #define B53_PORT_MII_PAGE(i)            (0x10 + i) /* Port i MII Registers */
35 #define B53_IM_PORT_PAGE                0x18 /* Inverse MII Port (to EMAC) */
36 #define B53_ALL_PORT_PAGE               0x19 /* All ports MII (broadcast) */
37
38 /* MIB registers */
39 #define B53_MIB_PAGE(i)                 (0x20 + i)
40
41 /* Quality of Service (QoS) Registers */
42 #define B53_QOS_PAGE                    0x30
43
44 /* Port VLAN Page */
45 #define B53_PVLAN_PAGE                  0x31
46
47 /* VLAN Registers */
48 #define B53_VLAN_PAGE                   0x34
49
50 /* Jumbo Frame Registers */
51 #define B53_JUMBO_PAGE                  0x40
52
53 /*************************************************************************
54  * Control Page registers
55  *************************************************************************/
56
57 /* Port Control Register (8 bit) */
58 #define B53_PORT_CTRL(i)                (0x00 + i)
59 #define   PORT_CTRL_RX_DISABLE          BIT(0)
60 #define   PORT_CTRL_TX_DISABLE          BIT(1)
61 #define   PORT_CTRL_RX_BCST_EN          BIT(2) /* Broadcast RX (P8 only) */
62 #define   PORT_CTRL_RX_MCST_EN          BIT(3) /* Multicast RX (P8 only) */
63 #define   PORT_CTRL_RX_UCST_EN          BIT(4) /* Unicast RX (P8 only) */
64 #define   PORT_CTRL_STP_STATE_S         5
65 #define   PORT_CTRL_STP_STATE_MASK      (0x3 << PORT_CTRL_STP_STATE_S)
66
67 /* SMP Control Register (8 bit) */
68 #define B53_SMP_CTRL                    0x0a
69
70 /* Switch Mode Control Register (8 bit) */
71 #define B53_SWITCH_MODE                 0x0b
72 #define   SM_SW_FWD_MODE                BIT(0)  /* 1 = Managed Mode */
73 #define   SM_SW_FWD_EN                  BIT(1)  /* Forwarding Enable */
74
75 /* IMP Port state override register (8 bit) */
76 #define B53_PORT_OVERRIDE_CTRL          0x0e
77 #define   PORT_OVERRIDE_LINK            BIT(0)
78 #define   PORT_OVERRIDE_HALF_DUPLEX     BIT(1) /* 0 = Full Duplex */
79 #define   PORT_OVERRIDE_SPEED_S         2
80 #define   PORT_OVERRIDE_SPEED_10M       (0 << PORT_OVERRIDE_SPEED_S)
81 #define   PORT_OVERRIDE_SPEED_100M      (1 << PORT_OVERRIDE_SPEED_S)
82 #define   PORT_OVERRIDE_SPEED_1000M     (2 << PORT_OVERRIDE_SPEED_S)
83 #define   PORT_OVERRIDE_RV_MII_25       BIT(4) /* BCM5325 only */
84 #define   PORT_OVERRIDE_RX_FLOW         BIT(4)
85 #define   PORT_OVERRIDE_TX_FLOW         BIT(5)
86 #define   PORT_OVERRIDE_EN              BIT(7) /* Use the register contents */
87
88 /* Power-down mode control */
89 #define B53_PD_MODE_CTRL_25             0x0f
90
91 /* IP Multicast control (8 bit) */
92 #define B53_IP_MULTICAST_CTRL           0x21
93 #define  B53_IPMC_FWD_EN                BIT(1)
94 #define  B53_UC_FWD_EN                  BIT(6)
95 #define  B53_MC_FWD_EN                  BIT(7)
96
97 /* (16 bit) */
98 #define B53_UC_FLOOD_MASK               0x32
99 #define B53_MC_FLOOD_MASK               0x34
100 #define B53_IPMC_FLOOD_MASK             0x36
101
102 /* Software reset register (8 bit) */
103 #define B53_SOFTRESET                   0x79
104
105 /* Fast Aging Control register (8 bit) */
106 #define B53_FAST_AGE_CTRL               0x88
107 #define   FAST_AGE_STATIC               BIT(0)
108 #define   FAST_AGE_DYNAMIC              BIT(1)
109 #define   FAST_AGE_PORT                 BIT(2)
110 #define   FAST_AGE_VLAN                 BIT(3)
111 #define   FAST_AGE_STP                  BIT(4)
112 #define   FAST_AGE_MC                   BIT(5)
113 #define   FAST_AGE_DONE                 BIT(7)
114
115 /*************************************************************************
116  * Status Page registers
117  *************************************************************************/
118
119 /* Link Status Summary Register (16bit) */
120 #define B53_LINK_STAT                   0x00
121
122 /* Link Status Change Register (16 bit) */
123 #define B53_LINK_STAT_CHANGE            0x02
124
125 /* Port Speed Summary Register (16 bit for FE, 32 bit for GE) */
126 #define B53_SPEED_STAT                  0x04
127 #define  SPEED_PORT_FE(reg, port)       (((reg) >> (port)) & 1)
128 #define  SPEED_PORT_GE(reg, port)       (((reg) >> 2 * (port)) & 3)
129 #define  SPEED_STAT_10M                 0
130 #define  SPEED_STAT_100M                1
131 #define  SPEED_STAT_1000M               2
132
133 /* Duplex Status Summary (16 bit) */
134 #define B53_DUPLEX_STAT_FE              0x06
135 #define B53_DUPLEX_STAT_GE              0x08
136 #define B53_DUPLEX_STAT_63XX            0x0c
137
138 /* Strap Value (48 bit) */
139 #define B53_STRAP_VALUE                 0x70
140 #define   SV_GMII_CTRL_115              BIT(27)
141
142 /*************************************************************************
143  * Management Mode Page Registers
144  *************************************************************************/
145
146 /* Global Management Config Register (8 bit) */
147 #define B53_GLOBAL_CONFIG               0x00
148 #define   GC_RESET_MIB                  0x01
149 #define   GC_RX_BPDU_EN                 0x02
150 #define   GC_MIB_AC_HDR_EN              0x10
151 #define   GC_MIB_AC_EN                  0x20
152 #define   GC_FRM_MGMT_PORT_M            0xC0
153 #define   GC_FRM_MGMT_PORT_04           0x00
154 #define   GC_FRM_MGMT_PORT_MII          0x80
155
156 /* Device ID register (8 or 32 bit) */
157 #define B53_DEVICE_ID                   0x30
158
159 /* Revision ID register (8 bit) */
160 #define B53_REV_ID                      0x40
161
162 /*************************************************************************
163  * ARL Access Page Registers
164  *************************************************************************/
165
166 /* VLAN Table Access Register (8 bit) */
167 #define B53_VT_ACCESS                   0x80
168 #define B53_VT_ACCESS_9798              0x60 /* for BCM5397/BCM5398 */
169 #define B53_VT_ACCESS_63XX              0x60 /* for BCM6328/62/68 */
170 #define   VTA_CMD_WRITE                 0
171 #define   VTA_CMD_READ                  1
172 #define   VTA_CMD_CLEAR                 2
173 #define   VTA_START_CMD                 BIT(7)
174
175 /* VLAN Table Index Register (16 bit) */
176 #define B53_VT_INDEX                    0x81
177 #define B53_VT_INDEX_9798               0x61
178 #define B53_VT_INDEX_63XX               0x62
179
180 /* VLAN Table Entry Register (32 bit) */
181 #define B53_VT_ENTRY                    0x83
182 #define B53_VT_ENTRY_9798               0x63
183 #define B53_VT_ENTRY_63XX               0x64
184 #define   VTE_MEMBERS                   0x1ff
185 #define   VTE_UNTAG_S                   9
186 #define   VTE_UNTAG                     (0x1ff << 9)
187
188 /*************************************************************************
189  * Port VLAN Registers
190  *************************************************************************/
191
192 /* Port VLAN mask (16 bit) IMP port is always 8, also on 5325 & co */
193 #define B53_PVLAN_PORT_MASK(i)          ((i) * 2)
194
195 /*************************************************************************
196  * 802.1Q Page Registers
197  *************************************************************************/
198
199 /* Global QoS Control (8 bit) */
200 #define B53_QOS_GLOBAL_CTL              0x00
201
202 /* Enable 802.1Q for individual Ports (16 bit) */
203 #define B53_802_1P_EN                   0x04
204
205 /*************************************************************************
206  * VLAN Page Registers
207  *************************************************************************/
208
209 /* VLAN Control 0 (8 bit) */
210 #define B53_VLAN_CTRL0                  0x00
211 #define   VC0_8021PF_CTRL_MASK          0x3
212 #define   VC0_8021PF_CTRL_NONE          0x0
213 #define   VC0_8021PF_CTRL_CHANGE_PRI    0x1
214 #define   VC0_8021PF_CTRL_CHANGE_VID    0x2
215 #define   VC0_8021PF_CTRL_CHANGE_BOTH   0x3
216 #define   VC0_8021QF_CTRL_MASK          0xc
217 #define   VC0_8021QF_CTRL_CHANGE_PRI    0x1
218 #define   VC0_8021QF_CTRL_CHANGE_VID    0x2
219 #define   VC0_8021QF_CTRL_CHANGE_BOTH   0x3
220 #define   VC0_RESERVED_1                BIT(1)
221 #define   VC0_DROP_VID_MISS             BIT(4)
222 #define   VC0_VID_HASH_VID              BIT(5)
223 #define   VC0_VID_CHK_EN                BIT(6)  /* Use VID,DA or VID,SA */
224 #define   VC0_VLAN_EN                   BIT(7)  /* 802.1Q VLAN Enabled */
225
226 /* VLAN Control 1 (8 bit) */
227 #define B53_VLAN_CTRL1                  0x01
228 #define   VC1_RX_MCST_TAG_EN            BIT(1)
229 #define   VC1_RX_MCST_FWD_EN            BIT(2)
230 #define   VC1_RX_MCST_UNTAG_EN          BIT(3)
231
232 /* VLAN Control 2 (8 bit) */
233 #define B53_VLAN_CTRL2                  0x02
234
235 /* VLAN Control 3 (8 bit when BCM5325, 16 bit else) */
236 #define B53_VLAN_CTRL3                  0x03
237 #define B53_VLAN_CTRL3_63XX             0x04
238 #define   VC3_MAXSIZE_1532              BIT(6) /* 5325 only */
239 #define   VC3_HIGH_8BIT_EN              BIT(7) /* 5325 only */
240
241 /* VLAN Control 4 (8 bit) */
242 #define B53_VLAN_CTRL4                  0x05
243 #define B53_VLAN_CTRL4_25               0x04
244 #define B53_VLAN_CTRL4_63XX             0x06
245 #define   VC4_ING_VID_CHECK_S           6
246 #define   VC4_ING_VID_CHECK_MASK        (0x3 << VC4_ING_VID_CHECK_S)
247 #define   VC4_ING_VID_VIO_FWD           0 /* forward, but do not learn */
248 #define   VC4_ING_VID_VIO_DROP          1 /* drop VID violations */
249 #define   VC4_NO_ING_VID_CHK            2 /* do not check */
250 #define   VC4_ING_VID_VIO_TO_IMP        3 /* redirect to MII port */
251
252 /* VLAN Control 5 (8 bit) */
253 #define B53_VLAN_CTRL5                  0x06
254 #define B53_VLAN_CTRL5_25               0x05
255 #define B53_VLAN_CTRL5_63XX             0x07
256 #define   VC5_VID_FFF_EN                BIT(2)
257 #define   VC5_DROP_VTABLE_MISS          BIT(3)
258
259 /* VLAN Control 6 (8 bit) */
260 #define B53_VLAN_CTRL6                  0x07
261 #define B53_VLAN_CTRL6_63XX             0x08
262
263 /* VLAN Table Access Register (16 bit) */
264 #define B53_VLAN_TABLE_ACCESS_25        0x06    /* BCM5325E/5350 */
265 #define B53_VLAN_TABLE_ACCESS_65        0x08    /* BCM5365 */
266 #define   VTA_VID_LOW_MASK_25           0xf
267 #define   VTA_VID_LOW_MASK_65           0xff
268 #define   VTA_VID_HIGH_S_25             4
269 #define   VTA_VID_HIGH_S_65             8
270 #define   VTA_VID_HIGH_MASK_25          (0xff << VTA_VID_HIGH_S_25E)
271 #define   VTA_VID_HIGH_MASK_65          (0xf << VTA_VID_HIGH_S_65)
272 #define   VTA_RW_STATE                  BIT(12)
273 #define   VTA_RW_STATE_RD               0
274 #define   VTA_RW_STATE_WR               BIT(12)
275 #define   VTA_RW_OP_EN                  BIT(13)
276
277 /* VLAN Read/Write Registers for (16/32 bit) */
278 #define B53_VLAN_WRITE_25               0x08
279 #define B53_VLAN_WRITE_65               0x0a
280 #define B53_VLAN_READ                   0x0c
281 #define   VA_MEMBER_MASK                0x3f
282 #define   VA_UNTAG_S                    6
283 #define   VA_UNTAG_MASK                 (0x3f << VA_UNTAG_S)
284 #define   VA_VID_HIGH_S                 12
285 #define   VA_VID_HIGH_MASK              (0xffff << VA_VID_HIGH_S)
286 #define   VA_VALID_25                   BIT(20)
287 #define   VA_VALID_25_R4                BIT(24)
288 #define   VA_VALID_65                   BIT(14)
289
290 /* VLAN Port Default Tag (16 bit) */
291 #define B53_VLAN_PORT_DEF_TAG(i)        (0x10 + 2 * (i))
292
293 /*************************************************************************
294  * Jumbo Frame Page Registers
295  *************************************************************************/
296
297 /* Jumbo Enable Port Mask (bit i == port i enabled) (32 bit) */
298 #define B53_JUMBO_PORT_MASK             0x01
299 #define B53_JUMBO_PORT_MASK_63XX        0x04
300 #define   JPM_10_100_JUMBO_EN           BIT(24) /* GigE always enabled */
301
302 /* Good Frame Max Size without 802.1Q TAG (16 bit) */
303 #define B53_JUMBO_MAX_SIZE              0x05
304 #define B53_JUMBO_MAX_SIZE_63XX         0x08
305 #define   JMS_MIN_SIZE                  1518
306 #define   JMS_MAX_SIZE                  9724
307
308 #endif /* !__B53_REGS_H */