dwmac1000.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*******************************************************************************
  3. Copyright (C) 2007-2009 STMicroelectronics Ltd
  4. Author: Giuseppe Cavallaro <[email protected]>
  5. *******************************************************************************/
  6. #ifndef __DWMAC1000_H__
  7. #define __DWMAC1000_H__
  8. #include <linux/phy.h>
  9. #include "common.h"
  10. #define GMAC_CONTROL 0x00000000 /* Configuration */
  11. #define GMAC_FRAME_FILTER 0x00000004 /* Frame Filter */
  12. #define GMAC_HASH_HIGH 0x00000008 /* Multicast Hash Table High */
  13. #define GMAC_HASH_LOW 0x0000000c /* Multicast Hash Table Low */
  14. #define GMAC_MII_ADDR 0x00000010 /* MII Address */
  15. #define GMAC_MII_DATA 0x00000014 /* MII Data */
  16. #define GMAC_FLOW_CTRL 0x00000018 /* Flow Control */
  17. #define GMAC_VLAN_TAG 0x0000001c /* VLAN Tag */
  18. #define GMAC_DEBUG 0x00000024 /* GMAC debug register */
  19. #define GMAC_WAKEUP_FILTER 0x00000028 /* Wake-up Frame Filter */
  20. #define GMAC_INT_STATUS 0x00000038 /* interrupt status register */
  21. #define GMAC_INT_STATUS_PMT BIT(3)
  22. #define GMAC_INT_STATUS_MMCIS BIT(4)
  23. #define GMAC_INT_STATUS_MMCRIS BIT(5)
  24. #define GMAC_INT_STATUS_MMCTIS BIT(6)
  25. #define GMAC_INT_STATUS_MMCCSUM BIT(7)
  26. #define GMAC_INT_STATUS_TSTAMP BIT(9)
  27. #define GMAC_INT_STATUS_LPIIS BIT(10)
  28. /* interrupt mask register */
  29. #define GMAC_INT_MASK 0x0000003c
  30. #define GMAC_INT_DISABLE_RGMII BIT(0)
  31. #define GMAC_INT_DISABLE_PCSLINK BIT(1)
  32. #define GMAC_INT_DISABLE_PCSAN BIT(2)
  33. #define GMAC_INT_DISABLE_PMT BIT(3)
  34. #define GMAC_INT_DISABLE_TIMESTAMP BIT(9)
  35. #define GMAC_INT_DISABLE_PCS (GMAC_INT_DISABLE_RGMII | \
  36. GMAC_INT_DISABLE_PCSLINK | \
  37. GMAC_INT_DISABLE_PCSAN)
  38. #define GMAC_INT_DEFAULT_MASK (GMAC_INT_DISABLE_TIMESTAMP | \
  39. GMAC_INT_DISABLE_PCS)
  40. /* PMT Control and Status */
  41. #define GMAC_PMT 0x0000002c
  42. enum power_event {
  43. pointer_reset = 0x80000000,
  44. global_unicast = 0x00000200,
  45. wake_up_rx_frame = 0x00000040,
  46. magic_frame = 0x00000020,
  47. wake_up_frame_en = 0x00000004,
  48. magic_pkt_en = 0x00000002,
  49. power_down = 0x00000001,
  50. };
  51. /* Energy Efficient Ethernet (EEE)
  52. *
  53. * LPI status, timer and control register offset
  54. */
  55. #define LPI_CTRL_STATUS 0x0030
  56. #define LPI_TIMER_CTRL 0x0034
  57. /* LPI control and status defines */
  58. #define LPI_CTRL_STATUS_LPITXA 0x00080000 /* Enable LPI TX Automate */
  59. #define LPI_CTRL_STATUS_PLSEN 0x00040000 /* Enable PHY Link Status */
  60. #define LPI_CTRL_STATUS_PLS 0x00020000 /* PHY Link Status */
  61. #define LPI_CTRL_STATUS_LPIEN 0x00010000 /* LPI Enable */
  62. #define LPI_CTRL_STATUS_RLPIST 0x00000200 /* Receive LPI state */
  63. #define LPI_CTRL_STATUS_TLPIST 0x00000100 /* Transmit LPI state */
  64. #define LPI_CTRL_STATUS_RLPIEX 0x00000008 /* Receive LPI Exit */
  65. #define LPI_CTRL_STATUS_RLPIEN 0x00000004 /* Receive LPI Entry */
  66. #define LPI_CTRL_STATUS_TLPIEX 0x00000002 /* Transmit LPI Exit */
  67. #define LPI_CTRL_STATUS_TLPIEN 0x00000001 /* Transmit LPI Entry */
  68. /* GMAC HW ADDR regs */
  69. #define GMAC_ADDR_HIGH(reg) ((reg > 15) ? 0x00000800 + (reg - 16) * 8 : \
  70. 0x00000040 + (reg * 8))
  71. #define GMAC_ADDR_LOW(reg) ((reg > 15) ? 0x00000804 + (reg - 16) * 8 : \
  72. 0x00000044 + (reg * 8))
  73. #define GMAC_MAX_PERFECT_ADDRESSES 1
  74. #define GMAC_PCS_BASE 0x000000c0 /* PCS register base */
  75. #define GMAC_RGSMIIIS 0x000000d8 /* RGMII/SMII status */
  76. /* SGMII/RGMII status register */
  77. #define GMAC_RGSMIIIS_LNKMODE BIT(0)
  78. #define GMAC_RGSMIIIS_SPEED GENMASK(2, 1)
  79. #define GMAC_RGSMIIIS_SPEED_SHIFT 1
  80. #define GMAC_RGSMIIIS_LNKSTS BIT(3)
  81. #define GMAC_RGSMIIIS_JABTO BIT(4)
  82. #define GMAC_RGSMIIIS_FALSECARDET BIT(5)
  83. #define GMAC_RGSMIIIS_SMIDRXS BIT(16)
  84. /* LNKMOD */
  85. #define GMAC_RGSMIIIS_LNKMOD_MASK 0x1
  86. /* LNKSPEED */
  87. #define GMAC_RGSMIIIS_SPEED_125 0x2
  88. #define GMAC_RGSMIIIS_SPEED_25 0x1
  89. #define GMAC_RGSMIIIS_SPEED_2_5 0x0
  90. /* GMAC Configuration defines */
  91. #define GMAC_CONTROL_2K 0x08000000 /* IEEE 802.3as 2K packets */
  92. #define GMAC_CONTROL_TC 0x01000000 /* Transmit Conf. in RGMII/SGMII */
  93. #define GMAC_CONTROL_WD 0x00800000 /* Disable Watchdog on receive */
  94. #define GMAC_CONTROL_JD 0x00400000 /* Jabber disable */
  95. #define GMAC_CONTROL_BE 0x00200000 /* Frame Burst Enable */
  96. #define GMAC_CONTROL_JE 0x00100000 /* Jumbo frame */
  97. enum inter_frame_gap {
  98. GMAC_CONTROL_IFG_88 = 0x00040000,
  99. GMAC_CONTROL_IFG_80 = 0x00020000,
  100. GMAC_CONTROL_IFG_40 = 0x000e0000,
  101. };
  102. #define GMAC_CONTROL_DCRS 0x00010000 /* Disable carrier sense */
  103. #define GMAC_CONTROL_PS 0x00008000 /* Port Select 0:GMI 1:MII */
  104. #define GMAC_CONTROL_FES 0x00004000 /* Speed 0:10 1:100 */
  105. #define GMAC_CONTROL_DO 0x00002000 /* Disable Rx Own */
  106. #define GMAC_CONTROL_LM 0x00001000 /* Loop-back mode */
  107. #define GMAC_CONTROL_DM 0x00000800 /* Duplex Mode */
  108. #define GMAC_CONTROL_IPC 0x00000400 /* Checksum Offload */
  109. #define GMAC_CONTROL_DR 0x00000200 /* Disable Retry */
  110. #define GMAC_CONTROL_LUD 0x00000100 /* Link up/down */
  111. #define GMAC_CONTROL_ACS 0x00000080 /* Auto Pad/FCS Stripping */
  112. #define GMAC_CONTROL_DC 0x00000010 /* Deferral Check */
  113. #define GMAC_CONTROL_TE 0x00000008 /* Transmitter Enable */
  114. #define GMAC_CONTROL_RE 0x00000004 /* Receiver Enable */
  115. #define GMAC_CORE_INIT (GMAC_CONTROL_JD | GMAC_CONTROL_PS | \
  116. GMAC_CONTROL_BE | GMAC_CONTROL_DCRS)
  117. /* GMAC Frame Filter defines */
  118. #define GMAC_FRAME_FILTER_PR 0x00000001 /* Promiscuous Mode */
  119. #define GMAC_FRAME_FILTER_HUC 0x00000002 /* Hash Unicast */
  120. #define GMAC_FRAME_FILTER_HMC 0x00000004 /* Hash Multicast */
  121. #define GMAC_FRAME_FILTER_DAIF 0x00000008 /* DA Inverse Filtering */
  122. #define GMAC_FRAME_FILTER_PM 0x00000010 /* Pass all multicast */
  123. #define GMAC_FRAME_FILTER_DBF 0x00000020 /* Disable Broadcast frames */
  124. #define GMAC_FRAME_FILTER_PCF 0x00000080 /* Pass Control frames */
  125. #define GMAC_FRAME_FILTER_SAIF 0x00000100 /* Inverse Filtering */
  126. #define GMAC_FRAME_FILTER_SAF 0x00000200 /* Source Address Filter */
  127. #define GMAC_FRAME_FILTER_HPF 0x00000400 /* Hash or perfect Filter */
  128. #define GMAC_FRAME_FILTER_RA 0x80000000 /* Receive all mode */
  129. /* GMII ADDR defines */
  130. #define GMAC_MII_ADDR_WRITE 0x00000002 /* MII Write */
  131. #define GMAC_MII_ADDR_BUSY 0x00000001 /* MII Busy */
  132. /* GMAC FLOW CTRL defines */
  133. #define GMAC_FLOW_CTRL_PT_MASK 0xffff0000 /* Pause Time Mask */
  134. #define GMAC_FLOW_CTRL_PT_SHIFT 16
  135. #define GMAC_FLOW_CTRL_UP 0x00000008 /* Unicast pause frame enable */
  136. #define GMAC_FLOW_CTRL_RFE 0x00000004 /* Rx Flow Control Enable */
  137. #define GMAC_FLOW_CTRL_TFE 0x00000002 /* Tx Flow Control Enable */
  138. #define GMAC_FLOW_CTRL_FCB_BPA 0x00000001 /* Flow Control Busy ... */
  139. /* DEBUG Register defines */
  140. /* MTL TxStatus FIFO */
  141. #define GMAC_DEBUG_TXSTSFSTS BIT(25) /* MTL TxStatus FIFO Full Status */
  142. #define GMAC_DEBUG_TXFSTS BIT(24) /* MTL Tx FIFO Not Empty Status */
  143. #define GMAC_DEBUG_TWCSTS BIT(22) /* MTL Tx FIFO Write Controller */
  144. /* MTL Tx FIFO Read Controller Status */
  145. #define GMAC_DEBUG_TRCSTS_MASK GENMASK(21, 20)
  146. #define GMAC_DEBUG_TRCSTS_SHIFT 20
  147. #define GMAC_DEBUG_TRCSTS_IDLE 0
  148. #define GMAC_DEBUG_TRCSTS_READ 1
  149. #define GMAC_DEBUG_TRCSTS_TXW 2
  150. #define GMAC_DEBUG_TRCSTS_WRITE 3
  151. #define GMAC_DEBUG_TXPAUSED BIT(19) /* MAC Transmitter in PAUSE */
  152. /* MAC Transmit Frame Controller Status */
  153. #define GMAC_DEBUG_TFCSTS_MASK GENMASK(18, 17)
  154. #define GMAC_DEBUG_TFCSTS_SHIFT 17
  155. #define GMAC_DEBUG_TFCSTS_IDLE 0
  156. #define GMAC_DEBUG_TFCSTS_WAIT 1
  157. #define GMAC_DEBUG_TFCSTS_GEN_PAUSE 2
  158. #define GMAC_DEBUG_TFCSTS_XFER 3
  159. /* MAC GMII or MII Transmit Protocol Engine Status */
  160. #define GMAC_DEBUG_TPESTS BIT(16)
  161. #define GMAC_DEBUG_RXFSTS_MASK GENMASK(9, 8) /* MTL Rx FIFO Fill-level */
  162. #define GMAC_DEBUG_RXFSTS_SHIFT 8
  163. #define GMAC_DEBUG_RXFSTS_EMPTY 0
  164. #define GMAC_DEBUG_RXFSTS_BT 1
  165. #define GMAC_DEBUG_RXFSTS_AT 2
  166. #define GMAC_DEBUG_RXFSTS_FULL 3
  167. #define GMAC_DEBUG_RRCSTS_MASK GENMASK(6, 5) /* MTL Rx FIFO Read Controller */
  168. #define GMAC_DEBUG_RRCSTS_SHIFT 5
  169. #define GMAC_DEBUG_RRCSTS_IDLE 0
  170. #define GMAC_DEBUG_RRCSTS_RDATA 1
  171. #define GMAC_DEBUG_RRCSTS_RSTAT 2
  172. #define GMAC_DEBUG_RRCSTS_FLUSH 3
  173. #define GMAC_DEBUG_RWCSTS BIT(4) /* MTL Rx FIFO Write Controller Active */
  174. /* MAC Receive Frame Controller FIFO Status */
  175. #define GMAC_DEBUG_RFCFCSTS_MASK GENMASK(2, 1)
  176. #define GMAC_DEBUG_RFCFCSTS_SHIFT 1
  177. /* MAC GMII or MII Receive Protocol Engine Status */
  178. #define GMAC_DEBUG_RPESTS BIT(0)
  179. /*--- DMA BLOCK defines ---*/
  180. /* DMA Bus Mode register defines */
  181. #define DMA_BUS_MODE_DA 0x00000002 /* Arbitration scheme */
  182. #define DMA_BUS_MODE_DSL_MASK 0x0000007c /* Descriptor Skip Length */
  183. #define DMA_BUS_MODE_DSL_SHIFT 2 /* (in DWORDS) */
  184. /* Programmable burst length (passed thorugh platform)*/
  185. #define DMA_BUS_MODE_PBL_MASK 0x00003f00 /* Programmable Burst Len */
  186. #define DMA_BUS_MODE_PBL_SHIFT 8
  187. #define DMA_BUS_MODE_ATDS 0x00000080 /* Alternate Descriptor Size */
  188. enum rx_tx_priority_ratio {
  189. double_ratio = 0x00004000, /* 2:1 */
  190. triple_ratio = 0x00008000, /* 3:1 */
  191. quadruple_ratio = 0x0000c000, /* 4:1 */
  192. };
  193. #define DMA_BUS_MODE_FB 0x00010000 /* Fixed burst */
  194. #define DMA_BUS_MODE_MB 0x04000000 /* Mixed burst */
  195. #define DMA_BUS_MODE_RPBL_MASK 0x007e0000 /* Rx-Programmable Burst Len */
  196. #define DMA_BUS_MODE_RPBL_SHIFT 17
  197. #define DMA_BUS_MODE_USP 0x00800000
  198. #define DMA_BUS_MODE_MAXPBL 0x01000000
  199. #define DMA_BUS_MODE_AAL 0x02000000
  200. /* DMA CRS Control and Status Register Mapping */
  201. #define DMA_HOST_TX_DESC 0x00001048 /* Current Host Tx descriptor */
  202. #define DMA_HOST_RX_DESC 0x0000104c /* Current Host Rx descriptor */
  203. /* DMA Bus Mode register defines */
  204. #define DMA_BUS_PR_RATIO_MASK 0x0000c000 /* Rx/Tx priority ratio */
  205. #define DMA_BUS_PR_RATIO_SHIFT 14
  206. #define DMA_BUS_FB 0x00010000 /* Fixed Burst */
  207. /* DMA operation mode defines (start/stop tx/rx are placed in common header)*/
  208. /* Disable Drop TCP/IP csum error */
  209. #define DMA_CONTROL_DT 0x04000000
  210. #define DMA_CONTROL_RSF 0x02000000 /* Receive Store and Forward */
  211. #define DMA_CONTROL_DFF 0x01000000 /* Disaable flushing */
  212. /* Threshold for Activating the FC */
  213. enum rfa {
  214. act_full_minus_1 = 0x00800000,
  215. act_full_minus_2 = 0x00800200,
  216. act_full_minus_3 = 0x00800400,
  217. act_full_minus_4 = 0x00800600,
  218. };
  219. /* Threshold for Deactivating the FC */
  220. enum rfd {
  221. deac_full_minus_1 = 0x00400000,
  222. deac_full_minus_2 = 0x00400800,
  223. deac_full_minus_3 = 0x00401000,
  224. deac_full_minus_4 = 0x00401800,
  225. };
  226. #define DMA_CONTROL_TSF 0x00200000 /* Transmit Store and Forward */
  227. enum ttc_control {
  228. DMA_CONTROL_TTC_64 = 0x00000000,
  229. DMA_CONTROL_TTC_128 = 0x00004000,
  230. DMA_CONTROL_TTC_192 = 0x00008000,
  231. DMA_CONTROL_TTC_256 = 0x0000c000,
  232. DMA_CONTROL_TTC_40 = 0x00010000,
  233. DMA_CONTROL_TTC_32 = 0x00014000,
  234. DMA_CONTROL_TTC_24 = 0x00018000,
  235. DMA_CONTROL_TTC_16 = 0x0001c000,
  236. };
  237. #define DMA_CONTROL_TC_TX_MASK 0xfffe3fff
  238. #define DMA_CONTROL_EFC 0x00000100
  239. #define DMA_CONTROL_FEF 0x00000080
  240. #define DMA_CONTROL_FUF 0x00000040
  241. /* Receive flow control activation field
  242. * RFA field in DMA control register, bits 23,10:9
  243. */
  244. #define DMA_CONTROL_RFA_MASK 0x00800600
  245. /* Receive flow control deactivation field
  246. * RFD field in DMA control register, bits 22,12:11
  247. */
  248. #define DMA_CONTROL_RFD_MASK 0x00401800
  249. /* RFD and RFA fields are encoded as follows
  250. *
  251. * Bit Field
  252. * 0,00 - Full minus 1KB (only valid when rxfifo >= 4KB and EFC enabled)
  253. * 0,01 - Full minus 2KB (only valid when rxfifo >= 4KB and EFC enabled)
  254. * 0,10 - Full minus 3KB (only valid when rxfifo >= 4KB and EFC enabled)
  255. * 0,11 - Full minus 4KB (only valid when rxfifo > 4KB and EFC enabled)
  256. * 1,00 - Full minus 5KB (only valid when rxfifo > 8KB and EFC enabled)
  257. * 1,01 - Full minus 6KB (only valid when rxfifo > 8KB and EFC enabled)
  258. * 1,10 - Full minus 7KB (only valid when rxfifo > 8KB and EFC enabled)
  259. * 1,11 - Reserved
  260. *
  261. * RFD should always be > RFA for a given FIFO size. RFD == RFA may work,
  262. * but packet throughput performance may not be as expected.
  263. *
  264. * Be sure that bit 3 in GMAC Register 6 is set for Unicast Pause frame
  265. * detection (IEEE Specification Requirement, Annex 31B, 31B.1, Pause
  266. * Description).
  267. *
  268. * Be sure that DZPA (bit 7 in Flow Control Register, GMAC Register 6),
  269. * is set to 0. This allows pause frames with a quanta of 0 to be sent
  270. * as an XOFF message to the link peer.
  271. */
  272. #define RFA_FULL_MINUS_1K 0x00000000
  273. #define RFA_FULL_MINUS_2K 0x00000200
  274. #define RFA_FULL_MINUS_3K 0x00000400
  275. #define RFA_FULL_MINUS_4K 0x00000600
  276. #define RFA_FULL_MINUS_5K 0x00800000
  277. #define RFA_FULL_MINUS_6K 0x00800200
  278. #define RFA_FULL_MINUS_7K 0x00800400
  279. #define RFD_FULL_MINUS_1K 0x00000000
  280. #define RFD_FULL_MINUS_2K 0x00000800
  281. #define RFD_FULL_MINUS_3K 0x00001000
  282. #define RFD_FULL_MINUS_4K 0x00001800
  283. #define RFD_FULL_MINUS_5K 0x00400000
  284. #define RFD_FULL_MINUS_6K 0x00400800
  285. #define RFD_FULL_MINUS_7K 0x00401000
  286. enum rtc_control {
  287. DMA_CONTROL_RTC_64 = 0x00000000,
  288. DMA_CONTROL_RTC_32 = 0x00000008,
  289. DMA_CONTROL_RTC_96 = 0x00000010,
  290. DMA_CONTROL_RTC_128 = 0x00000018,
  291. };
  292. #define DMA_CONTROL_TC_RX_MASK 0xffffffe7
  293. #define DMA_CONTROL_OSF 0x00000004 /* Operate on second frame */
  294. /* MMC registers offset */
  295. #define GMAC_MMC_CTRL 0x100
  296. #define GMAC_MMC_RX_INTR 0x104
  297. #define GMAC_MMC_TX_INTR 0x108
  298. #define GMAC_MMC_RX_CSUM_OFFLOAD 0x208
  299. #define GMAC_EXTHASH_BASE 0x500
  300. extern const struct stmmac_dma_ops dwmac1000_dma_ops;
  301. #endif /* __DWMAC1000_H__ */