ocelot_regs.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. // SPDX-License-Identifier: (GPL-2.0 OR MIT)
  2. /*
  3. * Microsemi Ocelot Switch driver
  4. *
  5. * Copyright (c) 2017 Microsemi Corporation
  6. */
  7. #include "ocelot.h"
  8. static const u32 ocelot_ana_regmap[] = {
  9. REG(ANA_ADVLEARN, 0x009000),
  10. REG(ANA_VLANMASK, 0x009004),
  11. REG(ANA_PORT_B_DOMAIN, 0x009008),
  12. REG(ANA_ANAGEFIL, 0x00900c),
  13. REG(ANA_ANEVENTS, 0x009010),
  14. REG(ANA_STORMLIMIT_BURST, 0x009014),
  15. REG(ANA_STORMLIMIT_CFG, 0x009018),
  16. REG(ANA_ISOLATED_PORTS, 0x009028),
  17. REG(ANA_COMMUNITY_PORTS, 0x00902c),
  18. REG(ANA_AUTOAGE, 0x009030),
  19. REG(ANA_MACTOPTIONS, 0x009034),
  20. REG(ANA_LEARNDISC, 0x009038),
  21. REG(ANA_AGENCTRL, 0x00903c),
  22. REG(ANA_MIRRORPORTS, 0x009040),
  23. REG(ANA_EMIRRORPORTS, 0x009044),
  24. REG(ANA_FLOODING, 0x009048),
  25. REG(ANA_FLOODING_IPMC, 0x00904c),
  26. REG(ANA_SFLOW_CFG, 0x009050),
  27. REG(ANA_PORT_MODE, 0x009080),
  28. REG(ANA_PGID_PGID, 0x008c00),
  29. REG(ANA_TABLES_ANMOVED, 0x008b30),
  30. REG(ANA_TABLES_MACHDATA, 0x008b34),
  31. REG(ANA_TABLES_MACLDATA, 0x008b38),
  32. REG(ANA_TABLES_MACACCESS, 0x008b3c),
  33. REG(ANA_TABLES_MACTINDX, 0x008b40),
  34. REG(ANA_TABLES_VLANACCESS, 0x008b44),
  35. REG(ANA_TABLES_VLANTIDX, 0x008b48),
  36. REG(ANA_TABLES_ISDXACCESS, 0x008b4c),
  37. REG(ANA_TABLES_ISDXTIDX, 0x008b50),
  38. REG(ANA_TABLES_ENTRYLIM, 0x008b00),
  39. REG(ANA_TABLES_PTP_ID_HIGH, 0x008b54),
  40. REG(ANA_TABLES_PTP_ID_LOW, 0x008b58),
  41. REG(ANA_MSTI_STATE, 0x008e00),
  42. REG(ANA_PORT_VLAN_CFG, 0x007000),
  43. REG(ANA_PORT_DROP_CFG, 0x007004),
  44. REG(ANA_PORT_QOS_CFG, 0x007008),
  45. REG(ANA_PORT_VCAP_CFG, 0x00700c),
  46. REG(ANA_PORT_VCAP_S1_KEY_CFG, 0x007010),
  47. REG(ANA_PORT_VCAP_S2_CFG, 0x00701c),
  48. REG(ANA_PORT_PCP_DEI_MAP, 0x007020),
  49. REG(ANA_PORT_CPU_FWD_CFG, 0x007060),
  50. REG(ANA_PORT_CPU_FWD_BPDU_CFG, 0x007064),
  51. REG(ANA_PORT_CPU_FWD_GARP_CFG, 0x007068),
  52. REG(ANA_PORT_CPU_FWD_CCM_CFG, 0x00706c),
  53. REG(ANA_PORT_PORT_CFG, 0x007070),
  54. REG(ANA_PORT_POL_CFG, 0x007074),
  55. REG(ANA_PORT_PTP_CFG, 0x007078),
  56. REG(ANA_PORT_PTP_DLY1_CFG, 0x00707c),
  57. REG(ANA_OAM_UPM_LM_CNT, 0x007c00),
  58. REG(ANA_PORT_PTP_DLY2_CFG, 0x007080),
  59. REG(ANA_PFC_PFC_CFG, 0x008800),
  60. REG(ANA_PFC_PFC_TIMER, 0x008804),
  61. REG(ANA_IPT_OAM_MEP_CFG, 0x008000),
  62. REG(ANA_IPT_IPT, 0x008004),
  63. REG(ANA_PPT_PPT, 0x008ac0),
  64. REG(ANA_FID_MAP_FID_MAP, 0x000000),
  65. REG(ANA_AGGR_CFG, 0x0090b4),
  66. REG(ANA_CPUQ_CFG, 0x0090b8),
  67. REG(ANA_CPUQ_CFG2, 0x0090bc),
  68. REG(ANA_CPUQ_8021_CFG, 0x0090c0),
  69. REG(ANA_DSCP_CFG, 0x009100),
  70. REG(ANA_DSCP_REWR_CFG, 0x009200),
  71. REG(ANA_VCAP_RNG_TYPE_CFG, 0x009240),
  72. REG(ANA_VCAP_RNG_VAL_CFG, 0x009260),
  73. REG(ANA_VRAP_CFG, 0x009280),
  74. REG(ANA_VRAP_HDR_DATA, 0x009284),
  75. REG(ANA_VRAP_HDR_MASK, 0x009288),
  76. REG(ANA_DISCARD_CFG, 0x00928c),
  77. REG(ANA_FID_CFG, 0x009290),
  78. REG(ANA_POL_PIR_CFG, 0x004000),
  79. REG(ANA_POL_CIR_CFG, 0x004004),
  80. REG(ANA_POL_MODE_CFG, 0x004008),
  81. REG(ANA_POL_PIR_STATE, 0x00400c),
  82. REG(ANA_POL_CIR_STATE, 0x004010),
  83. REG(ANA_POL_STATE, 0x004014),
  84. REG(ANA_POL_FLOWC, 0x008b80),
  85. REG(ANA_POL_HYST, 0x008bec),
  86. REG(ANA_POL_MISC_CFG, 0x008bf0),
  87. };
  88. static const u32 ocelot_qs_regmap[] = {
  89. REG(QS_XTR_GRP_CFG, 0x000000),
  90. REG(QS_XTR_RD, 0x000008),
  91. REG(QS_XTR_FRM_PRUNING, 0x000010),
  92. REG(QS_XTR_FLUSH, 0x000018),
  93. REG(QS_XTR_DATA_PRESENT, 0x00001c),
  94. REG(QS_XTR_CFG, 0x000020),
  95. REG(QS_INJ_GRP_CFG, 0x000024),
  96. REG(QS_INJ_WR, 0x00002c),
  97. REG(QS_INJ_CTRL, 0x000034),
  98. REG(QS_INJ_STATUS, 0x00003c),
  99. REG(QS_INJ_ERR, 0x000040),
  100. REG(QS_INH_DBG, 0x000048),
  101. };
  102. static const u32 ocelot_hsio_regmap[] = {
  103. REG(HSIO_PLL5G_CFG0, 0x000000),
  104. REG(HSIO_PLL5G_CFG1, 0x000004),
  105. REG(HSIO_PLL5G_CFG2, 0x000008),
  106. REG(HSIO_PLL5G_CFG3, 0x00000c),
  107. REG(HSIO_PLL5G_CFG4, 0x000010),
  108. REG(HSIO_PLL5G_CFG5, 0x000014),
  109. REG(HSIO_PLL5G_CFG6, 0x000018),
  110. REG(HSIO_PLL5G_STATUS0, 0x00001c),
  111. REG(HSIO_PLL5G_STATUS1, 0x000020),
  112. REG(HSIO_PLL5G_BIST_CFG0, 0x000024),
  113. REG(HSIO_PLL5G_BIST_CFG1, 0x000028),
  114. REG(HSIO_PLL5G_BIST_CFG2, 0x00002c),
  115. REG(HSIO_PLL5G_BIST_STAT0, 0x000030),
  116. REG(HSIO_PLL5G_BIST_STAT1, 0x000034),
  117. REG(HSIO_RCOMP_CFG0, 0x000038),
  118. REG(HSIO_RCOMP_STATUS, 0x00003c),
  119. REG(HSIO_SYNC_ETH_CFG, 0x000040),
  120. REG(HSIO_SYNC_ETH_PLL_CFG, 0x000048),
  121. REG(HSIO_S1G_DES_CFG, 0x00004c),
  122. REG(HSIO_S1G_IB_CFG, 0x000050),
  123. REG(HSIO_S1G_OB_CFG, 0x000054),
  124. REG(HSIO_S1G_SER_CFG, 0x000058),
  125. REG(HSIO_S1G_COMMON_CFG, 0x00005c),
  126. REG(HSIO_S1G_PLL_CFG, 0x000060),
  127. REG(HSIO_S1G_PLL_STATUS, 0x000064),
  128. REG(HSIO_S1G_DFT_CFG0, 0x000068),
  129. REG(HSIO_S1G_DFT_CFG1, 0x00006c),
  130. REG(HSIO_S1G_DFT_CFG2, 0x000070),
  131. REG(HSIO_S1G_TP_CFG, 0x000074),
  132. REG(HSIO_S1G_RC_PLL_BIST_CFG, 0x000078),
  133. REG(HSIO_S1G_MISC_CFG, 0x00007c),
  134. REG(HSIO_S1G_DFT_STATUS, 0x000080),
  135. REG(HSIO_S1G_MISC_STATUS, 0x000084),
  136. REG(HSIO_MCB_S1G_ADDR_CFG, 0x000088),
  137. REG(HSIO_S6G_DIG_CFG, 0x00008c),
  138. REG(HSIO_S6G_DFT_CFG0, 0x000090),
  139. REG(HSIO_S6G_DFT_CFG1, 0x000094),
  140. REG(HSIO_S6G_DFT_CFG2, 0x000098),
  141. REG(HSIO_S6G_TP_CFG0, 0x00009c),
  142. REG(HSIO_S6G_TP_CFG1, 0x0000a0),
  143. REG(HSIO_S6G_RC_PLL_BIST_CFG, 0x0000a4),
  144. REG(HSIO_S6G_MISC_CFG, 0x0000a8),
  145. REG(HSIO_S6G_OB_ANEG_CFG, 0x0000ac),
  146. REG(HSIO_S6G_DFT_STATUS, 0x0000b0),
  147. REG(HSIO_S6G_ERR_CNT, 0x0000b4),
  148. REG(HSIO_S6G_MISC_STATUS, 0x0000b8),
  149. REG(HSIO_S6G_DES_CFG, 0x0000bc),
  150. REG(HSIO_S6G_IB_CFG, 0x0000c0),
  151. REG(HSIO_S6G_IB_CFG1, 0x0000c4),
  152. REG(HSIO_S6G_IB_CFG2, 0x0000c8),
  153. REG(HSIO_S6G_IB_CFG3, 0x0000cc),
  154. REG(HSIO_S6G_IB_CFG4, 0x0000d0),
  155. REG(HSIO_S6G_IB_CFG5, 0x0000d4),
  156. REG(HSIO_S6G_OB_CFG, 0x0000d8),
  157. REG(HSIO_S6G_OB_CFG1, 0x0000dc),
  158. REG(HSIO_S6G_SER_CFG, 0x0000e0),
  159. REG(HSIO_S6G_COMMON_CFG, 0x0000e4),
  160. REG(HSIO_S6G_PLL_CFG, 0x0000e8),
  161. REG(HSIO_S6G_ACJTAG_CFG, 0x0000ec),
  162. REG(HSIO_S6G_GP_CFG, 0x0000f0),
  163. REG(HSIO_S6G_IB_STATUS0, 0x0000f4),
  164. REG(HSIO_S6G_IB_STATUS1, 0x0000f8),
  165. REG(HSIO_S6G_ACJTAG_STATUS, 0x0000fc),
  166. REG(HSIO_S6G_PLL_STATUS, 0x000100),
  167. REG(HSIO_S6G_REVID, 0x000104),
  168. REG(HSIO_MCB_S6G_ADDR_CFG, 0x000108),
  169. REG(HSIO_HW_CFG, 0x00010c),
  170. REG(HSIO_HW_QSGMII_CFG, 0x000110),
  171. REG(HSIO_HW_QSGMII_STAT, 0x000114),
  172. REG(HSIO_CLK_CFG, 0x000118),
  173. REG(HSIO_TEMP_SENSOR_CTRL, 0x00011c),
  174. REG(HSIO_TEMP_SENSOR_CFG, 0x000120),
  175. REG(HSIO_TEMP_SENSOR_STAT, 0x000124),
  176. };
  177. static const u32 ocelot_qsys_regmap[] = {
  178. REG(QSYS_PORT_MODE, 0x011200),
  179. REG(QSYS_SWITCH_PORT_MODE, 0x011234),
  180. REG(QSYS_STAT_CNT_CFG, 0x011264),
  181. REG(QSYS_EEE_CFG, 0x011268),
  182. REG(QSYS_EEE_THRES, 0x011294),
  183. REG(QSYS_IGR_NO_SHARING, 0x011298),
  184. REG(QSYS_EGR_NO_SHARING, 0x01129c),
  185. REG(QSYS_SW_STATUS, 0x0112a0),
  186. REG(QSYS_EXT_CPU_CFG, 0x0112d0),
  187. REG(QSYS_PAD_CFG, 0x0112d4),
  188. REG(QSYS_CPU_GROUP_MAP, 0x0112d8),
  189. REG(QSYS_QMAP, 0x0112dc),
  190. REG(QSYS_ISDX_SGRP, 0x011400),
  191. REG(QSYS_TIMED_FRAME_ENTRY, 0x014000),
  192. REG(QSYS_TFRM_MISC, 0x011310),
  193. REG(QSYS_TFRM_PORT_DLY, 0x011314),
  194. REG(QSYS_TFRM_TIMER_CFG_1, 0x011318),
  195. REG(QSYS_TFRM_TIMER_CFG_2, 0x01131c),
  196. REG(QSYS_TFRM_TIMER_CFG_3, 0x011320),
  197. REG(QSYS_TFRM_TIMER_CFG_4, 0x011324),
  198. REG(QSYS_TFRM_TIMER_CFG_5, 0x011328),
  199. REG(QSYS_TFRM_TIMER_CFG_6, 0x01132c),
  200. REG(QSYS_TFRM_TIMER_CFG_7, 0x011330),
  201. REG(QSYS_TFRM_TIMER_CFG_8, 0x011334),
  202. REG(QSYS_RED_PROFILE, 0x011338),
  203. REG(QSYS_RES_QOS_MODE, 0x011378),
  204. REG(QSYS_RES_CFG, 0x012000),
  205. REG(QSYS_RES_STAT, 0x012004),
  206. REG(QSYS_EGR_DROP_MODE, 0x01137c),
  207. REG(QSYS_EQ_CTRL, 0x011380),
  208. REG(QSYS_EVENTS_CORE, 0x011384),
  209. REG(QSYS_CIR_CFG, 0x000000),
  210. REG(QSYS_EIR_CFG, 0x000004),
  211. REG(QSYS_SE_CFG, 0x000008),
  212. REG(QSYS_SE_DWRR_CFG, 0x00000c),
  213. REG(QSYS_SE_CONNECT, 0x00003c),
  214. REG(QSYS_SE_DLB_SENSE, 0x000040),
  215. REG(QSYS_CIR_STATE, 0x000044),
  216. REG(QSYS_EIR_STATE, 0x000048),
  217. REG(QSYS_SE_STATE, 0x00004c),
  218. REG(QSYS_HSCH_MISC_CFG, 0x011388),
  219. };
  220. static const u32 ocelot_rew_regmap[] = {
  221. REG(REW_PORT_VLAN_CFG, 0x000000),
  222. REG(REW_TAG_CFG, 0x000004),
  223. REG(REW_PORT_CFG, 0x000008),
  224. REG(REW_DSCP_CFG, 0x00000c),
  225. REG(REW_PCP_DEI_QOS_MAP_CFG, 0x000010),
  226. REG(REW_PTP_CFG, 0x000050),
  227. REG(REW_PTP_DLY1_CFG, 0x000054),
  228. REG(REW_DSCP_REMAP_DP1_CFG, 0x000690),
  229. REG(REW_DSCP_REMAP_CFG, 0x000790),
  230. REG(REW_STAT_CFG, 0x000890),
  231. REG(REW_PPT, 0x000680),
  232. };
  233. static const u32 ocelot_sys_regmap[] = {
  234. REG(SYS_COUNT_RX_OCTETS, 0x000000),
  235. REG(SYS_COUNT_RX_UNICAST, 0x000004),
  236. REG(SYS_COUNT_RX_MULTICAST, 0x000008),
  237. REG(SYS_COUNT_RX_BROADCAST, 0x00000c),
  238. REG(SYS_COUNT_RX_SHORTS, 0x000010),
  239. REG(SYS_COUNT_RX_FRAGMENTS, 0x000014),
  240. REG(SYS_COUNT_RX_JABBERS, 0x000018),
  241. REG(SYS_COUNT_RX_CRC_ALIGN_ERRS, 0x00001c),
  242. REG(SYS_COUNT_RX_SYM_ERRS, 0x000020),
  243. REG(SYS_COUNT_RX_64, 0x000024),
  244. REG(SYS_COUNT_RX_65_127, 0x000028),
  245. REG(SYS_COUNT_RX_128_255, 0x00002c),
  246. REG(SYS_COUNT_RX_256_1023, 0x000030),
  247. REG(SYS_COUNT_RX_1024_1526, 0x000034),
  248. REG(SYS_COUNT_RX_1527_MAX, 0x000038),
  249. REG(SYS_COUNT_RX_PAUSE, 0x00003c),
  250. REG(SYS_COUNT_RX_CONTROL, 0x000040),
  251. REG(SYS_COUNT_RX_LONGS, 0x000044),
  252. REG(SYS_COUNT_RX_CLASSIFIED_DROPS, 0x000048),
  253. REG(SYS_COUNT_TX_OCTETS, 0x000100),
  254. REG(SYS_COUNT_TX_UNICAST, 0x000104),
  255. REG(SYS_COUNT_TX_MULTICAST, 0x000108),
  256. REG(SYS_COUNT_TX_BROADCAST, 0x00010c),
  257. REG(SYS_COUNT_TX_COLLISION, 0x000110),
  258. REG(SYS_COUNT_TX_DROPS, 0x000114),
  259. REG(SYS_COUNT_TX_PAUSE, 0x000118),
  260. REG(SYS_COUNT_TX_64, 0x00011c),
  261. REG(SYS_COUNT_TX_65_127, 0x000120),
  262. REG(SYS_COUNT_TX_128_511, 0x000124),
  263. REG(SYS_COUNT_TX_512_1023, 0x000128),
  264. REG(SYS_COUNT_TX_1024_1526, 0x00012c),
  265. REG(SYS_COUNT_TX_1527_MAX, 0x000130),
  266. REG(SYS_COUNT_TX_AGING, 0x000170),
  267. REG(SYS_RESET_CFG, 0x000508),
  268. REG(SYS_CMID, 0x00050c),
  269. REG(SYS_VLAN_ETYPE_CFG, 0x000510),
  270. REG(SYS_PORT_MODE, 0x000514),
  271. REG(SYS_FRONT_PORT_MODE, 0x000548),
  272. REG(SYS_FRM_AGING, 0x000574),
  273. REG(SYS_STAT_CFG, 0x000578),
  274. REG(SYS_SW_STATUS, 0x00057c),
  275. REG(SYS_MISC_CFG, 0x0005ac),
  276. REG(SYS_REW_MAC_HIGH_CFG, 0x0005b0),
  277. REG(SYS_REW_MAC_LOW_CFG, 0x0005dc),
  278. REG(SYS_CM_ADDR, 0x000500),
  279. REG(SYS_CM_DATA, 0x000504),
  280. REG(SYS_PAUSE_CFG, 0x000608),
  281. REG(SYS_PAUSE_TOT_CFG, 0x000638),
  282. REG(SYS_ATOP, 0x00063c),
  283. REG(SYS_ATOP_TOT_CFG, 0x00066c),
  284. REG(SYS_MAC_FC_CFG, 0x000670),
  285. REG(SYS_MMGT, 0x00069c),
  286. REG(SYS_MMGT_FAST, 0x0006a0),
  287. REG(SYS_EVENTS_DIF, 0x0006a4),
  288. REG(SYS_EVENTS_CORE, 0x0006b4),
  289. REG(SYS_CNT, 0x000000),
  290. REG(SYS_PTP_STATUS, 0x0006b8),
  291. REG(SYS_PTP_TXSTAMP, 0x0006bc),
  292. REG(SYS_PTP_NXT, 0x0006c0),
  293. REG(SYS_PTP_CFG, 0x0006c4),
  294. };
  295. static const u32 *ocelot_regmap[] = {
  296. [ANA] = ocelot_ana_regmap,
  297. [QS] = ocelot_qs_regmap,
  298. [HSIO] = ocelot_hsio_regmap,
  299. [QSYS] = ocelot_qsys_regmap,
  300. [REW] = ocelot_rew_regmap,
  301. [SYS] = ocelot_sys_regmap,
  302. };
  303. static const struct reg_field ocelot_regfields[] = {
  304. [ANA_ADVLEARN_VLAN_CHK] = REG_FIELD(ANA_ADVLEARN, 11, 11),
  305. [ANA_ADVLEARN_LEARN_MIRROR] = REG_FIELD(ANA_ADVLEARN, 0, 10),
  306. [ANA_ANEVENTS_MSTI_DROP] = REG_FIELD(ANA_ANEVENTS, 27, 27),
  307. [ANA_ANEVENTS_ACLKILL] = REG_FIELD(ANA_ANEVENTS, 26, 26),
  308. [ANA_ANEVENTS_ACLUSED] = REG_FIELD(ANA_ANEVENTS, 25, 25),
  309. [ANA_ANEVENTS_AUTOAGE] = REG_FIELD(ANA_ANEVENTS, 24, 24),
  310. [ANA_ANEVENTS_VS2TTL1] = REG_FIELD(ANA_ANEVENTS, 23, 23),
  311. [ANA_ANEVENTS_STORM_DROP] = REG_FIELD(ANA_ANEVENTS, 22, 22),
  312. [ANA_ANEVENTS_LEARN_DROP] = REG_FIELD(ANA_ANEVENTS, 21, 21),
  313. [ANA_ANEVENTS_AGED_ENTRY] = REG_FIELD(ANA_ANEVENTS, 20, 20),
  314. [ANA_ANEVENTS_CPU_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 19, 19),
  315. [ANA_ANEVENTS_AUTO_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 18, 18),
  316. [ANA_ANEVENTS_LEARN_REMOVE] = REG_FIELD(ANA_ANEVENTS, 17, 17),
  317. [ANA_ANEVENTS_AUTO_LEARNED] = REG_FIELD(ANA_ANEVENTS, 16, 16),
  318. [ANA_ANEVENTS_AUTO_MOVED] = REG_FIELD(ANA_ANEVENTS, 15, 15),
  319. [ANA_ANEVENTS_DROPPED] = REG_FIELD(ANA_ANEVENTS, 14, 14),
  320. [ANA_ANEVENTS_CLASSIFIED_DROP] = REG_FIELD(ANA_ANEVENTS, 13, 13),
  321. [ANA_ANEVENTS_CLASSIFIED_COPY] = REG_FIELD(ANA_ANEVENTS, 12, 12),
  322. [ANA_ANEVENTS_VLAN_DISCARD] = REG_FIELD(ANA_ANEVENTS, 11, 11),
  323. [ANA_ANEVENTS_FWD_DISCARD] = REG_FIELD(ANA_ANEVENTS, 10, 10),
  324. [ANA_ANEVENTS_MULTICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 9, 9),
  325. [ANA_ANEVENTS_UNICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 8, 8),
  326. [ANA_ANEVENTS_DEST_KNOWN] = REG_FIELD(ANA_ANEVENTS, 7, 7),
  327. [ANA_ANEVENTS_BUCKET3_MATCH] = REG_FIELD(ANA_ANEVENTS, 6, 6),
  328. [ANA_ANEVENTS_BUCKET2_MATCH] = REG_FIELD(ANA_ANEVENTS, 5, 5),
  329. [ANA_ANEVENTS_BUCKET1_MATCH] = REG_FIELD(ANA_ANEVENTS, 4, 4),
  330. [ANA_ANEVENTS_BUCKET0_MATCH] = REG_FIELD(ANA_ANEVENTS, 3, 3),
  331. [ANA_ANEVENTS_CPU_OPERATION] = REG_FIELD(ANA_ANEVENTS, 2, 2),
  332. [ANA_ANEVENTS_DMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 1, 1),
  333. [ANA_ANEVENTS_SMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 0, 0),
  334. [ANA_TABLES_MACACCESS_B_DOM] = REG_FIELD(ANA_TABLES_MACACCESS, 18, 18),
  335. [ANA_TABLES_MACTINDX_BUCKET] = REG_FIELD(ANA_TABLES_MACTINDX, 10, 11),
  336. [ANA_TABLES_MACTINDX_M_INDEX] = REG_FIELD(ANA_TABLES_MACTINDX, 0, 9),
  337. [QSYS_TIMED_FRAME_ENTRY_TFRM_VLD] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 20, 20),
  338. [QSYS_TIMED_FRAME_ENTRY_TFRM_FP] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 8, 19),
  339. [QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 4, 7),
  340. [QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 1, 3),
  341. [QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 0, 0),
  342. [SYS_RESET_CFG_CORE_ENA] = REG_FIELD(SYS_RESET_CFG, 2, 2),
  343. [SYS_RESET_CFG_MEM_ENA] = REG_FIELD(SYS_RESET_CFG, 1, 1),
  344. [SYS_RESET_CFG_MEM_INIT] = REG_FIELD(SYS_RESET_CFG, 0, 0),
  345. };
  346. static const struct ocelot_stat_layout ocelot_stats_layout[] = {
  347. { .name = "rx_octets", .offset = 0x00, },
  348. { .name = "rx_unicast", .offset = 0x01, },
  349. { .name = "rx_multicast", .offset = 0x02, },
  350. { .name = "rx_broadcast", .offset = 0x03, },
  351. { .name = "rx_shorts", .offset = 0x04, },
  352. { .name = "rx_fragments", .offset = 0x05, },
  353. { .name = "rx_jabbers", .offset = 0x06, },
  354. { .name = "rx_crc_align_errs", .offset = 0x07, },
  355. { .name = "rx_sym_errs", .offset = 0x08, },
  356. { .name = "rx_frames_below_65_octets", .offset = 0x09, },
  357. { .name = "rx_frames_65_to_127_octets", .offset = 0x0A, },
  358. { .name = "rx_frames_128_to_255_octets", .offset = 0x0B, },
  359. { .name = "rx_frames_256_to_511_octets", .offset = 0x0C, },
  360. { .name = "rx_frames_512_to_1023_octets", .offset = 0x0D, },
  361. { .name = "rx_frames_1024_to_1526_octets", .offset = 0x0E, },
  362. { .name = "rx_frames_over_1526_octets", .offset = 0x0F, },
  363. { .name = "rx_pause", .offset = 0x10, },
  364. { .name = "rx_control", .offset = 0x11, },
  365. { .name = "rx_longs", .offset = 0x12, },
  366. { .name = "rx_classified_drops", .offset = 0x13, },
  367. { .name = "rx_red_prio_0", .offset = 0x14, },
  368. { .name = "rx_red_prio_1", .offset = 0x15, },
  369. { .name = "rx_red_prio_2", .offset = 0x16, },
  370. { .name = "rx_red_prio_3", .offset = 0x17, },
  371. { .name = "rx_red_prio_4", .offset = 0x18, },
  372. { .name = "rx_red_prio_5", .offset = 0x19, },
  373. { .name = "rx_red_prio_6", .offset = 0x1A, },
  374. { .name = "rx_red_prio_7", .offset = 0x1B, },
  375. { .name = "rx_yellow_prio_0", .offset = 0x1C, },
  376. { .name = "rx_yellow_prio_1", .offset = 0x1D, },
  377. { .name = "rx_yellow_prio_2", .offset = 0x1E, },
  378. { .name = "rx_yellow_prio_3", .offset = 0x1F, },
  379. { .name = "rx_yellow_prio_4", .offset = 0x20, },
  380. { .name = "rx_yellow_prio_5", .offset = 0x21, },
  381. { .name = "rx_yellow_prio_6", .offset = 0x22, },
  382. { .name = "rx_yellow_prio_7", .offset = 0x23, },
  383. { .name = "rx_green_prio_0", .offset = 0x24, },
  384. { .name = "rx_green_prio_1", .offset = 0x25, },
  385. { .name = "rx_green_prio_2", .offset = 0x26, },
  386. { .name = "rx_green_prio_3", .offset = 0x27, },
  387. { .name = "rx_green_prio_4", .offset = 0x28, },
  388. { .name = "rx_green_prio_5", .offset = 0x29, },
  389. { .name = "rx_green_prio_6", .offset = 0x2A, },
  390. { .name = "rx_green_prio_7", .offset = 0x2B, },
  391. { .name = "tx_octets", .offset = 0x40, },
  392. { .name = "tx_unicast", .offset = 0x41, },
  393. { .name = "tx_multicast", .offset = 0x42, },
  394. { .name = "tx_broadcast", .offset = 0x43, },
  395. { .name = "tx_collision", .offset = 0x44, },
  396. { .name = "tx_drops", .offset = 0x45, },
  397. { .name = "tx_pause", .offset = 0x46, },
  398. { .name = "tx_frames_below_65_octets", .offset = 0x47, },
  399. { .name = "tx_frames_65_to_127_octets", .offset = 0x48, },
  400. { .name = "tx_frames_128_255_octets", .offset = 0x49, },
  401. { .name = "tx_frames_256_511_octets", .offset = 0x4A, },
  402. { .name = "tx_frames_512_1023_octets", .offset = 0x4B, },
  403. { .name = "tx_frames_1024_1526_octets", .offset = 0x4C, },
  404. { .name = "tx_frames_over_1526_octets", .offset = 0x4D, },
  405. { .name = "tx_yellow_prio_0", .offset = 0x4E, },
  406. { .name = "tx_yellow_prio_1", .offset = 0x4F, },
  407. { .name = "tx_yellow_prio_2", .offset = 0x50, },
  408. { .name = "tx_yellow_prio_3", .offset = 0x51, },
  409. { .name = "tx_yellow_prio_4", .offset = 0x52, },
  410. { .name = "tx_yellow_prio_5", .offset = 0x53, },
  411. { .name = "tx_yellow_prio_6", .offset = 0x54, },
  412. { .name = "tx_yellow_prio_7", .offset = 0x55, },
  413. { .name = "tx_green_prio_0", .offset = 0x56, },
  414. { .name = "tx_green_prio_1", .offset = 0x57, },
  415. { .name = "tx_green_prio_2", .offset = 0x58, },
  416. { .name = "tx_green_prio_3", .offset = 0x59, },
  417. { .name = "tx_green_prio_4", .offset = 0x5A, },
  418. { .name = "tx_green_prio_5", .offset = 0x5B, },
  419. { .name = "tx_green_prio_6", .offset = 0x5C, },
  420. { .name = "tx_green_prio_7", .offset = 0x5D, },
  421. { .name = "tx_aged", .offset = 0x5E, },
  422. { .name = "drop_local", .offset = 0x80, },
  423. { .name = "drop_tail", .offset = 0x81, },
  424. { .name = "drop_yellow_prio_0", .offset = 0x82, },
  425. { .name = "drop_yellow_prio_1", .offset = 0x83, },
  426. { .name = "drop_yellow_prio_2", .offset = 0x84, },
  427. { .name = "drop_yellow_prio_3", .offset = 0x85, },
  428. { .name = "drop_yellow_prio_4", .offset = 0x86, },
  429. { .name = "drop_yellow_prio_5", .offset = 0x87, },
  430. { .name = "drop_yellow_prio_6", .offset = 0x88, },
  431. { .name = "drop_yellow_prio_7", .offset = 0x89, },
  432. { .name = "drop_green_prio_0", .offset = 0x8A, },
  433. { .name = "drop_green_prio_1", .offset = 0x8B, },
  434. { .name = "drop_green_prio_2", .offset = 0x8C, },
  435. { .name = "drop_green_prio_3", .offset = 0x8D, },
  436. { .name = "drop_green_prio_4", .offset = 0x8E, },
  437. { .name = "drop_green_prio_5", .offset = 0x8F, },
  438. { .name = "drop_green_prio_6", .offset = 0x90, },
  439. { .name = "drop_green_prio_7", .offset = 0x91, },
  440. };
  441. static void ocelot_pll5_init(struct ocelot *ocelot)
  442. {
  443. /* Configure PLL5. This will need a proper CCF driver
  444. * The values are coming from the VTSS API for Ocelot
  445. */
  446. ocelot_write(ocelot, HSIO_PLL5G_CFG4_IB_CTRL(0x7600) |
  447. HSIO_PLL5G_CFG4_IB_BIAS_CTRL(0x8), HSIO_PLL5G_CFG4);
  448. ocelot_write(ocelot, HSIO_PLL5G_CFG0_CORE_CLK_DIV(0x11) |
  449. HSIO_PLL5G_CFG0_CPU_CLK_DIV(2) |
  450. HSIO_PLL5G_CFG0_ENA_BIAS |
  451. HSIO_PLL5G_CFG0_ENA_VCO_BUF |
  452. HSIO_PLL5G_CFG0_ENA_CP1 |
  453. HSIO_PLL5G_CFG0_SELCPI(2) |
  454. HSIO_PLL5G_CFG0_LOOP_BW_RES(0xe) |
  455. HSIO_PLL5G_CFG0_SELBGV820(4) |
  456. HSIO_PLL5G_CFG0_DIV4 |
  457. HSIO_PLL5G_CFG0_ENA_CLKTREE |
  458. HSIO_PLL5G_CFG0_ENA_LANE, HSIO_PLL5G_CFG0);
  459. ocelot_write(ocelot, HSIO_PLL5G_CFG2_EN_RESET_FRQ_DET |
  460. HSIO_PLL5G_CFG2_EN_RESET_OVERRUN |
  461. HSIO_PLL5G_CFG2_GAIN_TEST(0x8) |
  462. HSIO_PLL5G_CFG2_ENA_AMPCTRL |
  463. HSIO_PLL5G_CFG2_PWD_AMPCTRL_N |
  464. HSIO_PLL5G_CFG2_AMPC_SEL(0x10), HSIO_PLL5G_CFG2);
  465. }
  466. int ocelot_chip_init(struct ocelot *ocelot)
  467. {
  468. int ret;
  469. ocelot->map = ocelot_regmap;
  470. ocelot->stats_layout = ocelot_stats_layout;
  471. ocelot->num_stats = ARRAY_SIZE(ocelot_stats_layout);
  472. ocelot->shared_queue_sz = 224 * 1024;
  473. ret = ocelot_regfields_init(ocelot, ocelot_regfields);
  474. if (ret)
  475. return ret;
  476. ocelot_pll5_init(ocelot);
  477. eth_random_addr(ocelot->base_mac);
  478. ocelot->base_mac[5] &= 0xf0;
  479. return 0;
  480. }
  481. EXPORT_SYMBOL(ocelot_chip_init);