mv88e6xxx.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. /*
  2. * Marvell 88e6xxx common definitions
  3. *
  4. * Copyright (c) 2008 Marvell Semiconductor
  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 __MV88E6XXX_H
  12. #define __MV88E6XXX_H
  13. #include <linux/if_vlan.h>
  14. #include <linux/irq.h>
  15. #include <linux/gpio/consumer.h>
  16. #include <linux/phy.h>
  17. #include <net/dsa.h>
  18. #ifndef UINT64_MAX
  19. #define UINT64_MAX (u64)(~((u64)0))
  20. #endif
  21. #define SMI_CMD 0x00
  22. #define SMI_CMD_BUSY BIT(15)
  23. #define SMI_CMD_CLAUSE_22 BIT(12)
  24. #define SMI_CMD_OP_22_WRITE ((1 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22)
  25. #define SMI_CMD_OP_22_READ ((2 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22)
  26. #define SMI_CMD_OP_45_WRITE_ADDR ((0 << 10) | SMI_CMD_BUSY)
  27. #define SMI_CMD_OP_45_WRITE_DATA ((1 << 10) | SMI_CMD_BUSY)
  28. #define SMI_CMD_OP_45_READ_DATA ((2 << 10) | SMI_CMD_BUSY)
  29. #define SMI_CMD_OP_45_READ_DATA_INC ((3 << 10) | SMI_CMD_BUSY)
  30. #define SMI_DATA 0x01
  31. /* PHY Registers */
  32. #define PHY_PAGE 0x16
  33. #define PHY_PAGE_COPPER 0x00
  34. #define ADDR_SERDES 0x0f
  35. #define SERDES_PAGE_FIBER 0x01
  36. #define PORT_STATUS 0x00
  37. #define PORT_STATUS_PAUSE_EN BIT(15)
  38. #define PORT_STATUS_MY_PAUSE BIT(14)
  39. #define PORT_STATUS_HD_FLOW BIT(13)
  40. #define PORT_STATUS_PHY_DETECT BIT(12)
  41. #define PORT_STATUS_LINK BIT(11)
  42. #define PORT_STATUS_DUPLEX BIT(10)
  43. #define PORT_STATUS_SPEED_MASK 0x0300
  44. #define PORT_STATUS_SPEED_10 0x0000
  45. #define PORT_STATUS_SPEED_100 0x0100
  46. #define PORT_STATUS_SPEED_1000 0x0200
  47. #define PORT_STATUS_EEE BIT(6) /* 6352 */
  48. #define PORT_STATUS_AM_DIS BIT(6) /* 6165 */
  49. #define PORT_STATUS_MGMII BIT(6) /* 6185 */
  50. #define PORT_STATUS_TX_PAUSED BIT(5)
  51. #define PORT_STATUS_FLOW_CTRL BIT(4)
  52. #define PORT_STATUS_CMODE_MASK 0x0f
  53. #define PORT_STATUS_CMODE_100BASE_X 0x8
  54. #define PORT_STATUS_CMODE_1000BASE_X 0x9
  55. #define PORT_STATUS_CMODE_SGMII 0xa
  56. #define PORT_STATUS_CMODE_2500BASEX 0xb
  57. #define PORT_STATUS_CMODE_XAUI 0xc
  58. #define PORT_STATUS_CMODE_RXAUI 0xd
  59. #define PORT_PCS_CTRL 0x01
  60. #define PORT_PCS_CTRL_RGMII_DELAY_RXCLK BIT(15)
  61. #define PORT_PCS_CTRL_RGMII_DELAY_TXCLK BIT(14)
  62. #define PORT_PCS_CTRL_FORCE_SPEED BIT(13) /* 6390 */
  63. #define PORT_PCS_CTRL_ALTSPEED BIT(12) /* 6390 */
  64. #define PORT_PCS_CTRL_200BASE BIT(12) /* 6352 */
  65. #define PORT_PCS_CTRL_FC BIT(7)
  66. #define PORT_PCS_CTRL_FORCE_FC BIT(6)
  67. #define PORT_PCS_CTRL_LINK_UP BIT(5)
  68. #define PORT_PCS_CTRL_FORCE_LINK BIT(4)
  69. #define PORT_PCS_CTRL_DUPLEX_FULL BIT(3)
  70. #define PORT_PCS_CTRL_FORCE_DUPLEX BIT(2)
  71. #define PORT_PCS_CTRL_SPEED_MASK (0x03)
  72. #define PORT_PCS_CTRL_SPEED_10 (0x00)
  73. #define PORT_PCS_CTRL_SPEED_100 (0x01)
  74. #define PORT_PCS_CTRL_SPEED_200 (0x02) /* 6065 and non Gb chips */
  75. #define PORT_PCS_CTRL_SPEED_1000 (0x02)
  76. #define PORT_PCS_CTRL_SPEED_10000 (0x03) /* 6390X */
  77. #define PORT_PCS_CTRL_SPEED_UNFORCED (0x03)
  78. #define PORT_PAUSE_CTRL 0x02
  79. #define PORT_FLOW_CTRL_LIMIT_IN ((0x00 << 8) | BIT(15))
  80. #define PORT_FLOW_CTRL_LIMIT_OUT ((0x01 << 8) | BIT(15))
  81. #define PORT_SWITCH_ID 0x03
  82. #define PORT_SWITCH_ID_PROD_NUM_6085 0x04a
  83. #define PORT_SWITCH_ID_PROD_NUM_6095 0x095
  84. #define PORT_SWITCH_ID_PROD_NUM_6097 0x099
  85. #define PORT_SWITCH_ID_PROD_NUM_6131 0x106
  86. #define PORT_SWITCH_ID_PROD_NUM_6320 0x115
  87. #define PORT_SWITCH_ID_PROD_NUM_6123 0x121
  88. #define PORT_SWITCH_ID_PROD_NUM_6141 0x340
  89. #define PORT_SWITCH_ID_PROD_NUM_6161 0x161
  90. #define PORT_SWITCH_ID_PROD_NUM_6165 0x165
  91. #define PORT_SWITCH_ID_PROD_NUM_6171 0x171
  92. #define PORT_SWITCH_ID_PROD_NUM_6172 0x172
  93. #define PORT_SWITCH_ID_PROD_NUM_6175 0x175
  94. #define PORT_SWITCH_ID_PROD_NUM_6176 0x176
  95. #define PORT_SWITCH_ID_PROD_NUM_6185 0x1a7
  96. #define PORT_SWITCH_ID_PROD_NUM_6190 0x190
  97. #define PORT_SWITCH_ID_PROD_NUM_6190X 0x0a0
  98. #define PORT_SWITCH_ID_PROD_NUM_6191 0x191
  99. #define PORT_SWITCH_ID_PROD_NUM_6240 0x240
  100. #define PORT_SWITCH_ID_PROD_NUM_6290 0x290
  101. #define PORT_SWITCH_ID_PROD_NUM_6321 0x310
  102. #define PORT_SWITCH_ID_PROD_NUM_6341 0x341
  103. #define PORT_SWITCH_ID_PROD_NUM_6352 0x352
  104. #define PORT_SWITCH_ID_PROD_NUM_6350 0x371
  105. #define PORT_SWITCH_ID_PROD_NUM_6351 0x375
  106. #define PORT_SWITCH_ID_PROD_NUM_6390 0x390
  107. #define PORT_SWITCH_ID_PROD_NUM_6390X 0x0a1
  108. #define PORT_CONTROL 0x04
  109. #define PORT_CONTROL_USE_CORE_TAG BIT(15)
  110. #define PORT_CONTROL_DROP_ON_LOCK BIT(14)
  111. #define PORT_CONTROL_EGRESS_UNMODIFIED (0x0 << 12)
  112. #define PORT_CONTROL_EGRESS_UNTAGGED (0x1 << 12)
  113. #define PORT_CONTROL_EGRESS_TAGGED (0x2 << 12)
  114. #define PORT_CONTROL_EGRESS_ADD_TAG (0x3 << 12)
  115. #define PORT_CONTROL_EGRESS_MASK (0x3 << 12)
  116. #define PORT_CONTROL_HEADER BIT(11)
  117. #define PORT_CONTROL_IGMP_MLD_SNOOP BIT(10)
  118. #define PORT_CONTROL_DOUBLE_TAG BIT(9)
  119. #define PORT_CONTROL_FRAME_MODE_NORMAL (0x0 << 8)
  120. #define PORT_CONTROL_FRAME_MODE_DSA (0x1 << 8)
  121. #define PORT_CONTROL_FRAME_MODE_PROVIDER (0x2 << 8)
  122. #define PORT_CONTROL_FRAME_ETHER_TYPE_DSA (0x3 << 8)
  123. #define PORT_CONTROL_FRAME_MASK (0x3 << 8)
  124. #define PORT_CONTROL_DSA_TAG BIT(8)
  125. #define PORT_CONTROL_VLAN_TUNNEL BIT(7)
  126. #define PORT_CONTROL_TAG_IF_BOTH BIT(6)
  127. #define PORT_CONTROL_USE_IP BIT(5)
  128. #define PORT_CONTROL_USE_TAG BIT(4)
  129. #define PORT_CONTROL_FORWARD_UNKNOWN BIT(2)
  130. #define PORT_CONTROL_EGRESS_FLOODS_MASK (0x3 << 2)
  131. #define PORT_CONTROL_EGRESS_FLOODS_NO_UNKNOWN_DA (0x0 << 2)
  132. #define PORT_CONTROL_EGRESS_FLOODS_NO_UNKNOWN_MC_DA (0x1 << 2)
  133. #define PORT_CONTROL_EGRESS_FLOODS_NO_UNKNOWN_UC_DA (0x2 << 2)
  134. #define PORT_CONTROL_EGRESS_FLOODS_ALL_UNKNOWN_DA (0x3 << 2)
  135. #define PORT_CONTROL_STATE_MASK 0x03
  136. #define PORT_CONTROL_STATE_DISABLED 0x00
  137. #define PORT_CONTROL_STATE_BLOCKING 0x01
  138. #define PORT_CONTROL_STATE_LEARNING 0x02
  139. #define PORT_CONTROL_STATE_FORWARDING 0x03
  140. #define PORT_CONTROL_1 0x05
  141. #define PORT_CONTROL_1_MESSAGE_PORT BIT(15)
  142. #define PORT_CONTROL_1_FID_11_4_MASK (0xff << 0)
  143. #define PORT_BASE_VLAN 0x06
  144. #define PORT_BASE_VLAN_FID_3_0_MASK (0xf << 12)
  145. #define PORT_DEFAULT_VLAN 0x07
  146. #define PORT_DEFAULT_VLAN_MASK 0xfff
  147. #define PORT_CONTROL_2 0x08
  148. #define PORT_CONTROL_2_IGNORE_FCS BIT(15)
  149. #define PORT_CONTROL_2_VTU_PRI_OVERRIDE BIT(14)
  150. #define PORT_CONTROL_2_SA_PRIO_OVERRIDE BIT(13)
  151. #define PORT_CONTROL_2_DA_PRIO_OVERRIDE BIT(12)
  152. #define PORT_CONTROL_2_JUMBO_1522 (0x00 << 12)
  153. #define PORT_CONTROL_2_JUMBO_2048 (0x01 << 12)
  154. #define PORT_CONTROL_2_JUMBO_10240 (0x02 << 12)
  155. #define PORT_CONTROL_2_8021Q_MASK (0x03 << 10)
  156. #define PORT_CONTROL_2_8021Q_DISABLED (0x00 << 10)
  157. #define PORT_CONTROL_2_8021Q_FALLBACK (0x01 << 10)
  158. #define PORT_CONTROL_2_8021Q_CHECK (0x02 << 10)
  159. #define PORT_CONTROL_2_8021Q_SECURE (0x03 << 10)
  160. #define PORT_CONTROL_2_DISCARD_TAGGED BIT(9)
  161. #define PORT_CONTROL_2_DISCARD_UNTAGGED BIT(8)
  162. #define PORT_CONTROL_2_MAP_DA BIT(7)
  163. #define PORT_CONTROL_2_DEFAULT_FORWARD BIT(6)
  164. #define PORT_CONTROL_2_EGRESS_MONITOR BIT(5)
  165. #define PORT_CONTROL_2_INGRESS_MONITOR BIT(4)
  166. #define PORT_CONTROL_2_UPSTREAM_MASK 0x0f
  167. #define PORT_RATE_CONTROL 0x09
  168. #define PORT_RATE_CONTROL_2 0x0a
  169. #define PORT_ASSOC_VECTOR 0x0b
  170. #define PORT_ASSOC_VECTOR_HOLD_AT_1 BIT(15)
  171. #define PORT_ASSOC_VECTOR_INT_AGE_OUT BIT(14)
  172. #define PORT_ASSOC_VECTOR_LOCKED_PORT BIT(13)
  173. #define PORT_ASSOC_VECTOR_IGNORE_WRONG BIT(12)
  174. #define PORT_ASSOC_VECTOR_REFRESH_LOCKED BIT(11)
  175. #define PORT_ATU_CONTROL 0x0c
  176. #define PORT_PRI_OVERRIDE 0x0d
  177. #define PORT_ETH_TYPE 0x0f
  178. #define PORT_ETH_TYPE_DEFAULT 0x9100
  179. #define PORT_IN_DISCARD_LO 0x10
  180. #define PORT_IN_DISCARD_HI 0x11
  181. #define PORT_IN_FILTERED 0x12
  182. #define PORT_OUT_FILTERED 0x13
  183. #define PORT_TAG_REGMAP_0123 0x18
  184. #define PORT_TAG_REGMAP_4567 0x19
  185. #define PORT_IEEE_PRIO_MAP_TABLE 0x18 /* 6390 */
  186. #define PORT_IEEE_PRIO_MAP_TABLE_UPDATE BIT(15)
  187. #define PORT_IEEE_PRIO_MAP_TABLE_INGRESS_PCP (0x0 << 12)
  188. #define PORT_IEEE_PRIO_MAP_TABLE_EGRESS_GREEN_PCP (0x1 << 12)
  189. #define PORT_IEEE_PRIO_MAP_TABLE_EGRESS_YELLOW_PCP (0x2 << 12)
  190. #define PORT_IEEE_PRIO_MAP_TABLE_EGRESS_AVB_PCP (0x3 << 12)
  191. #define PORT_IEEE_PRIO_MAP_TABLE_EGRESS_GREEN_DSCP (0x5 << 12)
  192. #define PORT_IEEE_PRIO_MAP_TABLE_EGRESS_YELLOW_DSCP (0x6 << 12)
  193. #define PORT_IEEE_PRIO_MAP_TABLE_EGRESS_AVB_DSCP (0x7 << 12)
  194. #define PORT_IEEE_PRIO_MAP_TABLE_POINTER_SHIFT 9
  195. #define GLOBAL_STATUS 0x00
  196. #define GLOBAL_STATUS_PPU_STATE BIT(15) /* 6351 and 6171 */
  197. #define GLOBAL_STATUS_PPU_STATE_MASK (0x3 << 14) /* 6165 6185 */
  198. #define GLOBAL_STATUS_PPU_STATE_DISABLED_RST (0x0 << 14)
  199. #define GLOBAL_STATUS_PPU_STATE_INITIALIZING (0x1 << 14)
  200. #define GLOBAL_STATUS_PPU_STATE_DISABLED (0x2 << 14)
  201. #define GLOBAL_STATUS_PPU_STATE_POLLING (0x3 << 14)
  202. #define GLOBAL_STATUS_INIT_READY BIT(11)
  203. #define GLOBAL_STATUS_IRQ_AVB 8
  204. #define GLOBAL_STATUS_IRQ_DEVICE 7
  205. #define GLOBAL_STATUS_IRQ_STATS 6
  206. #define GLOBAL_STATUS_IRQ_VTU_PROBLEM 5
  207. #define GLOBAL_STATUS_IRQ_VTU_DONE 4
  208. #define GLOBAL_STATUS_IRQ_ATU_PROBLEM 3
  209. #define GLOBAL_STATUS_IRQ_ATU_DONE 2
  210. #define GLOBAL_STATUS_IRQ_TCAM_DONE 1
  211. #define GLOBAL_STATUS_IRQ_EEPROM_DONE 0
  212. #define GLOBAL_MAC_01 0x01
  213. #define GLOBAL_MAC_23 0x02
  214. #define GLOBAL_MAC_45 0x03
  215. #define GLOBAL_ATU_FID 0x01
  216. #define GLOBAL_VTU_FID 0x02
  217. #define GLOBAL_VTU_FID_MASK 0xfff
  218. #define GLOBAL_VTU_SID 0x03 /* 6097 6165 6351 6352 */
  219. #define GLOBAL_VTU_SID_MASK 0x3f
  220. #define GLOBAL_CONTROL 0x04
  221. #define GLOBAL_CONTROL_SW_RESET BIT(15)
  222. #define GLOBAL_CONTROL_PPU_ENABLE BIT(14)
  223. #define GLOBAL_CONTROL_DISCARD_EXCESS BIT(13) /* 6352 */
  224. #define GLOBAL_CONTROL_SCHED_PRIO BIT(11) /* 6152 */
  225. #define GLOBAL_CONTROL_MAX_FRAME_1632 BIT(10) /* 6152 */
  226. #define GLOBAL_CONTROL_RELOAD_EEPROM BIT(9) /* 6152 */
  227. #define GLOBAL_CONTROL_DEVICE_EN BIT(7)
  228. #define GLOBAL_CONTROL_STATS_DONE_EN BIT(6)
  229. #define GLOBAL_CONTROL_VTU_PROBLEM_EN BIT(5)
  230. #define GLOBAL_CONTROL_VTU_DONE_EN BIT(4)
  231. #define GLOBAL_CONTROL_ATU_PROBLEM_EN BIT(3)
  232. #define GLOBAL_CONTROL_ATU_DONE_EN BIT(2)
  233. #define GLOBAL_CONTROL_TCAM_EN BIT(1)
  234. #define GLOBAL_CONTROL_EEPROM_DONE_EN BIT(0)
  235. #define GLOBAL_VTU_OP 0x05
  236. #define GLOBAL_VTU_OP_BUSY BIT(15)
  237. #define GLOBAL_VTU_OP_FLUSH_ALL ((0x01 << 12) | GLOBAL_VTU_OP_BUSY)
  238. #define GLOBAL_VTU_OP_VTU_LOAD_PURGE ((0x03 << 12) | GLOBAL_VTU_OP_BUSY)
  239. #define GLOBAL_VTU_OP_VTU_GET_NEXT ((0x04 << 12) | GLOBAL_VTU_OP_BUSY)
  240. #define GLOBAL_VTU_OP_STU_LOAD_PURGE ((0x05 << 12) | GLOBAL_VTU_OP_BUSY)
  241. #define GLOBAL_VTU_OP_STU_GET_NEXT ((0x06 << 12) | GLOBAL_VTU_OP_BUSY)
  242. #define GLOBAL_VTU_VID 0x06
  243. #define GLOBAL_VTU_VID_MASK 0xfff
  244. #define GLOBAL_VTU_VID_PAGE BIT(13)
  245. #define GLOBAL_VTU_VID_VALID BIT(12)
  246. #define GLOBAL_VTU_DATA_0_3 0x07
  247. #define GLOBAL_VTU_DATA_4_7 0x08
  248. #define GLOBAL_VTU_DATA_8_11 0x09
  249. #define GLOBAL_VTU_STU_DATA_MASK 0x03
  250. #define GLOBAL_VTU_DATA_MEMBER_TAG_UNMODIFIED 0x00
  251. #define GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED 0x01
  252. #define GLOBAL_VTU_DATA_MEMBER_TAG_TAGGED 0x02
  253. #define GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER 0x03
  254. #define GLOBAL_STU_DATA_PORT_STATE_DISABLED 0x00
  255. #define GLOBAL_STU_DATA_PORT_STATE_BLOCKING 0x01
  256. #define GLOBAL_STU_DATA_PORT_STATE_LEARNING 0x02
  257. #define GLOBAL_STU_DATA_PORT_STATE_FORWARDING 0x03
  258. #define GLOBAL_ATU_CONTROL 0x0a
  259. #define GLOBAL_ATU_CONTROL_LEARN2ALL BIT(3)
  260. #define GLOBAL_ATU_OP 0x0b
  261. #define GLOBAL_ATU_OP_BUSY BIT(15)
  262. #define GLOBAL_ATU_OP_NOP (0 << 12)
  263. #define GLOBAL_ATU_OP_FLUSH_MOVE_ALL ((1 << 12) | GLOBAL_ATU_OP_BUSY)
  264. #define GLOBAL_ATU_OP_FLUSH_MOVE_NON_STATIC ((2 << 12) | GLOBAL_ATU_OP_BUSY)
  265. #define GLOBAL_ATU_OP_LOAD_DB ((3 << 12) | GLOBAL_ATU_OP_BUSY)
  266. #define GLOBAL_ATU_OP_GET_NEXT_DB ((4 << 12) | GLOBAL_ATU_OP_BUSY)
  267. #define GLOBAL_ATU_OP_FLUSH_MOVE_ALL_DB ((5 << 12) | GLOBAL_ATU_OP_BUSY)
  268. #define GLOBAL_ATU_OP_FLUSH_MOVE_NON_STATIC_DB ((6 << 12) | GLOBAL_ATU_OP_BUSY)
  269. #define GLOBAL_ATU_OP_GET_CLR_VIOLATION ((7 << 12) | GLOBAL_ATU_OP_BUSY)
  270. #define GLOBAL_ATU_DATA 0x0c
  271. #define GLOBAL_ATU_DATA_TRUNK BIT(15)
  272. #define GLOBAL_ATU_DATA_TRUNK_ID_MASK 0x00f0
  273. #define GLOBAL_ATU_DATA_TRUNK_ID_SHIFT 4
  274. #define GLOBAL_ATU_DATA_PORT_VECTOR_MASK 0x3ff0
  275. #define GLOBAL_ATU_DATA_PORT_VECTOR_SHIFT 4
  276. #define GLOBAL_ATU_DATA_STATE_MASK 0x0f
  277. #define GLOBAL_ATU_DATA_STATE_UNUSED 0x00
  278. #define GLOBAL_ATU_DATA_STATE_UC_MGMT 0x0d
  279. #define GLOBAL_ATU_DATA_STATE_UC_STATIC 0x0e
  280. #define GLOBAL_ATU_DATA_STATE_UC_PRIO_OVER 0x0f
  281. #define GLOBAL_ATU_DATA_STATE_MC_NONE_RATE 0x05
  282. #define GLOBAL_ATU_DATA_STATE_MC_STATIC 0x07
  283. #define GLOBAL_ATU_DATA_STATE_MC_MGMT 0x0e
  284. #define GLOBAL_ATU_DATA_STATE_MC_PRIO_OVER 0x0f
  285. #define GLOBAL_ATU_MAC_01 0x0d
  286. #define GLOBAL_ATU_MAC_23 0x0e
  287. #define GLOBAL_ATU_MAC_45 0x0f
  288. #define GLOBAL_IP_PRI_0 0x10
  289. #define GLOBAL_IP_PRI_1 0x11
  290. #define GLOBAL_IP_PRI_2 0x12
  291. #define GLOBAL_IP_PRI_3 0x13
  292. #define GLOBAL_IP_PRI_4 0x14
  293. #define GLOBAL_IP_PRI_5 0x15
  294. #define GLOBAL_IP_PRI_6 0x16
  295. #define GLOBAL_IP_PRI_7 0x17
  296. #define GLOBAL_IEEE_PRI 0x18
  297. #define GLOBAL_CORE_TAG_TYPE 0x19
  298. #define GLOBAL_MONITOR_CONTROL 0x1a
  299. #define GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT 12
  300. #define GLOBAL_MONITOR_CONTROL_INGRESS_MASK (0xf << 12)
  301. #define GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT 8
  302. #define GLOBAL_MONITOR_CONTROL_EGRESS_MASK (0xf << 8)
  303. #define GLOBAL_MONITOR_CONTROL_ARP_SHIFT 4
  304. #define GLOBAL_MONITOR_CONTROL_ARP_MASK (0xf << 4)
  305. #define GLOBAL_MONITOR_CONTROL_MIRROR_SHIFT 0
  306. #define GLOBAL_MONITOR_CONTROL_ARP_DISABLED (0xf0)
  307. #define GLOBAL_MONITOR_CONTROL_UPDATE BIT(15)
  308. #define GLOBAL_MONITOR_CONTROL_0180C280000000XLO (0x00 << 8)
  309. #define GLOBAL_MONITOR_CONTROL_0180C280000000XHI (0x01 << 8)
  310. #define GLOBAL_MONITOR_CONTROL_0180C280000002XLO (0x02 << 8)
  311. #define GLOBAL_MONITOR_CONTROL_0180C280000002XHI (0x03 << 8)
  312. #define GLOBAL_MONITOR_CONTROL_INGRESS (0x20 << 8)
  313. #define GLOBAL_MONITOR_CONTROL_EGRESS (0x21 << 8)
  314. #define GLOBAL_MONITOR_CONTROL_CPU_DEST (0x30 << 8)
  315. #define GLOBAL_CONTROL_2 0x1c
  316. #define GLOBAL_CONTROL_2_NO_CASCADE 0xe000
  317. #define GLOBAL_CONTROL_2_MULTIPLE_CASCADE 0xf000
  318. #define GLOBAL_CONTROL_2_HIST_RX (0x1 << 6)
  319. #define GLOBAL_CONTROL_2_HIST_TX (0x2 << 6)
  320. #define GLOBAL_CONTROL_2_HIST_RX_TX (0x3 << 6)
  321. #define GLOBAL_STATS_OP 0x1d
  322. #define GLOBAL_STATS_OP_BUSY BIT(15)
  323. #define GLOBAL_STATS_OP_NOP (0 << 12)
  324. #define GLOBAL_STATS_OP_FLUSH_ALL ((1 << 12) | GLOBAL_STATS_OP_BUSY)
  325. #define GLOBAL_STATS_OP_FLUSH_PORT ((2 << 12) | GLOBAL_STATS_OP_BUSY)
  326. #define GLOBAL_STATS_OP_READ_CAPTURED ((4 << 12) | GLOBAL_STATS_OP_BUSY)
  327. #define GLOBAL_STATS_OP_CAPTURE_PORT ((5 << 12) | GLOBAL_STATS_OP_BUSY)
  328. #define GLOBAL_STATS_OP_HIST_RX ((1 << 10) | GLOBAL_STATS_OP_BUSY)
  329. #define GLOBAL_STATS_OP_HIST_TX ((2 << 10) | GLOBAL_STATS_OP_BUSY)
  330. #define GLOBAL_STATS_OP_HIST_RX_TX ((3 << 10) | GLOBAL_STATS_OP_BUSY)
  331. #define GLOBAL_STATS_OP_BANK_1_BIT_9 BIT(9)
  332. #define GLOBAL_STATS_OP_BANK_1_BIT_10 BIT(10)
  333. #define GLOBAL_STATS_COUNTER_32 0x1e
  334. #define GLOBAL_STATS_COUNTER_01 0x1f
  335. #define GLOBAL2_INT_SOURCE 0x00
  336. #define GLOBAL2_INT_SOURCE_WATCHDOG 15
  337. #define GLOBAL2_INT_MASK 0x01
  338. #define GLOBAL2_MGMT_EN_2X 0x02
  339. #define GLOBAL2_MGMT_EN_0X 0x03
  340. #define GLOBAL2_FLOW_CONTROL 0x04
  341. #define GLOBAL2_SWITCH_MGMT 0x05
  342. #define GLOBAL2_SWITCH_MGMT_USE_DOUBLE_TAG_DATA BIT(15)
  343. #define GLOBAL2_SWITCH_MGMT_PREVENT_LOOPS BIT(14)
  344. #define GLOBAL2_SWITCH_MGMT_FLOW_CONTROL_MSG BIT(13)
  345. #define GLOBAL2_SWITCH_MGMT_FORCE_FLOW_CTRL_PRI BIT(7)
  346. #define GLOBAL2_SWITCH_MGMT_RSVD2CPU BIT(3)
  347. #define GLOBAL2_DEVICE_MAPPING 0x06
  348. #define GLOBAL2_DEVICE_MAPPING_UPDATE BIT(15)
  349. #define GLOBAL2_DEVICE_MAPPING_TARGET_SHIFT 8
  350. #define GLOBAL2_DEVICE_MAPPING_PORT_MASK 0x0f
  351. #define GLOBAL2_TRUNK_MASK 0x07
  352. #define GLOBAL2_TRUNK_MASK_UPDATE BIT(15)
  353. #define GLOBAL2_TRUNK_MASK_NUM_SHIFT 12
  354. #define GLOBAL2_TRUNK_MASK_HASK BIT(11)
  355. #define GLOBAL2_TRUNK_MAPPING 0x08
  356. #define GLOBAL2_TRUNK_MAPPING_UPDATE BIT(15)
  357. #define GLOBAL2_TRUNK_MAPPING_ID_SHIFT 11
  358. #define GLOBAL2_IRL_CMD 0x09
  359. #define GLOBAL2_IRL_CMD_BUSY BIT(15)
  360. #define GLOBAL2_IRL_CMD_OP_INIT_ALL ((0x001 << 12) | GLOBAL2_IRL_CMD_BUSY)
  361. #define GLOBAL2_IRL_CMD_OP_INIT_SEL ((0x010 << 12) | GLOBAL2_IRL_CMD_BUSY)
  362. #define GLOBAL2_IRL_CMD_OP_WRITE_SEL ((0x011 << 12) | GLOBAL2_IRL_CMD_BUSY)
  363. #define GLOBAL2_IRL_CMD_OP_READ_SEL ((0x100 << 12) | GLOBAL2_IRL_CMD_BUSY)
  364. #define GLOBAL2_IRL_DATA 0x0a
  365. #define GLOBAL2_PVT_ADDR 0x0b
  366. #define GLOBAL2_PVT_ADDR_BUSY BIT(15)
  367. #define GLOBAL2_PVT_ADDR_OP_INIT_ONES ((0x01 << 12) | GLOBAL2_PVT_ADDR_BUSY)
  368. #define GLOBAL2_PVT_ADDR_OP_WRITE_PVLAN ((0x03 << 12) | GLOBAL2_PVT_ADDR_BUSY)
  369. #define GLOBAL2_PVT_ADDR_OP_READ ((0x04 << 12) | GLOBAL2_PVT_ADDR_BUSY)
  370. #define GLOBAL2_PVT_DATA 0x0c
  371. #define GLOBAL2_SWITCH_MAC 0x0d
  372. #define GLOBAL2_ATU_STATS 0x0e
  373. #define GLOBAL2_PRIO_OVERRIDE 0x0f
  374. #define GLOBAL2_PRIO_OVERRIDE_FORCE_SNOOP BIT(7)
  375. #define GLOBAL2_PRIO_OVERRIDE_SNOOP_SHIFT 4
  376. #define GLOBAL2_PRIO_OVERRIDE_FORCE_ARP BIT(3)
  377. #define GLOBAL2_PRIO_OVERRIDE_ARP_SHIFT 0
  378. #define GLOBAL2_EEPROM_CMD 0x14
  379. #define GLOBAL2_EEPROM_CMD_BUSY BIT(15)
  380. #define GLOBAL2_EEPROM_CMD_OP_WRITE ((0x3 << 12) | GLOBAL2_EEPROM_CMD_BUSY)
  381. #define GLOBAL2_EEPROM_CMD_OP_READ ((0x4 << 12) | GLOBAL2_EEPROM_CMD_BUSY)
  382. #define GLOBAL2_EEPROM_CMD_OP_LOAD ((0x6 << 12) | GLOBAL2_EEPROM_CMD_BUSY)
  383. #define GLOBAL2_EEPROM_CMD_RUNNING BIT(11)
  384. #define GLOBAL2_EEPROM_CMD_WRITE_EN BIT(10)
  385. #define GLOBAL2_EEPROM_CMD_ADDR_MASK 0xff
  386. #define GLOBAL2_EEPROM_DATA 0x15
  387. #define GLOBAL2_EEPROM_ADDR 0x15 /* 6390, 6341 */
  388. #define GLOBAL2_PTP_AVB_OP 0x16
  389. #define GLOBAL2_PTP_AVB_DATA 0x17
  390. #define GLOBAL2_SMI_PHY_CMD 0x18
  391. #define GLOBAL2_SMI_PHY_CMD_BUSY BIT(15)
  392. #define GLOBAL2_SMI_PHY_CMD_EXTERNAL BIT(13)
  393. #define GLOBAL2_SMI_PHY_CMD_MODE_22 BIT(12)
  394. #define GLOBAL2_SMI_PHY_CMD_OP_22_WRITE_DATA ((0x1 << 10) | \
  395. GLOBAL2_SMI_PHY_CMD_MODE_22 | \
  396. GLOBAL2_SMI_PHY_CMD_BUSY)
  397. #define GLOBAL2_SMI_PHY_CMD_OP_22_READ_DATA ((0x2 << 10) | \
  398. GLOBAL2_SMI_PHY_CMD_MODE_22 | \
  399. GLOBAL2_SMI_PHY_CMD_BUSY)
  400. #define GLOBAL2_SMI_PHY_CMD_OP_45_WRITE_ADDR ((0x0 << 10) | \
  401. GLOBAL2_SMI_PHY_CMD_BUSY)
  402. #define GLOBAL2_SMI_PHY_CMD_OP_45_WRITE_DATA ((0x1 << 10) | \
  403. GLOBAL2_SMI_PHY_CMD_BUSY)
  404. #define GLOBAL2_SMI_PHY_CMD_OP_45_READ_DATA ((0x3 << 10) | \
  405. GLOBAL2_SMI_PHY_CMD_BUSY)
  406. #define GLOBAL2_SMI_PHY_DATA 0x19
  407. #define GLOBAL2_SCRATCH_MISC 0x1a
  408. #define GLOBAL2_SCRATCH_BUSY BIT(15)
  409. #define GLOBAL2_SCRATCH_REGISTER_SHIFT 8
  410. #define GLOBAL2_SCRATCH_VALUE_MASK 0xff
  411. #define GLOBAL2_WDOG_CONTROL 0x1b
  412. #define GLOBAL2_WDOG_CONTROL_EGRESS_EVENT BIT(7)
  413. #define GLOBAL2_WDOG_CONTROL_RMU_TIMEOUT BIT(6)
  414. #define GLOBAL2_WDOG_CONTROL_QC_ENABLE BIT(5)
  415. #define GLOBAL2_WDOG_CONTROL_EGRESS_HISTORY BIT(4)
  416. #define GLOBAL2_WDOG_CONTROL_EGRESS_ENABLE BIT(3)
  417. #define GLOBAL2_WDOG_CONTROL_FORCE_IRQ BIT(2)
  418. #define GLOBAL2_WDOG_CONTROL_HISTORY BIT(1)
  419. #define GLOBAL2_WDOG_CONTROL_SWRESET BIT(0)
  420. #define GLOBAL2_WDOG_UPDATE BIT(15)
  421. #define GLOBAL2_WDOG_INT_SOURCE (0x00 << 8)
  422. #define GLOBAL2_WDOG_INT_STATUS (0x10 << 8)
  423. #define GLOBAL2_WDOG_INT_ENABLE (0x11 << 8)
  424. #define GLOBAL2_WDOG_EVENT (0x12 << 8)
  425. #define GLOBAL2_WDOG_HISTORY (0x13 << 8)
  426. #define GLOBAL2_WDOG_DATA_MASK 0xff
  427. #define GLOBAL2_WDOG_CUT_THROUGH BIT(3)
  428. #define GLOBAL2_WDOG_QUEUE_CONTROLLER BIT(2)
  429. #define GLOBAL2_WDOG_EGRESS BIT(1)
  430. #define GLOBAL2_WDOG_FORCE_IRQ BIT(0)
  431. #define GLOBAL2_QOS_WEIGHT 0x1c
  432. #define GLOBAL2_MISC 0x1d
  433. #define GLOBAL2_MISC_5_BIT_PORT BIT(14)
  434. #define MV88E6XXX_N_FID 4096
  435. /* PVT limits for 4-bit port and 5-bit switch */
  436. #define MV88E6XXX_MAX_PVT_SWITCHES 32
  437. #define MV88E6XXX_MAX_PVT_PORTS 16
  438. enum mv88e6xxx_frame_mode {
  439. MV88E6XXX_FRAME_MODE_NORMAL,
  440. MV88E6XXX_FRAME_MODE_DSA,
  441. MV88E6XXX_FRAME_MODE_PROVIDER,
  442. MV88E6XXX_FRAME_MODE_ETHERTYPE,
  443. };
  444. /* List of supported models */
  445. enum mv88e6xxx_model {
  446. MV88E6085,
  447. MV88E6095,
  448. MV88E6097,
  449. MV88E6123,
  450. MV88E6131,
  451. MV88E6141,
  452. MV88E6161,
  453. MV88E6165,
  454. MV88E6171,
  455. MV88E6172,
  456. MV88E6175,
  457. MV88E6176,
  458. MV88E6185,
  459. MV88E6190,
  460. MV88E6190X,
  461. MV88E6191,
  462. MV88E6240,
  463. MV88E6290,
  464. MV88E6320,
  465. MV88E6321,
  466. MV88E6341,
  467. MV88E6350,
  468. MV88E6351,
  469. MV88E6352,
  470. MV88E6390,
  471. MV88E6390X,
  472. };
  473. enum mv88e6xxx_family {
  474. MV88E6XXX_FAMILY_NONE,
  475. MV88E6XXX_FAMILY_6065, /* 6031 6035 6061 6065 */
  476. MV88E6XXX_FAMILY_6095, /* 6092 6095 */
  477. MV88E6XXX_FAMILY_6097, /* 6046 6085 6096 6097 */
  478. MV88E6XXX_FAMILY_6165, /* 6123 6161 6165 */
  479. MV88E6XXX_FAMILY_6185, /* 6108 6121 6122 6131 6152 6155 6182 6185 */
  480. MV88E6XXX_FAMILY_6320, /* 6320 6321 */
  481. MV88E6XXX_FAMILY_6341, /* 6141 6341 */
  482. MV88E6XXX_FAMILY_6351, /* 6171 6175 6350 6351 */
  483. MV88E6XXX_FAMILY_6352, /* 6172 6176 6240 6352 */
  484. MV88E6XXX_FAMILY_6390, /* 6190 6190X 6191 6290 6390 6390X */
  485. };
  486. enum mv88e6xxx_cap {
  487. /* Energy Efficient Ethernet.
  488. */
  489. MV88E6XXX_CAP_EEE,
  490. /* Multi-chip Addressing Mode.
  491. * Some chips respond to only 2 registers of its own SMI device address
  492. * when it is non-zero, and use indirect access to internal registers.
  493. */
  494. MV88E6XXX_CAP_SMI_CMD, /* (0x00) SMI Command */
  495. MV88E6XXX_CAP_SMI_DATA, /* (0x01) SMI Data */
  496. /* PHY Registers.
  497. */
  498. MV88E6XXX_CAP_PHY_PAGE, /* (0x16) Page Register */
  499. /* Fiber/SERDES Registers (SMI address F).
  500. */
  501. MV88E6XXX_CAP_SERDES,
  502. /* Switch Global (1) Registers.
  503. */
  504. MV88E6XXX_CAP_G1_ATU_FID, /* (0x01) ATU FID Register */
  505. MV88E6XXX_CAP_G1_VTU_FID, /* (0x02) VTU FID Register */
  506. /* Switch Global 2 Registers.
  507. * The device contains a second set of global 16-bit registers.
  508. */
  509. MV88E6XXX_CAP_GLOBAL2,
  510. MV88E6XXX_CAP_G2_INT, /* (0x00) Interrupt Status */
  511. MV88E6XXX_CAP_G2_MGMT_EN_2X, /* (0x02) MGMT Enable Register 2x */
  512. MV88E6XXX_CAP_G2_MGMT_EN_0X, /* (0x03) MGMT Enable Register 0x */
  513. MV88E6XXX_CAP_G2_IRL_CMD, /* (0x09) Ingress Rate Command */
  514. MV88E6XXX_CAP_G2_IRL_DATA, /* (0x0a) Ingress Rate Data */
  515. MV88E6XXX_CAP_G2_POT, /* (0x0f) Priority Override Table */
  516. /* Per VLAN Spanning Tree Unit (STU).
  517. * The Port State database, if present, is accessed through VTU
  518. * operations and dedicated SID registers. See GLOBAL_VTU_SID.
  519. */
  520. MV88E6XXX_CAP_STU,
  521. /* VLAN Table Unit.
  522. * The VTU is used to program 802.1Q VLANs. See GLOBAL_VTU_OP.
  523. */
  524. MV88E6XXX_CAP_VTU,
  525. };
  526. /* Bitmask of capabilities */
  527. #define MV88E6XXX_FLAG_EEE BIT_ULL(MV88E6XXX_CAP_EEE)
  528. #define MV88E6XXX_FLAG_SMI_CMD BIT_ULL(MV88E6XXX_CAP_SMI_CMD)
  529. #define MV88E6XXX_FLAG_SMI_DATA BIT_ULL(MV88E6XXX_CAP_SMI_DATA)
  530. #define MV88E6XXX_FLAG_PHY_PAGE BIT_ULL(MV88E6XXX_CAP_PHY_PAGE)
  531. #define MV88E6XXX_FLAG_SERDES BIT_ULL(MV88E6XXX_CAP_SERDES)
  532. #define MV88E6XXX_FLAG_G1_VTU_FID BIT_ULL(MV88E6XXX_CAP_G1_VTU_FID)
  533. #define MV88E6XXX_FLAG_GLOBAL2 BIT_ULL(MV88E6XXX_CAP_GLOBAL2)
  534. #define MV88E6XXX_FLAG_G2_INT BIT_ULL(MV88E6XXX_CAP_G2_INT)
  535. #define MV88E6XXX_FLAG_G2_MGMT_EN_2X BIT_ULL(MV88E6XXX_CAP_G2_MGMT_EN_2X)
  536. #define MV88E6XXX_FLAG_G2_MGMT_EN_0X BIT_ULL(MV88E6XXX_CAP_G2_MGMT_EN_0X)
  537. #define MV88E6XXX_FLAG_G2_IRL_CMD BIT_ULL(MV88E6XXX_CAP_G2_IRL_CMD)
  538. #define MV88E6XXX_FLAG_G2_IRL_DATA BIT_ULL(MV88E6XXX_CAP_G2_IRL_DATA)
  539. #define MV88E6XXX_FLAG_G2_POT BIT_ULL(MV88E6XXX_CAP_G2_POT)
  540. /* Ingress Rate Limit unit */
  541. #define MV88E6XXX_FLAGS_IRL \
  542. (MV88E6XXX_FLAG_G2_IRL_CMD | \
  543. MV88E6XXX_FLAG_G2_IRL_DATA)
  544. /* Multi-chip Addressing Mode */
  545. #define MV88E6XXX_FLAGS_MULTI_CHIP \
  546. (MV88E6XXX_FLAG_SMI_CMD | \
  547. MV88E6XXX_FLAG_SMI_DATA)
  548. /* Fiber/SERDES Registers at SMI address F, page 1 */
  549. #define MV88E6XXX_FLAGS_SERDES \
  550. (MV88E6XXX_FLAG_PHY_PAGE | \
  551. MV88E6XXX_FLAG_SERDES)
  552. #define MV88E6XXX_FLAGS_FAMILY_6095 \
  553. (MV88E6XXX_FLAG_GLOBAL2 | \
  554. MV88E6XXX_FLAG_G2_MGMT_EN_0X | \
  555. MV88E6XXX_FLAGS_MULTI_CHIP)
  556. #define MV88E6XXX_FLAGS_FAMILY_6097 \
  557. (MV88E6XXX_FLAG_G1_VTU_FID | \
  558. MV88E6XXX_FLAG_GLOBAL2 | \
  559. MV88E6XXX_FLAG_G2_INT | \
  560. MV88E6XXX_FLAG_G2_MGMT_EN_2X | \
  561. MV88E6XXX_FLAG_G2_MGMT_EN_0X | \
  562. MV88E6XXX_FLAG_G2_POT | \
  563. MV88E6XXX_FLAGS_IRL | \
  564. MV88E6XXX_FLAGS_MULTI_CHIP)
  565. #define MV88E6XXX_FLAGS_FAMILY_6165 \
  566. (MV88E6XXX_FLAG_G1_VTU_FID | \
  567. MV88E6XXX_FLAG_GLOBAL2 | \
  568. MV88E6XXX_FLAG_G2_INT | \
  569. MV88E6XXX_FLAG_G2_MGMT_EN_2X | \
  570. MV88E6XXX_FLAG_G2_MGMT_EN_0X | \
  571. MV88E6XXX_FLAG_G2_POT | \
  572. MV88E6XXX_FLAGS_IRL | \
  573. MV88E6XXX_FLAGS_MULTI_CHIP)
  574. #define MV88E6XXX_FLAGS_FAMILY_6185 \
  575. (MV88E6XXX_FLAG_GLOBAL2 | \
  576. MV88E6XXX_FLAG_G2_INT | \
  577. MV88E6XXX_FLAG_G2_MGMT_EN_0X | \
  578. MV88E6XXX_FLAGS_MULTI_CHIP)
  579. #define MV88E6XXX_FLAGS_FAMILY_6320 \
  580. (MV88E6XXX_FLAG_EEE | \
  581. MV88E6XXX_FLAG_GLOBAL2 | \
  582. MV88E6XXX_FLAG_G2_MGMT_EN_2X | \
  583. MV88E6XXX_FLAG_G2_MGMT_EN_0X | \
  584. MV88E6XXX_FLAG_G2_POT | \
  585. MV88E6XXX_FLAGS_IRL | \
  586. MV88E6XXX_FLAGS_MULTI_CHIP)
  587. #define MV88E6XXX_FLAGS_FAMILY_6341 \
  588. (MV88E6XXX_FLAG_EEE | \
  589. MV88E6XXX_FLAG_G1_VTU_FID | \
  590. MV88E6XXX_FLAG_GLOBAL2 | \
  591. MV88E6XXX_FLAG_G2_INT | \
  592. MV88E6XXX_FLAG_G2_POT | \
  593. MV88E6XXX_FLAGS_IRL | \
  594. MV88E6XXX_FLAGS_MULTI_CHIP | \
  595. MV88E6XXX_FLAGS_SERDES)
  596. #define MV88E6XXX_FLAGS_FAMILY_6351 \
  597. (MV88E6XXX_FLAG_G1_VTU_FID | \
  598. MV88E6XXX_FLAG_GLOBAL2 | \
  599. MV88E6XXX_FLAG_G2_INT | \
  600. MV88E6XXX_FLAG_G2_MGMT_EN_2X | \
  601. MV88E6XXX_FLAG_G2_MGMT_EN_0X | \
  602. MV88E6XXX_FLAG_G2_POT | \
  603. MV88E6XXX_FLAGS_IRL | \
  604. MV88E6XXX_FLAGS_MULTI_CHIP)
  605. #define MV88E6XXX_FLAGS_FAMILY_6352 \
  606. (MV88E6XXX_FLAG_EEE | \
  607. MV88E6XXX_FLAG_G1_VTU_FID | \
  608. MV88E6XXX_FLAG_GLOBAL2 | \
  609. MV88E6XXX_FLAG_G2_INT | \
  610. MV88E6XXX_FLAG_G2_MGMT_EN_2X | \
  611. MV88E6XXX_FLAG_G2_MGMT_EN_0X | \
  612. MV88E6XXX_FLAG_G2_POT | \
  613. MV88E6XXX_FLAGS_IRL | \
  614. MV88E6XXX_FLAGS_MULTI_CHIP | \
  615. MV88E6XXX_FLAGS_SERDES)
  616. #define MV88E6XXX_FLAGS_FAMILY_6390 \
  617. (MV88E6XXX_FLAG_EEE | \
  618. MV88E6XXX_FLAG_GLOBAL2 | \
  619. MV88E6XXX_FLAG_G2_INT | \
  620. MV88E6XXX_FLAGS_IRL | \
  621. MV88E6XXX_FLAGS_MULTI_CHIP)
  622. struct mv88e6xxx_ops;
  623. struct mv88e6xxx_info {
  624. enum mv88e6xxx_family family;
  625. u16 prod_num;
  626. const char *name;
  627. unsigned int num_databases;
  628. unsigned int num_ports;
  629. unsigned int max_vid;
  630. unsigned int port_base_addr;
  631. unsigned int global1_addr;
  632. unsigned int age_time_coeff;
  633. unsigned int g1_irqs;
  634. bool pvt;
  635. enum dsa_tag_protocol tag_protocol;
  636. unsigned long long flags;
  637. /* Mask for FromPort and ToPort value of PortVec used in ATU Move
  638. * operation. 0 means that the ATU Move operation is not supported.
  639. */
  640. u8 atu_move_port_mask;
  641. const struct mv88e6xxx_ops *ops;
  642. };
  643. struct mv88e6xxx_atu_entry {
  644. u8 state;
  645. bool trunk;
  646. u16 portvec;
  647. u8 mac[ETH_ALEN];
  648. };
  649. struct mv88e6xxx_vtu_entry {
  650. u16 vid;
  651. u16 fid;
  652. u8 sid;
  653. bool valid;
  654. u8 member[DSA_MAX_PORTS];
  655. u8 state[DSA_MAX_PORTS];
  656. };
  657. struct mv88e6xxx_bus_ops;
  658. struct mv88e6xxx_irq_ops;
  659. struct mv88e6xxx_irq {
  660. u16 masked;
  661. struct irq_chip chip;
  662. struct irq_domain *domain;
  663. unsigned int nirqs;
  664. };
  665. struct mv88e6xxx_chip {
  666. const struct mv88e6xxx_info *info;
  667. /* The dsa_switch this private structure is related to */
  668. struct dsa_switch *ds;
  669. /* The device this structure is associated to */
  670. struct device *dev;
  671. /* This mutex protects the access to the switch registers */
  672. struct mutex reg_lock;
  673. /* The MII bus and the address on the bus that is used to
  674. * communication with the switch
  675. */
  676. const struct mv88e6xxx_bus_ops *smi_ops;
  677. struct mii_bus *bus;
  678. int sw_addr;
  679. /* Handles automatic disabling and re-enabling of the PHY
  680. * polling unit.
  681. */
  682. const struct mv88e6xxx_bus_ops *phy_ops;
  683. struct mutex ppu_mutex;
  684. int ppu_disabled;
  685. struct work_struct ppu_work;
  686. struct timer_list ppu_timer;
  687. /* This mutex serialises access to the statistics unit.
  688. * Hold this mutex over snapshot + dump sequences.
  689. */
  690. struct mutex stats_mutex;
  691. /* A switch may have a GPIO line tied to its reset pin. Parse
  692. * this from the device tree, and use it before performing
  693. * switch soft reset.
  694. */
  695. struct gpio_desc *reset;
  696. /* set to size of eeprom if supported by the switch */
  697. int eeprom_len;
  698. /* List of mdio busses */
  699. struct list_head mdios;
  700. /* There can be two interrupt controllers, which are chained
  701. * off a GPIO as interrupt source
  702. */
  703. struct mv88e6xxx_irq g1_irq;
  704. struct mv88e6xxx_irq g2_irq;
  705. int irq;
  706. int device_irq;
  707. int watchdog_irq;
  708. };
  709. struct mv88e6xxx_bus_ops {
  710. int (*read)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
  711. int (*write)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
  712. };
  713. struct mv88e6xxx_mdio_bus {
  714. struct mii_bus *bus;
  715. struct mv88e6xxx_chip *chip;
  716. struct list_head list;
  717. bool external;
  718. };
  719. struct mv88e6xxx_ops {
  720. int (*get_eeprom)(struct mv88e6xxx_chip *chip,
  721. struct ethtool_eeprom *eeprom, u8 *data);
  722. int (*set_eeprom)(struct mv88e6xxx_chip *chip,
  723. struct ethtool_eeprom *eeprom, u8 *data);
  724. int (*set_switch_mac)(struct mv88e6xxx_chip *chip, u8 *addr);
  725. int (*phy_read)(struct mv88e6xxx_chip *chip,
  726. struct mii_bus *bus,
  727. int addr, int reg, u16 *val);
  728. int (*phy_write)(struct mv88e6xxx_chip *chip,
  729. struct mii_bus *bus,
  730. int addr, int reg, u16 val);
  731. /* PHY Polling Unit (PPU) operations */
  732. int (*ppu_enable)(struct mv88e6xxx_chip *chip);
  733. int (*ppu_disable)(struct mv88e6xxx_chip *chip);
  734. /* Switch Software Reset */
  735. int (*reset)(struct mv88e6xxx_chip *chip);
  736. /* RGMII Receive/Transmit Timing Control
  737. * Add delay on PHY_INTERFACE_MODE_RGMII_*ID, no delay otherwise.
  738. */
  739. int (*port_set_rgmii_delay)(struct mv88e6xxx_chip *chip, int port,
  740. phy_interface_t mode);
  741. #define LINK_FORCED_DOWN 0
  742. #define LINK_FORCED_UP 1
  743. #define LINK_UNFORCED -2
  744. /* Port's MAC link state
  745. * Use LINK_FORCED_UP or LINK_FORCED_DOWN to force link up or down,
  746. * or LINK_UNFORCED for normal link detection.
  747. */
  748. int (*port_set_link)(struct mv88e6xxx_chip *chip, int port, int link);
  749. #define DUPLEX_UNFORCED -2
  750. /* Port's MAC duplex mode
  751. *
  752. * Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex,
  753. * or DUPLEX_UNFORCED for normal duplex detection.
  754. */
  755. int (*port_set_duplex)(struct mv88e6xxx_chip *chip, int port, int dup);
  756. #define SPEED_MAX INT_MAX
  757. #define SPEED_UNFORCED -2
  758. /* Port's MAC speed (in Mbps)
  759. *
  760. * Depending on the chip, 10, 100, 200, 1000, 2500, 10000 are valid.
  761. * Use SPEED_UNFORCED for normal detection, SPEED_MAX for max value.
  762. */
  763. int (*port_set_speed)(struct mv88e6xxx_chip *chip, int port, int speed);
  764. int (*port_tag_remap)(struct mv88e6xxx_chip *chip, int port);
  765. int (*port_set_frame_mode)(struct mv88e6xxx_chip *chip, int port,
  766. enum mv88e6xxx_frame_mode mode);
  767. int (*port_set_egress_floods)(struct mv88e6xxx_chip *chip, int port,
  768. bool unicast, bool multicast);
  769. int (*port_set_ether_type)(struct mv88e6xxx_chip *chip, int port,
  770. u16 etype);
  771. int (*port_jumbo_config)(struct mv88e6xxx_chip *chip, int port);
  772. int (*port_egress_rate_limiting)(struct mv88e6xxx_chip *chip, int port);
  773. int (*port_pause_config)(struct mv88e6xxx_chip *chip, int port);
  774. int (*port_disable_learn_limit)(struct mv88e6xxx_chip *chip, int port);
  775. int (*port_disable_pri_override)(struct mv88e6xxx_chip *chip, int port);
  776. /* CMODE control what PHY mode the MAC will use, eg. SGMII, RGMII, etc.
  777. * Some chips allow this to be configured on specific ports.
  778. */
  779. int (*port_set_cmode)(struct mv88e6xxx_chip *chip, int port,
  780. phy_interface_t mode);
  781. /* Some devices have a per port register indicating what is
  782. * the upstream port this port should forward to.
  783. */
  784. int (*port_set_upstream_port)(struct mv88e6xxx_chip *chip, int port,
  785. int upstream_port);
  786. /* Snapshot the statistics for a port. The statistics can then
  787. * be read back a leisure but still with a consistent view.
  788. */
  789. int (*stats_snapshot)(struct mv88e6xxx_chip *chip, int port);
  790. /* Set the histogram mode for statistics, when the control registers
  791. * are separated out of the STATS_OP register.
  792. */
  793. int (*stats_set_histogram)(struct mv88e6xxx_chip *chip);
  794. /* Return the number of strings describing statistics */
  795. int (*stats_get_sset_count)(struct mv88e6xxx_chip *chip);
  796. void (*stats_get_strings)(struct mv88e6xxx_chip *chip, uint8_t *data);
  797. void (*stats_get_stats)(struct mv88e6xxx_chip *chip, int port,
  798. uint64_t *data);
  799. int (*g1_set_cpu_port)(struct mv88e6xxx_chip *chip, int port);
  800. int (*g1_set_egress_port)(struct mv88e6xxx_chip *chip, int port);
  801. const struct mv88e6xxx_irq_ops *watchdog_ops;
  802. /* Can be either in g1 or g2, so don't use a prefix */
  803. int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip);
  804. /* VLAN Translation Unit operations */
  805. int (*vtu_getnext)(struct mv88e6xxx_chip *chip,
  806. struct mv88e6xxx_vtu_entry *entry);
  807. int (*vtu_loadpurge)(struct mv88e6xxx_chip *chip,
  808. struct mv88e6xxx_vtu_entry *entry);
  809. };
  810. struct mv88e6xxx_irq_ops {
  811. /* Action to be performed when the interrupt happens */
  812. int (*irq_action)(struct mv88e6xxx_chip *chip, int irq);
  813. /* Setup the hardware to generate the interrupt */
  814. int (*irq_setup)(struct mv88e6xxx_chip *chip);
  815. /* Reset the hardware to stop generating the interrupt */
  816. void (*irq_free)(struct mv88e6xxx_chip *chip);
  817. };
  818. #define STATS_TYPE_PORT BIT(0)
  819. #define STATS_TYPE_BANK0 BIT(1)
  820. #define STATS_TYPE_BANK1 BIT(2)
  821. struct mv88e6xxx_hw_stat {
  822. char string[ETH_GSTRING_LEN];
  823. int sizeof_stat;
  824. int reg;
  825. int type;
  826. };
  827. static inline bool mv88e6xxx_has(struct mv88e6xxx_chip *chip,
  828. unsigned long flags)
  829. {
  830. return (chip->info->flags & flags) == flags;
  831. }
  832. static inline bool mv88e6xxx_has_pvt(struct mv88e6xxx_chip *chip)
  833. {
  834. return chip->info->pvt;
  835. }
  836. static inline unsigned int mv88e6xxx_num_databases(struct mv88e6xxx_chip *chip)
  837. {
  838. return chip->info->num_databases;
  839. }
  840. static inline unsigned int mv88e6xxx_num_ports(struct mv88e6xxx_chip *chip)
  841. {
  842. return chip->info->num_ports;
  843. }
  844. static inline u16 mv88e6xxx_port_mask(struct mv88e6xxx_chip *chip)
  845. {
  846. return GENMASK(mv88e6xxx_num_ports(chip) - 1, 0);
  847. }
  848. int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
  849. int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
  850. int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg,
  851. u16 update);
  852. int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask);
  853. #endif