b53_regs.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. #ifndef __B53_REGS_H
  20. #define __B53_REGS_H
  21. /* Management Port (SMP) Page offsets */
  22. #define B53_CTRL_PAGE 0x00 /* Control */
  23. #define B53_STAT_PAGE 0x01 /* Status */
  24. #define B53_MGMT_PAGE 0x02 /* Management Mode */
  25. #define B53_MIB_AC_PAGE 0x03 /* MIB Autocast */
  26. #define B53_ARLCTRL_PAGE 0x04 /* ARL Control */
  27. #define B53_ARLIO_PAGE 0x05 /* ARL Access */
  28. #define B53_FRAMEBUF_PAGE 0x06 /* Management frame access */
  29. #define B53_MEM_ACCESS_PAGE 0x08 /* Memory access */
  30. /* PHY Registers */
  31. #define B53_PORT_MII_PAGE(i) (0x10 + (i)) /* Port i MII Registers */
  32. #define B53_IM_PORT_PAGE 0x18 /* Inverse MII Port (to EMAC) */
  33. #define B53_ALL_PORT_PAGE 0x19 /* All ports MII (broadcast) */
  34. /* MIB registers */
  35. #define B53_MIB_PAGE(i) (0x20 + (i))
  36. /* Quality of Service (QoS) Registers */
  37. #define B53_QOS_PAGE 0x30
  38. /* Port VLAN Page */
  39. #define B53_PVLAN_PAGE 0x31
  40. /* VLAN Registers */
  41. #define B53_VLAN_PAGE 0x34
  42. /* Jumbo Frame Registers */
  43. #define B53_JUMBO_PAGE 0x40
  44. /* CFP Configuration Registers Page */
  45. #define B53_CFP_PAGE 0xa1
  46. /*************************************************************************
  47. * Control Page registers
  48. *************************************************************************/
  49. /* Port Control Register (8 bit) */
  50. #define B53_PORT_CTRL(i) (0x00 + (i))
  51. #define PORT_CTRL_RX_DISABLE BIT(0)
  52. #define PORT_CTRL_TX_DISABLE BIT(1)
  53. #define PORT_CTRL_RX_BCST_EN BIT(2) /* Broadcast RX (P8 only) */
  54. #define PORT_CTRL_RX_MCST_EN BIT(3) /* Multicast RX (P8 only) */
  55. #define PORT_CTRL_RX_UCST_EN BIT(4) /* Unicast RX (P8 only) */
  56. #define PORT_CTRL_STP_STATE_S 5
  57. #define PORT_CTRL_STP_STATE_MASK (0x7 << PORT_CTRL_STP_STATE_S)
  58. /* SMP Control Register (8 bit) */
  59. #define B53_SMP_CTRL 0x0a
  60. /* Switch Mode Control Register (8 bit) */
  61. #define B53_SWITCH_MODE 0x0b
  62. #define SM_SW_FWD_MODE BIT(0) /* 1 = Managed Mode */
  63. #define SM_SW_FWD_EN BIT(1) /* Forwarding Enable */
  64. /* IMP Port state override register (8 bit) */
  65. #define B53_PORT_OVERRIDE_CTRL 0x0e
  66. #define PORT_OVERRIDE_LINK BIT(0)
  67. #define PORT_OVERRIDE_FULL_DUPLEX BIT(1) /* 0 = Half Duplex */
  68. #define PORT_OVERRIDE_SPEED_S 2
  69. #define PORT_OVERRIDE_SPEED_10M (0 << PORT_OVERRIDE_SPEED_S)
  70. #define PORT_OVERRIDE_SPEED_100M (1 << PORT_OVERRIDE_SPEED_S)
  71. #define PORT_OVERRIDE_SPEED_1000M (2 << PORT_OVERRIDE_SPEED_S)
  72. #define PORT_OVERRIDE_RV_MII_25 BIT(4) /* BCM5325 only */
  73. #define PORT_OVERRIDE_RX_FLOW BIT(4)
  74. #define PORT_OVERRIDE_TX_FLOW BIT(5)
  75. #define PORT_OVERRIDE_SPEED_2000M BIT(6) /* BCM5301X only, requires setting 1000M */
  76. #define PORT_OVERRIDE_EN BIT(7) /* Use the register contents */
  77. /* Power-down mode control */
  78. #define B53_PD_MODE_CTRL_25 0x0f
  79. /* IP Multicast control (8 bit) */
  80. #define B53_IP_MULTICAST_CTRL 0x21
  81. #define B53_IPMC_FWD_EN BIT(1)
  82. #define B53_UC_FWD_EN BIT(6)
  83. #define B53_MC_FWD_EN BIT(7)
  84. /* (16 bit) */
  85. #define B53_UC_FLOOD_MASK 0x32
  86. #define B53_MC_FLOOD_MASK 0x34
  87. #define B53_IPMC_FLOOD_MASK 0x36
  88. /*
  89. * Override Ports 0-7 State on devices with xMII interfaces (8 bit)
  90. *
  91. * For port 8 still use B53_PORT_OVERRIDE_CTRL
  92. * Please note that not all ports are available on every hardware, e.g. BCM5301X
  93. * don't include overriding port 6, BCM63xx also have some limitations.
  94. */
  95. #define B53_GMII_PORT_OVERRIDE_CTRL(i) (0x58 + (i))
  96. #define GMII_PO_LINK BIT(0)
  97. #define GMII_PO_FULL_DUPLEX BIT(1) /* 0 = Half Duplex */
  98. #define GMII_PO_SPEED_S 2
  99. #define GMII_PO_SPEED_10M (0 << GMII_PO_SPEED_S)
  100. #define GMII_PO_SPEED_100M (1 << GMII_PO_SPEED_S)
  101. #define GMII_PO_SPEED_1000M (2 << GMII_PO_SPEED_S)
  102. #define GMII_PO_RX_FLOW BIT(4)
  103. #define GMII_PO_TX_FLOW BIT(5)
  104. #define GMII_PO_EN BIT(6) /* Use the register contents */
  105. #define GMII_PO_SPEED_2000M BIT(7) /* BCM5301X only, requires setting 1000M */
  106. /* Software reset register (8 bit) */
  107. #define B53_SOFTRESET 0x79
  108. /* Fast Aging Control register (8 bit) */
  109. #define B53_FAST_AGE_CTRL 0x88
  110. #define FAST_AGE_STATIC BIT(0)
  111. #define FAST_AGE_DYNAMIC BIT(1)
  112. #define FAST_AGE_PORT BIT(2)
  113. #define FAST_AGE_VLAN BIT(3)
  114. #define FAST_AGE_STP BIT(4)
  115. #define FAST_AGE_MC BIT(5)
  116. #define FAST_AGE_DONE BIT(7)
  117. /*************************************************************************
  118. * Status Page registers
  119. *************************************************************************/
  120. /* Link Status Summary Register (16bit) */
  121. #define B53_LINK_STAT 0x00
  122. /* Link Status Change Register (16 bit) */
  123. #define B53_LINK_STAT_CHANGE 0x02
  124. /* Port Speed Summary Register (16 bit for FE, 32 bit for GE) */
  125. #define B53_SPEED_STAT 0x04
  126. #define SPEED_PORT_FE(reg, port) (((reg) >> (port)) & 1)
  127. #define SPEED_PORT_GE(reg, port) (((reg) >> 2 * (port)) & 3)
  128. #define SPEED_STAT_10M 0
  129. #define SPEED_STAT_100M 1
  130. #define SPEED_STAT_1000M 2
  131. /* Duplex Status Summary (16 bit) */
  132. #define B53_DUPLEX_STAT_FE 0x06
  133. #define B53_DUPLEX_STAT_GE 0x08
  134. #define B53_DUPLEX_STAT_63XX 0x0c
  135. /* Revision ID register for BCM5325 */
  136. #define B53_REV_ID_25 0x50
  137. /* Strap Value (48 bit) */
  138. #define B53_STRAP_VALUE 0x70
  139. #define SV_GMII_CTRL_115 BIT(27)
  140. /*************************************************************************
  141. * Management Mode Page Registers
  142. *************************************************************************/
  143. /* Global Management Config Register (8 bit) */
  144. #define B53_GLOBAL_CONFIG 0x00
  145. #define GC_RESET_MIB 0x01
  146. #define GC_RX_BPDU_EN 0x02
  147. #define GC_MIB_AC_HDR_EN 0x10
  148. #define GC_MIB_AC_EN 0x20
  149. #define GC_FRM_MGMT_PORT_M 0xC0
  150. #define GC_FRM_MGMT_PORT_04 0x00
  151. #define GC_FRM_MGMT_PORT_MII 0x80
  152. /* Broadcom Header control register (8 bit) */
  153. #define B53_BRCM_HDR 0x03
  154. #define BRCM_HDR_P8_EN BIT(0) /* Enable tagging on port 8 */
  155. #define BRCM_HDR_P5_EN BIT(1) /* Enable tagging on port 5 */
  156. /* Device ID register (8 or 32 bit) */
  157. #define B53_DEVICE_ID 0x30
  158. /* Revision ID register (8 bit) */
  159. #define B53_REV_ID 0x40
  160. /*************************************************************************
  161. * ARL Access Page Registers
  162. *************************************************************************/
  163. /* VLAN Table Access Register (8 bit) */
  164. #define B53_VT_ACCESS 0x80
  165. #define B53_VT_ACCESS_9798 0x60 /* for BCM5397/BCM5398 */
  166. #define B53_VT_ACCESS_63XX 0x60 /* for BCM6328/62/68 */
  167. #define VTA_CMD_WRITE 0
  168. #define VTA_CMD_READ 1
  169. #define VTA_CMD_CLEAR 2
  170. #define VTA_START_CMD BIT(7)
  171. /* VLAN Table Index Register (16 bit) */
  172. #define B53_VT_INDEX 0x81
  173. #define B53_VT_INDEX_9798 0x61
  174. #define B53_VT_INDEX_63XX 0x62
  175. /* VLAN Table Entry Register (32 bit) */
  176. #define B53_VT_ENTRY 0x83
  177. #define B53_VT_ENTRY_9798 0x63
  178. #define B53_VT_ENTRY_63XX 0x64
  179. #define VTE_MEMBERS 0x1ff
  180. #define VTE_UNTAG_S 9
  181. #define VTE_UNTAG (0x1ff << 9)
  182. /*************************************************************************
  183. * Port VLAN Registers
  184. *************************************************************************/
  185. /* Port VLAN mask (16 bit) IMP port is always 8, also on 5325 & co */
  186. #define B53_PVLAN_PORT_MASK(i) ((i) * 2)
  187. /*************************************************************************
  188. * 802.1Q Page Registers
  189. *************************************************************************/
  190. /* Global QoS Control (8 bit) */
  191. #define B53_QOS_GLOBAL_CTL 0x00
  192. /* Enable 802.1Q for individual Ports (16 bit) */
  193. #define B53_802_1P_EN 0x04
  194. /*************************************************************************
  195. * VLAN Page Registers
  196. *************************************************************************/
  197. /* VLAN Control 0 (8 bit) */
  198. #define B53_VLAN_CTRL0 0x00
  199. #define VC0_8021PF_CTRL_MASK 0x3
  200. #define VC0_8021PF_CTRL_NONE 0x0
  201. #define VC0_8021PF_CTRL_CHANGE_PRI 0x1
  202. #define VC0_8021PF_CTRL_CHANGE_VID 0x2
  203. #define VC0_8021PF_CTRL_CHANGE_BOTH 0x3
  204. #define VC0_8021QF_CTRL_MASK 0xc
  205. #define VC0_8021QF_CTRL_CHANGE_PRI 0x1
  206. #define VC0_8021QF_CTRL_CHANGE_VID 0x2
  207. #define VC0_8021QF_CTRL_CHANGE_BOTH 0x3
  208. #define VC0_RESERVED_1 BIT(1)
  209. #define VC0_DROP_VID_MISS BIT(4)
  210. #define VC0_VID_HASH_VID BIT(5)
  211. #define VC0_VID_CHK_EN BIT(6) /* Use VID,DA or VID,SA */
  212. #define VC0_VLAN_EN BIT(7) /* 802.1Q VLAN Enabled */
  213. /* VLAN Control 1 (8 bit) */
  214. #define B53_VLAN_CTRL1 0x01
  215. #define VC1_RX_MCST_TAG_EN BIT(1)
  216. #define VC1_RX_MCST_FWD_EN BIT(2)
  217. #define VC1_RX_MCST_UNTAG_EN BIT(3)
  218. /* VLAN Control 2 (8 bit) */
  219. #define B53_VLAN_CTRL2 0x02
  220. /* VLAN Control 3 (8 bit when BCM5325, 16 bit else) */
  221. #define B53_VLAN_CTRL3 0x03
  222. #define B53_VLAN_CTRL3_63XX 0x04
  223. #define VC3_MAXSIZE_1532 BIT(6) /* 5325 only */
  224. #define VC3_HIGH_8BIT_EN BIT(7) /* 5325 only */
  225. /* VLAN Control 4 (8 bit) */
  226. #define B53_VLAN_CTRL4 0x05
  227. #define B53_VLAN_CTRL4_25 0x04
  228. #define B53_VLAN_CTRL4_63XX 0x06
  229. #define VC4_ING_VID_CHECK_S 6
  230. #define VC4_ING_VID_CHECK_MASK (0x3 << VC4_ING_VID_CHECK_S)
  231. #define VC4_ING_VID_VIO_FWD 0 /* forward, but do not learn */
  232. #define VC4_ING_VID_VIO_DROP 1 /* drop VID violations */
  233. #define VC4_NO_ING_VID_CHK 2 /* do not check */
  234. #define VC4_ING_VID_VIO_TO_IMP 3 /* redirect to MII port */
  235. /* VLAN Control 5 (8 bit) */
  236. #define B53_VLAN_CTRL5 0x06
  237. #define B53_VLAN_CTRL5_25 0x05
  238. #define B53_VLAN_CTRL5_63XX 0x07
  239. #define VC5_VID_FFF_EN BIT(2)
  240. #define VC5_DROP_VTABLE_MISS BIT(3)
  241. /* VLAN Control 6 (8 bit) */
  242. #define B53_VLAN_CTRL6 0x07
  243. #define B53_VLAN_CTRL6_63XX 0x08
  244. /* VLAN Table Access Register (16 bit) */
  245. #define B53_VLAN_TABLE_ACCESS_25 0x06 /* BCM5325E/5350 */
  246. #define B53_VLAN_TABLE_ACCESS_65 0x08 /* BCM5365 */
  247. #define VTA_VID_LOW_MASK_25 0xf
  248. #define VTA_VID_LOW_MASK_65 0xff
  249. #define VTA_VID_HIGH_S_25 4
  250. #define VTA_VID_HIGH_S_65 8
  251. #define VTA_VID_HIGH_MASK_25 (0xff << VTA_VID_HIGH_S_25E)
  252. #define VTA_VID_HIGH_MASK_65 (0xf << VTA_VID_HIGH_S_65)
  253. #define VTA_RW_STATE BIT(12)
  254. #define VTA_RW_STATE_RD 0
  255. #define VTA_RW_STATE_WR BIT(12)
  256. #define VTA_RW_OP_EN BIT(13)
  257. /* VLAN Read/Write Registers for (16/32 bit) */
  258. #define B53_VLAN_WRITE_25 0x08
  259. #define B53_VLAN_WRITE_65 0x0a
  260. #define B53_VLAN_READ 0x0c
  261. #define VA_MEMBER_MASK 0x3f
  262. #define VA_UNTAG_S_25 6
  263. #define VA_UNTAG_MASK_25 0x3f
  264. #define VA_UNTAG_S_65 7
  265. #define VA_UNTAG_MASK_65 0x1f
  266. #define VA_VID_HIGH_S 12
  267. #define VA_VID_HIGH_MASK (0xffff << VA_VID_HIGH_S)
  268. #define VA_VALID_25 BIT(20)
  269. #define VA_VALID_25_R4 BIT(24)
  270. #define VA_VALID_65 BIT(14)
  271. /* VLAN Port Default Tag (16 bit) */
  272. #define B53_VLAN_PORT_DEF_TAG(i) (0x10 + 2 * (i))
  273. /*************************************************************************
  274. * Jumbo Frame Page Registers
  275. *************************************************************************/
  276. /* Jumbo Enable Port Mask (bit i == port i enabled) (32 bit) */
  277. #define B53_JUMBO_PORT_MASK 0x01
  278. #define B53_JUMBO_PORT_MASK_63XX 0x04
  279. #define JPM_10_100_JUMBO_EN BIT(24) /* GigE always enabled */
  280. /* Good Frame Max Size without 802.1Q TAG (16 bit) */
  281. #define B53_JUMBO_MAX_SIZE 0x05
  282. #define B53_JUMBO_MAX_SIZE_63XX 0x08
  283. #define JMS_MIN_SIZE 1518
  284. #define JMS_MAX_SIZE 9724
  285. /*************************************************************************
  286. * CFP Configuration Page Registers
  287. *************************************************************************/
  288. /* CFP Control Register with ports map (8 bit) */
  289. #define B53_CFP_CTRL 0x00
  290. #endif /* !__B53_REGS_H */