ksz9477_reg.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Microchip KSZ9477 register definitions
  4. *
  5. * Copyright (C) 2017-2018 Microchip Technology Inc.
  6. */
  7. #ifndef __KSZ9477_REGS_H
  8. #define __KSZ9477_REGS_H
  9. #define KS_PRIO_M 0x7
  10. #define KS_PRIO_S 4
  11. /* 0 - Operation */
  12. #define REG_CHIP_ID0__1 0x0000
  13. #define REG_CHIP_ID1__1 0x0001
  14. #define FAMILY_ID 0x95
  15. #define FAMILY_ID_94 0x94
  16. #define FAMILY_ID_95 0x95
  17. #define FAMILY_ID_85 0x85
  18. #define FAMILY_ID_98 0x98
  19. #define FAMILY_ID_88 0x88
  20. #define REG_CHIP_ID2__1 0x0002
  21. #define CHIP_ID_66 0x66
  22. #define CHIP_ID_67 0x67
  23. #define CHIP_ID_77 0x77
  24. #define CHIP_ID_93 0x93
  25. #define CHIP_ID_96 0x96
  26. #define CHIP_ID_97 0x97
  27. #define REG_CHIP_ID3__1 0x0003
  28. #define SWITCH_REVISION_M 0x0F
  29. #define SWITCH_REVISION_S 4
  30. #define SWITCH_RESET 0x01
  31. #define REG_SW_PME_CTRL 0x0006
  32. #define PME_ENABLE BIT(1)
  33. #define PME_POLARITY BIT(0)
  34. #define REG_GLOBAL_OPTIONS 0x000F
  35. #define SW_GIGABIT_ABLE BIT(6)
  36. #define SW_REDUNDANCY_ABLE BIT(5)
  37. #define SW_AVB_ABLE BIT(4)
  38. #define SW_9567_RL_5_2 0xC
  39. #define SW_9477_SL_5_2 0xD
  40. #define SW_9896_GL_5_1 0xB
  41. #define SW_9896_RL_5_1 0x8
  42. #define SW_9896_SL_5_1 0x9
  43. #define SW_9895_GL_4_1 0x7
  44. #define SW_9895_RL_4_1 0x4
  45. #define SW_9895_SL_4_1 0x5
  46. #define SW_9896_RL_4_2 0x6
  47. #define SW_9893_RL_2_1 0x0
  48. #define SW_9893_SL_2_1 0x1
  49. #define SW_9893_GL_2_1 0x3
  50. #define SW_QW_ABLE BIT(5)
  51. #define SW_9893_RN_2_1 0xC
  52. #define REG_SW_INT_STATUS__4 0x0010
  53. #define REG_SW_INT_MASK__4 0x0014
  54. #define LUE_INT BIT(31)
  55. #define TRIG_TS_INT BIT(30)
  56. #define APB_TIMEOUT_INT BIT(29)
  57. #define SWITCH_INT_MASK (TRIG_TS_INT | APB_TIMEOUT_INT)
  58. #define REG_SW_PORT_INT_STATUS__4 0x0018
  59. #define REG_SW_PORT_INT_MASK__4 0x001C
  60. #define REG_SW_PHY_INT_STATUS 0x0020
  61. #define REG_SW_PHY_INT_ENABLE 0x0024
  62. /* 1 - Global */
  63. #define REG_SW_GLOBAL_SERIAL_CTRL_0 0x0100
  64. #define SW_SPARE_REG_2 BIT(7)
  65. #define SW_SPARE_REG_1 BIT(6)
  66. #define SW_SPARE_REG_0 BIT(5)
  67. #define SW_BIG_ENDIAN BIT(4)
  68. #define SPI_AUTO_EDGE_DETECTION BIT(1)
  69. #define SPI_CLOCK_OUT_RISING_EDGE BIT(0)
  70. #define REG_SW_GLOBAL_OUTPUT_CTRL__1 0x0103
  71. #define SW_ENABLE_REFCLKO BIT(1)
  72. #define SW_REFCLKO_IS_125MHZ BIT(0)
  73. #define REG_SW_IBA__4 0x0104
  74. #define SW_IBA_ENABLE BIT(31)
  75. #define SW_IBA_DA_MATCH BIT(30)
  76. #define SW_IBA_INIT BIT(29)
  77. #define SW_IBA_QID_M 0xF
  78. #define SW_IBA_QID_S 22
  79. #define SW_IBA_PORT_M 0x2F
  80. #define SW_IBA_PORT_S 16
  81. #define SW_IBA_FRAME_TPID_M 0xFFFF
  82. #define REG_SW_APB_TIMEOUT_ADDR__4 0x0108
  83. #define APB_TIMEOUT_ACKNOWLEDGE BIT(31)
  84. #define REG_SW_IBA_SYNC__1 0x010C
  85. #define REG_SW_IO_STRENGTH__1 0x010D
  86. #define SW_DRIVE_STRENGTH_M 0x7
  87. #define SW_DRIVE_STRENGTH_2MA 0
  88. #define SW_DRIVE_STRENGTH_4MA 1
  89. #define SW_DRIVE_STRENGTH_8MA 2
  90. #define SW_DRIVE_STRENGTH_12MA 3
  91. #define SW_DRIVE_STRENGTH_16MA 4
  92. #define SW_DRIVE_STRENGTH_20MA 5
  93. #define SW_DRIVE_STRENGTH_24MA 6
  94. #define SW_DRIVE_STRENGTH_28MA 7
  95. #define SW_HI_SPEED_DRIVE_STRENGTH_S 4
  96. #define SW_LO_SPEED_DRIVE_STRENGTH_S 0
  97. #define REG_SW_IBA_STATUS__4 0x0110
  98. #define SW_IBA_REQ BIT(31)
  99. #define SW_IBA_RESP BIT(30)
  100. #define SW_IBA_DA_MISMATCH BIT(14)
  101. #define SW_IBA_FMT_MISMATCH BIT(13)
  102. #define SW_IBA_CODE_ERROR BIT(12)
  103. #define SW_IBA_CMD_ERROR BIT(11)
  104. #define SW_IBA_CMD_LOC_M (BIT(6) - 1)
  105. #define REG_SW_IBA_STATES__4 0x0114
  106. #define SW_IBA_BUF_STATE_S 30
  107. #define SW_IBA_CMD_STATE_S 28
  108. #define SW_IBA_RESP_STATE_S 26
  109. #define SW_IBA_STATE_M 0x3
  110. #define SW_IBA_PACKET_SIZE_M 0x7F
  111. #define SW_IBA_PACKET_SIZE_S 16
  112. #define SW_IBA_FMT_ID_M 0xFFFF
  113. #define REG_SW_IBA_RESULT__4 0x0118
  114. #define SW_IBA_SIZE_S 24
  115. #define SW_IBA_RETRY_CNT_M (BIT(5) - 1)
  116. /* 2 - PHY */
  117. #define REG_SW_POWER_MANAGEMENT_CTRL 0x0201
  118. #define SW_PLL_POWER_DOWN BIT(5)
  119. #define SW_POWER_DOWN_MODE 0x3
  120. #define SW_ENERGY_DETECTION 1
  121. #define SW_SOFT_POWER_DOWN 2
  122. #define SW_POWER_SAVING 3
  123. /* 3 - Operation Control */
  124. #define REG_SW_OPERATION 0x0300
  125. #define SW_DOUBLE_TAG BIT(7)
  126. #define SW_RESET BIT(1)
  127. #define REG_SW_MAC_ADDR_0 0x0302
  128. #define REG_SW_MAC_ADDR_1 0x0303
  129. #define REG_SW_MAC_ADDR_2 0x0304
  130. #define REG_SW_MAC_ADDR_3 0x0305
  131. #define REG_SW_MAC_ADDR_4 0x0306
  132. #define REG_SW_MAC_ADDR_5 0x0307
  133. #define REG_SW_MTU__2 0x0308
  134. #define REG_SW_MTU_MASK GENMASK(13, 0)
  135. #define REG_SW_ISP_TPID__2 0x030A
  136. #define REG_SW_HSR_TPID__2 0x030C
  137. #define REG_AVB_STRATEGY__2 0x030E
  138. #define SW_SHAPING_CREDIT_ACCT BIT(1)
  139. #define SW_POLICING_CREDIT_ACCT BIT(0)
  140. #define REG_SW_LUE_CTRL_0 0x0310
  141. #define SW_VLAN_ENABLE BIT(7)
  142. #define SW_DROP_INVALID_VID BIT(6)
  143. #define SW_AGE_CNT_M GENMASK(5, 3)
  144. #define SW_AGE_CNT_S 3
  145. #define SW_AGE_PERIOD_10_8_M GENMASK(10, 8)
  146. #define SW_RESV_MCAST_ENABLE BIT(2)
  147. #define SW_HASH_OPTION_M 0x03
  148. #define SW_HASH_OPTION_CRC 1
  149. #define SW_HASH_OPTION_XOR 2
  150. #define SW_HASH_OPTION_DIRECT 3
  151. #define REG_SW_LUE_CTRL_1 0x0311
  152. #define UNICAST_LEARN_DISABLE BIT(7)
  153. #define SW_SRC_ADDR_FILTER BIT(6)
  154. #define SW_FLUSH_STP_TABLE BIT(5)
  155. #define SW_FLUSH_MSTP_TABLE BIT(4)
  156. #define SW_FWD_MCAST_SRC_ADDR BIT(3)
  157. #define SW_AGING_ENABLE BIT(2)
  158. #define SW_FAST_AGING BIT(1)
  159. #define SW_LINK_AUTO_AGING BIT(0)
  160. #define REG_SW_LUE_CTRL_2 0x0312
  161. #define SW_TRAP_DOUBLE_TAG BIT(6)
  162. #define SW_EGRESS_VLAN_FILTER_DYN BIT(5)
  163. #define SW_EGRESS_VLAN_FILTER_STA BIT(4)
  164. #define SW_FLUSH_OPTION_M 0x3
  165. #define SW_FLUSH_OPTION_S 2
  166. #define SW_FLUSH_OPTION_DYN_MAC 1
  167. #define SW_FLUSH_OPTION_STA_MAC 2
  168. #define SW_FLUSH_OPTION_BOTH 3
  169. #define SW_PRIO_M 0x3
  170. #define SW_PRIO_DA 0
  171. #define SW_PRIO_SA 1
  172. #define SW_PRIO_HIGHEST_DA_SA 2
  173. #define SW_PRIO_LOWEST_DA_SA 3
  174. #define REG_SW_LUE_CTRL_3 0x0313
  175. #define SW_AGE_PERIOD_7_0_M GENMASK(7, 0)
  176. #define REG_SW_LUE_INT_STATUS 0x0314
  177. #define REG_SW_LUE_INT_ENABLE 0x0315
  178. #define LEARN_FAIL_INT BIT(2)
  179. #define ALMOST_FULL_INT BIT(1)
  180. #define WRITE_FAIL_INT BIT(0)
  181. #define REG_SW_LUE_INDEX_0__2 0x0316
  182. #define ENTRY_INDEX_M 0x0FFF
  183. #define REG_SW_LUE_INDEX_1__2 0x0318
  184. #define FAIL_INDEX_M 0x03FF
  185. #define REG_SW_LUE_INDEX_2__2 0x031A
  186. #define REG_SW_LUE_UNK_UCAST_CTRL__4 0x0320
  187. #define SW_UNK_UCAST_ENABLE BIT(31)
  188. #define REG_SW_LUE_UNK_MCAST_CTRL__4 0x0324
  189. #define SW_UNK_MCAST_ENABLE BIT(31)
  190. #define REG_SW_LUE_UNK_VID_CTRL__4 0x0328
  191. #define SW_UNK_VID_ENABLE BIT(31)
  192. #define REG_SW_MAC_CTRL_0 0x0330
  193. #define SW_NEW_BACKOFF BIT(7)
  194. #define SW_CHECK_LENGTH BIT(3)
  195. #define SW_PAUSE_UNH_MODE BIT(1)
  196. #define SW_AGGR_BACKOFF BIT(0)
  197. #define REG_SW_MAC_CTRL_1 0x0331
  198. #define SW_BACK_PRESSURE BIT(5)
  199. #define FAIR_FLOW_CTRL BIT(4)
  200. #define NO_EXC_COLLISION_DROP BIT(3)
  201. #define SW_JUMBO_PACKET BIT(2)
  202. #define SW_LEGAL_PACKET_DISABLE BIT(1)
  203. #define SW_PASS_SHORT_FRAME BIT(0)
  204. #define REG_SW_MAC_CTRL_2 0x0332
  205. #define SW_REPLACE_VID BIT(3)
  206. #define REG_SW_MAC_CTRL_3 0x0333
  207. #define REG_SW_MAC_CTRL_4 0x0334
  208. #define SW_PASS_PAUSE BIT(3)
  209. #define REG_SW_MAC_CTRL_5 0x0335
  210. #define SW_OUT_RATE_LIMIT_QUEUE_BASED BIT(3)
  211. #define REG_SW_MAC_CTRL_6 0x0336
  212. #define SW_MIB_COUNTER_FLUSH BIT(7)
  213. #define SW_MIB_COUNTER_FREEZE BIT(6)
  214. #define REG_SW_MAC_802_1P_MAP_0 0x0338
  215. #define REG_SW_MAC_802_1P_MAP_1 0x0339
  216. #define REG_SW_MAC_802_1P_MAP_2 0x033A
  217. #define REG_SW_MAC_802_1P_MAP_3 0x033B
  218. #define SW_802_1P_MAP_M KS_PRIO_M
  219. #define SW_802_1P_MAP_S KS_PRIO_S
  220. #define REG_SW_MAC_ISP_CTRL 0x033C
  221. #define REG_SW_MAC_TOS_CTRL 0x033E
  222. #define SW_TOS_DSCP_REMARK BIT(1)
  223. #define SW_TOS_DSCP_REMAP BIT(0)
  224. #define REG_SW_MAC_TOS_PRIO_0 0x0340
  225. #define REG_SW_MAC_TOS_PRIO_1 0x0341
  226. #define REG_SW_MAC_TOS_PRIO_2 0x0342
  227. #define REG_SW_MAC_TOS_PRIO_3 0x0343
  228. #define REG_SW_MAC_TOS_PRIO_4 0x0344
  229. #define REG_SW_MAC_TOS_PRIO_5 0x0345
  230. #define REG_SW_MAC_TOS_PRIO_6 0x0346
  231. #define REG_SW_MAC_TOS_PRIO_7 0x0347
  232. #define REG_SW_MAC_TOS_PRIO_8 0x0348
  233. #define REG_SW_MAC_TOS_PRIO_9 0x0349
  234. #define REG_SW_MAC_TOS_PRIO_10 0x034A
  235. #define REG_SW_MAC_TOS_PRIO_11 0x034B
  236. #define REG_SW_MAC_TOS_PRIO_12 0x034C
  237. #define REG_SW_MAC_TOS_PRIO_13 0x034D
  238. #define REG_SW_MAC_TOS_PRIO_14 0x034E
  239. #define REG_SW_MAC_TOS_PRIO_15 0x034F
  240. #define REG_SW_MAC_TOS_PRIO_16 0x0350
  241. #define REG_SW_MAC_TOS_PRIO_17 0x0351
  242. #define REG_SW_MAC_TOS_PRIO_18 0x0352
  243. #define REG_SW_MAC_TOS_PRIO_19 0x0353
  244. #define REG_SW_MAC_TOS_PRIO_20 0x0354
  245. #define REG_SW_MAC_TOS_PRIO_21 0x0355
  246. #define REG_SW_MAC_TOS_PRIO_22 0x0356
  247. #define REG_SW_MAC_TOS_PRIO_23 0x0357
  248. #define REG_SW_MAC_TOS_PRIO_24 0x0358
  249. #define REG_SW_MAC_TOS_PRIO_25 0x0359
  250. #define REG_SW_MAC_TOS_PRIO_26 0x035A
  251. #define REG_SW_MAC_TOS_PRIO_27 0x035B
  252. #define REG_SW_MAC_TOS_PRIO_28 0x035C
  253. #define REG_SW_MAC_TOS_PRIO_29 0x035D
  254. #define REG_SW_MAC_TOS_PRIO_30 0x035E
  255. #define REG_SW_MAC_TOS_PRIO_31 0x035F
  256. #define REG_SW_MRI_CTRL_0 0x0370
  257. #define SW_IGMP_SNOOP BIT(6)
  258. #define SW_IPV6_MLD_OPTION BIT(3)
  259. #define SW_IPV6_MLD_SNOOP BIT(2)
  260. #define SW_MIRROR_RX_TX BIT(0)
  261. #define REG_SW_CLASS_D_IP_CTRL__4 0x0374
  262. #define SW_CLASS_D_IP_ENABLE BIT(31)
  263. #define REG_SW_MRI_CTRL_8 0x0378
  264. #define SW_NO_COLOR_S 6
  265. #define SW_RED_COLOR_S 4
  266. #define SW_YELLOW_COLOR_S 2
  267. #define SW_GREEN_COLOR_S 0
  268. #define SW_COLOR_M 0x3
  269. #define REG_SW_QM_CTRL__4 0x0390
  270. #define PRIO_SCHEME_SELECT_M KS_PRIO_M
  271. #define PRIO_SCHEME_SELECT_S 6
  272. #define PRIO_MAP_3_HI 0
  273. #define PRIO_MAP_2_HI 2
  274. #define PRIO_MAP_0_LO 3
  275. #define UNICAST_VLAN_BOUNDARY BIT(1)
  276. #define REG_SW_EEE_QM_CTRL__2 0x03C0
  277. #define REG_SW_EEE_TXQ_WAIT_TIME__2 0x03C2
  278. /* 4 - */
  279. #define REG_SW_VLAN_ENTRY__4 0x0400
  280. #define VLAN_VALID BIT(31)
  281. #define VLAN_FORWARD_OPTION BIT(27)
  282. #define VLAN_PRIO_M KS_PRIO_M
  283. #define VLAN_PRIO_S 24
  284. #define VLAN_MSTP_M 0x7
  285. #define VLAN_MSTP_S 12
  286. #define VLAN_FID_M 0x7F
  287. #define REG_SW_VLAN_ENTRY_UNTAG__4 0x0404
  288. #define REG_SW_VLAN_ENTRY_PORTS__4 0x0408
  289. #define REG_SW_VLAN_ENTRY_INDEX__2 0x040C
  290. #define VLAN_INDEX_M 0x0FFF
  291. #define REG_SW_VLAN_CTRL 0x040E
  292. #define VLAN_START BIT(7)
  293. #define VLAN_ACTION 0x3
  294. #define VLAN_WRITE 1
  295. #define VLAN_READ 2
  296. #define VLAN_CLEAR 3
  297. #define REG_SW_ALU_INDEX_0 0x0410
  298. #define ALU_FID_INDEX_S 16
  299. #define ALU_MAC_ADDR_HI 0xFFFF
  300. #define REG_SW_ALU_INDEX_1 0x0414
  301. #define ALU_DIRECT_INDEX_M (BIT(12) - 1)
  302. #define REG_SW_ALU_CTRL__4 0x0418
  303. #define ALU_VALID_CNT_M (BIT(14) - 1)
  304. #define ALU_VALID_CNT_S 16
  305. #define ALU_START BIT(7)
  306. #define ALU_VALID BIT(6)
  307. #define ALU_DIRECT BIT(2)
  308. #define ALU_ACTION 0x3
  309. #define ALU_WRITE 1
  310. #define ALU_READ 2
  311. #define ALU_SEARCH 3
  312. #define REG_SW_ALU_STAT_CTRL__4 0x041C
  313. #define ALU_RESV_MCAST_INDEX_M (BIT(6) - 1)
  314. #define ALU_STAT_START BIT(7)
  315. #define ALU_RESV_MCAST_ADDR BIT(1)
  316. #define REG_SW_ALU_VAL_A 0x0420
  317. #define ALU_V_STATIC_VALID BIT(31)
  318. #define ALU_V_SRC_FILTER BIT(30)
  319. #define ALU_V_DST_FILTER BIT(29)
  320. #define ALU_V_PRIO_AGE_CNT_M (BIT(3) - 1)
  321. #define ALU_V_PRIO_AGE_CNT_S 26
  322. #define ALU_V_MSTP_M 0x7
  323. #define REG_SW_ALU_VAL_B 0x0424
  324. #define ALU_V_OVERRIDE BIT(31)
  325. #define ALU_V_USE_FID BIT(30)
  326. #define ALU_V_PORT_MAP (BIT(24) - 1)
  327. #define REG_SW_ALU_VAL_C 0x0428
  328. #define ALU_V_FID_M (BIT(16) - 1)
  329. #define ALU_V_FID_S 16
  330. #define ALU_V_MAC_ADDR_HI 0xFFFF
  331. #define REG_SW_ALU_VAL_D 0x042C
  332. #define REG_HSR_ALU_INDEX_0 0x0440
  333. #define REG_HSR_ALU_INDEX_1 0x0444
  334. #define HSR_DST_MAC_INDEX_LO_S 16
  335. #define HSR_SRC_MAC_INDEX_HI 0xFFFF
  336. #define REG_HSR_ALU_INDEX_2 0x0448
  337. #define HSR_INDEX_MAX BIT(9)
  338. #define HSR_DIRECT_INDEX_M (HSR_INDEX_MAX - 1)
  339. #define REG_HSR_ALU_INDEX_3 0x044C
  340. #define HSR_PATH_INDEX_M (BIT(4) - 1)
  341. #define REG_HSR_ALU_CTRL__4 0x0450
  342. #define HSR_VALID_CNT_M (BIT(14) - 1)
  343. #define HSR_VALID_CNT_S 16
  344. #define HSR_START BIT(7)
  345. #define HSR_VALID BIT(6)
  346. #define HSR_SEARCH_END BIT(5)
  347. #define HSR_DIRECT BIT(2)
  348. #define HSR_ACTION 0x3
  349. #define HSR_WRITE 1
  350. #define HSR_READ 2
  351. #define HSR_SEARCH 3
  352. #define REG_HSR_ALU_VAL_A 0x0454
  353. #define HSR_V_STATIC_VALID BIT(31)
  354. #define HSR_V_AGE_CNT_M (BIT(3) - 1)
  355. #define HSR_V_AGE_CNT_S 26
  356. #define HSR_V_PATH_ID_M (BIT(4) - 1)
  357. #define REG_HSR_ALU_VAL_B 0x0458
  358. #define REG_HSR_ALU_VAL_C 0x045C
  359. #define HSR_V_DST_MAC_ADDR_LO_S 16
  360. #define HSR_V_SRC_MAC_ADDR_HI 0xFFFF
  361. #define REG_HSR_ALU_VAL_D 0x0460
  362. #define REG_HSR_ALU_VAL_E 0x0464
  363. #define HSR_V_START_SEQ_1_S 16
  364. #define HSR_V_START_SEQ_2_S 0
  365. #define REG_HSR_ALU_VAL_F 0x0468
  366. #define HSR_V_EXP_SEQ_1_S 16
  367. #define HSR_V_EXP_SEQ_2_S 0
  368. #define REG_HSR_ALU_VAL_G 0x046C
  369. #define HSR_V_SEQ_CNT_1_S 16
  370. #define HSR_V_SEQ_CNT_2_S 0
  371. #define HSR_V_SEQ_M (BIT(16) - 1)
  372. /* 5 - PTP Clock */
  373. #define REG_PTP_CLK_CTRL 0x0500
  374. #define PTP_STEP_ADJ BIT(6)
  375. #define PTP_STEP_DIR BIT(5)
  376. #define PTP_READ_TIME BIT(4)
  377. #define PTP_LOAD_TIME BIT(3)
  378. #define PTP_CLK_ADJ_ENABLE BIT(2)
  379. #define PTP_CLK_ENABLE BIT(1)
  380. #define PTP_CLK_RESET BIT(0)
  381. #define REG_PTP_RTC_SUB_NANOSEC__2 0x0502
  382. #define PTP_RTC_SUB_NANOSEC_M 0x0007
  383. #define REG_PTP_RTC_NANOSEC 0x0504
  384. #define REG_PTP_RTC_NANOSEC_H 0x0504
  385. #define REG_PTP_RTC_NANOSEC_L 0x0506
  386. #define REG_PTP_RTC_SEC 0x0508
  387. #define REG_PTP_RTC_SEC_H 0x0508
  388. #define REG_PTP_RTC_SEC_L 0x050A
  389. #define REG_PTP_SUBNANOSEC_RATE 0x050C
  390. #define REG_PTP_SUBNANOSEC_RATE_H 0x050C
  391. #define PTP_RATE_DIR BIT(31)
  392. #define PTP_TMP_RATE_ENABLE BIT(30)
  393. #define REG_PTP_SUBNANOSEC_RATE_L 0x050E
  394. #define REG_PTP_RATE_DURATION 0x0510
  395. #define REG_PTP_RATE_DURATION_H 0x0510
  396. #define REG_PTP_RATE_DURATION_L 0x0512
  397. #define REG_PTP_MSG_CONF1 0x0514
  398. #define PTP_802_1AS BIT(7)
  399. #define PTP_ENABLE BIT(6)
  400. #define PTP_ETH_ENABLE BIT(5)
  401. #define PTP_IPV4_UDP_ENABLE BIT(4)
  402. #define PTP_IPV6_UDP_ENABLE BIT(3)
  403. #define PTP_TC_P2P BIT(2)
  404. #define PTP_MASTER BIT(1)
  405. #define PTP_1STEP BIT(0)
  406. #define REG_PTP_MSG_CONF2 0x0516
  407. #define PTP_UNICAST_ENABLE BIT(12)
  408. #define PTP_ALTERNATE_MASTER BIT(11)
  409. #define PTP_ALL_HIGH_PRIO BIT(10)
  410. #define PTP_SYNC_CHECK BIT(9)
  411. #define PTP_DELAY_CHECK BIT(8)
  412. #define PTP_PDELAY_CHECK BIT(7)
  413. #define PTP_DROP_SYNC_DELAY_REQ BIT(5)
  414. #define PTP_DOMAIN_CHECK BIT(4)
  415. #define PTP_UDP_CHECKSUM BIT(2)
  416. #define REG_PTP_DOMAIN_VERSION 0x0518
  417. #define PTP_VERSION_M 0xFF00
  418. #define PTP_DOMAIN_M 0x00FF
  419. #define REG_PTP_UNIT_INDEX__4 0x0520
  420. #define PTP_UNIT_M 0xF
  421. #define PTP_GPIO_INDEX_S 16
  422. #define PTP_TSI_INDEX_S 8
  423. #define PTP_TOU_INDEX_S 0
  424. #define REG_PTP_TRIG_STATUS__4 0x0524
  425. #define TRIG_ERROR_S 16
  426. #define TRIG_DONE_S 0
  427. #define REG_PTP_INT_STATUS__4 0x0528
  428. #define TRIG_INT_S 16
  429. #define TS_INT_S 0
  430. #define TRIG_UNIT_M 0x7
  431. #define TS_UNIT_M 0x3
  432. #define REG_PTP_CTRL_STAT__4 0x052C
  433. #define GPIO_IN BIT(7)
  434. #define GPIO_OUT BIT(6)
  435. #define TS_INT_ENABLE BIT(5)
  436. #define TRIG_ACTIVE BIT(4)
  437. #define TRIG_ENABLE BIT(3)
  438. #define TRIG_RESET BIT(2)
  439. #define TS_ENABLE BIT(1)
  440. #define TS_RESET BIT(0)
  441. #define GPIO_CTRL_M (GPIO_IN | GPIO_OUT)
  442. #define TRIG_CTRL_M \
  443. (TRIG_ACTIVE | TRIG_ENABLE | TRIG_RESET)
  444. #define TS_CTRL_M \
  445. (TS_INT_ENABLE | TS_ENABLE | TS_RESET)
  446. #define REG_TRIG_TARGET_NANOSEC 0x0530
  447. #define REG_TRIG_TARGET_SEC 0x0534
  448. #define REG_TRIG_CTRL__4 0x0538
  449. #define TRIG_CASCADE_ENABLE BIT(31)
  450. #define TRIG_CASCADE_TAIL BIT(30)
  451. #define TRIG_CASCADE_UPS_M 0xF
  452. #define TRIG_CASCADE_UPS_S 26
  453. #define TRIG_NOW BIT(25)
  454. #define TRIG_NOTIFY BIT(24)
  455. #define TRIG_EDGE BIT(23)
  456. #define TRIG_PATTERN_S 20
  457. #define TRIG_PATTERN_M 0x7
  458. #define TRIG_NEG_EDGE 0
  459. #define TRIG_POS_EDGE 1
  460. #define TRIG_NEG_PULSE 2
  461. #define TRIG_POS_PULSE 3
  462. #define TRIG_NEG_PERIOD 4
  463. #define TRIG_POS_PERIOD 5
  464. #define TRIG_REG_OUTPUT 6
  465. #define TRIG_GPO_S 16
  466. #define TRIG_GPO_M 0xF
  467. #define TRIG_CASCADE_ITERATE_CNT_M 0xFFFF
  468. #define REG_TRIG_CYCLE_WIDTH 0x053C
  469. #define REG_TRIG_CYCLE_CNT 0x0540
  470. #define TRIG_CYCLE_CNT_M 0xFFFF
  471. #define TRIG_CYCLE_CNT_S 16
  472. #define TRIG_BIT_PATTERN_M 0xFFFF
  473. #define REG_TRIG_ITERATE_TIME 0x0544
  474. #define REG_TRIG_PULSE_WIDTH__4 0x0548
  475. #define TRIG_PULSE_WIDTH_M 0x00FFFFFF
  476. #define REG_TS_CTRL_STAT__4 0x0550
  477. #define TS_EVENT_DETECT_M 0xF
  478. #define TS_EVENT_DETECT_S 17
  479. #define TS_EVENT_OVERFLOW BIT(16)
  480. #define TS_GPI_M 0xF
  481. #define TS_GPI_S 8
  482. #define TS_DETECT_RISE BIT(7)
  483. #define TS_DETECT_FALL BIT(6)
  484. #define TS_DETECT_S 6
  485. #define TS_CASCADE_TAIL BIT(5)
  486. #define TS_CASCADE_UPS_M 0xF
  487. #define TS_CASCADE_UPS_S 1
  488. #define TS_CASCADE_ENABLE BIT(0)
  489. #define DETECT_RISE (TS_DETECT_RISE >> TS_DETECT_S)
  490. #define DETECT_FALL (TS_DETECT_FALL >> TS_DETECT_S)
  491. #define REG_TS_EVENT_0_NANOSEC 0x0554
  492. #define REG_TS_EVENT_0_SEC 0x0558
  493. #define REG_TS_EVENT_0_SUB_NANOSEC 0x055C
  494. #define REG_TS_EVENT_1_NANOSEC 0x0560
  495. #define REG_TS_EVENT_1_SEC 0x0564
  496. #define REG_TS_EVENT_1_SUB_NANOSEC 0x0568
  497. #define REG_TS_EVENT_2_NANOSEC 0x056C
  498. #define REG_TS_EVENT_2_SEC 0x0570
  499. #define REG_TS_EVENT_2_SUB_NANOSEC 0x0574
  500. #define REG_TS_EVENT_3_NANOSEC 0x0578
  501. #define REG_TS_EVENT_3_SEC 0x057C
  502. #define REG_TS_EVENT_3_SUB_NANOSEC 0x0580
  503. #define REG_TS_EVENT_4_NANOSEC 0x0584
  504. #define REG_TS_EVENT_4_SEC 0x0588
  505. #define REG_TS_EVENT_4_SUB_NANOSEC 0x058C
  506. #define REG_TS_EVENT_5_NANOSEC 0x0590
  507. #define REG_TS_EVENT_5_SEC 0x0594
  508. #define REG_TS_EVENT_5_SUB_NANOSEC 0x0598
  509. #define REG_TS_EVENT_6_NANOSEC 0x059C
  510. #define REG_TS_EVENT_6_SEC 0x05A0
  511. #define REG_TS_EVENT_6_SUB_NANOSEC 0x05A4
  512. #define REG_TS_EVENT_7_NANOSEC 0x05A8
  513. #define REG_TS_EVENT_7_SEC 0x05AC
  514. #define REG_TS_EVENT_7_SUB_NANOSEC 0x05B0
  515. #define TS_EVENT_EDGE_M 0x1
  516. #define TS_EVENT_EDGE_S 30
  517. #define TS_EVENT_NANOSEC_M (BIT(30) - 1)
  518. #define TS_EVENT_SUB_NANOSEC_M 0x7
  519. #define TS_EVENT_SAMPLE \
  520. (REG_TS_EVENT_1_NANOSEC - REG_TS_EVENT_0_NANOSEC)
  521. #define PORT_CTRL_ADDR(port, addr) ((addr) | (((port) + 1) << 12))
  522. #define REG_GLOBAL_RR_INDEX__1 0x0600
  523. /* DLR */
  524. #define REG_DLR_SRC_PORT__4 0x0604
  525. #define DLR_SRC_PORT_UNICAST BIT(31)
  526. #define DLR_SRC_PORT_M 0x3
  527. #define DLR_SRC_PORT_BOTH 0
  528. #define DLR_SRC_PORT_EACH 1
  529. #define REG_DLR_IP_ADDR__4 0x0608
  530. #define REG_DLR_CTRL__1 0x0610
  531. #define DLR_RESET_SEQ_ID BIT(3)
  532. #define DLR_BACKUP_AUTO_ON BIT(2)
  533. #define DLR_BEACON_TX_ENABLE BIT(1)
  534. #define DLR_ASSIST_ENABLE BIT(0)
  535. #define REG_DLR_STATE__1 0x0611
  536. #define DLR_NODE_STATE_M 0x3
  537. #define DLR_NODE_STATE_S 1
  538. #define DLR_NODE_STATE_IDLE 0
  539. #define DLR_NODE_STATE_FAULT 1
  540. #define DLR_NODE_STATE_NORMAL 2
  541. #define DLR_RING_STATE_FAULT 0
  542. #define DLR_RING_STATE_NORMAL 1
  543. #define REG_DLR_PRECEDENCE__1 0x0612
  544. #define REG_DLR_BEACON_INTERVAL__4 0x0614
  545. #define REG_DLR_BEACON_TIMEOUT__4 0x0618
  546. #define REG_DLR_TIMEOUT_WINDOW__4 0x061C
  547. #define DLR_TIMEOUT_WINDOW_M (BIT(22) - 1)
  548. #define REG_DLR_VLAN_ID__2 0x0620
  549. #define DLR_VLAN_ID_M (BIT(12) - 1)
  550. #define REG_DLR_DEST_ADDR_0 0x0622
  551. #define REG_DLR_DEST_ADDR_1 0x0623
  552. #define REG_DLR_DEST_ADDR_2 0x0624
  553. #define REG_DLR_DEST_ADDR_3 0x0625
  554. #define REG_DLR_DEST_ADDR_4 0x0626
  555. #define REG_DLR_DEST_ADDR_5 0x0627
  556. #define REG_DLR_PORT_MAP__4 0x0628
  557. #define REG_DLR_CLASS__1 0x062C
  558. #define DLR_FRAME_QID_M 0x3
  559. /* HSR */
  560. #define REG_HSR_PORT_MAP__4 0x0640
  561. #define REG_HSR_ALU_CTRL_0__1 0x0644
  562. #define HSR_DUPLICATE_DISCARD BIT(7)
  563. #define HSR_NODE_UNICAST BIT(6)
  564. #define HSR_AGE_CNT_DEFAULT_M 0x7
  565. #define HSR_AGE_CNT_DEFAULT_S 3
  566. #define HSR_LEARN_MCAST_DISABLE BIT(2)
  567. #define HSR_HASH_OPTION_M 0x3
  568. #define HSR_HASH_DISABLE 0
  569. #define HSR_HASH_UPPER_BITS 1
  570. #define HSR_HASH_LOWER_BITS 2
  571. #define HSR_HASH_XOR_BOTH_BITS 3
  572. #define REG_HSR_ALU_CTRL_1__1 0x0645
  573. #define HSR_LEARN_UCAST_DISABLE BIT(7)
  574. #define HSR_FLUSH_TABLE BIT(5)
  575. #define HSR_PROC_MCAST_SRC BIT(3)
  576. #define HSR_AGING_ENABLE BIT(2)
  577. #define REG_HSR_ALU_CTRL_2__2 0x0646
  578. #define REG_HSR_ALU_AGE_PERIOD__4 0x0648
  579. #define REG_HSR_ALU_INT_STATUS__1 0x064C
  580. #define REG_HSR_ALU_INT_MASK__1 0x064D
  581. #define HSR_WINDOW_OVERFLOW_INT BIT(3)
  582. #define HSR_LEARN_FAIL_INT BIT(2)
  583. #define HSR_ALMOST_FULL_INT BIT(1)
  584. #define HSR_WRITE_FAIL_INT BIT(0)
  585. #define REG_HSR_ALU_ENTRY_0__2 0x0650
  586. #define HSR_ENTRY_INDEX_M (BIT(10) - 1)
  587. #define HSR_FAIL_INDEX_M (BIT(8) - 1)
  588. #define REG_HSR_ALU_ENTRY_1__2 0x0652
  589. #define HSR_FAIL_LEARN_INDEX_M (BIT(8) - 1)
  590. #define REG_HSR_ALU_ENTRY_3__2 0x0654
  591. #define HSR_CPU_ACCESS_ENTRY_INDEX_M (BIT(8) - 1)
  592. /* 0 - Operation */
  593. #define REG_PORT_DEFAULT_VID 0x0000
  594. #define REG_PORT_CUSTOM_VID 0x0002
  595. #define REG_PORT_AVB_SR_1_VID 0x0004
  596. #define REG_PORT_AVB_SR_2_VID 0x0006
  597. #define REG_PORT_AVB_SR_1_TYPE 0x0008
  598. #define REG_PORT_AVB_SR_2_TYPE 0x000A
  599. #define REG_PORT_PME_STATUS 0x0013
  600. #define REG_PORT_PME_CTRL 0x0017
  601. #define PME_WOL_MAGICPKT BIT(2)
  602. #define PME_WOL_LINKUP BIT(1)
  603. #define PME_WOL_ENERGY BIT(0)
  604. #define REG_PORT_INT_STATUS 0x001B
  605. #define REG_PORT_INT_MASK 0x001F
  606. #define PORT_SGMII_INT BIT(3)
  607. #define PORT_PTP_INT BIT(2)
  608. #define PORT_PHY_INT BIT(1)
  609. #define PORT_ACL_INT BIT(0)
  610. #define PORT_INT_MASK \
  611. (PORT_SGMII_INT | PORT_PTP_INT | PORT_PHY_INT | PORT_ACL_INT)
  612. #define REG_PORT_CTRL_0 0x0020
  613. #define PORT_MAC_LOOPBACK BIT(7)
  614. #define PORT_FORCE_TX_FLOW_CTRL BIT(4)
  615. #define PORT_FORCE_RX_FLOW_CTRL BIT(3)
  616. #define PORT_TAIL_TAG_ENABLE BIT(2)
  617. #define PORT_QUEUE_SPLIT_ENABLE 0x3
  618. #define REG_PORT_CTRL_1 0x0021
  619. #define PORT_SRP_ENABLE 0x3
  620. #define REG_PORT_STATUS_0 0x0030
  621. #define PORT_INTF_SPEED_M 0x3
  622. #define PORT_INTF_SPEED_S 3
  623. #define PORT_INTF_FULL_DUPLEX BIT(2)
  624. #define PORT_TX_FLOW_CTRL BIT(1)
  625. #define PORT_RX_FLOW_CTRL BIT(0)
  626. #define REG_PORT_STATUS_1 0x0034
  627. /* 1 - PHY */
  628. #define REG_PORT_PHY_CTRL 0x0100
  629. #define PORT_PHY_RESET BIT(15)
  630. #define PORT_PHY_LOOPBACK BIT(14)
  631. #define PORT_SPEED_100MBIT BIT(13)
  632. #define PORT_AUTO_NEG_ENABLE BIT(12)
  633. #define PORT_POWER_DOWN BIT(11)
  634. #define PORT_ISOLATE BIT(10)
  635. #define PORT_AUTO_NEG_RESTART BIT(9)
  636. #define PORT_FULL_DUPLEX BIT(8)
  637. #define PORT_COLLISION_TEST BIT(7)
  638. #define PORT_SPEED_1000MBIT BIT(6)
  639. #define REG_PORT_PHY_STATUS 0x0102
  640. #define PORT_100BT4_CAPABLE BIT(15)
  641. #define PORT_100BTX_FD_CAPABLE BIT(14)
  642. #define PORT_100BTX_CAPABLE BIT(13)
  643. #define PORT_10BT_FD_CAPABLE BIT(12)
  644. #define PORT_10BT_CAPABLE BIT(11)
  645. #define PORT_EXTENDED_STATUS BIT(8)
  646. #define PORT_MII_SUPPRESS_CAPABLE BIT(6)
  647. #define PORT_AUTO_NEG_ACKNOWLEDGE BIT(5)
  648. #define PORT_REMOTE_FAULT BIT(4)
  649. #define PORT_AUTO_NEG_CAPABLE BIT(3)
  650. #define PORT_LINK_STATUS BIT(2)
  651. #define PORT_JABBER_DETECT BIT(1)
  652. #define PORT_EXTENDED_CAPABILITY BIT(0)
  653. #define REG_PORT_PHY_ID_HI 0x0104
  654. #define REG_PORT_PHY_ID_LO 0x0106
  655. #define KSZ9477_ID_HI 0x0022
  656. #define KSZ9477_ID_LO 0x1622
  657. #define REG_PORT_PHY_AUTO_NEGOTIATION 0x0108
  658. #define PORT_AUTO_NEG_NEXT_PAGE BIT(15)
  659. #define PORT_AUTO_NEG_REMOTE_FAULT BIT(13)
  660. #define PORT_AUTO_NEG_ASYM_PAUSE BIT(11)
  661. #define PORT_AUTO_NEG_SYM_PAUSE BIT(10)
  662. #define PORT_AUTO_NEG_100BT4 BIT(9)
  663. #define PORT_AUTO_NEG_100BTX_FD BIT(8)
  664. #define PORT_AUTO_NEG_100BTX BIT(7)
  665. #define PORT_AUTO_NEG_10BT_FD BIT(6)
  666. #define PORT_AUTO_NEG_10BT BIT(5)
  667. #define PORT_AUTO_NEG_SELECTOR 0x001F
  668. #define PORT_AUTO_NEG_802_3 0x0001
  669. #define PORT_AUTO_NEG_PAUSE \
  670. (PORT_AUTO_NEG_ASYM_PAUSE | PORT_AUTO_NEG_SYM_PAUSE)
  671. #define REG_PORT_PHY_REMOTE_CAPABILITY 0x010A
  672. #define PORT_REMOTE_NEXT_PAGE BIT(15)
  673. #define PORT_REMOTE_ACKNOWLEDGE BIT(14)
  674. #define PORT_REMOTE_REMOTE_FAULT BIT(13)
  675. #define PORT_REMOTE_ASYM_PAUSE BIT(11)
  676. #define PORT_REMOTE_SYM_PAUSE BIT(10)
  677. #define PORT_REMOTE_100BTX_FD BIT(8)
  678. #define PORT_REMOTE_100BTX BIT(7)
  679. #define PORT_REMOTE_10BT_FD BIT(6)
  680. #define PORT_REMOTE_10BT BIT(5)
  681. #define REG_PORT_PHY_1000_CTRL 0x0112
  682. #define PORT_AUTO_NEG_MANUAL BIT(12)
  683. #define PORT_AUTO_NEG_MASTER BIT(11)
  684. #define PORT_AUTO_NEG_MASTER_PREFERRED BIT(10)
  685. #define PORT_AUTO_NEG_1000BT_FD BIT(9)
  686. #define PORT_AUTO_NEG_1000BT BIT(8)
  687. #define REG_PORT_PHY_1000_STATUS 0x0114
  688. #define PORT_MASTER_FAULT BIT(15)
  689. #define PORT_LOCAL_MASTER BIT(14)
  690. #define PORT_LOCAL_RX_OK BIT(13)
  691. #define PORT_REMOTE_RX_OK BIT(12)
  692. #define PORT_REMOTE_1000BT_FD BIT(11)
  693. #define PORT_REMOTE_1000BT BIT(10)
  694. #define PORT_REMOTE_IDLE_CNT_M 0x0F
  695. #define PORT_PHY_1000_STATIC_STATUS \
  696. (PORT_LOCAL_RX_OK | \
  697. PORT_REMOTE_RX_OK | \
  698. PORT_REMOTE_1000BT_FD | \
  699. PORT_REMOTE_1000BT)
  700. #define REG_PORT_PHY_MMD_SETUP 0x011A
  701. #define PORT_MMD_OP_MODE_M 0x3
  702. #define PORT_MMD_OP_MODE_S 14
  703. #define PORT_MMD_OP_INDEX 0
  704. #define PORT_MMD_OP_DATA_NO_INCR 1
  705. #define PORT_MMD_OP_DATA_INCR_RW 2
  706. #define PORT_MMD_OP_DATA_INCR_W 3
  707. #define PORT_MMD_DEVICE_ID_M 0x1F
  708. #define MMD_SETUP(mode, dev) \
  709. (((u16)(mode) << PORT_MMD_OP_MODE_S) | (dev))
  710. #define REG_PORT_PHY_MMD_INDEX_DATA 0x011C
  711. #define MMD_DEVICE_ID_DSP 1
  712. #define MMD_DSP_SQI_CHAN_A 0xAC
  713. #define MMD_DSP_SQI_CHAN_B 0xAD
  714. #define MMD_DSP_SQI_CHAN_C 0xAE
  715. #define MMD_DSP_SQI_CHAN_D 0xAF
  716. #define DSP_SQI_ERR_DETECTED BIT(15)
  717. #define DSP_SQI_AVG_ERR 0x7FFF
  718. #define MMD_DEVICE_ID_COMMON 2
  719. #define MMD_DEVICE_ID_EEE_ADV 7
  720. #define MMD_EEE_ADV 0x3C
  721. #define EEE_ADV_100MBIT BIT(1)
  722. #define EEE_ADV_1GBIT BIT(2)
  723. #define MMD_EEE_LP_ADV 0x3D
  724. #define MMD_EEE_MSG_CODE 0x3F
  725. #define MMD_DEVICE_ID_AFED 0x1C
  726. #define REG_PORT_PHY_EXTENDED_STATUS 0x011E
  727. #define PORT_100BTX_FD_ABLE BIT(15)
  728. #define PORT_100BTX_ABLE BIT(14)
  729. #define PORT_10BT_FD_ABLE BIT(13)
  730. #define PORT_10BT_ABLE BIT(12)
  731. #define REG_PORT_SGMII_ADDR__4 0x0200
  732. #define PORT_SGMII_AUTO_INCR BIT(23)
  733. #define PORT_SGMII_DEVICE_ID_M 0x1F
  734. #define PORT_SGMII_DEVICE_ID_S 16
  735. #define PORT_SGMII_ADDR_M (BIT(21) - 1)
  736. #define REG_PORT_SGMII_DATA__4 0x0204
  737. #define PORT_SGMII_DATA_M (BIT(16) - 1)
  738. #define MMD_DEVICE_ID_PMA 0x01
  739. #define MMD_DEVICE_ID_PCS 0x03
  740. #define MMD_DEVICE_ID_PHY_XS 0x04
  741. #define MMD_DEVICE_ID_DTE_XS 0x05
  742. #define MMD_DEVICE_ID_AN 0x07
  743. #define MMD_DEVICE_ID_VENDOR_CTRL 0x1E
  744. #define MMD_DEVICE_ID_VENDOR_MII 0x1F
  745. #define SR_MII MMD_DEVICE_ID_VENDOR_MII
  746. #define MMD_SR_MII_CTRL 0x0000
  747. #define SR_MII_RESET BIT(15)
  748. #define SR_MII_LOOPBACK BIT(14)
  749. #define SR_MII_SPEED_100MBIT BIT(13)
  750. #define SR_MII_AUTO_NEG_ENABLE BIT(12)
  751. #define SR_MII_POWER_DOWN BIT(11)
  752. #define SR_MII_AUTO_NEG_RESTART BIT(9)
  753. #define SR_MII_FULL_DUPLEX BIT(8)
  754. #define SR_MII_SPEED_1000MBIT BIT(6)
  755. #define MMD_SR_MII_STATUS 0x0001
  756. #define MMD_SR_MII_ID_1 0x0002
  757. #define MMD_SR_MII_ID_2 0x0003
  758. #define MMD_SR_MII_AUTO_NEGOTIATION 0x0004
  759. #define SR_MII_AUTO_NEG_NEXT_PAGE BIT(15)
  760. #define SR_MII_AUTO_NEG_REMOTE_FAULT_M 0x3
  761. #define SR_MII_AUTO_NEG_REMOTE_FAULT_S 12
  762. #define SR_MII_AUTO_NEG_NO_ERROR 0
  763. #define SR_MII_AUTO_NEG_OFFLINE 1
  764. #define SR_MII_AUTO_NEG_LINK_FAILURE 2
  765. #define SR_MII_AUTO_NEG_ERROR 3
  766. #define SR_MII_AUTO_NEG_PAUSE_M 0x3
  767. #define SR_MII_AUTO_NEG_PAUSE_S 7
  768. #define SR_MII_AUTO_NEG_NO_PAUSE 0
  769. #define SR_MII_AUTO_NEG_ASYM_PAUSE_TX 1
  770. #define SR_MII_AUTO_NEG_SYM_PAUSE 2
  771. #define SR_MII_AUTO_NEG_ASYM_PAUSE_RX 3
  772. #define SR_MII_AUTO_NEG_HALF_DUPLEX BIT(6)
  773. #define SR_MII_AUTO_NEG_FULL_DUPLEX BIT(5)
  774. #define MMD_SR_MII_REMOTE_CAPABILITY 0x0005
  775. #define MMD_SR_MII_AUTO_NEG_EXP 0x0006
  776. #define MMD_SR_MII_AUTO_NEG_EXT 0x000F
  777. #define MMD_SR_MII_DIGITAL_CTRL_1 0x8000
  778. #define MMD_SR_MII_AUTO_NEG_CTRL 0x8001
  779. #define SR_MII_8_BIT BIT(8)
  780. #define SR_MII_SGMII_LINK_UP BIT(4)
  781. #define SR_MII_TX_CFG_PHY_MASTER BIT(3)
  782. #define SR_MII_PCS_MODE_M 0x3
  783. #define SR_MII_PCS_MODE_S 1
  784. #define SR_MII_PCS_SGMII 2
  785. #define SR_MII_AUTO_NEG_COMPLETE_INTR BIT(0)
  786. #define MMD_SR_MII_AUTO_NEG_STATUS 0x8002
  787. #define SR_MII_STAT_LINK_UP BIT(4)
  788. #define SR_MII_STAT_M 0x3
  789. #define SR_MII_STAT_S 2
  790. #define SR_MII_STAT_10_MBPS 0
  791. #define SR_MII_STAT_100_MBPS 1
  792. #define SR_MII_STAT_1000_MBPS 2
  793. #define SR_MII_STAT_FULL_DUPLEX BIT(1)
  794. #define MMD_SR_MII_PHY_CTRL 0x80A0
  795. #define SR_MII_PHY_LANE_SEL_M 0xF
  796. #define SR_MII_PHY_LANE_SEL_S 8
  797. #define SR_MII_PHY_WRITE BIT(1)
  798. #define SR_MII_PHY_START_BUSY BIT(0)
  799. #define MMD_SR_MII_PHY_ADDR 0x80A1
  800. #define SR_MII_PHY_ADDR_M (BIT(16) - 1)
  801. #define MMD_SR_MII_PHY_DATA 0x80A2
  802. #define SR_MII_PHY_DATA_M (BIT(16) - 1)
  803. #define SR_MII_PHY_JTAG_CHIP_ID_HI 0x000C
  804. #define SR_MII_PHY_JTAG_CHIP_ID_LO 0x000D
  805. #define REG_PORT_PHY_REMOTE_LB_LED 0x0122
  806. #define PORT_REMOTE_LOOPBACK BIT(8)
  807. #define PORT_LED_SELECT (3 << 6)
  808. #define PORT_LED_CTRL (3 << 4)
  809. #define PORT_LED_CTRL_TEST BIT(3)
  810. #define PORT_10BT_PREAMBLE BIT(2)
  811. #define PORT_LINK_MD_10BT_ENABLE BIT(1)
  812. #define PORT_LINK_MD_PASS BIT(0)
  813. #define REG_PORT_PHY_LINK_MD 0x0124
  814. #define PORT_START_CABLE_DIAG BIT(15)
  815. #define PORT_TX_DISABLE BIT(14)
  816. #define PORT_CABLE_DIAG_PAIR_M 0x3
  817. #define PORT_CABLE_DIAG_PAIR_S 12
  818. #define PORT_CABLE_DIAG_SELECT_M 0x3
  819. #define PORT_CABLE_DIAG_SELECT_S 10
  820. #define PORT_CABLE_DIAG_RESULT_M 0x3
  821. #define PORT_CABLE_DIAG_RESULT_S 8
  822. #define PORT_CABLE_STAT_NORMAL 0
  823. #define PORT_CABLE_STAT_OPEN 1
  824. #define PORT_CABLE_STAT_SHORT 2
  825. #define PORT_CABLE_STAT_FAILED 3
  826. #define PORT_CABLE_FAULT_COUNTER 0x00FF
  827. #define REG_PORT_PHY_PMA_STATUS 0x0126
  828. #define PORT_1000_LINK_GOOD BIT(1)
  829. #define PORT_100_LINK_GOOD BIT(0)
  830. #define REG_PORT_PHY_DIGITAL_STATUS 0x0128
  831. #define PORT_LINK_DETECT BIT(14)
  832. #define PORT_SIGNAL_DETECT BIT(13)
  833. #define PORT_PHY_STAT_MDI BIT(12)
  834. #define PORT_PHY_STAT_MASTER BIT(11)
  835. #define REG_PORT_PHY_RXER_COUNTER 0x012A
  836. #define REG_PORT_PHY_INT_ENABLE 0x0136
  837. #define REG_PORT_PHY_INT_STATUS 0x0137
  838. #define JABBER_INT BIT(7)
  839. #define RX_ERR_INT BIT(6)
  840. #define PAGE_RX_INT BIT(5)
  841. #define PARALLEL_DETECT_FAULT_INT BIT(4)
  842. #define LINK_PARTNER_ACK_INT BIT(3)
  843. #define LINK_DOWN_INT BIT(2)
  844. #define REMOTE_FAULT_INT BIT(1)
  845. #define LINK_UP_INT BIT(0)
  846. #define REG_PORT_PHY_DIGITAL_DEBUG_1 0x0138
  847. #define PORT_REG_CLK_SPEED_25_MHZ BIT(14)
  848. #define PORT_PHY_FORCE_MDI BIT(7)
  849. #define PORT_PHY_AUTO_MDIX_DISABLE BIT(6)
  850. /* Same as PORT_PHY_LOOPBACK */
  851. #define PORT_PHY_PCS_LOOPBACK BIT(0)
  852. #define REG_PORT_PHY_DIGITAL_DEBUG_2 0x013A
  853. #define REG_PORT_PHY_DIGITAL_DEBUG_3 0x013C
  854. #define PORT_100BT_FIXED_LATENCY BIT(15)
  855. #define REG_PORT_PHY_PHY_CTRL 0x013E
  856. #define PORT_INT_PIN_HIGH BIT(14)
  857. #define PORT_ENABLE_JABBER BIT(9)
  858. #define PORT_STAT_SPEED_1000MBIT BIT(6)
  859. #define PORT_STAT_SPEED_100MBIT BIT(5)
  860. #define PORT_STAT_SPEED_10MBIT BIT(4)
  861. #define PORT_STAT_FULL_DUPLEX BIT(3)
  862. /* Same as PORT_PHY_STAT_MASTER */
  863. #define PORT_STAT_MASTER BIT(2)
  864. #define PORT_RESET BIT(1)
  865. #define PORT_LINK_STATUS_FAIL BIT(0)
  866. /* 3 - xMII */
  867. #define PORT_SGMII_SEL BIT(7)
  868. #define PORT_GRXC_ENABLE BIT(0)
  869. #define PORT_RMII_CLK_SEL BIT(7)
  870. #define PORT_MII_SEL_EDGE BIT(5)
  871. /* 4 - MAC */
  872. #define REG_PORT_MAC_CTRL_0 0x0400
  873. #define PORT_BROADCAST_STORM BIT(1)
  874. #define PORT_JUMBO_FRAME BIT(0)
  875. #define REG_PORT_MAC_CTRL_1 0x0401
  876. #define PORT_BACK_PRESSURE BIT(3)
  877. #define PORT_PASS_ALL BIT(0)
  878. #define REG_PORT_MAC_CTRL_2 0x0402
  879. #define PORT_100BT_EEE_DISABLE BIT(7)
  880. #define PORT_1000BT_EEE_DISABLE BIT(6)
  881. #define REG_PORT_MAC_IN_RATE_LIMIT 0x0403
  882. #define PORT_IN_PORT_BASED_S 6
  883. #define PORT_RATE_PACKET_BASED_S 5
  884. #define PORT_IN_FLOW_CTRL_S 4
  885. #define PORT_COUNT_IFG_S 1
  886. #define PORT_COUNT_PREAMBLE_S 0
  887. #define PORT_IN_PORT_BASED BIT(6)
  888. #define PORT_IN_PACKET_BASED BIT(5)
  889. #define PORT_IN_FLOW_CTRL BIT(4)
  890. #define PORT_IN_LIMIT_MODE_M 0x3
  891. #define PORT_IN_LIMIT_MODE_S 2
  892. #define PORT_IN_ALL 0
  893. #define PORT_IN_UNICAST 1
  894. #define PORT_IN_MULTICAST 2
  895. #define PORT_IN_BROADCAST 3
  896. #define PORT_COUNT_IFG BIT(1)
  897. #define PORT_COUNT_PREAMBLE BIT(0)
  898. #define REG_PORT_IN_RATE_0 0x0410
  899. #define REG_PORT_IN_RATE_1 0x0411
  900. #define REG_PORT_IN_RATE_2 0x0412
  901. #define REG_PORT_IN_RATE_3 0x0413
  902. #define REG_PORT_IN_RATE_4 0x0414
  903. #define REG_PORT_IN_RATE_5 0x0415
  904. #define REG_PORT_IN_RATE_6 0x0416
  905. #define REG_PORT_IN_RATE_7 0x0417
  906. #define REG_PORT_OUT_RATE_0 0x0420
  907. #define REG_PORT_OUT_RATE_1 0x0421
  908. #define REG_PORT_OUT_RATE_2 0x0422
  909. #define REG_PORT_OUT_RATE_3 0x0423
  910. #define PORT_RATE_LIMIT_M (BIT(7) - 1)
  911. /* 5 - MIB Counters */
  912. #define REG_PORT_MIB_CTRL_STAT__4 0x0500
  913. #define MIB_COUNTER_READ BIT(25)
  914. #define MIB_COUNTER_FLUSH_FREEZE BIT(24)
  915. #define MIB_COUNTER_INDEX_M (BIT(8) - 1)
  916. #define MIB_COUNTER_INDEX_S 16
  917. #define MIB_COUNTER_DATA_HI_M 0xF
  918. #define REG_PORT_MIB_DATA 0x0504
  919. /* 6 - ACL */
  920. #define REG_PORT_ACL_0 0x0600
  921. #define ACL_FIRST_RULE_M 0xF
  922. #define REG_PORT_ACL_1 0x0601
  923. #define ACL_MODE_M 0x3
  924. #define ACL_MODE_S 4
  925. #define ACL_MODE_DISABLE 0
  926. #define ACL_MODE_LAYER_2 1
  927. #define ACL_MODE_LAYER_3 2
  928. #define ACL_MODE_LAYER_4 3
  929. #define ACL_ENABLE_M 0x3
  930. #define ACL_ENABLE_S 2
  931. #define ACL_ENABLE_2_COUNT 0
  932. #define ACL_ENABLE_2_TYPE 1
  933. #define ACL_ENABLE_2_MAC 2
  934. #define ACL_ENABLE_2_BOTH 3
  935. #define ACL_ENABLE_3_IP 1
  936. #define ACL_ENABLE_3_SRC_DST_COMP 2
  937. #define ACL_ENABLE_4_PROTOCOL 0
  938. #define ACL_ENABLE_4_TCP_PORT_COMP 1
  939. #define ACL_ENABLE_4_UDP_PORT_COMP 2
  940. #define ACL_ENABLE_4_TCP_SEQN_COMP 3
  941. #define ACL_SRC BIT(1)
  942. #define ACL_EQUAL BIT(0)
  943. #define REG_PORT_ACL_2 0x0602
  944. #define REG_PORT_ACL_3 0x0603
  945. #define ACL_MAX_PORT 0xFFFF
  946. #define REG_PORT_ACL_4 0x0604
  947. #define REG_PORT_ACL_5 0x0605
  948. #define ACL_MIN_PORT 0xFFFF
  949. #define ACL_IP_ADDR 0xFFFFFFFF
  950. #define ACL_TCP_SEQNUM 0xFFFFFFFF
  951. #define REG_PORT_ACL_6 0x0606
  952. #define ACL_RESERVED 0xF8
  953. #define ACL_PORT_MODE_M 0x3
  954. #define ACL_PORT_MODE_S 1
  955. #define ACL_PORT_MODE_DISABLE 0
  956. #define ACL_PORT_MODE_EITHER 1
  957. #define ACL_PORT_MODE_IN_RANGE 2
  958. #define ACL_PORT_MODE_OUT_OF_RANGE 3
  959. #define REG_PORT_ACL_7 0x0607
  960. #define ACL_TCP_FLAG_ENABLE BIT(0)
  961. #define REG_PORT_ACL_8 0x0608
  962. #define ACL_TCP_FLAG_M 0xFF
  963. #define REG_PORT_ACL_9 0x0609
  964. #define ACL_TCP_FLAG 0xFF
  965. #define ACL_ETH_TYPE 0xFFFF
  966. #define ACL_IP_M 0xFFFFFFFF
  967. #define REG_PORT_ACL_A 0x060A
  968. #define ACL_PRIO_MODE_M 0x3
  969. #define ACL_PRIO_MODE_S 6
  970. #define ACL_PRIO_MODE_DISABLE 0
  971. #define ACL_PRIO_MODE_HIGHER 1
  972. #define ACL_PRIO_MODE_LOWER 2
  973. #define ACL_PRIO_MODE_REPLACE 3
  974. #define ACL_PRIO_M KS_PRIO_M
  975. #define ACL_PRIO_S 3
  976. #define ACL_VLAN_PRIO_REPLACE BIT(2)
  977. #define ACL_VLAN_PRIO_M KS_PRIO_M
  978. #define ACL_VLAN_PRIO_HI_M 0x3
  979. #define REG_PORT_ACL_B 0x060B
  980. #define ACL_VLAN_PRIO_LO_M 0x8
  981. #define ACL_VLAN_PRIO_S 7
  982. #define ACL_MAP_MODE_M 0x3
  983. #define ACL_MAP_MODE_S 5
  984. #define ACL_MAP_MODE_DISABLE 0
  985. #define ACL_MAP_MODE_OR 1
  986. #define ACL_MAP_MODE_AND 2
  987. #define ACL_MAP_MODE_REPLACE 3
  988. #define ACL_CNT_M (BIT(11) - 1)
  989. #define ACL_CNT_S 5
  990. #define REG_PORT_ACL_C 0x060C
  991. #define REG_PORT_ACL_D 0x060D
  992. #define ACL_MSEC_UNIT BIT(6)
  993. #define ACL_INTR_MODE BIT(5)
  994. #define ACL_PORT_MAP 0x7F
  995. #define REG_PORT_ACL_E 0x060E
  996. #define REG_PORT_ACL_F 0x060F
  997. #define REG_PORT_ACL_BYTE_EN_MSB 0x0610
  998. #define REG_PORT_ACL_BYTE_EN_LSB 0x0611
  999. #define ACL_ACTION_START 0xA
  1000. #define ACL_ACTION_LEN 4
  1001. #define ACL_INTR_CNT_START 0xD
  1002. #define ACL_RULESET_START 0xE
  1003. #define ACL_RULESET_LEN 2
  1004. #define ACL_TABLE_LEN 16
  1005. #define ACL_ACTION_ENABLE 0x003C
  1006. #define ACL_MATCH_ENABLE 0x7FC3
  1007. #define ACL_RULESET_ENABLE 0x8003
  1008. #define ACL_BYTE_ENABLE 0xFFFF
  1009. #define REG_PORT_ACL_CTRL_0 0x0612
  1010. #define PORT_ACL_WRITE_DONE BIT(6)
  1011. #define PORT_ACL_READ_DONE BIT(5)
  1012. #define PORT_ACL_WRITE BIT(4)
  1013. #define PORT_ACL_INDEX_M 0xF
  1014. #define REG_PORT_ACL_CTRL_1 0x0613
  1015. /* 8 - Classification and Policing */
  1016. #define REG_PORT_MRI_MIRROR_CTRL 0x0800
  1017. #define PORT_MIRROR_RX BIT(6)
  1018. #define PORT_MIRROR_TX BIT(5)
  1019. #define PORT_MIRROR_SNIFFER BIT(1)
  1020. #define REG_PORT_MRI_PRIO_CTRL 0x0801
  1021. #define PORT_HIGHEST_PRIO BIT(7)
  1022. #define PORT_OR_PRIO BIT(6)
  1023. #define PORT_MAC_PRIO_ENABLE BIT(4)
  1024. #define PORT_VLAN_PRIO_ENABLE BIT(3)
  1025. #define PORT_802_1P_PRIO_ENABLE BIT(2)
  1026. #define PORT_DIFFSERV_PRIO_ENABLE BIT(1)
  1027. #define PORT_ACL_PRIO_ENABLE BIT(0)
  1028. #define REG_PORT_MRI_MAC_CTRL 0x0802
  1029. #define PORT_USER_PRIO_CEILING BIT(7)
  1030. #define PORT_DROP_NON_VLAN BIT(4)
  1031. #define PORT_DROP_TAG BIT(3)
  1032. #define PORT_BASED_PRIO_M KS_PRIO_M
  1033. #define PORT_BASED_PRIO_S 0
  1034. #define REG_PORT_MRI_AUTHEN_CTRL 0x0803
  1035. #define PORT_ACL_ENABLE BIT(2)
  1036. #define PORT_AUTHEN_MODE 0x3
  1037. #define PORT_AUTHEN_PASS 0
  1038. #define PORT_AUTHEN_BLOCK 1
  1039. #define PORT_AUTHEN_TRAP 2
  1040. #define REG_PORT_MRI_INDEX__4 0x0804
  1041. #define MRI_INDEX_P_M 0x7
  1042. #define MRI_INDEX_P_S 16
  1043. #define MRI_INDEX_Q_M 0x3
  1044. #define MRI_INDEX_Q_S 0
  1045. #define REG_PORT_MRI_TC_MAP__4 0x0808
  1046. #define PORT_TC_MAP_M 0xf
  1047. #define PORT_TC_MAP_S 4
  1048. #define REG_PORT_MRI_POLICE_CTRL__4 0x080C
  1049. #define POLICE_DROP_ALL BIT(10)
  1050. #define POLICE_PACKET_TYPE_M 0x3
  1051. #define POLICE_PACKET_TYPE_S 8
  1052. #define POLICE_PACKET_DROPPED 0
  1053. #define POLICE_PACKET_GREEN 1
  1054. #define POLICE_PACKET_YELLOW 2
  1055. #define POLICE_PACKET_RED 3
  1056. #define PORT_BASED_POLICING BIT(7)
  1057. #define NON_DSCP_COLOR_M 0x3
  1058. #define NON_DSCP_COLOR_S 5
  1059. #define COLOR_MARK_ENABLE BIT(4)
  1060. #define COLOR_REMAP_ENABLE BIT(3)
  1061. #define POLICE_DROP_SRP BIT(2)
  1062. #define POLICE_COLOR_NOT_AWARE BIT(1)
  1063. #define POLICE_ENABLE BIT(0)
  1064. #define REG_PORT_POLICE_COLOR_0__4 0x0810
  1065. #define REG_PORT_POLICE_COLOR_1__4 0x0814
  1066. #define REG_PORT_POLICE_COLOR_2__4 0x0818
  1067. #define REG_PORT_POLICE_COLOR_3__4 0x081C
  1068. #define POLICE_COLOR_MAP_S 2
  1069. #define POLICE_COLOR_MAP_M (BIT(POLICE_COLOR_MAP_S) - 1)
  1070. #define REG_PORT_POLICE_RATE__4 0x0820
  1071. #define POLICE_CIR_S 16
  1072. #define POLICE_PIR_S 0
  1073. #define REG_PORT_POLICE_BURST_SIZE__4 0x0824
  1074. #define POLICE_BURST_SIZE_M 0x3FFF
  1075. #define POLICE_CBS_S 16
  1076. #define POLICE_PBS_S 0
  1077. #define REG_PORT_WRED_PM_CTRL_0__4 0x0830
  1078. #define WRED_PM_CTRL_M (BIT(11) - 1)
  1079. #define WRED_PM_MAX_THRESHOLD_S 16
  1080. #define WRED_PM_MIN_THRESHOLD_S 0
  1081. #define REG_PORT_WRED_PM_CTRL_1__4 0x0834
  1082. #define WRED_PM_MULTIPLIER_S 16
  1083. #define WRED_PM_AVG_QUEUE_SIZE_S 0
  1084. #define REG_PORT_WRED_QUEUE_CTRL_0__4 0x0840
  1085. #define REG_PORT_WRED_QUEUE_CTRL_1__4 0x0844
  1086. #define REG_PORT_WRED_QUEUE_PMON__4 0x0848
  1087. #define WRED_RANDOM_DROP_ENABLE BIT(31)
  1088. #define WRED_PMON_FLUSH BIT(30)
  1089. #define WRED_DROP_GYR_DISABLE BIT(29)
  1090. #define WRED_DROP_YR_DISABLE BIT(28)
  1091. #define WRED_DROP_R_DISABLE BIT(27)
  1092. #define WRED_DROP_ALL BIT(26)
  1093. #define WRED_PMON_M (BIT(24) - 1)
  1094. /* 9 - Shaping */
  1095. #define REG_PORT_MTI_QUEUE_INDEX__4 0x0900
  1096. #define REG_PORT_MTI_QUEUE_CTRL_0__4 0x0904
  1097. #define MTI_PVID_REPLACE BIT(0)
  1098. #define REG_PORT_MTI_QUEUE_CTRL_0 0x0914
  1099. #define MTI_SCHEDULE_MODE_M 0x3
  1100. #define MTI_SCHEDULE_MODE_S 6
  1101. #define MTI_SCHEDULE_STRICT_PRIO 0
  1102. #define MTI_SCHEDULE_WRR 2
  1103. #define MTI_SHAPING_M 0x3
  1104. #define MTI_SHAPING_S 4
  1105. #define MTI_SHAPING_OFF 0
  1106. #define MTI_SHAPING_SRP 1
  1107. #define MTI_SHAPING_TIME_AWARE 2
  1108. #define REG_PORT_MTI_QUEUE_CTRL_1 0x0915
  1109. #define MTI_TX_RATIO_M (BIT(7) - 1)
  1110. #define REG_PORT_MTI_QUEUE_CTRL_2__2 0x0916
  1111. #define REG_PORT_MTI_HI_WATER_MARK 0x0916
  1112. #define REG_PORT_MTI_QUEUE_CTRL_3__2 0x0918
  1113. #define REG_PORT_MTI_LO_WATER_MARK 0x0918
  1114. #define REG_PORT_MTI_QUEUE_CTRL_4__2 0x091A
  1115. #define REG_PORT_MTI_CREDIT_INCREMENT 0x091A
  1116. /* A - QM */
  1117. #define REG_PORT_QM_CTRL__4 0x0A00
  1118. #define PORT_QM_DROP_PRIO_M 0x3
  1119. #define REG_PORT_VLAN_MEMBERSHIP__4 0x0A04
  1120. #define REG_PORT_QM_QUEUE_INDEX__4 0x0A08
  1121. #define PORT_QM_QUEUE_INDEX_S 24
  1122. #define PORT_QM_BURST_SIZE_S 16
  1123. #define PORT_QM_MIN_RESV_SPACE_M (BIT(11) - 1)
  1124. #define REG_PORT_QM_WATER_MARK__4 0x0A0C
  1125. #define PORT_QM_HI_WATER_MARK_S 16
  1126. #define PORT_QM_LO_WATER_MARK_S 0
  1127. #define PORT_QM_WATER_MARK_M (BIT(11) - 1)
  1128. #define REG_PORT_QM_TX_CNT_0__4 0x0A10
  1129. #define PORT_QM_TX_CNT_USED_S 0
  1130. #define PORT_QM_TX_CNT_M (BIT(11) - 1)
  1131. #define REG_PORT_QM_TX_CNT_1__4 0x0A14
  1132. #define PORT_QM_TX_CNT_CALCULATED_S 16
  1133. #define PORT_QM_TX_CNT_AVAIL_S 0
  1134. /* B - LUE */
  1135. #define REG_PORT_LUE_CTRL 0x0B00
  1136. #define PORT_VLAN_LOOKUP_VID_0 BIT(7)
  1137. #define PORT_INGRESS_FILTER BIT(6)
  1138. #define PORT_DISCARD_NON_VID BIT(5)
  1139. #define PORT_MAC_BASED_802_1X BIT(4)
  1140. #define PORT_SRC_ADDR_FILTER BIT(3)
  1141. #define REG_PORT_LUE_MSTP_INDEX 0x0B01
  1142. #define REG_PORT_LUE_MSTP_STATE 0x0B04
  1143. /* C - PTP */
  1144. #define REG_PTP_PORT_RX_DELAY__2 0x0C00
  1145. #define REG_PTP_PORT_TX_DELAY__2 0x0C02
  1146. #define REG_PTP_PORT_ASYM_DELAY__2 0x0C04
  1147. #define REG_PTP_PORT_XDELAY_TS 0x0C08
  1148. #define REG_PTP_PORT_XDELAY_TS_H 0x0C08
  1149. #define REG_PTP_PORT_XDELAY_TS_L 0x0C0A
  1150. #define REG_PTP_PORT_SYNC_TS 0x0C0C
  1151. #define REG_PTP_PORT_SYNC_TS_H 0x0C0C
  1152. #define REG_PTP_PORT_SYNC_TS_L 0x0C0E
  1153. #define REG_PTP_PORT_PDRESP_TS 0x0C10
  1154. #define REG_PTP_PORT_PDRESP_TS_H 0x0C10
  1155. #define REG_PTP_PORT_PDRESP_TS_L 0x0C12
  1156. #define REG_PTP_PORT_TX_INT_STATUS__2 0x0C14
  1157. #define REG_PTP_PORT_TX_INT_ENABLE__2 0x0C16
  1158. #define PTP_PORT_SYNC_INT BIT(15)
  1159. #define PTP_PORT_XDELAY_REQ_INT BIT(14)
  1160. #define PTP_PORT_PDELAY_RESP_INT BIT(13)
  1161. #define REG_PTP_PORT_LINK_DELAY__4 0x0C18
  1162. #define PRIO_QUEUES 4
  1163. #define RX_PRIO_QUEUES 8
  1164. #define KS_PRIO_IN_REG 2
  1165. #define TOTAL_PORT_NUM 7
  1166. #define KSZ9477_COUNTER_NUM 0x20
  1167. #define TOTAL_KSZ9477_COUNTER_NUM (KSZ9477_COUNTER_NUM + 2 + 2)
  1168. #define SWITCH_COUNTER_NUM KSZ9477_COUNTER_NUM
  1169. #define TOTAL_SWITCH_COUNTER_NUM TOTAL_KSZ9477_COUNTER_NUM
  1170. #define P_BCAST_STORM_CTRL REG_PORT_MAC_CTRL_0
  1171. #define P_PRIO_CTRL REG_PORT_MRI_PRIO_CTRL
  1172. #define P_MIRROR_CTRL REG_PORT_MRI_MIRROR_CTRL
  1173. #define P_PHY_CTRL REG_PORT_PHY_CTRL
  1174. #define P_RATE_LIMIT_CTRL REG_PORT_MAC_IN_RATE_LIMIT
  1175. #define S_LINK_AGING_CTRL REG_SW_LUE_CTRL_1
  1176. #define S_MIRROR_CTRL REG_SW_MRI_CTRL_0
  1177. #define S_REPLACE_VID_CTRL REG_SW_MAC_CTRL_2
  1178. #define S_802_1P_PRIO_CTRL REG_SW_MAC_802_1P_MAP_0
  1179. #define S_TOS_PRIO_CTRL REG_SW_MAC_TOS_PRIO_0
  1180. #define S_FLUSH_TABLE_CTRL REG_SW_LUE_CTRL_1
  1181. #define SW_FLUSH_DYN_MAC_TABLE SW_FLUSH_MSTP_TABLE
  1182. #define MAX_TIMESTAMP_UNIT 2
  1183. #define MAX_TRIG_UNIT 3
  1184. #define MAX_TIMESTAMP_EVENT_UNIT 8
  1185. #define MAX_GPIO 4
  1186. #define PTP_TRIG_UNIT_M (BIT(MAX_TRIG_UNIT) - 1)
  1187. #define PTP_TS_UNIT_M (BIT(MAX_TIMESTAMP_UNIT) - 1)
  1188. #define KSZ9477_MAX_FRAME_SIZE 9000
  1189. #endif /* KSZ9477_REGS_H */