dwmac1000.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*******************************************************************************
  2. Copyright (C) 2007-2009 STMicroelectronics Ltd
  3. This program is free software; you can redistribute it and/or modify it
  4. under the terms and conditions of the GNU General Public License,
  5. version 2, as published by the Free Software Foundation.
  6. This program is distributed in the hope it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  8. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  9. more details.
  10. You should have received a copy of the GNU General Public License along with
  11. this program; if not, write to the Free Software Foundation, Inc.,
  12. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  13. The full GNU General Public License is included in this distribution in
  14. the file called "COPYING".
  15. Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
  16. *******************************************************************************/
  17. #ifndef __DWMAC1000_H__
  18. #define __DWMAC1000_H__
  19. #include <linux/phy.h>
  20. #include "common.h"
  21. #define GMAC_CONTROL 0x00000000 /* Configuration */
  22. #define GMAC_FRAME_FILTER 0x00000004 /* Frame Filter */
  23. #define GMAC_HASH_HIGH 0x00000008 /* Multicast Hash Table High */
  24. #define GMAC_HASH_LOW 0x0000000c /* Multicast Hash Table Low */
  25. #define GMAC_MII_ADDR 0x00000010 /* MII Address */
  26. #define GMAC_MII_DATA 0x00000014 /* MII Data */
  27. #define GMAC_FLOW_CTRL 0x00000018 /* Flow Control */
  28. #define GMAC_VLAN_TAG 0x0000001c /* VLAN Tag */
  29. #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */
  30. #define GMAC_WAKEUP_FILTER 0x00000028 /* Wake-up Frame Filter */
  31. #define GMAC_INT_STATUS 0x00000038 /* interrupt status register */
  32. enum dwmac1000_irq_status {
  33. lpiis_irq = 0x400,
  34. time_stamp_irq = 0x0200,
  35. mmc_rx_csum_offload_irq = 0x0080,
  36. mmc_tx_irq = 0x0040,
  37. mmc_rx_irq = 0x0020,
  38. mmc_irq = 0x0010,
  39. pmt_irq = 0x0008,
  40. pcs_ane_irq = 0x0004,
  41. pcs_link_irq = 0x0002,
  42. rgmii_irq = 0x0001,
  43. };
  44. #define GMAC_INT_MASK 0x0000003c /* interrupt mask register */
  45. /* PMT Control and Status */
  46. #define GMAC_PMT 0x0000002c
  47. enum power_event {
  48. pointer_reset = 0x80000000,
  49. global_unicast = 0x00000200,
  50. wake_up_rx_frame = 0x00000040,
  51. magic_frame = 0x00000020,
  52. wake_up_frame_en = 0x00000004,
  53. magic_pkt_en = 0x00000002,
  54. power_down = 0x00000001,
  55. };
  56. /* Energy Efficient Ethernet (EEE)
  57. *
  58. * LPI status, timer and control register offset
  59. */
  60. #define LPI_CTRL_STATUS 0x0030
  61. #define LPI_TIMER_CTRL 0x0034
  62. /* LPI control and status defines */
  63. #define LPI_CTRL_STATUS_LPITXA 0x00080000 /* Enable LPI TX Automate */
  64. #define LPI_CTRL_STATUS_PLSEN 0x00040000 /* Enable PHY Link Status */
  65. #define LPI_CTRL_STATUS_PLS 0x00020000 /* PHY Link Status */
  66. #define LPI_CTRL_STATUS_LPIEN 0x00010000 /* LPI Enable */
  67. #define LPI_CTRL_STATUS_RLPIST 0x00000200 /* Receive LPI state */
  68. #define LPI_CTRL_STATUS_TLPIST 0x00000100 /* Transmit LPI state */
  69. #define LPI_CTRL_STATUS_RLPIEX 0x00000008 /* Receive LPI Exit */
  70. #define LPI_CTRL_STATUS_RLPIEN 0x00000004 /* Receive LPI Entry */
  71. #define LPI_CTRL_STATUS_TLPIEX 0x00000002 /* Transmit LPI Exit */
  72. #define LPI_CTRL_STATUS_TLPIEN 0x00000001 /* Transmit LPI Entry */
  73. /* GMAC HW ADDR regs */
  74. #define GMAC_ADDR_HIGH(reg) (((reg > 15) ? 0x00000800 : 0x00000040) + \
  75. (reg * 8))
  76. #define GMAC_ADDR_LOW(reg) (((reg > 15) ? 0x00000804 : 0x00000044) + \
  77. (reg * 8))
  78. #define GMAC_MAX_PERFECT_ADDRESSES 1
  79. /* PCS registers (AN/TBI/SGMII/RGMII) offset */
  80. #define GMAC_AN_CTRL 0x000000c0 /* AN control */
  81. #define GMAC_AN_STATUS 0x000000c4 /* AN status */
  82. #define GMAC_ANE_ADV 0x000000c8 /* Auto-Neg. Advertisement */
  83. #define GMAC_ANE_LPA 0x000000cc /* Auto-Neg. link partener ability */
  84. #define GMAC_ANE_EXP 0x000000d0 /* ANE expansion */
  85. #define GMAC_TBI 0x000000d4 /* TBI extend status */
  86. #define GMAC_S_R_GMII 0x000000d8 /* SGMII RGMII status */
  87. /* AN Configuration defines */
  88. #define GMAC_AN_CTRL_RAN 0x00000200 /* Restart Auto-Negotiation */
  89. #define GMAC_AN_CTRL_ANE 0x00001000 /* Auto-Negotiation Enable */
  90. #define GMAC_AN_CTRL_ELE 0x00004000 /* External Loopback Enable */
  91. #define GMAC_AN_CTRL_ECD 0x00010000 /* Enable Comma Detect */
  92. #define GMAC_AN_CTRL_LR 0x00020000 /* Lock to Reference */
  93. #define GMAC_AN_CTRL_SGMRAL 0x00040000 /* SGMII RAL Control */
  94. /* AN Status defines */
  95. #define GMAC_AN_STATUS_LS 0x00000004 /* Link Status 0:down 1:up */
  96. #define GMAC_AN_STATUS_ANA 0x00000008 /* Auto-Negotiation Ability */
  97. #define GMAC_AN_STATUS_ANC 0x00000020 /* Auto-Negotiation Complete */
  98. #define GMAC_AN_STATUS_ES 0x00000100 /* Extended Status */
  99. /* Register 54 (SGMII/RGMII status register) */
  100. #define GMAC_S_R_GMII_LINK 0x8
  101. #define GMAC_S_R_GMII_SPEED 0x5
  102. #define GMAC_S_R_GMII_SPEED_SHIFT 0x1
  103. #define GMAC_S_R_GMII_MODE 0x1
  104. #define GMAC_S_R_GMII_SPEED_125 2
  105. #define GMAC_S_R_GMII_SPEED_25 1
  106. /* Common ADV and LPA defines */
  107. #define GMAC_ANE_FD (1 << 5)
  108. #define GMAC_ANE_HD (1 << 6)
  109. #define GMAC_ANE_PSE (3 << 7)
  110. #define GMAC_ANE_PSE_SHIFT 7
  111. /* GMAC Configuration defines */
  112. #define GMAC_CONTROL_2K 0x08000000 /* IEEE 802.3as 2K packets */
  113. #define GMAC_CONTROL_TC 0x01000000 /* Transmit Conf. in RGMII/SGMII */
  114. #define GMAC_CONTROL_WD 0x00800000 /* Disable Watchdog on receive */
  115. #define GMAC_CONTROL_JD 0x00400000 /* Jabber disable */
  116. #define GMAC_CONTROL_BE 0x00200000 /* Frame Burst Enable */
  117. #define GMAC_CONTROL_JE 0x00100000 /* Jumbo frame */
  118. enum inter_frame_gap {
  119. GMAC_CONTROL_IFG_88 = 0x00040000,
  120. GMAC_CONTROL_IFG_80 = 0x00020000,
  121. GMAC_CONTROL_IFG_40 = 0x000e0000,
  122. };
  123. #define GMAC_CONTROL_DCRS 0x00010000 /* Disable carrier sense */
  124. #define GMAC_CONTROL_PS 0x00008000 /* Port Select 0:GMI 1:MII */
  125. #define GMAC_CONTROL_FES 0x00004000 /* Speed 0:10 1:100 */
  126. #define GMAC_CONTROL_DO 0x00002000 /* Disable Rx Own */
  127. #define GMAC_CONTROL_LM 0x00001000 /* Loop-back mode */
  128. #define GMAC_CONTROL_DM 0x00000800 /* Duplex Mode */
  129. #define GMAC_CONTROL_IPC 0x00000400 /* Checksum Offload */
  130. #define GMAC_CONTROL_DR 0x00000200 /* Disable Retry */
  131. #define GMAC_CONTROL_LUD 0x00000100 /* Link up/down */
  132. #define GMAC_CONTROL_ACS 0x00000080 /* Auto Pad/FCS Stripping */
  133. #define GMAC_CONTROL_DC 0x00000010 /* Deferral Check */
  134. #define GMAC_CONTROL_TE 0x00000008 /* Transmitter Enable */
  135. #define GMAC_CONTROL_RE 0x00000004 /* Receiver Enable */
  136. #define GMAC_CORE_INIT (GMAC_CONTROL_JD | GMAC_CONTROL_PS | GMAC_CONTROL_ACS | \
  137. GMAC_CONTROL_BE | GMAC_CONTROL_DCRS)
  138. /* GMAC Frame Filter defines */
  139. #define GMAC_FRAME_FILTER_PR 0x00000001 /* Promiscuous Mode */
  140. #define GMAC_FRAME_FILTER_HUC 0x00000002 /* Hash Unicast */
  141. #define GMAC_FRAME_FILTER_HMC 0x00000004 /* Hash Multicast */
  142. #define GMAC_FRAME_FILTER_DAIF 0x00000008 /* DA Inverse Filtering */
  143. #define GMAC_FRAME_FILTER_PM 0x00000010 /* Pass all multicast */
  144. #define GMAC_FRAME_FILTER_DBF 0x00000020 /* Disable Broadcast frames */
  145. #define GMAC_FRAME_FILTER_SAIF 0x00000100 /* Inverse Filtering */
  146. #define GMAC_FRAME_FILTER_SAF 0x00000200 /* Source Address Filter */
  147. #define GMAC_FRAME_FILTER_HPF 0x00000400 /* Hash or perfect Filter */
  148. #define GMAC_FRAME_FILTER_RA 0x80000000 /* Receive all mode */
  149. /* GMII ADDR defines */
  150. #define GMAC_MII_ADDR_WRITE 0x00000002 /* MII Write */
  151. #define GMAC_MII_ADDR_BUSY 0x00000001 /* MII Busy */
  152. /* GMAC FLOW CTRL defines */
  153. #define GMAC_FLOW_CTRL_PT_MASK 0xffff0000 /* Pause Time Mask */
  154. #define GMAC_FLOW_CTRL_PT_SHIFT 16
  155. #define GMAC_FLOW_CTRL_UP 0x00000008 /* Unicast pause frame enable */
  156. #define GMAC_FLOW_CTRL_RFE 0x00000004 /* Rx Flow Control Enable */
  157. #define GMAC_FLOW_CTRL_TFE 0x00000002 /* Tx Flow Control Enable */
  158. #define GMAC_FLOW_CTRL_FCB_BPA 0x00000001 /* Flow Control Busy ... */
  159. /*--- DMA BLOCK defines ---*/
  160. /* DMA Bus Mode register defines */
  161. #define DMA_BUS_MODE_SFT_RESET 0x00000001 /* Software Reset */
  162. #define DMA_BUS_MODE_DA 0x00000002 /* Arbitration scheme */
  163. #define DMA_BUS_MODE_DSL_MASK 0x0000007c /* Descriptor Skip Length */
  164. #define DMA_BUS_MODE_DSL_SHIFT 2 /* (in DWORDS) */
  165. /* Programmable burst length (passed thorugh platform)*/
  166. #define DMA_BUS_MODE_PBL_MASK 0x00003f00 /* Programmable Burst Len */
  167. #define DMA_BUS_MODE_PBL_SHIFT 8
  168. #define DMA_BUS_MODE_ATDS 0x00000080 /* Alternate Descriptor Size */
  169. enum rx_tx_priority_ratio {
  170. double_ratio = 0x00004000, /* 2:1 */
  171. triple_ratio = 0x00008000, /* 3:1 */
  172. quadruple_ratio = 0x0000c000, /* 4:1 */
  173. };
  174. #define DMA_BUS_MODE_FB 0x00010000 /* Fixed burst */
  175. #define DMA_BUS_MODE_MB 0x04000000 /* Mixed burst */
  176. #define DMA_BUS_MODE_RPBL_MASK 0x003e0000 /* Rx-Programmable Burst Len */
  177. #define DMA_BUS_MODE_RPBL_SHIFT 17
  178. #define DMA_BUS_MODE_USP 0x00800000
  179. #define DMA_BUS_MODE_PBL 0x01000000
  180. #define DMA_BUS_MODE_AAL 0x02000000
  181. /* DMA CRS Control and Status Register Mapping */
  182. #define DMA_HOST_TX_DESC 0x00001048 /* Current Host Tx descriptor */
  183. #define DMA_HOST_RX_DESC 0x0000104c /* Current Host Rx descriptor */
  184. /* DMA Bus Mode register defines */
  185. #define DMA_BUS_PR_RATIO_MASK 0x0000c000 /* Rx/Tx priority ratio */
  186. #define DMA_BUS_PR_RATIO_SHIFT 14
  187. #define DMA_BUS_FB 0x00010000 /* Fixed Burst */
  188. /* DMA operation mode defines (start/stop tx/rx are placed in common header)*/
  189. /* Disable Drop TCP/IP csum error */
  190. #define DMA_CONTROL_DT 0x04000000
  191. #define DMA_CONTROL_RSF 0x02000000 /* Receive Store and Forward */
  192. #define DMA_CONTROL_DFF 0x01000000 /* Disaable flushing */
  193. /* Threshold for Activating the FC */
  194. enum rfa {
  195. act_full_minus_1 = 0x00800000,
  196. act_full_minus_2 = 0x00800200,
  197. act_full_minus_3 = 0x00800400,
  198. act_full_minus_4 = 0x00800600,
  199. };
  200. /* Threshold for Deactivating the FC */
  201. enum rfd {
  202. deac_full_minus_1 = 0x00400000,
  203. deac_full_minus_2 = 0x00400800,
  204. deac_full_minus_3 = 0x00401000,
  205. deac_full_minus_4 = 0x00401800,
  206. };
  207. #define DMA_CONTROL_TSF 0x00200000 /* Transmit Store and Forward */
  208. enum ttc_control {
  209. DMA_CONTROL_TTC_64 = 0x00000000,
  210. DMA_CONTROL_TTC_128 = 0x00004000,
  211. DMA_CONTROL_TTC_192 = 0x00008000,
  212. DMA_CONTROL_TTC_256 = 0x0000c000,
  213. DMA_CONTROL_TTC_40 = 0x00010000,
  214. DMA_CONTROL_TTC_32 = 0x00014000,
  215. DMA_CONTROL_TTC_24 = 0x00018000,
  216. DMA_CONTROL_TTC_16 = 0x0001c000,
  217. };
  218. #define DMA_CONTROL_TC_TX_MASK 0xfffe3fff
  219. #define DMA_CONTROL_EFC 0x00000100
  220. #define DMA_CONTROL_FEF 0x00000080
  221. #define DMA_CONTROL_FUF 0x00000040
  222. /* Receive flow control activation field
  223. * RFA field in DMA control register, bits 23,10:9
  224. */
  225. #define DMA_CONTROL_RFA_MASK 0x00800600
  226. /* Receive flow control deactivation field
  227. * RFD field in DMA control register, bits 22,12:11
  228. */
  229. #define DMA_CONTROL_RFD_MASK 0x00401800
  230. /* RFD and RFA fields are encoded as follows
  231. *
  232. * Bit Field
  233. * 0,00 - Full minus 1KB (only valid when rxfifo >= 4KB and EFC enabled)
  234. * 0,01 - Full minus 2KB (only valid when rxfifo >= 4KB and EFC enabled)
  235. * 0,10 - Full minus 3KB (only valid when rxfifo >= 4KB and EFC enabled)
  236. * 0,11 - Full minus 4KB (only valid when rxfifo > 4KB and EFC enabled)
  237. * 1,00 - Full minus 5KB (only valid when rxfifo > 8KB and EFC enabled)
  238. * 1,01 - Full minus 6KB (only valid when rxfifo > 8KB and EFC enabled)
  239. * 1,10 - Full minus 7KB (only valid when rxfifo > 8KB and EFC enabled)
  240. * 1,11 - Reserved
  241. *
  242. * RFD should always be > RFA for a given FIFO size. RFD == RFA may work,
  243. * but packet throughput performance may not be as expected.
  244. *
  245. * Be sure that bit 3 in GMAC Register 6 is set for Unicast Pause frame
  246. * detection (IEEE Specification Requirement, Annex 31B, 31B.1, Pause
  247. * Description).
  248. *
  249. * Be sure that DZPA (bit 7 in Flow Control Register, GMAC Register 6),
  250. * is set to 0. This allows pause frames with a quanta of 0 to be sent
  251. * as an XOFF message to the link peer.
  252. */
  253. #define RFA_FULL_MINUS_1K 0x00000000
  254. #define RFA_FULL_MINUS_2K 0x00000200
  255. #define RFA_FULL_MINUS_3K 0x00000400
  256. #define RFA_FULL_MINUS_4K 0x00000600
  257. #define RFA_FULL_MINUS_5K 0x00800000
  258. #define RFA_FULL_MINUS_6K 0x00800200
  259. #define RFA_FULL_MINUS_7K 0x00800400
  260. #define RFD_FULL_MINUS_1K 0x00000000
  261. #define RFD_FULL_MINUS_2K 0x00000800
  262. #define RFD_FULL_MINUS_3K 0x00001000
  263. #define RFD_FULL_MINUS_4K 0x00001800
  264. #define RFD_FULL_MINUS_5K 0x00400000
  265. #define RFD_FULL_MINUS_6K 0x00400800
  266. #define RFD_FULL_MINUS_7K 0x00401000
  267. enum rtc_control {
  268. DMA_CONTROL_RTC_64 = 0x00000000,
  269. DMA_CONTROL_RTC_32 = 0x00000008,
  270. DMA_CONTROL_RTC_96 = 0x00000010,
  271. DMA_CONTROL_RTC_128 = 0x00000018,
  272. };
  273. #define DMA_CONTROL_TC_RX_MASK 0xffffffe7
  274. #define DMA_CONTROL_OSF 0x00000004 /* Operate on second frame */
  275. /* MMC registers offset */
  276. #define GMAC_MMC_CTRL 0x100
  277. #define GMAC_MMC_RX_INTR 0x104
  278. #define GMAC_MMC_TX_INTR 0x108
  279. #define GMAC_MMC_RX_CSUM_OFFLOAD 0x208
  280. #define GMAC_EXTHASH_BASE 0x500
  281. extern const struct stmmac_dma_ops dwmac1000_dma_ops;
  282. #endif /* __DWMAC1000_H__ */