xref: /openbmc/linux/drivers/net/dsa/bcm_sf2_regs.h (revision 4f6cce39)
1 /*
2  * Broadcom Starfighter 2 switch register defines
3  *
4  * Copyright (C) 2014, Broadcom Corporation
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  */
11 #ifndef __BCM_SF2_REGS_H
12 #define __BCM_SF2_REGS_H
13 
14 /* Register set relative to 'REG' */
15 
16 enum bcm_sf2_reg_offs {
17 	REG_SWITCH_CNTRL = 0,
18 	REG_SWITCH_STATUS,
19 	REG_DIR_DATA_WRITE,
20 	REG_DIR_DATA_READ,
21 	REG_SWITCH_REVISION,
22 	REG_PHY_REVISION,
23 	REG_SPHY_CNTRL,
24 	REG_RGMII_0_CNTRL,
25 	REG_RGMII_1_CNTRL,
26 	REG_RGMII_2_CNTRL,
27 	REG_LED_0_CNTRL,
28 	REG_LED_1_CNTRL,
29 	REG_LED_2_CNTRL,
30 	REG_SWITCH_REG_MAX,
31 };
32 
33 /* Relative to REG_SWITCH_CNTRL */
34 #define  MDIO_MASTER_SEL		(1 << 0)
35 
36 /* Relative to REG_SWITCH_REVISION */
37 #define  SF2_REV_MASK			0xffff
38 #define  SWITCH_TOP_REV_SHIFT		16
39 #define  SWITCH_TOP_REV_MASK		0xffff
40 
41 /* Relative to REG_PHY_REVISION */
42 #define  PHY_REVISION_MASK		0xffff
43 
44 /* Relative to REG_SPHY_CNTRL */
45 #define  IDDQ_BIAS			(1 << 0)
46 #define  EXT_PWR_DOWN			(1 << 1)
47 #define  FORCE_DLL_EN			(1 << 2)
48 #define  IDDQ_GLOBAL_PWR		(1 << 3)
49 #define  CK25_DIS			(1 << 4)
50 #define  PHY_RESET			(1 << 5)
51 #define  PHY_PHYAD_SHIFT		8
52 #define  PHY_PHYAD_MASK			0x1F
53 
54 #define REG_RGMII_CNTRL_P(x)		(REG_RGMII_0_CNTRL + (x))
55 
56 /* Relative to REG_RGMII_CNTRL */
57 #define  RGMII_MODE_EN			(1 << 0)
58 #define  ID_MODE_DIS			(1 << 1)
59 #define  PORT_MODE_SHIFT		2
60 #define  INT_EPHY			(0 << PORT_MODE_SHIFT)
61 #define  INT_GPHY			(1 << PORT_MODE_SHIFT)
62 #define  EXT_EPHY			(2 << PORT_MODE_SHIFT)
63 #define  EXT_GPHY			(3 << PORT_MODE_SHIFT)
64 #define  EXT_REVMII			(4 << PORT_MODE_SHIFT)
65 #define  PORT_MODE_MASK			0x7
66 #define  RVMII_REF_SEL			(1 << 5)
67 #define  RX_PAUSE_EN			(1 << 6)
68 #define  TX_PAUSE_EN			(1 << 7)
69 #define  TX_CLK_STOP_EN			(1 << 8)
70 #define  LPI_COUNT_SHIFT		9
71 #define  LPI_COUNT_MASK			0x3F
72 
73 #define REG_LED_CNTRL(x)		(REG_LED_0_CNTRL + (x))
74 
75 #define  SPDLNK_SRC_SEL			(1 << 24)
76 
77 /* Register set relative to 'INTRL2_0' and 'INTRL2_1' */
78 #define INTRL2_CPU_STATUS		0x00
79 #define INTRL2_CPU_SET			0x04
80 #define INTRL2_CPU_CLEAR		0x08
81 #define INTRL2_CPU_MASK_STATUS		0x0c
82 #define INTRL2_CPU_MASK_SET		0x10
83 #define INTRL2_CPU_MASK_CLEAR		0x14
84 
85 /* Shared INTRL2_0 and INTRL2_ interrupt sources macros */
86 #define P_LINK_UP_IRQ(x)		(1 << (0 + (x)))
87 #define P_LINK_DOWN_IRQ(x)		(1 << (1 + (x)))
88 #define P_ENERGY_ON_IRQ(x)		(1 << (2 + (x)))
89 #define P_ENERGY_OFF_IRQ(x)		(1 << (3 + (x)))
90 #define P_GPHY_IRQ(x)			(1 << (4 + (x)))
91 #define P_NUM_IRQ			5
92 #define P_IRQ_MASK(x)			(P_LINK_UP_IRQ((x)) | \
93 					 P_LINK_DOWN_IRQ((x)) | \
94 					 P_ENERGY_ON_IRQ((x)) | \
95 					 P_ENERGY_OFF_IRQ((x)) | \
96 					 P_GPHY_IRQ((x)))
97 
98 /* INTRL2_0 interrupt sources */
99 #define P0_IRQ_OFF			0
100 #define MEM_DOUBLE_IRQ			(1 << 5)
101 #define EEE_LPI_IRQ			(1 << 6)
102 #define P5_CPU_WAKE_IRQ			(1 << 7)
103 #define P8_CPU_WAKE_IRQ			(1 << 8)
104 #define P7_CPU_WAKE_IRQ			(1 << 9)
105 #define IEEE1588_IRQ			(1 << 10)
106 #define MDIO_ERR_IRQ			(1 << 11)
107 #define MDIO_DONE_IRQ			(1 << 12)
108 #define GISB_ERR_IRQ			(1 << 13)
109 #define UBUS_ERR_IRQ			(1 << 14)
110 #define FAILOVER_ON_IRQ			(1 << 15)
111 #define FAILOVER_OFF_IRQ		(1 << 16)
112 #define TCAM_SOFT_ERR_IRQ		(1 << 17)
113 
114 /* INTRL2_1 interrupt sources */
115 #define P7_IRQ_OFF			0
116 #define P_IRQ_OFF(x)			((6 - (x)) * P_NUM_IRQ)
117 
118 /* Register set relative to 'CORE' */
119 #define CORE_G_PCTL_PORT0		0x00000
120 #define CORE_G_PCTL_PORT(x)		(CORE_G_PCTL_PORT0 + (x * 0x4))
121 #define CORE_IMP_CTL			0x00020
122 #define  RX_DIS				(1 << 0)
123 #define  TX_DIS				(1 << 1)
124 #define  RX_BCST_EN			(1 << 2)
125 #define  RX_MCST_EN			(1 << 3)
126 #define  RX_UCST_EN			(1 << 4)
127 
128 #define CORE_SWMODE			0x0002c
129 #define  SW_FWDG_MODE			(1 << 0)
130 #define  SW_FWDG_EN			(1 << 1)
131 #define  RTRY_LMT_DIS			(1 << 2)
132 
133 #define CORE_STS_OVERRIDE_IMP		0x00038
134 #define  GMII_SPEED_UP_2G		(1 << 6)
135 #define  MII_SW_OR			(1 << 7)
136 
137 /* Alternate layout for e.g: 7278 */
138 #define CORE_STS_OVERRIDE_IMP2		0x39040
139 
140 #define CORE_NEW_CTRL			0x00084
141 #define  IP_MC				(1 << 0)
142 #define  OUTRANGEERR_DISCARD		(1 << 1)
143 #define  INRANGEERR_DISCARD		(1 << 2)
144 #define  CABLE_DIAG_LEN			(1 << 3)
145 #define  OVERRIDE_AUTO_PD_WAR		(1 << 4)
146 #define  EN_AUTO_PD_WAR			(1 << 5)
147 #define  UC_FWD_EN			(1 << 6)
148 #define  MC_FWD_EN			(1 << 7)
149 
150 #define CORE_SWITCH_CTRL		0x00088
151 #define  MII_DUMB_FWDG_EN		(1 << 6)
152 
153 #define CORE_SFT_LRN_CTRL		0x000f8
154 #define  SW_LEARN_CNTL(x)		(1 << (x))
155 
156 #define CORE_STS_OVERRIDE_GMIIP_PORT(x)	(0x160 + (x) * 4)
157 #define CORE_STS_OVERRIDE_GMIIP2_PORT(x) (0x39000 + (x) * 8)
158 #define  LINK_STS			(1 << 0)
159 #define  DUPLX_MODE			(1 << 1)
160 #define  SPEED_SHIFT			2
161 #define  SPEED_MASK			0x3
162 #define  RXFLOW_CNTL			(1 << 4)
163 #define  TXFLOW_CNTL			(1 << 5)
164 #define  SW_OVERRIDE			(1 << 6)
165 
166 #define CORE_WATCHDOG_CTRL		0x001e4
167 #define  SOFTWARE_RESET			(1 << 7)
168 #define  EN_CHIP_RST			(1 << 6)
169 #define  EN_SW_RESET			(1 << 4)
170 
171 #define CORE_FAST_AGE_CTRL		0x00220
172 #define  EN_FAST_AGE_STATIC		(1 << 0)
173 #define  EN_AGE_DYNAMIC			(1 << 1)
174 #define  EN_AGE_PORT			(1 << 2)
175 #define  EN_AGE_VLAN			(1 << 3)
176 #define  EN_AGE_SPT			(1 << 4)
177 #define  EN_AGE_MCAST			(1 << 5)
178 #define  FAST_AGE_STR_DONE		(1 << 7)
179 
180 #define CORE_FAST_AGE_PORT		0x00224
181 #define  AGE_PORT_MASK			0xf
182 
183 #define CORE_FAST_AGE_VID		0x00228
184 #define  AGE_VID_MASK			0x3fff
185 
186 #define CORE_LNKSTS			0x00400
187 #define  LNK_STS_MASK			0x1ff
188 
189 #define CORE_SPDSTS			0x00410
190 #define  SPDSTS_10			0
191 #define  SPDSTS_100			1
192 #define  SPDSTS_1000			2
193 #define  SPDSTS_SHIFT			2
194 #define  SPDSTS_MASK			0x3
195 
196 #define CORE_DUPSTS			0x00420
197 #define  CORE_DUPSTS_MASK		0x1ff
198 
199 #define CORE_PAUSESTS			0x00428
200 #define  PAUSESTS_TX_PAUSE_SHIFT	9
201 
202 #define CORE_GMNCFGCFG			0x0800
203 #define  RST_MIB_CNT			(1 << 0)
204 #define  RXBPDU_EN			(1 << 1)
205 
206 #define CORE_IMP0_PRT_ID		0x0804
207 
208 #define CORE_BRCM_HDR_CTRL		0x0080c
209 #define  BRCM_HDR_EN_P8			(1 << 0)
210 #define  BRCM_HDR_EN_P5			(1 << 1)
211 #define  BRCM_HDR_EN_P7			(1 << 2)
212 
213 #define CORE_RST_MIB_CNT_EN		0x0950
214 
215 #define CORE_BRCM_HDR_RX_DIS		0x0980
216 #define CORE_BRCM_HDR_TX_DIS		0x0988
217 
218 #define CORE_ARLA_VTBL_RWCTRL		0x1600
219 #define  ARLA_VTBL_CMD_WRITE		0
220 #define  ARLA_VTBL_CMD_READ		1
221 #define  ARLA_VTBL_CMD_CLEAR		2
222 #define  ARLA_VTBL_STDN			(1 << 7)
223 
224 #define CORE_ARLA_VTBL_ADDR		0x1604
225 #define  VTBL_ADDR_INDEX_MASK		0xfff
226 
227 #define CORE_ARLA_VTBL_ENTRY		0x160c
228 #define  FWD_MAP_MASK			0x1ff
229 #define  UNTAG_MAP_MASK			0x1ff
230 #define  UNTAG_MAP_SHIFT		9
231 #define  MSTP_INDEX_MASK		0x7
232 #define  MSTP_INDEX_SHIFT		18
233 #define  FWD_MODE			(1 << 21)
234 
235 #define CORE_MEM_PSM_VDD_CTRL		0x2380
236 #define  P_TXQ_PSM_VDD_SHIFT		2
237 #define  P_TXQ_PSM_VDD_MASK		0x3
238 #define  P_TXQ_PSM_VDD(x)		(P_TXQ_PSM_VDD_MASK << \
239 					((x) * P_TXQ_PSM_VDD_SHIFT))
240 
241 #define CORE_PORT_TC2_QOS_MAP_PORT(x)	(0xc1c0 + ((x) * 0x10))
242 #define  PRT_TO_QID_MASK		0x3
243 #define  PRT_TO_QID_SHIFT		3
244 
245 #define CORE_PORT_VLAN_CTL_PORT(x)	(0xc400 + ((x) * 0x8))
246 #define  PORT_VLAN_CTRL_MASK		0x1ff
247 
248 #define CORE_DEFAULT_1Q_TAG_P(x)	(0xd040 + ((x) * 8))
249 #define  CFI_SHIFT			12
250 #define  PRI_SHIFT			13
251 #define  PRI_MASK			0x7
252 
253 #define CORE_JOIN_ALL_VLAN_EN		0xd140
254 
255 #define CORE_EEE_EN_CTRL		0x24800
256 #define CORE_EEE_LPI_INDICATE		0x24810
257 
258 #define CORE_CFP_ACC			0x28000
259 #define  OP_STR_DONE			(1 << 0)
260 #define  OP_SEL_SHIFT			1
261 #define  OP_SEL_READ			(1 << OP_SEL_SHIFT)
262 #define  OP_SEL_WRITE			(2 << OP_SEL_SHIFT)
263 #define  OP_SEL_SEARCH			(4 << OP_SEL_SHIFT)
264 #define  OP_SEL_MASK			(7 << OP_SEL_SHIFT)
265 #define  CFP_RAM_CLEAR			(1 << 4)
266 #define  RAM_SEL_SHIFT			10
267 #define  TCAM_SEL			(1 << RAM_SEL_SHIFT)
268 #define  ACT_POL_RAM			(2 << RAM_SEL_SHIFT)
269 #define  RATE_METER_RAM			(4 << RAM_SEL_SHIFT)
270 #define  GREEN_STAT_RAM			(8 << RAM_SEL_SHIFT)
271 #define  YELLOW_STAT_RAM		(16 << RAM_SEL_SHIFT)
272 #define  RED_STAT_RAM			(24 << RAM_SEL_SHIFT)
273 #define  RAM_SEL_MASK			(0x1f << RAM_SEL_SHIFT)
274 #define  TCAM_RESET			(1 << 15)
275 #define  XCESS_ADDR_SHIFT		16
276 #define  XCESS_ADDR_MASK		0xff
277 #define  SEARCH_STS			(1 << 27)
278 #define  RD_STS_SHIFT			28
279 #define  RD_STS_TCAM			(1 << RD_STS_SHIFT)
280 #define  RD_STS_ACT_POL_RAM		(2 << RD_STS_SHIFT)
281 #define  RD_STS_RATE_METER_RAM		(4 << RD_STS_SHIFT)
282 #define  RD_STS_STAT_RAM		(8 << RD_STS_SHIFT)
283 
284 #define CORE_CFP_RATE_METER_GLOBAL_CTL	0x28010
285 
286 #define CORE_CFP_DATA_PORT_0		0x28040
287 #define CORE_CFP_DATA_PORT(x)		(CORE_CFP_DATA_PORT_0 + \
288 					(x) * 0x10)
289 
290 /* UDF_DATA7 */
291 #define L3_FRAMING_SHIFT		24
292 #define L3_FRAMING_MASK			(0x3 << L3_FRAMING_SHIFT)
293 #define IPPROTO_SHIFT			8
294 #define IPPROTO_MASK			(0xff << IPPROTO_SHIFT)
295 #define IP_FRAG				(1 << 7)
296 
297 /* UDF_DATA0 */
298 #define  SLICE_VALID			3
299 #define  SLICE_NUM_SHIFT		2
300 #define  SLICE_NUM(x)			((x) << SLICE_NUM_SHIFT)
301 
302 #define CORE_CFP_MASK_PORT_0		0x280c0
303 
304 #define CORE_CFP_MASK_PORT(x)		(CORE_CFP_MASK_PORT_0 + \
305 					(x) * 0x10)
306 
307 #define CORE_ACT_POL_DATA0		0x28140
308 #define  VLAN_BYP			(1 << 0)
309 #define  EAP_BYP			(1 << 1)
310 #define  STP_BYP			(1 << 2)
311 #define  REASON_CODE_SHIFT		3
312 #define  REASON_CODE_MASK		0x3f
313 #define  LOOP_BK_EN			(1 << 9)
314 #define  NEW_TC_SHIFT			10
315 #define  NEW_TC_MASK			0x7
316 #define  CHANGE_TC			(1 << 13)
317 #define  DST_MAP_IB_SHIFT		14
318 #define  DST_MAP_IB_MASK		0x1ff
319 #define  CHANGE_FWRD_MAP_IB_SHIFT	24
320 #define  CHANGE_FWRD_MAP_IB_MASK	0x3
321 #define  CHANGE_FWRD_MAP_IB_NO_DEST	(0 << CHANGE_FWRD_MAP_IB_SHIFT)
322 #define  CHANGE_FWRD_MAP_IB_REM_ARL	(1 << CHANGE_FWRD_MAP_IB_SHIFT)
323 #define  CHANGE_FWRD_MAP_IB_REP_ARL	(2 << CHANGE_FWRD_MAP_IB_SHIFT)
324 #define  CHANGE_FWRD_MAP_IB_ADD_DST	(3 << CHANGE_FWRD_MAP_IB_SHIFT)
325 #define  NEW_DSCP_IB_SHIFT		26
326 #define  NEW_DSCP_IB_MASK		0x3f
327 
328 #define CORE_ACT_POL_DATA1		0x28150
329 #define  CHANGE_DSCP_IB			(1 << 0)
330 #define  DST_MAP_OB_SHIFT		1
331 #define  DST_MAP_OB_MASK		0x3ff
332 #define  CHANGE_FWRD_MAP_OB_SHIT	11
333 #define  CHANGE_FWRD_MAP_OB_MASK	0x3
334 #define  NEW_DSCP_OB_SHIFT		13
335 #define  NEW_DSCP_OB_MASK		0x3f
336 #define  CHANGE_DSCP_OB			(1 << 19)
337 #define  CHAIN_ID_SHIFT			20
338 #define  CHAIN_ID_MASK			0xff
339 #define  CHANGE_COLOR			(1 << 28)
340 #define  NEW_COLOR_SHIFT		29
341 #define  NEW_COLOR_MASK			0x3
342 #define  NEW_COLOR_GREEN		(0 << NEW_COLOR_SHIFT)
343 #define  NEW_COLOR_YELLOW		(1 << NEW_COLOR_SHIFT)
344 #define  NEW_COLOR_RED			(2 << NEW_COLOR_SHIFT)
345 #define  RED_DEFAULT			(1 << 31)
346 
347 #define CORE_ACT_POL_DATA2		0x28160
348 #define  MAC_LIMIT_BYPASS		(1 << 0)
349 #define  CHANGE_TC_O			(1 << 1)
350 #define  NEW_TC_O_SHIFT			2
351 #define  NEW_TC_O_MASK			0x7
352 #define  SPCP_RMK_DISABLE		(1 << 5)
353 #define  CPCP_RMK_DISABLE		(1 << 6)
354 #define  DEI_RMK_DISABLE		(1 << 7)
355 
356 #define CORE_RATE_METER0		0x28180
357 #define  COLOR_MODE			(1 << 0)
358 #define  POLICER_ACTION			(1 << 1)
359 #define  COUPLING_FLAG			(1 << 2)
360 #define  POLICER_MODE_SHIFT		3
361 #define  POLICER_MODE_MASK		0x3
362 #define  POLICER_MODE_RFC2698		(0 << POLICER_MODE_SHIFT)
363 #define  POLICER_MODE_RFC4115		(1 << POLICER_MODE_SHIFT)
364 #define  POLICER_MODE_MEF		(2 << POLICER_MODE_SHIFT)
365 #define  POLICER_MODE_DISABLE		(3 << POLICER_MODE_SHIFT)
366 
367 #define CORE_RATE_METER1		0x28190
368 #define  EIR_TK_BKT_MASK		0x7fffff
369 
370 #define CORE_RATE_METER2		0x281a0
371 #define  EIR_BKT_SIZE_MASK		0xfffff
372 
373 #define CORE_RATE_METER3		0x281b0
374 #define  EIR_REF_CNT_MASK		0x7ffff
375 
376 #define CORE_RATE_METER4		0x281c0
377 #define  CIR_TK_BKT_MASK		0x7fffff
378 
379 #define CORE_RATE_METER5		0x281d0
380 #define  CIR_BKT_SIZE_MASK		0xfffff
381 
382 #define CORE_RATE_METER6		0x281e0
383 #define  CIR_REF_CNT_MASK		0x7ffff
384 
385 #define CORE_CFP_CTL_REG		0x28400
386 #define  CFP_EN_MAP_MASK		0x1ff
387 
388 /* IPv4 slices, 3 of them */
389 #define CORE_UDF_0_A_0_8_PORT_0		0x28440
390 #define  CFG_UDF_OFFSET_MASK		0x1f
391 #define  CFG_UDF_OFFSET_BASE_SHIFT	5
392 #define  CFG_UDF_SOF			(0 << CFG_UDF_OFFSET_BASE_SHIFT)
393 #define  CFG_UDF_EOL2			(2 << CFG_UDF_OFFSET_BASE_SHIFT)
394 #define  CFG_UDF_EOL3			(3 << CFG_UDF_OFFSET_BASE_SHIFT)
395 
396 /* Number of slices for IPv4, IPv6 and non-IP */
397 #define UDF_NUM_SLICES			9
398 
399 /* Spacing between different slices */
400 #define UDF_SLICE_OFFSET		0x40
401 
402 #define CFP_NUM_RULES			256
403 
404 #endif /* __BCM_SF2_REGS_H */
405