dwmac4.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. * DWMAC4 Header file.
  3. *
  4. * Copyright (C) 2015 STMicroelectronics Ltd
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * Author: Alexandre Torgue <alexandre.torgue@st.com>
  11. */
  12. #ifndef __DWMAC4_H__
  13. #define __DWMAC4_H__
  14. #include "common.h"
  15. /* MAC registers */
  16. #define GMAC_CONFIG 0x00000000
  17. #define GMAC_PACKET_FILTER 0x00000008
  18. #define GMAC_HASH_TAB_0_31 0x00000010
  19. #define GMAC_HASH_TAB_32_63 0x00000014
  20. #define GMAC_RX_FLOW_CTRL 0x00000090
  21. #define GMAC_QX_TX_FLOW_CTRL(x) (0x70 + x * 4)
  22. #define GMAC_INT_STATUS 0x000000b0
  23. #define GMAC_INT_EN 0x000000b4
  24. #define GMAC_PCS_BASE 0x000000e0
  25. #define GMAC_PHYIF_CONTROL_STATUS 0x000000f8
  26. #define GMAC_PMT 0x000000c0
  27. #define GMAC_VERSION 0x00000110
  28. #define GMAC_DEBUG 0x00000114
  29. #define GMAC_HW_FEATURE0 0x0000011c
  30. #define GMAC_HW_FEATURE1 0x00000120
  31. #define GMAC_HW_FEATURE2 0x00000124
  32. #define GMAC_MDIO_ADDR 0x00000200
  33. #define GMAC_MDIO_DATA 0x00000204
  34. #define GMAC_ADDR_HIGH(reg) (0x300 + reg * 8)
  35. #define GMAC_ADDR_LOW(reg) (0x304 + reg * 8)
  36. /* MAC Packet Filtering */
  37. #define GMAC_PACKET_FILTER_PR BIT(0)
  38. #define GMAC_PACKET_FILTER_HMC BIT(2)
  39. #define GMAC_PACKET_FILTER_PM BIT(4)
  40. #define GMAC_MAX_PERFECT_ADDRESSES 128
  41. /* MAC Flow Control RX */
  42. #define GMAC_RX_FLOW_CTRL_RFE BIT(0)
  43. /* MAC Flow Control TX */
  44. #define GMAC_TX_FLOW_CTRL_TFE BIT(1)
  45. #define GMAC_TX_FLOW_CTRL_PT_SHIFT 16
  46. /* MAC Interrupt bitmap*/
  47. #define GMAC_INT_RGSMIIS BIT(0)
  48. #define GMAC_INT_PCS_LINK BIT(1)
  49. #define GMAC_INT_PCS_ANE BIT(2)
  50. #define GMAC_INT_PCS_PHYIS BIT(3)
  51. #define GMAC_INT_PMT_EN BIT(4)
  52. #define GMAC_INT_LPI_EN BIT(5)
  53. #define GMAC_PCS_IRQ_DEFAULT (GMAC_INT_RGSMIIS | GMAC_INT_PCS_LINK | \
  54. GMAC_INT_PCS_ANE)
  55. #define GMAC_INT_DEFAULT_MASK GMAC_INT_PMT_EN
  56. enum dwmac4_irq_status {
  57. time_stamp_irq = 0x00001000,
  58. mmc_rx_csum_offload_irq = 0x00000800,
  59. mmc_tx_irq = 0x00000400,
  60. mmc_rx_irq = 0x00000200,
  61. mmc_irq = 0x00000100,
  62. pmt_irq = 0x00000010,
  63. };
  64. /* MAC PMT bitmap */
  65. enum power_event {
  66. pointer_reset = 0x80000000,
  67. global_unicast = 0x00000200,
  68. wake_up_rx_frame = 0x00000040,
  69. magic_frame = 0x00000020,
  70. wake_up_frame_en = 0x00000004,
  71. magic_pkt_en = 0x00000002,
  72. power_down = 0x00000001,
  73. };
  74. /* MAC Debug bitmap */
  75. #define GMAC_DEBUG_TFCSTS_MASK GENMASK(18, 17)
  76. #define GMAC_DEBUG_TFCSTS_SHIFT 17
  77. #define GMAC_DEBUG_TFCSTS_IDLE 0
  78. #define GMAC_DEBUG_TFCSTS_WAIT 1
  79. #define GMAC_DEBUG_TFCSTS_GEN_PAUSE 2
  80. #define GMAC_DEBUG_TFCSTS_XFER 3
  81. #define GMAC_DEBUG_TPESTS BIT(16)
  82. #define GMAC_DEBUG_RFCFCSTS_MASK GENMASK(2, 1)
  83. #define GMAC_DEBUG_RFCFCSTS_SHIFT 1
  84. #define GMAC_DEBUG_RPESTS BIT(0)
  85. /* MAC config */
  86. #define GMAC_CONFIG_IPC BIT(27)
  87. #define GMAC_CONFIG_2K BIT(22)
  88. #define GMAC_CONFIG_ACS BIT(20)
  89. #define GMAC_CONFIG_BE BIT(18)
  90. #define GMAC_CONFIG_JD BIT(17)
  91. #define GMAC_CONFIG_JE BIT(16)
  92. #define GMAC_CONFIG_PS BIT(15)
  93. #define GMAC_CONFIG_FES BIT(14)
  94. #define GMAC_CONFIG_DM BIT(13)
  95. #define GMAC_CONFIG_DCRS BIT(9)
  96. #define GMAC_CONFIG_TE BIT(1)
  97. #define GMAC_CONFIG_RE BIT(0)
  98. /* MAC HW features0 bitmap */
  99. #define GMAC_HW_FEAT_ADDMAC BIT(18)
  100. #define GMAC_HW_FEAT_RXCOESEL BIT(16)
  101. #define GMAC_HW_FEAT_TXCOSEL BIT(14)
  102. #define GMAC_HW_FEAT_EEESEL BIT(13)
  103. #define GMAC_HW_FEAT_TSSEL BIT(12)
  104. #define GMAC_HW_FEAT_MMCSEL BIT(8)
  105. #define GMAC_HW_FEAT_MGKSEL BIT(7)
  106. #define GMAC_HW_FEAT_RWKSEL BIT(6)
  107. #define GMAC_HW_FEAT_SMASEL BIT(5)
  108. #define GMAC_HW_FEAT_VLHASH BIT(4)
  109. #define GMAC_HW_FEAT_PCSSEL BIT(3)
  110. #define GMAC_HW_FEAT_HDSEL BIT(2)
  111. #define GMAC_HW_FEAT_GMIISEL BIT(1)
  112. #define GMAC_HW_FEAT_MIISEL BIT(0)
  113. /* MAC HW features1 bitmap */
  114. #define GMAC_HW_FEAT_AVSEL BIT(20)
  115. #define GMAC_HW_TSOEN BIT(18)
  116. /* MAC HW features2 bitmap */
  117. #define GMAC_HW_FEAT_TXCHCNT GENMASK(21, 18)
  118. #define GMAC_HW_FEAT_RXCHCNT GENMASK(15, 12)
  119. /* MAC HW ADDR regs */
  120. #define GMAC_HI_DCS GENMASK(18, 16)
  121. #define GMAC_HI_DCS_SHIFT 16
  122. #define GMAC_HI_REG_AE BIT(31)
  123. /* MTL registers */
  124. #define MTL_INT_STATUS 0x00000c20
  125. #define MTL_INT_Q0 BIT(0)
  126. #define MTL_CHAN_BASE_ADDR 0x00000d00
  127. #define MTL_CHAN_BASE_OFFSET 0x40
  128. #define MTL_CHANX_BASE_ADDR(x) (MTL_CHAN_BASE_ADDR + \
  129. (x * MTL_CHAN_BASE_OFFSET))
  130. #define MTL_CHAN_TX_OP_MODE(x) MTL_CHANX_BASE_ADDR(x)
  131. #define MTL_CHAN_TX_DEBUG(x) (MTL_CHANX_BASE_ADDR(x) + 0x8)
  132. #define MTL_CHAN_INT_CTRL(x) (MTL_CHANX_BASE_ADDR(x) + 0x2c)
  133. #define MTL_CHAN_RX_OP_MODE(x) (MTL_CHANX_BASE_ADDR(x) + 0x30)
  134. #define MTL_CHAN_RX_DEBUG(x) (MTL_CHANX_BASE_ADDR(x) + 0x38)
  135. #define MTL_OP_MODE_RSF BIT(5)
  136. #define MTL_OP_MODE_TSF BIT(1)
  137. #define MTL_OP_MODE_TTC_MASK 0x70
  138. #define MTL_OP_MODE_TTC_SHIFT 4
  139. #define MTL_OP_MODE_TTC_32 0
  140. #define MTL_OP_MODE_TTC_64 (1 << MTL_OP_MODE_TTC_SHIFT)
  141. #define MTL_OP_MODE_TTC_96 (2 << MTL_OP_MODE_TTC_SHIFT)
  142. #define MTL_OP_MODE_TTC_128 (3 << MTL_OP_MODE_TTC_SHIFT)
  143. #define MTL_OP_MODE_TTC_192 (4 << MTL_OP_MODE_TTC_SHIFT)
  144. #define MTL_OP_MODE_TTC_256 (5 << MTL_OP_MODE_TTC_SHIFT)
  145. #define MTL_OP_MODE_TTC_384 (6 << MTL_OP_MODE_TTC_SHIFT)
  146. #define MTL_OP_MODE_TTC_512 (7 << MTL_OP_MODE_TTC_SHIFT)
  147. #define MTL_OP_MODE_RTC_MASK 0x18
  148. #define MTL_OP_MODE_RTC_SHIFT 3
  149. #define MTL_OP_MODE_RTC_32 (1 << MTL_OP_MODE_RTC_SHIFT)
  150. #define MTL_OP_MODE_RTC_64 0
  151. #define MTL_OP_MODE_RTC_96 (2 << MTL_OP_MODE_RTC_SHIFT)
  152. #define MTL_OP_MODE_RTC_128 (3 << MTL_OP_MODE_RTC_SHIFT)
  153. /* MTL debug */
  154. #define MTL_DEBUG_TXSTSFSTS BIT(5)
  155. #define MTL_DEBUG_TXFSTS BIT(4)
  156. #define MTL_DEBUG_TWCSTS BIT(3)
  157. /* MTL debug: Tx FIFO Read Controller Status */
  158. #define MTL_DEBUG_TRCSTS_MASK GENMASK(2, 1)
  159. #define MTL_DEBUG_TRCSTS_SHIFT 1
  160. #define MTL_DEBUG_TRCSTS_IDLE 0
  161. #define MTL_DEBUG_TRCSTS_READ 1
  162. #define MTL_DEBUG_TRCSTS_TXW 2
  163. #define MTL_DEBUG_TRCSTS_WRITE 3
  164. #define MTL_DEBUG_TXPAUSED BIT(0)
  165. /* MAC debug: GMII or MII Transmit Protocol Engine Status */
  166. #define MTL_DEBUG_RXFSTS_MASK GENMASK(5, 4)
  167. #define MTL_DEBUG_RXFSTS_SHIFT 4
  168. #define MTL_DEBUG_RXFSTS_EMPTY 0
  169. #define MTL_DEBUG_RXFSTS_BT 1
  170. #define MTL_DEBUG_RXFSTS_AT 2
  171. #define MTL_DEBUG_RXFSTS_FULL 3
  172. #define MTL_DEBUG_RRCSTS_MASK GENMASK(2, 1)
  173. #define MTL_DEBUG_RRCSTS_SHIFT 1
  174. #define MTL_DEBUG_RRCSTS_IDLE 0
  175. #define MTL_DEBUG_RRCSTS_RDATA 1
  176. #define MTL_DEBUG_RRCSTS_RSTAT 2
  177. #define MTL_DEBUG_RRCSTS_FLUSH 3
  178. #define MTL_DEBUG_RWCSTS BIT(0)
  179. /* MTL interrupt */
  180. #define MTL_RX_OVERFLOW_INT_EN BIT(24)
  181. #define MTL_RX_OVERFLOW_INT BIT(16)
  182. /* Default operating mode of the MAC */
  183. #define GMAC_CORE_INIT (GMAC_CONFIG_JD | GMAC_CONFIG_PS | GMAC_CONFIG_ACS | \
  184. GMAC_CONFIG_BE | GMAC_CONFIG_DCRS)
  185. /* To dump the core regs excluding the Address Registers */
  186. #define GMAC_REG_NUM 132
  187. /* MTL debug */
  188. #define MTL_DEBUG_TXSTSFSTS BIT(5)
  189. #define MTL_DEBUG_TXFSTS BIT(4)
  190. #define MTL_DEBUG_TWCSTS BIT(3)
  191. /* MTL debug: Tx FIFO Read Controller Status */
  192. #define MTL_DEBUG_TRCSTS_MASK GENMASK(2, 1)
  193. #define MTL_DEBUG_TRCSTS_SHIFT 1
  194. #define MTL_DEBUG_TRCSTS_IDLE 0
  195. #define MTL_DEBUG_TRCSTS_READ 1
  196. #define MTL_DEBUG_TRCSTS_TXW 2
  197. #define MTL_DEBUG_TRCSTS_WRITE 3
  198. #define MTL_DEBUG_TXPAUSED BIT(0)
  199. /* MAC debug: GMII or MII Transmit Protocol Engine Status */
  200. #define MTL_DEBUG_RXFSTS_MASK GENMASK(5, 4)
  201. #define MTL_DEBUG_RXFSTS_SHIFT 4
  202. #define MTL_DEBUG_RXFSTS_EMPTY 0
  203. #define MTL_DEBUG_RXFSTS_BT 1
  204. #define MTL_DEBUG_RXFSTS_AT 2
  205. #define MTL_DEBUG_RXFSTS_FULL 3
  206. #define MTL_DEBUG_RRCSTS_MASK GENMASK(2, 1)
  207. #define MTL_DEBUG_RRCSTS_SHIFT 1
  208. #define MTL_DEBUG_RRCSTS_IDLE 0
  209. #define MTL_DEBUG_RRCSTS_RDATA 1
  210. #define MTL_DEBUG_RRCSTS_RSTAT 2
  211. #define MTL_DEBUG_RRCSTS_FLUSH 3
  212. #define MTL_DEBUG_RWCSTS BIT(0)
  213. /* SGMII/RGMII status register */
  214. #define GMAC_PHYIF_CTRLSTATUS_TC BIT(0)
  215. #define GMAC_PHYIF_CTRLSTATUS_LUD BIT(1)
  216. #define GMAC_PHYIF_CTRLSTATUS_SMIDRXS BIT(4)
  217. #define GMAC_PHYIF_CTRLSTATUS_LNKMOD BIT(16)
  218. #define GMAC_PHYIF_CTRLSTATUS_SPEED GENMASK(18, 17)
  219. #define GMAC_PHYIF_CTRLSTATUS_SPEED_SHIFT 17
  220. #define GMAC_PHYIF_CTRLSTATUS_LNKSTS BIT(19)
  221. #define GMAC_PHYIF_CTRLSTATUS_JABTO BIT(20)
  222. #define GMAC_PHYIF_CTRLSTATUS_FALSECARDET BIT(21)
  223. /* LNKMOD */
  224. #define GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK 0x1
  225. /* LNKSPEED */
  226. #define GMAC_PHYIF_CTRLSTATUS_SPEED_125 0x2
  227. #define GMAC_PHYIF_CTRLSTATUS_SPEED_25 0x1
  228. #define GMAC_PHYIF_CTRLSTATUS_SPEED_2_5 0x0
  229. extern const struct stmmac_dma_ops dwmac4_dma_ops;
  230. extern const struct stmmac_dma_ops dwmac410_dma_ops;
  231. #endif /* __DWMAC4_H__ */