bcm_sf2_regs.h 12 KB

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