2 * B53 register definitions
4 * Copyright (C) 2004 Broadcom Corporation
5 * Copyright (C) 2011-2013 Jonas Gorski <jogo@openwrt.org>
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.
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.
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 */
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) */
39 #define B53_MIB_PAGE(i) (0x20 + (i))
41 /* Quality of Service (QoS) Registers */
42 #define B53_QOS_PAGE 0x30
45 #define B53_PVLAN_PAGE 0x31
48 #define B53_VLAN_PAGE 0x34
50 /* Jumbo Frame Registers */
51 #define B53_JUMBO_PAGE 0x40
53 /* CFP Configuration Registers Page */
54 #define B53_CFP_PAGE 0xa1
56 /*************************************************************************
57 * Control Page registers
58 *************************************************************************/
60 /* Port Control Register (8 bit) */
61 #define B53_PORT_CTRL(i) (0x00 + (i))
62 #define PORT_CTRL_RX_DISABLE BIT(0)
63 #define PORT_CTRL_TX_DISABLE BIT(1)
64 #define PORT_CTRL_RX_BCST_EN BIT(2) /* Broadcast RX (P8 only) */
65 #define PORT_CTRL_RX_MCST_EN BIT(3) /* Multicast RX (P8 only) */
66 #define PORT_CTRL_RX_UCST_EN BIT(4) /* Unicast RX (P8 only) */
67 #define PORT_CTRL_STP_STATE_S 5
68 #define PORT_CTRL_NO_STP (0 << PORT_CTRL_STP_STATE_S)
69 #define PORT_CTRL_DIS_STATE (1 << PORT_CTRL_STP_STATE_S)
70 #define PORT_CTRL_BLOCK_STATE (2 << PORT_CTRL_STP_STATE_S)
71 #define PORT_CTRL_LISTEN_STATE (3 << PORT_CTRL_STP_STATE_S)
72 #define PORT_CTRL_LEARN_STATE (4 << PORT_CTRL_STP_STATE_S)
73 #define PORT_CTRL_FWD_STATE (5 << PORT_CTRL_STP_STATE_S)
74 #define PORT_CTRL_STP_STATE_MASK (0x7 << PORT_CTRL_STP_STATE_S)
76 /* SMP Control Register (8 bit) */
77 #define B53_SMP_CTRL 0x0a
79 /* Switch Mode Control Register (8 bit) */
80 #define B53_SWITCH_MODE 0x0b
81 #define SM_SW_FWD_MODE BIT(0) /* 1 = Managed Mode */
82 #define SM_SW_FWD_EN BIT(1) /* Forwarding Enable */
84 /* IMP Port state override register (8 bit) */
85 #define B53_PORT_OVERRIDE_CTRL 0x0e
86 #define PORT_OVERRIDE_LINK BIT(0)
87 #define PORT_OVERRIDE_FULL_DUPLEX BIT(1) /* 0 = Half Duplex */
88 #define PORT_OVERRIDE_SPEED_S 2
89 #define PORT_OVERRIDE_SPEED_10M (0 << PORT_OVERRIDE_SPEED_S)
90 #define PORT_OVERRIDE_SPEED_100M (1 << PORT_OVERRIDE_SPEED_S)
91 #define PORT_OVERRIDE_SPEED_1000M (2 << PORT_OVERRIDE_SPEED_S)
92 #define PORT_OVERRIDE_RV_MII_25 BIT(4) /* BCM5325 only */
93 #define PORT_OVERRIDE_RX_FLOW BIT(4)
94 #define PORT_OVERRIDE_TX_FLOW BIT(5)
95 #define PORT_OVERRIDE_SPEED_2000M BIT(6) /* BCM5301X only, requires setting 1000M */
96 #define PORT_OVERRIDE_EN BIT(7) /* Use the register contents */
98 /* Power-down mode control */
99 #define B53_PD_MODE_CTRL_25 0x0f
101 /* IP Multicast control (8 bit) */
102 #define B53_IP_MULTICAST_CTRL 0x21
103 #define B53_IPMC_FWD_EN BIT(1)
104 #define B53_UC_FWD_EN BIT(6)
105 #define B53_MC_FWD_EN BIT(7)
107 /* Switch control (8 bit) */
108 #define B53_SWITCH_CTRL 0x22
109 #define B53_MII_DUMB_FWDG_EN BIT(6)
112 #define B53_UC_FLOOD_MASK 0x32
113 #define B53_MC_FLOOD_MASK 0x34
114 #define B53_IPMC_FLOOD_MASK 0x36
115 #define B53_DIS_LEARNING 0x3c
118 * Override Ports 0-7 State on devices with xMII interfaces (8 bit)
120 * For port 8 still use B53_PORT_OVERRIDE_CTRL
121 * Please note that not all ports are available on every hardware, e.g. BCM5301X
122 * don't include overriding port 6, BCM63xx also have some limitations.
124 #define B53_GMII_PORT_OVERRIDE_CTRL(i) (0x58 + (i))
125 #define GMII_PO_LINK BIT(0)
126 #define GMII_PO_FULL_DUPLEX BIT(1) /* 0 = Half Duplex */
127 #define GMII_PO_SPEED_S 2
128 #define GMII_PO_SPEED_10M (0 << GMII_PO_SPEED_S)
129 #define GMII_PO_SPEED_100M (1 << GMII_PO_SPEED_S)
130 #define GMII_PO_SPEED_1000M (2 << GMII_PO_SPEED_S)
131 #define GMII_PO_RX_FLOW BIT(4)
132 #define GMII_PO_TX_FLOW BIT(5)
133 #define GMII_PO_EN BIT(6) /* Use the register contents */
134 #define GMII_PO_SPEED_2000M BIT(7) /* BCM5301X only, requires setting 1000M */
136 #define B53_RGMII_CTRL_IMP 0x60
137 #define RGMII_CTRL_ENABLE_GMII BIT(7)
138 #define RGMII_CTRL_TIMING_SEL BIT(2)
139 #define RGMII_CTRL_DLL_RXC BIT(1)
140 #define RGMII_CTRL_DLL_TXC BIT(0)
142 #define B53_RGMII_CTRL_P(i) (B53_RGMII_CTRL_IMP + (i))
144 /* Software reset register (8 bit) */
145 #define B53_SOFTRESET 0x79
146 #define SW_RST BIT(7)
147 #define EN_SW_RST BIT(4)
149 /* Fast Aging Control register (8 bit) */
150 #define B53_FAST_AGE_CTRL 0x88
151 #define FAST_AGE_STATIC BIT(0)
152 #define FAST_AGE_DYNAMIC BIT(1)
153 #define FAST_AGE_PORT BIT(2)
154 #define FAST_AGE_VLAN BIT(3)
155 #define FAST_AGE_STP BIT(4)
156 #define FAST_AGE_MC BIT(5)
157 #define FAST_AGE_DONE BIT(7)
159 /* Fast Aging Port Control register (8 bit) */
160 #define B53_FAST_AGE_PORT_CTRL 0x89
162 /* Fast Aging VID Control register (16 bit) */
163 #define B53_FAST_AGE_VID_CTRL 0x8a
165 /*************************************************************************
166 * Status Page registers
167 *************************************************************************/
169 /* Link Status Summary Register (16bit) */
170 #define B53_LINK_STAT 0x00
172 /* Link Status Change Register (16 bit) */
173 #define B53_LINK_STAT_CHANGE 0x02
175 /* Port Speed Summary Register (16 bit for FE, 32 bit for GE) */
176 #define B53_SPEED_STAT 0x04
177 #define SPEED_PORT_FE(reg, port) (((reg) >> (port)) & 1)
178 #define SPEED_PORT_GE(reg, port) (((reg) >> 2 * (port)) & 3)
179 #define SPEED_STAT_10M 0
180 #define SPEED_STAT_100M 1
181 #define SPEED_STAT_1000M 2
183 /* Duplex Status Summary (16 bit) */
184 #define B53_DUPLEX_STAT_FE 0x06
185 #define B53_DUPLEX_STAT_GE 0x08
186 #define B53_DUPLEX_STAT_63XX 0x0c
188 /* Revision ID register for BCM5325 */
189 #define B53_REV_ID_25 0x50
191 /* Strap Value (48 bit) */
192 #define B53_STRAP_VALUE 0x70
193 #define SV_GMII_CTRL_115 BIT(27)
195 /*************************************************************************
196 * Management Mode Page Registers
197 *************************************************************************/
199 /* Global Management Config Register (8 bit) */
200 #define B53_GLOBAL_CONFIG 0x00
201 #define GC_RESET_MIB 0x01
202 #define GC_RX_BPDU_EN 0x02
203 #define GC_MIB_AC_HDR_EN 0x10
204 #define GC_MIB_AC_EN 0x20
205 #define GC_FRM_MGMT_PORT_M 0xC0
206 #define GC_FRM_MGMT_PORT_04 0x00
207 #define GC_FRM_MGMT_PORT_MII 0x80
209 /* Broadcom Header control register (8 bit) */
210 #define B53_BRCM_HDR 0x03
211 #define BRCM_HDR_P8_EN BIT(0) /* Enable tagging on port 8 */
212 #define BRCM_HDR_P5_EN BIT(1) /* Enable tagging on port 5 */
214 /* Device ID register (8 or 32 bit) */
215 #define B53_DEVICE_ID 0x30
217 /* Revision ID register (8 bit) */
218 #define B53_REV_ID 0x40
220 /*************************************************************************
221 * ARL Access Page Registers
222 *************************************************************************/
224 /* VLAN Table Access Register (8 bit) */
225 #define B53_VT_ACCESS 0x80
226 #define B53_VT_ACCESS_9798 0x60 /* for BCM5397/BCM5398 */
227 #define B53_VT_ACCESS_63XX 0x60 /* for BCM6328/62/68 */
228 #define VTA_CMD_WRITE 0
229 #define VTA_CMD_READ 1
230 #define VTA_CMD_CLEAR 2
231 #define VTA_START_CMD BIT(7)
233 /* VLAN Table Index Register (16 bit) */
234 #define B53_VT_INDEX 0x81
235 #define B53_VT_INDEX_9798 0x61
236 #define B53_VT_INDEX_63XX 0x62
238 /* VLAN Table Entry Register (32 bit) */
239 #define B53_VT_ENTRY 0x83
240 #define B53_VT_ENTRY_9798 0x63
241 #define B53_VT_ENTRY_63XX 0x64
242 #define VTE_MEMBERS 0x1ff
243 #define VTE_UNTAG_S 9
244 #define VTE_UNTAG (0x1ff << 9)
246 /*************************************************************************
248 *************************************************************************/
250 /* ARL Table Read/Write Register (8 bit) */
251 #define B53_ARLTBL_RW_CTRL 0x00
252 #define ARLTBL_RW BIT(0)
253 #define ARLTBL_START_DONE BIT(7)
255 /* MAC Address Index Register (48 bit) */
256 #define B53_MAC_ADDR_IDX 0x02
258 /* VLAN ID Index Register (16 bit) */
259 #define B53_VLAN_ID_IDX 0x08
261 /* ARL Table MAC/VID Entry N Registers (64 bit)
263 * BCM5325 and BCM5365 share most definitions below
265 #define B53_ARLTBL_MAC_VID_ENTRY(n) ((0x10 * (n)) + 0x10)
266 #define ARLTBL_MAC_MASK 0xffffffffffffULL
267 #define ARLTBL_VID_S 48
268 #define ARLTBL_VID_MASK_25 0xff
269 #define ARLTBL_VID_MASK 0xfff
270 #define ARLTBL_DATA_PORT_ID_S_25 48
271 #define ARLTBL_DATA_PORT_ID_MASK_25 0xf
272 #define ARLTBL_AGE_25 BIT(61)
273 #define ARLTBL_STATIC_25 BIT(62)
274 #define ARLTBL_VALID_25 BIT(63)
276 /* ARL Table Data Entry N Registers (32 bit) */
277 #define B53_ARLTBL_DATA_ENTRY(n) ((0x10 * (n)) + 0x18)
278 #define ARLTBL_DATA_PORT_ID_MASK 0x1ff
279 #define ARLTBL_TC(tc) ((3 & tc) << 11)
280 #define ARLTBL_AGE BIT(14)
281 #define ARLTBL_STATIC BIT(15)
282 #define ARLTBL_VALID BIT(16)
284 /* Maximum number of bin entries in the ARL for all switches */
285 #define B53_ARLTBL_MAX_BIN_ENTRIES 4
287 /* ARL Search Control Register (8 bit) */
288 #define B53_ARL_SRCH_CTL 0x50
289 #define B53_ARL_SRCH_CTL_25 0x20
290 #define ARL_SRCH_VLID BIT(0)
291 #define ARL_SRCH_STDN BIT(7)
293 /* ARL Search Address Register (16 bit) */
294 #define B53_ARL_SRCH_ADDR 0x51
295 #define B53_ARL_SRCH_ADDR_25 0x22
296 #define B53_ARL_SRCH_ADDR_65 0x24
297 #define ARL_ADDR_MASK GENMASK(14, 0)
299 /* ARL Search MAC/VID Result (64 bit) */
300 #define B53_ARL_SRCH_RSTL_0_MACVID 0x60
302 /* Single register search result on 5325 */
303 #define B53_ARL_SRCH_RSTL_0_MACVID_25 0x24
304 /* Single register search result on 5365 */
305 #define B53_ARL_SRCH_RSTL_0_MACVID_65 0x30
307 /* ARL Search Data Result (32 bit) */
308 #define B53_ARL_SRCH_RSTL_0 0x68
310 #define B53_ARL_SRCH_RSTL_MACVID(x) (B53_ARL_SRCH_RSTL_0_MACVID + ((x) * 0x10))
311 #define B53_ARL_SRCH_RSTL(x) (B53_ARL_SRCH_RSTL_0 + ((x) * 0x10))
313 /*************************************************************************
314 * Port VLAN Registers
315 *************************************************************************/
317 /* Port VLAN mask (16 bit) IMP port is always 8, also on 5325 & co */
318 #define B53_PVLAN_PORT_MASK(i) ((i) * 2)
320 /* Join all VLANs register (16 bit) */
321 #define B53_JOIN_ALL_VLAN_EN 0x50
323 /*************************************************************************
324 * 802.1Q Page Registers
325 *************************************************************************/
327 /* Global QoS Control (8 bit) */
328 #define B53_QOS_GLOBAL_CTL 0x00
330 /* Enable 802.1Q for individual Ports (16 bit) */
331 #define B53_802_1P_EN 0x04
333 /*************************************************************************
334 * VLAN Page Registers
335 *************************************************************************/
337 /* VLAN Control 0 (8 bit) */
338 #define B53_VLAN_CTRL0 0x00
339 #define VC0_8021PF_CTRL_MASK 0x3
340 #define VC0_8021PF_CTRL_NONE 0x0
341 #define VC0_8021PF_CTRL_CHANGE_PRI 0x1
342 #define VC0_8021PF_CTRL_CHANGE_VID 0x2
343 #define VC0_8021PF_CTRL_CHANGE_BOTH 0x3
344 #define VC0_8021QF_CTRL_MASK 0xc
345 #define VC0_8021QF_CTRL_CHANGE_PRI 0x1
346 #define VC0_8021QF_CTRL_CHANGE_VID 0x2
347 #define VC0_8021QF_CTRL_CHANGE_BOTH 0x3
348 #define VC0_RESERVED_1 BIT(1)
349 #define VC0_DROP_VID_MISS BIT(4)
350 #define VC0_VID_HASH_VID BIT(5)
351 #define VC0_VID_CHK_EN BIT(6) /* Use VID,DA or VID,SA */
352 #define VC0_VLAN_EN BIT(7) /* 802.1Q VLAN Enabled */
354 /* VLAN Control 1 (8 bit) */
355 #define B53_VLAN_CTRL1 0x01
356 #define VC1_RX_MCST_TAG_EN BIT(1)
357 #define VC1_RX_MCST_FWD_EN BIT(2)
358 #define VC1_RX_MCST_UNTAG_EN BIT(3)
360 /* VLAN Control 2 (8 bit) */
361 #define B53_VLAN_CTRL2 0x02
363 /* VLAN Control 3 (8 bit when BCM5325, 16 bit else) */
364 #define B53_VLAN_CTRL3 0x03
365 #define B53_VLAN_CTRL3_63XX 0x04
366 #define VC3_MAXSIZE_1532 BIT(6) /* 5325 only */
367 #define VC3_HIGH_8BIT_EN BIT(7) /* 5325 only */
369 /* VLAN Control 4 (8 bit) */
370 #define B53_VLAN_CTRL4 0x05
371 #define B53_VLAN_CTRL4_25 0x04
372 #define B53_VLAN_CTRL4_63XX 0x06
373 #define VC4_ING_VID_CHECK_S 6
374 #define VC4_ING_VID_CHECK_MASK (0x3 << VC4_ING_VID_CHECK_S)
375 #define VC4_ING_VID_VIO_FWD 0 /* forward, but do not learn */
376 #define VC4_ING_VID_VIO_DROP 1 /* drop VID violations */
377 #define VC4_NO_ING_VID_CHK 2 /* do not check */
378 #define VC4_ING_VID_VIO_TO_IMP 3 /* redirect to MII port */
380 /* VLAN Control 5 (8 bit) */
381 #define B53_VLAN_CTRL5 0x06
382 #define B53_VLAN_CTRL5_25 0x05
383 #define B53_VLAN_CTRL5_63XX 0x07
384 #define VC5_VID_FFF_EN BIT(2)
385 #define VC5_DROP_VTABLE_MISS BIT(3)
387 /* VLAN Control 6 (8 bit) */
388 #define B53_VLAN_CTRL6 0x07
389 #define B53_VLAN_CTRL6_63XX 0x08
391 /* VLAN Table Access Register (16 bit) */
392 #define B53_VLAN_TABLE_ACCESS_25 0x06 /* BCM5325E/5350 */
393 #define B53_VLAN_TABLE_ACCESS_65 0x08 /* BCM5365 */
394 #define VTA_VID_LOW_MASK_25 0xf
395 #define VTA_VID_LOW_MASK_65 0xff
396 #define VTA_VID_HIGH_S_25 4
397 #define VTA_VID_HIGH_S_65 8
398 #define VTA_VID_HIGH_MASK_25 (0xff << VTA_VID_HIGH_S_25E)
399 #define VTA_VID_HIGH_MASK_65 (0xf << VTA_VID_HIGH_S_65)
400 #define VTA_RW_STATE BIT(12)
401 #define VTA_RW_STATE_RD 0
402 #define VTA_RW_STATE_WR BIT(12)
403 #define VTA_RW_OP_EN BIT(13)
405 /* VLAN Read/Write Registers for (16/32 bit) */
406 #define B53_VLAN_WRITE_25 0x08
407 #define B53_VLAN_WRITE_65 0x0a
408 #define B53_VLAN_READ 0x0c
409 #define VA_MEMBER_MASK 0x3f
410 #define VA_UNTAG_S_25 6
411 #define VA_UNTAG_MASK_25 0x3f
412 #define VA_UNTAG_S_65 7
413 #define VA_UNTAG_MASK_65 0x1f
414 #define VA_VID_HIGH_S 12
415 #define VA_VID_HIGH_MASK (0xffff << VA_VID_HIGH_S)
416 #define VA_VALID_25 BIT(20)
417 #define VA_VALID_25_R4 BIT(24)
418 #define VA_VALID_65 BIT(14)
420 /* VLAN Port Default Tag (16 bit) */
421 #define B53_VLAN_PORT_DEF_TAG(i) (0x10 + 2 * (i))
423 /*************************************************************************
424 * Jumbo Frame Page Registers
425 *************************************************************************/
427 /* Jumbo Enable Port Mask (bit i == port i enabled) (32 bit) */
428 #define B53_JUMBO_PORT_MASK 0x01
429 #define B53_JUMBO_PORT_MASK_63XX 0x04
430 #define JPM_10_100_JUMBO_EN BIT(24) /* GigE always enabled */
432 /* Good Frame Max Size without 802.1Q TAG (16 bit) */
433 #define B53_JUMBO_MAX_SIZE 0x05
434 #define B53_JUMBO_MAX_SIZE_63XX 0x08
435 #define JMS_MIN_SIZE 1518
436 #define JMS_MAX_SIZE 9724
438 /*************************************************************************
439 * CFP Configuration Page Registers
440 *************************************************************************/
442 /* CFP Control Register with ports map (8 bit) */
443 #define B53_CFP_CTRL 0x00
445 #endif /* !__B53_REGS_H */