lan937x_reg.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Microchip LAN937X switch register definitions
  3. * Copyright (C) 2019-2024 Microchip Technology Inc.
  4. */
  5. #ifndef __LAN937X_REG_H
  6. #define __LAN937X_REG_H
  7. #define PORT_CTRL_ADDR(port, addr) ((addr) | (((port) + 1) << 12))
  8. /* 0 - Operation */
  9. #define REG_GLOBAL_CTRL_0 0x0007
  10. #define SW_PHY_REG_BLOCK BIT(7)
  11. #define SW_FAST_MODE BIT(3)
  12. #define SW_FAST_MODE_OVERRIDE BIT(2)
  13. #define REG_SW_INT_STATUS__4 0x0010
  14. #define REG_SW_INT_MASK__4 0x0014
  15. #define LUE_INT BIT(31)
  16. #define TRIG_TS_INT BIT(30)
  17. #define APB_TIMEOUT_INT BIT(29)
  18. #define OVER_TEMP_INT BIT(28)
  19. #define HSR_INT BIT(27)
  20. #define PIO_INT BIT(26)
  21. #define POR_READY_INT BIT(25)
  22. #define SWITCH_INT_MASK \
  23. (LUE_INT | TRIG_TS_INT | APB_TIMEOUT_INT | OVER_TEMP_INT | HSR_INT | \
  24. PIO_INT | POR_READY_INT)
  25. #define REG_SW_PORT_INT_STATUS__4 0x0018
  26. #define REG_SW_PORT_INT_MASK__4 0x001C
  27. /* 1 - Global */
  28. #define REG_SW_GLOBAL_OUTPUT_CTRL__1 0x0103
  29. #define SW_CLK125_ENB BIT(1)
  30. #define SW_CLK25_ENB BIT(0)
  31. /* 2 - PHY Control */
  32. #define REG_SW_CFG_STRAP_OVR 0x0214
  33. #define SW_VPHY_DISABLE BIT(31)
  34. /* 3 - Operation Control */
  35. #define REG_SW_OPERATION 0x0300
  36. #define SW_DOUBLE_TAG BIT(7)
  37. #define SW_OVER_TEMP_ENABLE BIT(2)
  38. #define SW_RESET BIT(1)
  39. #define REG_SW_LUE_CTRL_0 0x0310
  40. #define SW_VLAN_ENABLE BIT(7)
  41. #define SW_DROP_INVALID_VID BIT(6)
  42. #define SW_AGE_CNT_M GENMASK(5, 3)
  43. #define SW_RESV_MCAST_ENABLE BIT(2)
  44. #define REG_SW_LUE_CTRL_1 0x0311
  45. #define UNICAST_LEARN_DISABLE BIT(7)
  46. #define SW_FLUSH_STP_TABLE BIT(5)
  47. #define SW_FLUSH_MSTP_TABLE BIT(4)
  48. #define SW_SRC_ADDR_FILTER BIT(3)
  49. #define SW_AGING_ENABLE BIT(2)
  50. #define SW_FAST_AGING BIT(1)
  51. #define SW_LINK_AUTO_AGING BIT(0)
  52. #define REG_SW_LUE_CTRL_2 0x0312
  53. #define SW_AGE_CNT_IN_MICROSEC BIT(7)
  54. #define REG_SW_AGE_PERIOD__1 0x0313
  55. #define SW_AGE_PERIOD_7_0_M GENMASK(7, 0)
  56. #define REG_SW_AGE_PERIOD__2 0x0320
  57. #define SW_AGE_PERIOD_19_8_M GENMASK(19, 8)
  58. #define REG_SW_MAC_CTRL_0 0x0330
  59. #define SW_NEW_BACKOFF BIT(7)
  60. #define SW_PAUSE_UNH_MODE BIT(1)
  61. #define SW_AGGR_BACKOFF BIT(0)
  62. #define REG_SW_MAC_CTRL_1 0x0331
  63. #define SW_SHORT_IFG BIT(7)
  64. #define MULTICAST_STORM_DISABLE BIT(6)
  65. #define SW_BACK_PRESSURE BIT(5)
  66. #define FAIR_FLOW_CTRL BIT(4)
  67. #define NO_EXC_COLLISION_DROP BIT(3)
  68. #define SW_LEGAL_PACKET_DISABLE BIT(1)
  69. #define SW_PASS_SHORT_FRAME BIT(0)
  70. #define REG_SW_MAC_CTRL_6 0x0336
  71. #define SW_MIB_COUNTER_FLUSH BIT(7)
  72. #define SW_MIB_COUNTER_FREEZE BIT(6)
  73. /* 4 - LUE */
  74. #define REG_SW_ALU_STAT_CTRL__4 0x041C
  75. #define REG_SW_ALU_VAL_B 0x0424
  76. #define ALU_V_OVERRIDE BIT(31)
  77. #define ALU_V_USE_FID BIT(30)
  78. #define ALU_V_PORT_MAP 0xFF
  79. /* 7 - VPhy */
  80. #define REG_VPHY_IND_ADDR__2 0x075C
  81. #define REG_VPHY_IND_DATA__2 0x0760
  82. #define REG_VPHY_IND_CTRL__2 0x0768
  83. #define VPHY_IND_WRITE BIT(1)
  84. #define VPHY_IND_BUSY BIT(0)
  85. #define REG_VPHY_SPECIAL_CTRL__2 0x077C
  86. #define VPHY_SMI_INDIRECT_ENABLE BIT(15)
  87. #define VPHY_SW_LOOPBACK BIT(14)
  88. #define VPHY_MDIO_INTERNAL_ENABLE BIT(13)
  89. #define VPHY_SPI_INDIRECT_ENABLE BIT(12)
  90. #define VPHY_PORT_MODE_M 0x3
  91. #define VPHY_PORT_MODE_S 8
  92. #define VPHY_MODE_RGMII 0
  93. #define VPHY_MODE_MII_PHY 1
  94. #define VPHY_MODE_SGMII 2
  95. #define VPHY_MODE_RMII_PHY 3
  96. #define VPHY_SW_COLLISION_TEST BIT(7)
  97. #define VPHY_SPEED_DUPLEX_STAT_M 0x7
  98. #define VPHY_SPEED_DUPLEX_STAT_S 2
  99. #define VPHY_SPEED_1000 BIT(4)
  100. #define VPHY_SPEED_100 BIT(3)
  101. #define VPHY_FULL_DUPLEX BIT(2)
  102. /* Port Registers */
  103. /* 0 - Operation */
  104. #define REG_PORT_INT_STATUS 0x001B
  105. #define REG_PORT_INT_MASK 0x001F
  106. #define PORT_TAS_INT BIT(5)
  107. #define PORT_QCI_INT BIT(4)
  108. #define PORT_SGMII_INT BIT(3)
  109. #define PORT_PTP_INT BIT(2)
  110. #define PORT_PHY_INT BIT(1)
  111. #define PORT_ACL_INT BIT(0)
  112. #define PORT_SRC_PHY_INT 1
  113. #define REG_PORT_CTRL_0 0x0020
  114. #define PORT_MAC_LOOPBACK BIT(7)
  115. #define PORT_MAC_REMOTE_LOOPBACK BIT(6)
  116. #define PORT_K2L_INSERT_ENABLE BIT(5)
  117. #define PORT_K2L_DEBUG_ENABLE BIT(4)
  118. #define PORT_TAIL_TAG_ENABLE BIT(2)
  119. #define PORT_QUEUE_SPLIT_ENABLE 0x3
  120. /* 1 - Phy */
  121. #define REG_PORT_T1_PHY_CTRL_BASE 0x0100
  122. #define REG_PORT_TX_PHY_CTRL_BASE 0x0280
  123. /* 3 - xMII */
  124. #define PORT_SGMII_SEL BIT(7)
  125. #define PORT_GRXC_ENABLE BIT(0)
  126. #define PORT_MII_SEL_EDGE BIT(5)
  127. #define REG_PORT_XMII_CTRL_4 0x0304
  128. #define REG_PORT_XMII_CTRL_5 0x0306
  129. #define PORT_DLL_RESET BIT(15)
  130. #define PORT_TUNE_ADJ GENMASK(13, 7)
  131. /* 4 - MAC */
  132. #define REG_PORT_MAC_CTRL_0 0x0400
  133. #define PORT_CHECK_LENGTH BIT(2)
  134. #define PORT_BROADCAST_STORM BIT(1)
  135. #define PORT_JUMBO_PACKET BIT(0)
  136. #define REG_PORT_MAC_CTRL_1 0x0401
  137. #define PORT_BACK_PRESSURE BIT(3)
  138. #define PORT_PASS_ALL BIT(0)
  139. #define PORT_MAX_FR_SIZE 0x404
  140. #define FR_MIN_SIZE 1522
  141. /* 8 - Classification and Policing */
  142. #define REG_PORT_MRI_PRIO_CTRL 0x0801
  143. #define PORT_HIGHEST_PRIO BIT(7)
  144. #define PORT_OR_PRIO BIT(6)
  145. #define PORT_MAC_PRIO_ENABLE BIT(4)
  146. #define PORT_VLAN_PRIO_ENABLE BIT(3)
  147. #define PORT_802_1P_PRIO_ENABLE BIT(2)
  148. #define PORT_DIFFSERV_PRIO_ENABLE BIT(1)
  149. #define PORT_ACL_PRIO_ENABLE BIT(0)
  150. #define P_PRIO_CTRL REG_PORT_MRI_PRIO_CTRL
  151. /* 9 - Shaping */
  152. #define REG_PORT_MTI_CREDIT_INCREMENT 0x091C
  153. /* The port number as per the datasheet */
  154. #define RGMII_2_PORT_NUM 5
  155. #define RGMII_1_PORT_NUM 6
  156. #define LAN937X_RGMII_2_PORT (RGMII_2_PORT_NUM - 1)
  157. #define LAN937X_RGMII_1_PORT (RGMII_1_PORT_NUM - 1)
  158. #define RGMII_1_TX_DELAY_2NS 2
  159. #define RGMII_2_TX_DELAY_2NS 0
  160. #define RGMII_1_RX_DELAY_2NS 0x1B
  161. #define RGMII_2_RX_DELAY_2NS 0x14
  162. #define LAN937X_TAG_LEN 2
  163. #endif