ksz8795_reg.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Microchip KSZ8795 register definitions
  4. *
  5. * Copyright (c) 2017 Microchip Technology Inc.
  6. * Tristram Ha <[email protected]>
  7. */
  8. #ifndef __KSZ8795_REG_H
  9. #define __KSZ8795_REG_H
  10. #define KS_PORT_M 0x1F
  11. #define KS_PRIO_M 0x3
  12. #define KS_PRIO_S 2
  13. #define SW_REVISION_M 0x0E
  14. #define SW_REVISION_S 1
  15. #define KSZ8863_REG_SW_RESET 0x43
  16. #define KSZ8863_GLOBAL_SOFTWARE_RESET BIT(4)
  17. #define KSZ8863_PCS_RESET BIT(0)
  18. #define REG_SW_CTRL_0 0x02
  19. #define SW_NEW_BACKOFF BIT(7)
  20. #define SW_GLOBAL_RESET BIT(6)
  21. #define SW_FLUSH_DYN_MAC_TABLE BIT(5)
  22. #define SW_FLUSH_STA_MAC_TABLE BIT(4)
  23. #define SW_LINK_AUTO_AGING BIT(0)
  24. #define REG_SW_CTRL_1 0x03
  25. #define SW_HUGE_PACKET BIT(6)
  26. #define SW_TX_FLOW_CTRL_DISABLE BIT(5)
  27. #define SW_RX_FLOW_CTRL_DISABLE BIT(4)
  28. #define SW_CHECK_LENGTH BIT(3)
  29. #define SW_AGING_ENABLE BIT(2)
  30. #define SW_FAST_AGING BIT(1)
  31. #define SW_AGGR_BACKOFF BIT(0)
  32. #define REG_SW_CTRL_2 0x04
  33. #define UNICAST_VLAN_BOUNDARY BIT(7)
  34. #define SW_BACK_PRESSURE BIT(5)
  35. #define FAIR_FLOW_CTRL BIT(4)
  36. #define NO_EXC_COLLISION_DROP BIT(3)
  37. #define SW_LEGAL_PACKET_DISABLE BIT(1)
  38. #define REG_SW_CTRL_3 0x05
  39. #define WEIGHTED_FAIR_QUEUE_ENABLE BIT(3)
  40. #define SW_VLAN_ENABLE BIT(7)
  41. #define SW_IGMP_SNOOP BIT(6)
  42. #define SW_MIRROR_RX_TX BIT(0)
  43. #define REG_SW_CTRL_4 0x06
  44. #define SW_HALF_DUPLEX_FLOW_CTRL BIT(7)
  45. #define SW_HALF_DUPLEX BIT(6)
  46. #define SW_FLOW_CTRL BIT(5)
  47. #define SW_10_MBIT BIT(4)
  48. #define SW_REPLACE_VID BIT(3)
  49. #define REG_SW_CTRL_5 0x07
  50. #define REG_SW_CTRL_6 0x08
  51. #define SW_MIB_COUNTER_FLUSH BIT(7)
  52. #define SW_MIB_COUNTER_FREEZE BIT(6)
  53. #define SW_MIB_COUNTER_CTRL_ENABLE KS_PORT_M
  54. #define REG_SW_CTRL_9 0x0B
  55. #define SPI_CLK_125_MHZ 0x80
  56. #define SPI_CLK_62_5_MHZ 0x40
  57. #define SPI_CLK_31_25_MHZ 0x00
  58. #define SW_LED_MODE_M 0x3
  59. #define SW_LED_MODE_S 4
  60. #define SW_LED_LINK_ACT_SPEED 0
  61. #define SW_LED_LINK_ACT 1
  62. #define SW_LED_LINK_ACT_DUPLEX 2
  63. #define SW_LED_LINK_DUPLEX 3
  64. #define REG_SW_CTRL_10 0x0C
  65. #define SW_PASS_PAUSE BIT(0)
  66. #define REG_SW_CTRL_11 0x0D
  67. #define REG_POWER_MANAGEMENT_1 0x0E
  68. #define SW_PLL_POWER_DOWN BIT(5)
  69. #define SW_POWER_MANAGEMENT_MODE_M 0x3
  70. #define SW_POWER_MANAGEMENT_MODE_S 3
  71. #define SW_POWER_NORMAL 0
  72. #define SW_ENERGY_DETECTION 1
  73. #define SW_SOFTWARE_POWER_DOWN 2
  74. #define REG_POWER_MANAGEMENT_2 0x0F
  75. #define REG_PORT_1_CTRL_0 0x10
  76. #define REG_PORT_2_CTRL_0 0x20
  77. #define REG_PORT_3_CTRL_0 0x30
  78. #define REG_PORT_4_CTRL_0 0x40
  79. #define REG_PORT_5_CTRL_0 0x50
  80. #define PORT_BROADCAST_STORM BIT(7)
  81. #define PORT_DIFFSERV_ENABLE BIT(6)
  82. #define PORT_802_1P_ENABLE BIT(5)
  83. #define PORT_BASED_PRIO_S 3
  84. #define PORT_BASED_PRIO_M KS_PRIO_M
  85. #define PORT_BASED_PRIO_0 0
  86. #define PORT_BASED_PRIO_1 1
  87. #define PORT_BASED_PRIO_2 2
  88. #define PORT_BASED_PRIO_3 3
  89. #define PORT_INSERT_TAG BIT(2)
  90. #define PORT_REMOVE_TAG BIT(1)
  91. #define PORT_QUEUE_SPLIT_L BIT(0)
  92. #define REG_PORT_1_CTRL_1 0x11
  93. #define REG_PORT_2_CTRL_1 0x21
  94. #define REG_PORT_3_CTRL_1 0x31
  95. #define REG_PORT_4_CTRL_1 0x41
  96. #define REG_PORT_5_CTRL_1 0x51
  97. #define PORT_MIRROR_SNIFFER BIT(7)
  98. #define PORT_MIRROR_RX BIT(6)
  99. #define PORT_MIRROR_TX BIT(5)
  100. #define PORT_VLAN_MEMBERSHIP KS_PORT_M
  101. #define REG_PORT_1_CTRL_2 0x12
  102. #define REG_PORT_2_CTRL_2 0x22
  103. #define REG_PORT_3_CTRL_2 0x32
  104. #define REG_PORT_4_CTRL_2 0x42
  105. #define REG_PORT_5_CTRL_2 0x52
  106. #define PORT_INGRESS_FILTER BIT(6)
  107. #define PORT_DISCARD_NON_VID BIT(5)
  108. #define PORT_FORCE_FLOW_CTRL BIT(4)
  109. #define PORT_BACK_PRESSURE BIT(3)
  110. #define REG_PORT_1_CTRL_3 0x13
  111. #define REG_PORT_2_CTRL_3 0x23
  112. #define REG_PORT_3_CTRL_3 0x33
  113. #define REG_PORT_4_CTRL_3 0x43
  114. #define REG_PORT_5_CTRL_3 0x53
  115. #define REG_PORT_1_CTRL_4 0x14
  116. #define REG_PORT_2_CTRL_4 0x24
  117. #define REG_PORT_3_CTRL_4 0x34
  118. #define REG_PORT_4_CTRL_4 0x44
  119. #define REG_PORT_5_CTRL_4 0x54
  120. #define PORT_DEFAULT_VID 0x0001
  121. #define REG_PORT_1_CTRL_5 0x15
  122. #define REG_PORT_2_CTRL_5 0x25
  123. #define REG_PORT_3_CTRL_5 0x35
  124. #define REG_PORT_4_CTRL_5 0x45
  125. #define REG_PORT_5_CTRL_5 0x55
  126. #define PORT_ACL_ENABLE BIT(2)
  127. #define PORT_AUTHEN_MODE 0x3
  128. #define PORT_AUTHEN_PASS 0
  129. #define PORT_AUTHEN_BLOCK 1
  130. #define PORT_AUTHEN_TRAP 2
  131. #define REG_PORT_5_CTRL_6 0x56
  132. #define PORT_MII_INTERNAL_CLOCK BIT(7)
  133. #define PORT_GMII_MAC_MODE BIT(2)
  134. #define REG_PORT_1_CTRL_7 0x17
  135. #define REG_PORT_2_CTRL_7 0x27
  136. #define REG_PORT_3_CTRL_7 0x37
  137. #define REG_PORT_4_CTRL_7 0x47
  138. #define PORT_AUTO_NEG_ASYM_PAUSE BIT(5)
  139. #define PORT_AUTO_NEG_SYM_PAUSE BIT(4)
  140. #define PORT_AUTO_NEG_100BTX_FD BIT(3)
  141. #define PORT_AUTO_NEG_100BTX BIT(2)
  142. #define PORT_AUTO_NEG_10BT_FD BIT(1)
  143. #define PORT_AUTO_NEG_10BT BIT(0)
  144. #define REG_PORT_1_STATUS_0 0x18
  145. #define REG_PORT_2_STATUS_0 0x28
  146. #define REG_PORT_3_STATUS_0 0x38
  147. #define REG_PORT_4_STATUS_0 0x48
  148. /* For KSZ8765. */
  149. #define PORT_REMOTE_ASYM_PAUSE BIT(5)
  150. #define PORT_REMOTE_SYM_PAUSE BIT(4)
  151. #define PORT_REMOTE_100BTX_FD BIT(3)
  152. #define PORT_REMOTE_100BTX BIT(2)
  153. #define PORT_REMOTE_10BT_FD BIT(1)
  154. #define PORT_REMOTE_10BT BIT(0)
  155. #define REG_PORT_1_STATUS_1 0x19
  156. #define REG_PORT_2_STATUS_1 0x29
  157. #define REG_PORT_3_STATUS_1 0x39
  158. #define REG_PORT_4_STATUS_1 0x49
  159. #define PORT_HP_MDIX BIT(7)
  160. #define PORT_REVERSED_POLARITY BIT(5)
  161. #define PORT_TX_FLOW_CTRL BIT(4)
  162. #define PORT_RX_FLOW_CTRL BIT(3)
  163. #define PORT_STAT_SPEED_100MBIT BIT(2)
  164. #define PORT_STAT_FULL_DUPLEX BIT(1)
  165. #define PORT_REMOTE_FAULT BIT(0)
  166. #define REG_PORT_1_LINK_MD_CTRL 0x1A
  167. #define REG_PORT_2_LINK_MD_CTRL 0x2A
  168. #define REG_PORT_3_LINK_MD_CTRL 0x3A
  169. #define REG_PORT_4_LINK_MD_CTRL 0x4A
  170. #define PORT_CABLE_10M_SHORT BIT(7)
  171. #define PORT_CABLE_DIAG_RESULT_M GENMASK(6, 5)
  172. #define PORT_CABLE_DIAG_RESULT_S 5
  173. #define PORT_CABLE_STAT_NORMAL 0
  174. #define PORT_CABLE_STAT_OPEN 1
  175. #define PORT_CABLE_STAT_SHORT 2
  176. #define PORT_CABLE_STAT_FAILED 3
  177. #define PORT_START_CABLE_DIAG BIT(4)
  178. #define PORT_FORCE_LINK BIT(3)
  179. #define PORT_POWER_SAVING BIT(2)
  180. #define PORT_PHY_REMOTE_LOOPBACK BIT(1)
  181. #define PORT_CABLE_FAULT_COUNTER_H 0x01
  182. #define REG_PORT_1_LINK_MD_RESULT 0x1B
  183. #define REG_PORT_2_LINK_MD_RESULT 0x2B
  184. #define REG_PORT_3_LINK_MD_RESULT 0x3B
  185. #define REG_PORT_4_LINK_MD_RESULT 0x4B
  186. #define PORT_CABLE_FAULT_COUNTER_L 0xFF
  187. #define PORT_CABLE_FAULT_COUNTER 0x1FF
  188. #define REG_PORT_1_CTRL_9 0x1C
  189. #define REG_PORT_2_CTRL_9 0x2C
  190. #define REG_PORT_3_CTRL_9 0x3C
  191. #define REG_PORT_4_CTRL_9 0x4C
  192. #define PORT_AUTO_NEG_ENABLE BIT(7)
  193. #define PORT_AUTO_NEG_DISABLE BIT(7)
  194. #define PORT_FORCE_100_MBIT BIT(6)
  195. #define PORT_FORCE_FULL_DUPLEX BIT(5)
  196. #define REG_PORT_1_CTRL_10 0x1D
  197. #define REG_PORT_2_CTRL_10 0x2D
  198. #define REG_PORT_3_CTRL_10 0x3D
  199. #define REG_PORT_4_CTRL_10 0x4D
  200. #define PORT_LED_OFF BIT(7)
  201. #define PORT_TX_DISABLE BIT(6)
  202. #define PORT_AUTO_NEG_RESTART BIT(5)
  203. #define PORT_POWER_DOWN BIT(3)
  204. #define PORT_AUTO_MDIX_DISABLE BIT(2)
  205. #define PORT_FORCE_MDIX BIT(1)
  206. #define PORT_MAC_LOOPBACK BIT(0)
  207. #define REG_PORT_1_STATUS_2 0x1E
  208. #define REG_PORT_2_STATUS_2 0x2E
  209. #define REG_PORT_3_STATUS_2 0x3E
  210. #define REG_PORT_4_STATUS_2 0x4E
  211. #define PORT_MDIX_STATUS BIT(7)
  212. #define PORT_AUTO_NEG_COMPLETE BIT(6)
  213. #define PORT_STAT_LINK_GOOD BIT(5)
  214. #define REG_PORT_1_STATUS_3 0x1F
  215. #define REG_PORT_2_STATUS_3 0x2F
  216. #define REG_PORT_3_STATUS_3 0x3F
  217. #define REG_PORT_4_STATUS_3 0x4F
  218. #define PORT_PHY_LOOPBACK BIT(7)
  219. #define PORT_PHY_ISOLATE BIT(5)
  220. #define PORT_PHY_SOFT_RESET BIT(4)
  221. #define PORT_PHY_FORCE_LINK BIT(3)
  222. #define PORT_PHY_MODE_M 0x7
  223. #define PHY_MODE_IN_AUTO_NEG 1
  224. #define PHY_MODE_10BT_HALF 2
  225. #define PHY_MODE_100BT_HALF 3
  226. #define PHY_MODE_10BT_FULL 5
  227. #define PHY_MODE_100BT_FULL 6
  228. #define PHY_MODE_ISOLDATE 7
  229. #define REG_PORT_CTRL_0 0x00
  230. #define REG_PORT_CTRL_1 0x01
  231. #define REG_PORT_CTRL_2 0x02
  232. #define REG_PORT_CTRL_VID 0x03
  233. #define REG_PORT_CTRL_5 0x05
  234. #define REG_PORT_STATUS_1 0x09
  235. #define REG_PORT_LINK_MD_CTRL 0x0A
  236. #define REG_PORT_LINK_MD_RESULT 0x0B
  237. #define REG_PORT_CTRL_9 0x0C
  238. #define REG_PORT_CTRL_10 0x0D
  239. #define REG_PORT_STATUS_3 0x0F
  240. #define REG_PORT_CTRL_12 0xA0
  241. #define REG_PORT_CTRL_13 0xA1
  242. #define REG_PORT_RATE_CTRL_3 0xA2
  243. #define REG_PORT_RATE_CTRL_2 0xA3
  244. #define REG_PORT_RATE_CTRL_1 0xA4
  245. #define REG_PORT_RATE_CTRL_0 0xA5
  246. #define REG_PORT_RATE_LIMIT 0xA6
  247. #define REG_PORT_IN_RATE_0 0xA7
  248. #define REG_PORT_IN_RATE_1 0xA8
  249. #define REG_PORT_IN_RATE_2 0xA9
  250. #define REG_PORT_IN_RATE_3 0xAA
  251. #define REG_PORT_OUT_RATE_0 0xAB
  252. #define REG_PORT_OUT_RATE_1 0xAC
  253. #define REG_PORT_OUT_RATE_2 0xAD
  254. #define REG_PORT_OUT_RATE_3 0xAE
  255. #define PORT_CTRL_ADDR(port, addr) \
  256. ((addr) + REG_PORT_1_CTRL_0 + (port) * \
  257. (REG_PORT_2_CTRL_0 - REG_PORT_1_CTRL_0))
  258. #define REG_SW_MAC_ADDR_0 0x68
  259. #define REG_SW_MAC_ADDR_1 0x69
  260. #define REG_SW_MAC_ADDR_2 0x6A
  261. #define REG_SW_MAC_ADDR_3 0x6B
  262. #define REG_SW_MAC_ADDR_4 0x6C
  263. #define REG_SW_MAC_ADDR_5 0x6D
  264. #define TABLE_EXT_SELECT_S 5
  265. #define TABLE_EEE_V 1
  266. #define TABLE_ACL_V 2
  267. #define TABLE_PME_V 4
  268. #define TABLE_LINK_MD_V 5
  269. #define TABLE_EEE (TABLE_EEE_V << TABLE_EXT_SELECT_S)
  270. #define TABLE_ACL (TABLE_ACL_V << TABLE_EXT_SELECT_S)
  271. #define TABLE_PME (TABLE_PME_V << TABLE_EXT_SELECT_S)
  272. #define TABLE_LINK_MD (TABLE_LINK_MD << TABLE_EXT_SELECT_S)
  273. #define TABLE_READ BIT(4)
  274. #define TABLE_SELECT_S 2
  275. #define TABLE_STATIC_MAC_V 0
  276. #define TABLE_VLAN_V 1
  277. #define TABLE_DYNAMIC_MAC_V 2
  278. #define TABLE_MIB_V 3
  279. #define TABLE_STATIC_MAC (TABLE_STATIC_MAC_V << TABLE_SELECT_S)
  280. #define TABLE_VLAN (TABLE_VLAN_V << TABLE_SELECT_S)
  281. #define TABLE_DYNAMIC_MAC (TABLE_DYNAMIC_MAC_V << TABLE_SELECT_S)
  282. #define TABLE_MIB (TABLE_MIB_V << TABLE_SELECT_S)
  283. #define REG_IND_CTRL_1 0x6F
  284. #define TABLE_ENTRY_MASK 0x03FF
  285. #define TABLE_EXT_ENTRY_MASK 0x0FFF
  286. #define REG_IND_DATA_5 0x73
  287. #define REG_IND_DATA_2 0x76
  288. #define REG_IND_DATA_1 0x77
  289. #define REG_IND_DATA_0 0x78
  290. #define REG_IND_DATA_PME_EEE_ACL 0xA0
  291. #define REG_INT_STATUS 0x7C
  292. #define REG_INT_ENABLE 0x7D
  293. #define INT_PME BIT(4)
  294. #define REG_ACL_INT_STATUS 0x7E
  295. #define REG_ACL_INT_ENABLE 0x7F
  296. #define INT_PORT_5 BIT(4)
  297. #define INT_PORT_4 BIT(3)
  298. #define INT_PORT_3 BIT(2)
  299. #define INT_PORT_2 BIT(1)
  300. #define INT_PORT_1 BIT(0)
  301. #define INT_PORT_ALL \
  302. (INT_PORT_5 | INT_PORT_4 | INT_PORT_3 | INT_PORT_2 | INT_PORT_1)
  303. #define REG_SW_CTRL_12 0x80
  304. #define REG_SW_CTRL_13 0x81
  305. #define SWITCH_802_1P_MASK 3
  306. #define SWITCH_802_1P_BASE 3
  307. #define SWITCH_802_1P_SHIFT 2
  308. #define SW_802_1P_MAP_M KS_PRIO_M
  309. #define SW_802_1P_MAP_S KS_PRIO_S
  310. #define REG_SWITCH_CTRL_14 0x82
  311. #define SW_PRIO_MAPPING_M KS_PRIO_M
  312. #define SW_PRIO_MAPPING_S 6
  313. #define SW_PRIO_MAP_3_HI 0
  314. #define SW_PRIO_MAP_2_HI 2
  315. #define SW_PRIO_MAP_0_LO 3
  316. #define REG_SW_CTRL_15 0x83
  317. #define REG_SW_CTRL_16 0x84
  318. #define REG_SW_CTRL_17 0x85
  319. #define REG_SW_CTRL_18 0x86
  320. #define SW_SELF_ADDR_FILTER_ENABLE BIT(6)
  321. #define REG_SW_UNK_UCAST_CTRL 0x83
  322. #define REG_SW_UNK_MCAST_CTRL 0x84
  323. #define REG_SW_UNK_VID_CTRL 0x85
  324. #define REG_SW_UNK_IP_MCAST_CTRL 0x86
  325. #define SW_UNK_FWD_ENABLE BIT(5)
  326. #define SW_UNK_FWD_MAP KS_PORT_M
  327. #define REG_SW_CTRL_19 0x87
  328. #define SW_IN_RATE_LIMIT_PERIOD_M 0x3
  329. #define SW_IN_RATE_LIMIT_PERIOD_S 4
  330. #define SW_IN_RATE_LIMIT_16_MS 0
  331. #define SW_IN_RATE_LIMIT_64_MS 1
  332. #define SW_IN_RATE_LIMIT_256_MS 2
  333. #define SW_OUT_RATE_LIMIT_QUEUE_BASED BIT(3)
  334. #define SW_INS_TAG_ENABLE BIT(2)
  335. #define REG_TOS_PRIO_CTRL_0 0x90
  336. #define REG_TOS_PRIO_CTRL_1 0x91
  337. #define REG_TOS_PRIO_CTRL_2 0x92
  338. #define REG_TOS_PRIO_CTRL_3 0x93
  339. #define REG_TOS_PRIO_CTRL_4 0x94
  340. #define REG_TOS_PRIO_CTRL_5 0x95
  341. #define REG_TOS_PRIO_CTRL_6 0x96
  342. #define REG_TOS_PRIO_CTRL_7 0x97
  343. #define REG_TOS_PRIO_CTRL_8 0x98
  344. #define REG_TOS_PRIO_CTRL_9 0x99
  345. #define REG_TOS_PRIO_CTRL_10 0x9A
  346. #define REG_TOS_PRIO_CTRL_11 0x9B
  347. #define REG_TOS_PRIO_CTRL_12 0x9C
  348. #define REG_TOS_PRIO_CTRL_13 0x9D
  349. #define REG_TOS_PRIO_CTRL_14 0x9E
  350. #define REG_TOS_PRIO_CTRL_15 0x9F
  351. #define TOS_PRIO_M KS_PRIO_M
  352. #define TOS_PRIO_S KS_PRIO_S
  353. #define REG_SW_CTRL_20 0xA3
  354. #define SW_GMII_DRIVE_STRENGTH_S 4
  355. #define SW_DRIVE_STRENGTH_M 0x7
  356. #define SW_DRIVE_STRENGTH_2MA 0
  357. #define SW_DRIVE_STRENGTH_4MA 1
  358. #define SW_DRIVE_STRENGTH_8MA 2
  359. #define SW_DRIVE_STRENGTH_12MA 3
  360. #define SW_DRIVE_STRENGTH_16MA 4
  361. #define SW_DRIVE_STRENGTH_20MA 5
  362. #define SW_DRIVE_STRENGTH_24MA 6
  363. #define SW_DRIVE_STRENGTH_28MA 7
  364. #define SW_MII_DRIVE_STRENGTH_S 0
  365. #define REG_SW_CTRL_21 0xA4
  366. #define SW_IPV6_MLD_OPTION BIT(3)
  367. #define SW_IPV6_MLD_SNOOP BIT(2)
  368. #define REG_PORT_1_CTRL_12 0xB0
  369. #define REG_PORT_2_CTRL_12 0xC0
  370. #define REG_PORT_3_CTRL_12 0xD0
  371. #define REG_PORT_4_CTRL_12 0xE0
  372. #define REG_PORT_5_CTRL_12 0xF0
  373. #define PORT_PASS_ALL BIT(6)
  374. #define PORT_INS_TAG_FOR_PORT_5_S 3
  375. #define PORT_INS_TAG_FOR_PORT_5 BIT(3)
  376. #define PORT_INS_TAG_FOR_PORT_4 BIT(2)
  377. #define PORT_INS_TAG_FOR_PORT_3 BIT(1)
  378. #define PORT_INS_TAG_FOR_PORT_2 BIT(0)
  379. #define REG_PORT_1_CTRL_13 0xB1
  380. #define REG_PORT_2_CTRL_13 0xC1
  381. #define REG_PORT_3_CTRL_13 0xD1
  382. #define REG_PORT_4_CTRL_13 0xE1
  383. #define REG_PORT_5_CTRL_13 0xF1
  384. #define PORT_QUEUE_SPLIT_H BIT(1)
  385. #define PORT_QUEUE_SPLIT_1 0
  386. #define PORT_QUEUE_SPLIT_2 1
  387. #define PORT_QUEUE_SPLIT_4 2
  388. #define PORT_DROP_TAG BIT(0)
  389. #define REG_PORT_1_CTRL_14 0xB2
  390. #define REG_PORT_2_CTRL_14 0xC2
  391. #define REG_PORT_3_CTRL_14 0xD2
  392. #define REG_PORT_4_CTRL_14 0xE2
  393. #define REG_PORT_5_CTRL_14 0xF2
  394. #define REG_PORT_1_CTRL_15 0xB3
  395. #define REG_PORT_2_CTRL_15 0xC3
  396. #define REG_PORT_3_CTRL_15 0xD3
  397. #define REG_PORT_4_CTRL_15 0xE3
  398. #define REG_PORT_5_CTRL_15 0xF3
  399. #define REG_PORT_1_CTRL_16 0xB4
  400. #define REG_PORT_2_CTRL_16 0xC4
  401. #define REG_PORT_3_CTRL_16 0xD4
  402. #define REG_PORT_4_CTRL_16 0xE4
  403. #define REG_PORT_5_CTRL_16 0xF4
  404. #define REG_PORT_1_CTRL_17 0xB5
  405. #define REG_PORT_2_CTRL_17 0xC5
  406. #define REG_PORT_3_CTRL_17 0xD5
  407. #define REG_PORT_4_CTRL_17 0xE5
  408. #define REG_PORT_5_CTRL_17 0xF5
  409. #define REG_PORT_1_RATE_CTRL_3 0xB2
  410. #define REG_PORT_1_RATE_CTRL_2 0xB3
  411. #define REG_PORT_1_RATE_CTRL_1 0xB4
  412. #define REG_PORT_1_RATE_CTRL_0 0xB5
  413. #define REG_PORT_2_RATE_CTRL_3 0xC2
  414. #define REG_PORT_2_RATE_CTRL_2 0xC3
  415. #define REG_PORT_2_RATE_CTRL_1 0xC4
  416. #define REG_PORT_2_RATE_CTRL_0 0xC5
  417. #define REG_PORT_3_RATE_CTRL_3 0xD2
  418. #define REG_PORT_3_RATE_CTRL_2 0xD3
  419. #define REG_PORT_3_RATE_CTRL_1 0xD4
  420. #define REG_PORT_3_RATE_CTRL_0 0xD5
  421. #define REG_PORT_4_RATE_CTRL_3 0xE2
  422. #define REG_PORT_4_RATE_CTRL_2 0xE3
  423. #define REG_PORT_4_RATE_CTRL_1 0xE4
  424. #define REG_PORT_4_RATE_CTRL_0 0xE5
  425. #define REG_PORT_5_RATE_CTRL_3 0xF2
  426. #define REG_PORT_5_RATE_CTRL_2 0xF3
  427. #define REG_PORT_5_RATE_CTRL_1 0xF4
  428. #define REG_PORT_5_RATE_CTRL_0 0xF5
  429. #define RATE_CTRL_ENABLE BIT(7)
  430. #define RATE_RATIO_M (BIT(7) - 1)
  431. #define PORT_OUT_RATE_ENABLE BIT(7)
  432. #define REG_PORT_1_RATE_LIMIT 0xB6
  433. #define REG_PORT_2_RATE_LIMIT 0xC6
  434. #define REG_PORT_3_RATE_LIMIT 0xD6
  435. #define REG_PORT_4_RATE_LIMIT 0xE6
  436. #define REG_PORT_5_RATE_LIMIT 0xF6
  437. #define PORT_IN_PORT_BASED_S 6
  438. #define PORT_RATE_PACKET_BASED_S 5
  439. #define PORT_IN_FLOW_CTRL_S 4
  440. #define PORT_IN_LIMIT_MODE_M 0x3
  441. #define PORT_IN_LIMIT_MODE_S 2
  442. #define PORT_COUNT_IFG_S 1
  443. #define PORT_COUNT_PREAMBLE_S 0
  444. #define PORT_IN_PORT_BASED BIT(PORT_IN_PORT_BASED_S)
  445. #define PORT_RATE_PACKET_BASED BIT(PORT_RATE_PACKET_BASED_S)
  446. #define PORT_IN_FLOW_CTRL BIT(PORT_IN_FLOW_CTRL_S)
  447. #define PORT_IN_ALL 0
  448. #define PORT_IN_UNICAST 1
  449. #define PORT_IN_MULTICAST 2
  450. #define PORT_IN_BROADCAST 3
  451. #define PORT_COUNT_IFG BIT(PORT_COUNT_IFG_S)
  452. #define PORT_COUNT_PREAMBLE BIT(PORT_COUNT_PREAMBLE_S)
  453. #define REG_PORT_1_IN_RATE_0 0xB7
  454. #define REG_PORT_2_IN_RATE_0 0xC7
  455. #define REG_PORT_3_IN_RATE_0 0xD7
  456. #define REG_PORT_4_IN_RATE_0 0xE7
  457. #define REG_PORT_5_IN_RATE_0 0xF7
  458. #define REG_PORT_1_IN_RATE_1 0xB8
  459. #define REG_PORT_2_IN_RATE_1 0xC8
  460. #define REG_PORT_3_IN_RATE_1 0xD8
  461. #define REG_PORT_4_IN_RATE_1 0xE8
  462. #define REG_PORT_5_IN_RATE_1 0xF8
  463. #define REG_PORT_1_IN_RATE_2 0xB9
  464. #define REG_PORT_2_IN_RATE_2 0xC9
  465. #define REG_PORT_3_IN_RATE_2 0xD9
  466. #define REG_PORT_4_IN_RATE_2 0xE9
  467. #define REG_PORT_5_IN_RATE_2 0xF9
  468. #define REG_PORT_1_IN_RATE_3 0xBA
  469. #define REG_PORT_2_IN_RATE_3 0xCA
  470. #define REG_PORT_3_IN_RATE_3 0xDA
  471. #define REG_PORT_4_IN_RATE_3 0xEA
  472. #define REG_PORT_5_IN_RATE_3 0xFA
  473. #define PORT_IN_RATE_ENABLE BIT(7)
  474. #define PORT_RATE_LIMIT_M (BIT(7) - 1)
  475. #define REG_PORT_1_OUT_RATE_0 0xBB
  476. #define REG_PORT_2_OUT_RATE_0 0xCB
  477. #define REG_PORT_3_OUT_RATE_0 0xDB
  478. #define REG_PORT_4_OUT_RATE_0 0xEB
  479. #define REG_PORT_5_OUT_RATE_0 0xFB
  480. #define REG_PORT_1_OUT_RATE_1 0xBC
  481. #define REG_PORT_2_OUT_RATE_1 0xCC
  482. #define REG_PORT_3_OUT_RATE_1 0xDC
  483. #define REG_PORT_4_OUT_RATE_1 0xEC
  484. #define REG_PORT_5_OUT_RATE_1 0xFC
  485. #define REG_PORT_1_OUT_RATE_2 0xBD
  486. #define REG_PORT_2_OUT_RATE_2 0xCD
  487. #define REG_PORT_3_OUT_RATE_2 0xDD
  488. #define REG_PORT_4_OUT_RATE_2 0xED
  489. #define REG_PORT_5_OUT_RATE_2 0xFD
  490. #define REG_PORT_1_OUT_RATE_3 0xBE
  491. #define REG_PORT_2_OUT_RATE_3 0xCE
  492. #define REG_PORT_3_OUT_RATE_3 0xDE
  493. #define REG_PORT_4_OUT_RATE_3 0xEE
  494. #define REG_PORT_5_OUT_RATE_3 0xFE
  495. /* 88x3 specific */
  496. #define REG_SW_INSERT_SRC_PVID 0xC2
  497. /* PME */
  498. #define SW_PME_OUTPUT_ENABLE BIT(1)
  499. #define SW_PME_ACTIVE_HIGH BIT(0)
  500. #define PORT_MAGIC_PACKET_DETECT BIT(2)
  501. #define PORT_LINK_UP_DETECT BIT(1)
  502. #define PORT_ENERGY_DETECT BIT(0)
  503. /* ACL */
  504. #define ACL_FIRST_RULE_M 0xF
  505. #define ACL_MODE_M 0x3
  506. #define ACL_MODE_S 4
  507. #define ACL_MODE_DISABLE 0
  508. #define ACL_MODE_LAYER_2 1
  509. #define ACL_MODE_LAYER_3 2
  510. #define ACL_MODE_LAYER_4 3
  511. #define ACL_ENABLE_M 0x3
  512. #define ACL_ENABLE_S 2
  513. #define ACL_ENABLE_2_COUNT 0
  514. #define ACL_ENABLE_2_TYPE 1
  515. #define ACL_ENABLE_2_MAC 2
  516. #define ACL_ENABLE_2_BOTH 3
  517. #define ACL_ENABLE_3_IP 1
  518. #define ACL_ENABLE_3_SRC_DST_COMP 2
  519. #define ACL_ENABLE_4_PROTOCOL 0
  520. #define ACL_ENABLE_4_TCP_PORT_COMP 1
  521. #define ACL_ENABLE_4_UDP_PORT_COMP 2
  522. #define ACL_ENABLE_4_TCP_SEQN_COMP 3
  523. #define ACL_SRC BIT(1)
  524. #define ACL_EQUAL BIT(0)
  525. #define ACL_MAX_PORT 0xFFFF
  526. #define ACL_MIN_PORT 0xFFFF
  527. #define ACL_IP_ADDR 0xFFFFFFFF
  528. #define ACL_TCP_SEQNUM 0xFFFFFFFF
  529. #define ACL_RESERVED 0xF8
  530. #define ACL_PORT_MODE_M 0x3
  531. #define ACL_PORT_MODE_S 1
  532. #define ACL_PORT_MODE_DISABLE 0
  533. #define ACL_PORT_MODE_EITHER 1
  534. #define ACL_PORT_MODE_IN_RANGE 2
  535. #define ACL_PORT_MODE_OUT_OF_RANGE 3
  536. #define ACL_TCP_FLAG_ENABLE BIT(0)
  537. #define ACL_TCP_FLAG_M 0xFF
  538. #define ACL_TCP_FLAG 0xFF
  539. #define ACL_ETH_TYPE 0xFFFF
  540. #define ACL_IP_M 0xFFFFFFFF
  541. #define ACL_PRIO_MODE_M 0x3
  542. #define ACL_PRIO_MODE_S 6
  543. #define ACL_PRIO_MODE_DISABLE 0
  544. #define ACL_PRIO_MODE_HIGHER 1
  545. #define ACL_PRIO_MODE_LOWER 2
  546. #define ACL_PRIO_MODE_REPLACE 3
  547. #define ACL_PRIO_M 0x7
  548. #define ACL_PRIO_S 3
  549. #define ACL_VLAN_PRIO_REPLACE BIT(2)
  550. #define ACL_VLAN_PRIO_M 0x7
  551. #define ACL_VLAN_PRIO_HI_M 0x3
  552. #define ACL_VLAN_PRIO_LO_M 0x8
  553. #define ACL_VLAN_PRIO_S 7
  554. #define ACL_MAP_MODE_M 0x3
  555. #define ACL_MAP_MODE_S 5
  556. #define ACL_MAP_MODE_DISABLE 0
  557. #define ACL_MAP_MODE_OR 1
  558. #define ACL_MAP_MODE_AND 2
  559. #define ACL_MAP_MODE_REPLACE 3
  560. #define ACL_MAP_PORT_M 0x1F
  561. #define ACL_CNT_M (BIT(11) - 1)
  562. #define ACL_CNT_S 5
  563. #define ACL_MSEC_UNIT BIT(4)
  564. #define ACL_INTR_MODE BIT(3)
  565. #define REG_PORT_ACL_BYTE_EN_MSB 0x10
  566. #define ACL_BYTE_EN_MSB_M 0x3F
  567. #define REG_PORT_ACL_BYTE_EN_LSB 0x11
  568. #define ACL_ACTION_START 0xA
  569. #define ACL_ACTION_LEN 2
  570. #define ACL_INTR_CNT_START 0xB
  571. #define ACL_RULESET_START 0xC
  572. #define ACL_RULESET_LEN 2
  573. #define ACL_TABLE_LEN 14
  574. #define ACL_ACTION_ENABLE 0x000C
  575. #define ACL_MATCH_ENABLE 0x1FF0
  576. #define ACL_RULESET_ENABLE 0x2003
  577. #define ACL_BYTE_ENABLE ((ACL_BYTE_EN_MSB_M << 8) | 0xFF)
  578. #define ACL_MODE_ENABLE (0x10 << 8)
  579. #define REG_PORT_ACL_CTRL_0 0x12
  580. #define PORT_ACL_WRITE_DONE BIT(6)
  581. #define PORT_ACL_READ_DONE BIT(5)
  582. #define PORT_ACL_WRITE BIT(4)
  583. #define PORT_ACL_INDEX_M 0xF
  584. #define REG_PORT_ACL_CTRL_1 0x13
  585. #define PORT_ACL_FORCE_DLR_MISS BIT(0)
  586. #define KSZ8795_ID_HI 0x0022
  587. #define KSZ8795_ID_LO 0x1550
  588. #define KSZ8863_ID_LO 0x1430
  589. #define KSZ8795_SW_ID 0x8795
  590. #define PHY_REG_LINK_MD 0x1D
  591. #define PHY_START_CABLE_DIAG BIT(15)
  592. #define PHY_CABLE_DIAG_RESULT_M GENMASK(14, 13)
  593. #define PHY_CABLE_DIAG_RESULT 0x6000
  594. #define PHY_CABLE_STAT_NORMAL 0x0000
  595. #define PHY_CABLE_STAT_OPEN 0x2000
  596. #define PHY_CABLE_STAT_SHORT 0x4000
  597. #define PHY_CABLE_STAT_FAILED 0x6000
  598. #define PHY_CABLE_10M_SHORT BIT(12)
  599. #define PHY_CABLE_FAULT_COUNTER_M GENMASK(8, 0)
  600. #define PHY_REG_PHY_CTRL 0x1F
  601. #define PHY_MODE_M 0x7
  602. #define PHY_MODE_S 8
  603. #define PHY_STAT_REVERSED_POLARITY BIT(5)
  604. #define PHY_STAT_MDIX BIT(4)
  605. #define PHY_FORCE_LINK BIT(3)
  606. #define PHY_POWER_SAVING_ENABLE BIT(2)
  607. #define PHY_REMOTE_LOOPBACK BIT(1)
  608. /* Chip resource */
  609. #define PRIO_QUEUES 4
  610. #define KS_PRIO_IN_REG 4
  611. #define MIB_COUNTER_NUM 0x20
  612. /* Common names used by other drivers */
  613. #define P_BCAST_STORM_CTRL REG_PORT_CTRL_0
  614. #define P_PRIO_CTRL REG_PORT_CTRL_0
  615. #define P_TAG_CTRL REG_PORT_CTRL_0
  616. #define P_MIRROR_CTRL REG_PORT_CTRL_1
  617. #define P_802_1P_CTRL REG_PORT_CTRL_2
  618. #define P_PASS_ALL_CTRL REG_PORT_CTRL_12
  619. #define P_INS_SRC_PVID_CTRL REG_PORT_CTRL_12
  620. #define P_DROP_TAG_CTRL REG_PORT_CTRL_13
  621. #define P_RATE_LIMIT_CTRL REG_PORT_RATE_LIMIT
  622. #define S_UNKNOWN_DA_CTRL REG_SWITCH_CTRL_12
  623. #define S_FORWARD_INVALID_VID_CTRL REG_FORWARD_INVALID_VID
  624. #define S_FLUSH_TABLE_CTRL REG_SW_CTRL_0
  625. #define S_LINK_AGING_CTRL REG_SW_CTRL_0
  626. #define S_HUGE_PACKET_CTRL REG_SW_CTRL_1
  627. #define S_MIRROR_CTRL REG_SW_CTRL_3
  628. #define S_REPLACE_VID_CTRL REG_SW_CTRL_4
  629. #define S_PASS_PAUSE_CTRL REG_SW_CTRL_10
  630. #define S_802_1P_PRIO_CTRL REG_SW_CTRL_12
  631. #define S_TOS_PRIO_CTRL REG_TOS_PRIO_CTRL_0
  632. #define S_IPV6_MLD_CTRL REG_SW_CTRL_21
  633. #define IND_ACC_TABLE(table) ((table) << 8)
  634. /* */
  635. #define REG_IND_EEE_GLOB2_LO 0x34
  636. #define REG_IND_EEE_GLOB2_HI 0x35
  637. /**
  638. * MIB_COUNTER_VALUE 00-00000000-3FFFFFFF
  639. * MIB_TOTAL_BYTES 00-0000000F-FFFFFFFF
  640. * MIB_PACKET_DROPPED 00-00000000-0000FFFF
  641. * MIB_COUNTER_VALID 00-00000020-00000000
  642. * MIB_COUNTER_OVERFLOW 00-00000040-00000000
  643. */
  644. #define MIB_COUNTER_VALUE 0x3FFFFFFF
  645. #define KSZ8795_MIB_TOTAL_RX_0 0x100
  646. #define KSZ8795_MIB_TOTAL_TX_0 0x101
  647. #define KSZ8795_MIB_TOTAL_RX_1 0x104
  648. #define KSZ8795_MIB_TOTAL_TX_1 0x105
  649. #define KSZ8863_MIB_PACKET_DROPPED_TX_0 0x100
  650. #define KSZ8863_MIB_PACKET_DROPPED_RX_0 0x105
  651. #define MIB_PACKET_DROPPED 0x0000FFFF
  652. #define MIB_TOTAL_BYTES_H 0x0000000F
  653. #define TAIL_TAG_OVERRIDE BIT(6)
  654. #define TAIL_TAG_LOOKUP BIT(7)
  655. #define FID_ENTRIES 128
  656. #endif