emac.h 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. //*****************************************************************************
  2. //
  3. // emac.h - Defines and Macros for the Ethernet module on Snowflake-class
  4. // devices.
  5. //
  6. // Copyright (c) 2012-2014 Texas Instruments Incorporated. All rights reserved.
  7. // Software License Agreement
  8. //
  9. // Redistribution and use in source and binary forms, with or without
  10. // modification, are permitted provided that the following conditions
  11. // are met:
  12. //
  13. // Redistributions of source code must retain the above copyright
  14. // notice, this list of conditions and the following disclaimer.
  15. //
  16. // Redistributions in binary form must reproduce the above copyright
  17. // notice, this list of conditions and the following disclaimer in the
  18. // documentation and/or other materials provided with the
  19. // distribution.
  20. //
  21. // Neither the name of Texas Instruments Incorporated nor the names of
  22. // its contributors may be used to endorse or promote products derived
  23. // from this software without specific prior written permission.
  24. //
  25. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. //
  37. // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
  38. //
  39. //*****************************************************************************
  40. #ifndef __DRIVERLIB_EMAC_H__
  41. #define __DRIVERLIB_EMAC_H__
  42. //*****************************************************************************
  43. //
  44. // If building with a C++ compiler, make all of the definitions in this header
  45. // have a C binding.
  46. //
  47. //*****************************************************************************
  48. #ifdef __cplusplus
  49. extern "C"
  50. {
  51. #endif
  52. //*****************************************************************************
  53. //
  54. //! \addtogroup emac_api
  55. //! @{
  56. //
  57. //*****************************************************************************
  58. //*****************************************************************************
  59. //
  60. // The physical address of the internal PHY. This should be in hw_emac.h.
  61. //
  62. //*****************************************************************************
  63. #define EMAC_PHY_ADDR 0
  64. //*****************************************************************************
  65. //
  66. // Helper Macros for Ethernet Processing
  67. //
  68. //*****************************************************************************
  69. //
  70. // htonl/ntohl - Big endian/little endian byte swapping macros for 32-bit
  71. // values.
  72. //
  73. //*****************************************************************************
  74. #ifndef htonl
  75. #define htonl(a) \
  76. ((((a) >> 24) & 0x000000ff) | \
  77. (((a) >> 8) & 0x0000ff00) | \
  78. (((a) << 8) & 0x00ff0000) | \
  79. (((a) << 24) & 0xff000000))
  80. #endif
  81. #ifndef ntohl
  82. #define ntohl(a) htonl((a))
  83. #endif
  84. //*****************************************************************************
  85. //
  86. // htons/ntohs - Big endian/little endian byte swapping macros for 16-bit
  87. // values.
  88. //
  89. //*****************************************************************************
  90. #ifndef htons
  91. #define htons(a) \
  92. ((((a) >> 8) & 0x00ff) | \
  93. (((a) << 8) & 0xff00))
  94. #endif
  95. #ifndef ntohs
  96. #define ntohs(a) htons((a))
  97. #endif
  98. //*****************************************************************************
  99. //
  100. // Forward reference to the Ethernet DMA descriptor structure.
  101. //
  102. //*****************************************************************************
  103. typedef struct tEMACDMADescriptor tEMACDMADescriptor;
  104. //*****************************************************************************
  105. //
  106. //! A union used to describe the two overlapping fields forming the third
  107. //! word of the Ethernet DMA descriptor.
  108. //
  109. //*****************************************************************************
  110. typedef union
  111. {
  112. //
  113. //! When DMA descriptors are used in chained mode, this field is used to
  114. //! provide a link to the next descriptor.
  115. //
  116. tEMACDMADescriptor *pLink;
  117. //
  118. //! When the DMA descriptors are unchained, this field may be used to point
  119. //! to a second buffer containing data for transmission or providing
  120. //! storage for a received frame.
  121. //
  122. void *pvBuffer2;
  123. }
  124. tEMACDES3;
  125. //*****************************************************************************
  126. //
  127. //! A structure defining a single Ethernet DMA buffer descriptor.
  128. //
  129. //*****************************************************************************
  130. struct tEMACDMADescriptor
  131. {
  132. //
  133. //! The first DMA descriptor word contains various control and status bits
  134. //! depending upon whether the descriptor is in the transmit or receive
  135. //! queue. Bit 31 is always the ``OWN'' bit which, when set, indicates
  136. //! that the hardware has control of the descriptor.
  137. //
  138. volatile uint32_t ui32CtrlStatus;
  139. //
  140. //! The second descriptor word contains information on the size of the
  141. //! buffer or buffers attached to the descriptor and various additional
  142. //! control bits.
  143. //
  144. volatile uint32_t ui32Count;
  145. //
  146. //! The third descriptor word contains a pointer to the buffer containing
  147. //! data to transmit or into which received data should be written. This
  148. //! pointer must refer to a buffer in internal SRAM. Pointers to flash or
  149. //! EPI-connected memory may not be used and will result in the MAC
  150. //! reporting a bus error.
  151. //
  152. void *pvBuffer1;
  153. //
  154. //! The fourth descriptor word contains either a pointer to the next
  155. //! descriptor in the ring or a pointer to a second data buffer. The
  156. //! meaning of the word is controlled by the ``CHAINED'' control bit which
  157. //! appears in the first word of the transmit descriptor or the second
  158. //! word of the receive descriptor.
  159. //!
  160. tEMACDES3 DES3;
  161. //
  162. //! The fifth descriptor word is reserved for transmit descriptors but
  163. //! used to report extended status in a receive descriptor.
  164. //
  165. volatile uint32_t ui32ExtRxStatus;
  166. //
  167. //! The sixth descriptor word is reserved for both transmit and receive
  168. //! descriptors.
  169. //
  170. uint32_t ui32Reserved;
  171. //
  172. //! The seventh descriptor word contains the low 32 bits of the 64-bit
  173. //! timestamp captured for transmitted or received data. The value is set
  174. //! only when the transmitted or received data contains the end of a
  175. //! packet. Availability of the timestamp is indicated via a status bit
  176. //! in the first descriptor word.
  177. //
  178. volatile uint32_t ui32IEEE1588TimeLo;
  179. //
  180. //! The eighth descriptor word contains the high 32 bits of the 64-bit
  181. //! timestamp captured for transmitted or received data.
  182. //
  183. volatile uint32_t ui32IEEE1588TimeHi;
  184. };
  185. //*****************************************************************************
  186. //
  187. // Fields found in the DES0 word of the transmit descriptor (ui32CtrlStatus in
  188. // tEMACDMADescriptor)
  189. //
  190. //*****************************************************************************
  191. #define DES0_TX_CTRL_OWN 0x80000000
  192. #define DES0_TX_CTRL_INTERRUPT 0x40000000
  193. #define DES0_TX_CTRL_LAST_SEG 0x20000000
  194. #define DES0_TX_CTRL_FIRST_SEG 0x10000000
  195. //
  196. // This value indicates that the MAC should not append a CRC to transmitted
  197. // packets. If used with DES0_TX_CTRL_REPLACE_CRC, the last 4 bytes of the
  198. // packet passed to the transmitter are replaced with a newly calculated CRC.
  199. // If DES0_TX_CTRL_REPLACE_CRC is not specified, it is assumed that packets
  200. // transmitted have valid CRCs precomputed and included in the frame data.
  201. //
  202. // If DES0_TX_CTRL_DISABLE_CRC is not specified, the MAC will calculate the
  203. // CRC for all frames transmitted and append this value as the 4-byte FCS
  204. // after the last data byte in the frame.
  205. //
  206. #define DES0_TX_CTRL_DISABLE_CRC 0x08000000
  207. #define DES0_TX_CTRL_DISABLE_PADDING 0x04000000
  208. #define DES0_TX_CTRL_ENABLE_TS 0x02000000
  209. //
  210. // This value is only valid if used alongside DES0_TX_CTRL_DISABLE_CRC. When
  211. // specified, the MAC will replace the last 4 bytes of a transmitted frame
  212. // with a newly calculated CRC.
  213. //
  214. #define DES0_TX_CTRL_REPLACE_CRC 0x01000000
  215. #define DES0_TX_CTRL_CHKSUM_M 0x00C00000
  216. #define DES0_TX_CTRL_NO_CHKSUM 0x00000000
  217. #define DES0_TX_CTRL_IP_HDR_CHKSUM 0x00400000
  218. #define DES0_TX_CTRL_IP_HDR_PAY_CHKSUM 0x00800000
  219. #define DES0_TX_CTRL_IP_ALL_CKHSUMS 0x00C00000
  220. #define DES0_TX_CTRL_END_OF_RING 0x00200000
  221. #define DES0_TX_CTRL_CHAINED 0x00100000
  222. #define DES0_TX_CTRL_VLAN_M 0x000C0000
  223. #define DES0_TX_CTRL_VLAN_NONE 0x00000000
  224. #define DES0_TX_CTRL_VLAN_REMOVE 0x00040000
  225. #define DES0_TX_CTRL_VLAN_INSERT 0x00080000
  226. #define DES0_TX_CTRL_VLAN_REPLACE 0x000C0000
  227. #define DES0_TX_STAT_TS_CAPTURED 0x00020000
  228. #define DES0_TX_STAT_IPH_ERR 0x00010000
  229. #define DES0_TX_STAT_ERR 0x00008000
  230. #define DES0_TX_STAT_JABBER_TO 0x00004000
  231. #define DES0_TX_STAT_FLUSHED 0x00002000
  232. #define DES0_TX_STAT_PAYLOAD_ERR 0x00001000
  233. #define DES0_TX_STAT_CARRIER_LOST 0x00000800
  234. #define DES0_TX_STAT_NO_CARRIER 0x00000400
  235. #define DES0_TX_STAT_TX_L_COLLISION 0x00000200
  236. #define DES0_TX_STAT_E_COLLISION 0x00000100
  237. #define DES0_TX_STAT_VLAN_FRAME 0x00000080
  238. #define DES0_TX_STAT_COL_COUNT_M 0x00000078
  239. #define DES0_TX_STAT_COL_COUNT_S 3
  240. #define DES0_TX_STAT_E_DEFERRAL 0x00000004
  241. #define DES0_TX_STAT_UNDERFLOW 0x00000002
  242. #define DES0_TX_STAT_DEFERRED 0x00000001
  243. //*****************************************************************************
  244. //
  245. // Fields found in the DES1 word of the transmit descriptor (ui32Count in
  246. // tEMACDMADescriptor)
  247. //
  248. //*****************************************************************************
  249. #define DES1_TX_CTRL_SADDR_MAC1 0x80000000
  250. #define DES1_TX_CTRL_SADDR_M 0x60000000
  251. #define DES1_TX_CTRL_SADDR_NONE 0x00000000
  252. #define DES1_TX_CTRL_SADDR_INSERT 0x20000000
  253. #define DES1_TX_CTRL_SADDR_REPLACE 0x40000000
  254. #define DES1_TX_CTRL_BUFF2_SIZE_M 0x1FFF0000
  255. #define DES1_TX_CTRL_BUFF1_SIZE_M 0x00001FFF
  256. #define DES1_TX_CTRL_BUFF2_SIZE_S 16
  257. #define DES1_TX_CTRL_BUFF1_SIZE_S 0
  258. //*****************************************************************************
  259. //
  260. // Fields found in the DES0 word of the receive descriptor (ui32CtrlStatus in
  261. // tEMACDMADescriptor)
  262. //
  263. //*****************************************************************************
  264. #define DES0_RX_CTRL_OWN 0x80000000
  265. #define DES0_RX_STAT_DEST_ADDR_FAIL 0x40000000
  266. #define DES0_RX_STAT_FRAME_LENGTH_M 0x3FFF0000
  267. #define DES0_RX_STAT_FRAME_LENGTH_S 16
  268. #define DES0_RX_STAT_ERR 0x00008000
  269. #define DES0_RX_STAT_DESCRIPTOR_ERR 0x00004000
  270. #define DES0_RX_STAT_SRC_ADDR_FAIL 0x00002000
  271. #define DES0_RX_STAT_LENGTH_ERR 0x00001000
  272. #define DES0_RX_STAT_OVERFLOW 0x00000800
  273. #define DES0_RX_STAT_VLAN_TAG 0x00000400
  274. #define DES0_RX_STAT_FIRST_DESC 0x00000200
  275. #define DES0_RX_STAT_LAST_DESC 0x00000100
  276. #define DES0_RX_STAT_TS_AVAILABLE 0x00000080
  277. #define DES0_RX_STAT_RX_L_COLLISION 0x00000040
  278. #define DES0_RX_STAT_FRAME_TYPE 0x00000020
  279. #define DES0_RX_STAT_WDOG_TIMEOUT 0x00000010
  280. #define DES0_RX_STAT_RX_ERR 0x00000008
  281. #define DES0_RX_STAT_DRIBBLE_ERR 0x00000004
  282. #define DES0_RX_STAT_CRC_ERR 0x00000002
  283. #define DES0_RX_STAT_MAC_ADDR 0x00000001
  284. #define DES0_RX_STAT_EXT_AVAILABLE 0x00000001
  285. //*****************************************************************************
  286. //
  287. // Fields found in the DES1 word of the receive descriptor (ui32Count in
  288. // tEMACDMADescriptor)
  289. //
  290. //*****************************************************************************
  291. #define DES1_RX_CTRL_DISABLE_INT 0x80000000
  292. #define DES1_RX_CTRL_BUFF2_SIZE_M 0x1FFF0000
  293. #define DES1_RX_CTRL_BUFF2_SIZE_S 16
  294. #define DES1_RX_CTRL_END_OF_RING 0x00008000
  295. #define DES1_RX_CTRL_CHAINED 0x00004000
  296. #define DES1_RX_CTRL_BUFF1_SIZE_M 0x00001FFF
  297. #define DES1_RX_CTRL_BUFF1_SIZE_S 0
  298. //*****************************************************************************
  299. //
  300. // Fields found in the DES4 word of the receive descriptor (ui32ExtRxStatus in
  301. // tEMACDMADescriptor)
  302. //
  303. //*****************************************************************************
  304. #define DES4_RX_STAT_TS_DROPPED 0x00004000
  305. #define DES4_RX_STAT_PTP_VERSION2 0x00002000
  306. #define DES4_RX_STAT_PTP_TYPE_ETH 0x00001000
  307. #define DES4_RX_STAT_PTP_TYPE_UDP 0x00000000
  308. #define DES4_RX_STAT_PTP_MT_M 0x00000F00
  309. #define DES4_RX_STAT_PTP_MT_NONE 0x00000000
  310. #define DES4_RX_STAT_PTP_MT_SYNC 0x00000100
  311. #define DES4_RX_STAT_PTP_MT_FOLLOW_UP 0x00000200
  312. #define DES4_RX_STAT_PTP_MT_DELAY_REQ 0x00000300
  313. #define DES4_RX_STAT_PTP_MT_DELAY_RESP 0x00000400
  314. #define DES4_RX_STAT_PTP_MT_PDELAY_REQ 0x00000500
  315. #define DES4_RX_STAT_PTP_MT_PDELAY_RESP 0x00000600
  316. #define DES4_RX_STAT_PTP_MT_PDELAY_RFU 0x00000700
  317. #define DES4_RX_STAT_PTP_MT_ANNOUNCE 0x00000800
  318. #define DES4_RX_STAT_PTP_MT_SIGNALLING 0x00000A00
  319. #define DES4_RX_STAT_PTP_MT_RESERVED 0x00000F00
  320. #define DES4_RX_STAT_IPV6 0x00000080
  321. #define DES4_RX_STAT_IPV4 0x00000040
  322. #define DES4_RX_STAT_IP_CHK_BYPASSED 0x00000020
  323. #define DES4_RX_STAT_IP_PAYLOAD_ERR 0x00000010
  324. #define DES4_RX_STAT_IP_HEADER_ERR 0x00000008
  325. #define DES4_RX_STAT_PAYLOAD_M 0x00000007
  326. #define DES4_RX_STAT_PAYLOAD_UNKNOWN 0x00000000
  327. #define DES4_RX_STAT_PAYLOAD_UDP 0x00000001
  328. #define DES4_RX_STAT_PAYLOAD_TCP 0x00000002
  329. #define DES4_RX_STAT_PAYLOAD_ICMP 0x00000003
  330. //*****************************************************************************
  331. //
  332. // Values used in the ui32BusConfig parameter to EMACInit().
  333. //
  334. //***************************************************************************
  335. #define EMAC_BCONFIG_DMA_PRIO_WEIGHT_M 0x30000000
  336. #define EMAC_BCONFIG_DMA_PRIO_WEIGHT_1 0x00000000
  337. #define EMAC_BCONFIG_DMA_PRIO_WEIGHT_2 0x10000000
  338. #define EMAC_BCONFIG_DMA_PRIO_WEIGHT_3 0x20000000
  339. #define EMAC_BCONFIG_DMA_PRIO_WEIGHT_4 0x30000000
  340. #define EMAC_BCONFIG_TX_PRIORITY 0x08000000
  341. #define EMAC_BCONFIG_ADDR_ALIGNED 0x02000000
  342. #define EMAC_BCONFIG_PRIORITY_M 0x0000C000
  343. #define EMAC_BCONFIG_PRIORITY_1_1 (0 << 14)
  344. #define EMAC_BCONFIG_PRIORITY_2_1 (1 << 14)
  345. #define EMAC_BCONFIG_PRIORITY_3_1 (2 << 14)
  346. #define EMAC_BCONFIG_PRIORITY_4_1 (3 << 14)
  347. #define EMAC_BCONFIG_PRIORITY_FIXED 0x00000002
  348. #define EMAC_BCONFIG_FIXED_BURST 0x00010000
  349. #define EMAC_BCONFIG_MIXED_BURST 0x04000000
  350. //*****************************************************************************
  351. //
  352. // Options used in the ui32Config parameter to EMACPHYConfigSet().
  353. //
  354. //*****************************************************************************
  355. #define EMAC_PHY_TYPE_INTERNAL 0x00000000
  356. #define EMAC_PHY_TYPE_EXTERNAL_MII 0x80000000
  357. #define EMAC_PHY_TYPE_EXTERNAL_RMII 0xC0000000
  358. #define EMAC_PHY_INT_NIB_TXERR_DET_DIS 0x01000000
  359. #define EMAC_PHY_INT_RX_ER_DURING_IDLE 0x00800000
  360. #define EMAC_PHY_INT_ISOLATE_MII_LLOSS 0x00400000
  361. #define EMAC_PHY_INT_LINK_LOSS_RECOVERY 0x00200000
  362. #define EMAC_PHY_INT_TDRRUN 0x00100000
  363. #define EMAC_PHY_INT_LD_ON_RX_ERR_COUNT 0x00040000
  364. #define EMAC_PHY_INT_LD_ON_MTL3_ERR_COUNT 0x00020000
  365. #define EMAC_PHY_INT_LD_ON_LOW_SNR 0x00010000
  366. #define EMAC_PHY_INT_LD_ON_SIGNAL_ENERGY 0x00008000
  367. #define EMAC_PHY_INT_POLARITY_SWAP 0x00004000
  368. #define EMAC_PHY_INT_MDI_SWAP 0x00002000
  369. #define EMAC_PHY_INT_ROBUST_MDIX 0x00001000
  370. #define EMAC_PHY_INT_FAST_MDIX 0x00000800
  371. #define EMAC_PHY_INT_MDIX_EN 0x00000400
  372. #define EMAC_PHY_INT_FAST_RXDV_DETECT 0x00000200
  373. #define EMAC_PHY_INT_FAST_L_UP_DETECT 0x00000100
  374. #define EMAC_PHY_INT_EXT_FULL_DUPLEX 0x00000080
  375. #define EMAC_PHY_INT_FAST_AN_80_50_35 0x00000040
  376. #define EMAC_PHY_INT_FAST_AN_120_75_50 0x00000050
  377. #define EMAC_PHY_INT_FAST_AN_140_150_100 0x00000060
  378. #define EMAC_PHY_FORCE_10B_T_HALF_DUPLEX 0x00000000
  379. #define EMAC_PHY_FORCE_10B_T_FULL_DUPLEX 0x00000002
  380. #define EMAC_PHY_FORCE_100B_T_HALF_DUPLEX 0x00000004
  381. #define EMAC_PHY_FORCE_100B_T_FULL_DUPLEX 0x00000006
  382. #define EMAC_PHY_AN_10B_T_HALF_DUPLEX 0x00000008
  383. #define EMAC_PHY_AN_10B_T_FULL_DUPLEX 0x0000000A
  384. #define EMAC_PHY_AN_100B_T_HALF_DUPLEX 0x0000000C
  385. #define EMAC_PHY_AN_100B_T_FULL_DUPLEX 0x0000000E
  386. #define EMAC_PHY_INT_HOLD 0x00000001
  387. #define EMAC_PHY_TYPE_MASK 0xC0000000
  388. //*****************************************************************************
  389. //
  390. // Options used in the ui32Config parameter to EMACConfigSet().
  391. //
  392. //*****************************************************************************
  393. #define EMAC_CONFIG_USE_MACADDR1 0x40000000
  394. #define EMAC_CONFIG_USE_MACADDR0 0x00000000
  395. #define EMAC_CONFIG_SA_FROM_DESCRIPTOR 0x00000000
  396. #define EMAC_CONFIG_SA_INSERT 0x20000000
  397. #define EMAC_CONFIG_SA_REPLACE 0x30000000
  398. #define EMAC_CONFIG_2K_PACKETS 0x08000000
  399. #define EMAC_CONFIG_STRIP_CRC 0x02000000
  400. #define EMAC_CONFIG_JABBER_DISABLE 0x00400000
  401. #define EMAC_CONFIG_JUMBO_ENABLE 0x00100000
  402. #define EMAC_CONFIG_IF_GAP_MASK 0x000E0000
  403. #define EMAC_CONFIG_IF_GAP_96BITS (0x0 << 17)
  404. #define EMAC_CONFIG_IF_GAP_88BITS (0x1 << 17)
  405. #define EMAC_CONFIG_IF_GAP_80BITS (0x2 << 17)
  406. #define EMAC_CONFIG_IF_GAP_72BITS (0x3 << 17)
  407. #define EMAC_CONFIG_IF_GAP_64BITS (0x4 << 17)
  408. #define EMAC_CONFIG_IF_GAP_56BITS (0x5 << 17)
  409. #define EMAC_CONFIG_IF_GAP_48BITS (0x6 << 17)
  410. #define EMAC_CONFIG_IF_GAP_40BITS (0x7 << 17)
  411. #define EMAC_CONFIG_CS_DISABLE 0x00010000
  412. #define EMAC_CONFIG_100MBPS 0x00004000
  413. #define EMAC_CONFIG_10MBPS 0x00000000
  414. #define EMAC_CONFIG_RX_OWN_DISABLE 0x00002000
  415. #define EMAC_CONFIG_LOOPBACK 0x00001000
  416. #define EMAC_CONFIG_FULL_DUPLEX 0x00000800
  417. #define EMAC_CONFIG_HALF_DUPLEX 0x00000000
  418. #define EMAC_CONFIG_CHECKSUM_OFFLOAD 0x00000400
  419. #define EMAC_CONFIG_RETRY_DISABLE 0x00000200
  420. #define EMAC_CONFIG_AUTO_CRC_STRIPPING 0x00000080
  421. #define EMAC_CONFIG_BO_MASK 0x00000060
  422. #define EMAC_CONFIG_BO_LIMIT_1024 (0x0 << 5)
  423. #define EMAC_CONFIG_BO_LIMIT_256 (0x1 << 5)
  424. #define EMAC_CONFIG_BO_LIMIT_16 (0x2 << 5)
  425. #define EMAC_CONFIG_BO_LIMIT_2 (0x3 << 5)
  426. #define EMAC_CONFIG_DEFERRAL_CHK_ENABLE 0x00000010
  427. #define EMAC_CONFIG_PREAMBLE_MASK 0x00000003
  428. #define EMAC_CONFIG_7BYTE_PREAMBLE 0x00000000
  429. #define EMAC_CONFIG_5BYTE_PREAMBLE 0x00000001
  430. #define EMAC_CONFIG_3BYTE_PREAMBLE 0x00000002
  431. //*****************************************************************************
  432. //
  433. // Options used in the ui32ModeFlags parameter to EMACConfigSet().
  434. //
  435. //*****************************************************************************
  436. #define EMAC_MODE_KEEP_BAD_CRC 0x04000000
  437. #define EMAC_MODE_RX_STORE_FORWARD 0x02000000
  438. #define EMAC_MODE_RX_FLUSH_DISABLE 0x01000000
  439. #define EMAC_MODE_TX_STORE_FORWARD 0x00200000
  440. #define EMAC_MODE_TX_THRESHOLD_16_BYTES (7 << 14)
  441. #define EMAC_MODE_TX_THRESHOLD_24_BYTES (6 << 14)
  442. #define EMAC_MODE_TX_THRESHOLD_32_BYTES (5 << 14)
  443. #define EMAC_MODE_TX_THRESHOLD_40_BYTES (4 << 14)
  444. #define EMAC_MODE_TX_THRESHOLD_64_BYTES (0 << 14)
  445. #define EMAC_MODE_TX_THRESHOLD_128_BYTES (1 << 14)
  446. #define EMAC_MODE_TX_THRESHOLD_192_BYTES (2 << 14)
  447. #define EMAC_MODE_TX_THRESHOLD_256_BYTES (3 << 14)
  448. #define EMAC_MODE_RX_ERROR_FRAMES 0x00000080
  449. #define EMAC_MODE_RX_UNDERSIZED_FRAMES 0x00000040
  450. #define EMAC_MODE_RX_THRESHOLD_64_BYTES (0 << 3)
  451. #define EMAC_MODE_RX_THRESHOLD_32_BYTES (1 << 3)
  452. #define EMAC_MODE_RX_THRESHOLD_96_BYTES (2 << 3)
  453. #define EMAC_MODE_RX_THRESHOLD_128_BYTES (3 << 3)
  454. #define EMAC_MODE_OPERATE_2ND_FRAME 0x00000002
  455. //*****************************************************************************
  456. //
  457. // These two values may be returned by EMACConfigGet() in the *pui32Config
  458. // parameter. The transmitter and receiver are, however, enabled and disabled
  459. // using independent functions, EMACTxEnable/Disable() and
  460. // EMACRxEnable/Disable().
  461. //
  462. //*****************************************************************************
  463. #define EMAC_CONFIG_TX_ENABLED 0x00000008
  464. #define EMAC_CONFIG_RX_ENABLED 0x00000004
  465. //*****************************************************************************
  466. //
  467. // These two values may be returned by EMACConfigGet() in the *pui32Mode
  468. // parameter. The transmit and receive DMA channels are, however, enabled and
  469. // disabled using independent functions, EMACTxEnable/Disable() and
  470. // EMACRxEnable/Disable().
  471. //
  472. //*****************************************************************************
  473. #define EMAC_MODE_TX_DMA_ENABLED 0x00002000
  474. #define EMAC_MODE_RX_DMA_ENABLED 0x00000002
  475. //*****************************************************************************
  476. //
  477. // These values may be passed to EMACFrameFilterSet() in the ui32FilterOpts
  478. // parameter, and are returned by EMACFrameFilterGet().
  479. //
  480. //*****************************************************************************
  481. #define EMAC_FRMFILTER_RX_ALL 0x80000000
  482. #define EMAC_FRMFILTER_VLAN 0x00010000
  483. #define EMAC_FRMFILTER_HASH_AND_PERFECT 0x00000400
  484. #define EMAC_FRMFILTER_SADDR 0x00000200
  485. #define EMAC_FRMFILTER_INV_SADDR 0x00000100
  486. #define EMAC_FRMFILTER_PASS_MASK (0x03 << 6)
  487. #define EMAC_FRMFILTER_PASS_NO_CTRL (0x00 << 6)
  488. #define EMAC_FRMFILTER_PASS_NO_PAUSE (0x01 << 6)
  489. #define EMAC_FRMFILTER_PASS_ALL_CTRL (0x02 << 6)
  490. #define EMAC_FRMFILTER_PASS_ADDR_CTRL (0x03 << 6)
  491. #define EMAC_FRMFILTER_BROADCAST 0x00000020
  492. #define EMAC_FRMFILTER_PASS_MULTICAST 0x00000010
  493. #define EMAC_FRMFILTER_INV_DADDR 0x00000008
  494. #define EMAC_FRMFILTER_HASH_MULTICAST 0x00000004
  495. #define EMAC_FRMFILTER_HASH_UNICAST 0x00000002
  496. #define EMAC_FRMFILTER_PROMISCUOUS 0x00000001
  497. //*****************************************************************************
  498. //
  499. // Values which may be returned by EMACStatusGet().
  500. //
  501. //*****************************************************************************
  502. #define EMAC_STATUS_TX_NOT_EMPTY 0x01000000
  503. #define EMAC_STATUS_TX_WRITING_FIFO 0x00400000
  504. #define EMAC_STATUS_TRC_STATE_MASK 0x00300000
  505. #define EMAC_STATUS_TRC_STATE_IDLE (0x00 << 20)
  506. #define EMAC_STATUS_TRC_STATE_READING (0x01 << 20)
  507. #define EMAC_STATUS_TRC_STATE_WAITING (0x02 << 20)
  508. #define EMAC_STATUS_TRC_STATE_STATUS (0x03 << 20)
  509. #define EMAC_STATUS_TX_PAUSED 0x00080000
  510. #define EMAC_STATUS_TFC_STATE_MASK 0x00060000
  511. #define EMAC_STATUS_TFC_STATE_IDLE (0x00 << 17)
  512. #define EMAC_STATUS_TFC_STATE_WAITING (0x01 << 17)
  513. #define EMAC_STATUS_TFC_STATE_PAUSING (0x02 << 17)
  514. #define EMAC_STATUS_TFC_STATE_WRITING (0x03 << 17)
  515. #define EMAC_STATUS_MAC_NOT_IDLE 0x00010000
  516. #define EMAC_STATUS_RX_FIFO_LEVEL_MASK 0x00000300
  517. #define EMAC_STATUS_RX_FIFO_EMPTY (0x00 << 8)
  518. #define EMAC_STATUS_RX_FIFO_BELOW (0x01 << 8)
  519. #define EMAC_STATUS_RX_FIFO_ABOVE (0x02 << 8)
  520. #define EMAC_STATUS_RX_FIFO_FULL (0x03 << 8)
  521. #define EMAC_STATUS_RX_FIFO_STATE_MASK 0x00000060
  522. #define EMAC_STATUS_RX_FIFO_IDLE (0x00 << 5)
  523. #define EMAC_STATUS_RX_FIFO_READING (0x01 << 5)
  524. #define EMAC_STATUS_RX_FIFO_STATUS (0x02 << 5)
  525. #define EMAC_STATUS_RX_FIFO_FLUSHING (0x03 << 5)
  526. #define EMAC_STATUS_RWC_ACTIVE 0x00000010
  527. #define EMAC_STATUS_RPE_ACTIVE 0x00000001
  528. //*****************************************************************************
  529. //
  530. // Values which may be returned by EMACDMAStateGet().
  531. //
  532. //*****************************************************************************
  533. #define EMAC_DMA_TXSTAT_MASK (0x07 << 20)
  534. #define EMAC_DMA_TXSTAT_STOPPED (0x00 << 20)
  535. #define EMAC_DMA_TXSTAT_RUN_FETCH_DESC (0x01 << 20)
  536. #define EMAC_DMA_TXSTAT_RUN_WAIT_STATUS (0x02 << 20)
  537. #define EMAC_DMA_TXSTAT_RUN_READING (0x03 << 20)
  538. #define EMAC_DMA_TXSTAT_RUN_CLOSE_DESC (0x07 << 20)
  539. #define EMAC_DMA_TXSTAT_TS_WRITE (0x04 << 20)
  540. #define EMAC_DMA_TXSTAT_SUSPENDED (0x06 << 20)
  541. #define EMAC_DMA_RXSTAT_MASK (0x07 << 17)
  542. #define EMAC_DMA_RXSTAT_STOPPED (0x00 << 17)
  543. #define EMAC_DMA_RXSTAT_RUN_FETCH_DESC (0x01 << 17)
  544. #define EMAC_DMA_RXSTAT_RUN_WAIT_PACKET (0x03 << 17)
  545. #define EMAC_DMA_RXSTAT_SUSPENDED (0x04 << 17)
  546. #define EMAC_DMA_RXSTAT_RUN_CLOSE_DESC (0x05 << 17)
  547. #define EMAC_DMA_RXSTAT_TS_WRITE (0x06 << 17)
  548. #define EMAC_DMA_RXSTAT_RUN_RECEIVING (0x07 << 17)
  549. #define EMAC_TX_DMA_STATE(x) ((x) & EMAC_DMA_TXSTAT_MASK)
  550. #define EMAC_RX_DMA_STATE(x) ((x) & EMAC_DMA_RXSTAT_MASK)
  551. #define EMAC_DMA_ERROR 0x00002000
  552. #define EMAC_DMA_ERR_MASK 0x03800000
  553. #define EMAC_DMA_ERR_RX_DATA_WRITE 0x00000000
  554. #define EMAC_DMA_ERR_TX_DATA_READ 0x01800000
  555. #define EMAC_DMA_ERR_RX_DESC_WRITE 0x02000000
  556. #define EMAC_DMA_ERR_TX_DESC_WRITE 0x02800000
  557. #define EMAC_DMA_ERR_RX_DESC_READ 0x03000000
  558. #define EMAC_DMA_ERR_TX_DESC_READ 0x03800000
  559. //*****************************************************************************
  560. //
  561. // Values which may be ORed together in the ui32Config parameter passed to
  562. // EMACAddrFilterSet and which may be returned by EMACAddrFilterGet.
  563. //
  564. //*****************************************************************************
  565. #define EMAC_FILTER_ADDR_ENABLE 0x80000000
  566. #define EMAC_FILTER_SOURCE_ADDR 0x40000000
  567. #define EMAC_FILTER_MASK_BYTE_6 0x20000000
  568. #define EMAC_FILTER_MASK_BYTE_5 0x10000000
  569. #define EMAC_FILTER_MASK_BYTE_4 0x08000000
  570. #define EMAC_FILTER_MASK_BYTE_3 0x04000000
  571. #define EMAC_FILTER_MASK_BYTE_2 0x03000000
  572. #define EMAC_FILTER_MASK_BYTE_1 0x01000000
  573. #define EMAC_FILTER_BYTE_MASK_M 0x3F000000
  574. #define EMAC_FILTER_BYTE_MASK_S 24
  575. //*****************************************************************************
  576. //
  577. // Flags passed to EMACTimestampConfigSet or returned from
  578. // EMACTimestampConfigGet.
  579. //
  580. //*****************************************************************************
  581. #define EMAC_TS_MAC_FILTER_ENABLE 0x00040000
  582. #define EMAC_TS_MAC_FILTER_DISABLE 0x00000000
  583. #define EMAC_TS_SYNC_FOLLOW_DREQ_DRESP 0x00000000
  584. #define EMAC_TS_SYNC_ONLY 0x00004000
  585. #define EMAC_TS_DELAYREQ_ONLY 0x0000C000
  586. #define EMAC_TS_ALL 0x00010000
  587. #define EMAC_TS_SYNC_PDREQ_PDRESP 0x00014000
  588. #define EMAC_TS_DREQ_PDREQ_PDRESP 0x0001C000
  589. #define EMAC_TS_SYNC_DELAYREQ 0x00020000
  590. #define EMAC_TS_PDREQ_PDRESP 0x00030000
  591. #define EMAC_TS_PROCESS_IPV4_UDP 0x00002000
  592. #define EMAC_TS_PROCESS_IPV6_UDP 0x00001000
  593. #define EMAC_TS_PROCESS_ETHERNET 0x00000800
  594. #define EMAC_TS_PTP_VERSION_2 0x00000400
  595. #define EMAC_TS_PTP_VERSION_1 0x00000000
  596. #define EMAC_TS_DIGITAL_ROLLOVER 0x00000200
  597. #define EMAC_TS_BINARY_ROLLOVER 0x00000000
  598. #define EMAC_TS_ALL_RX_FRAMES 0x00000100
  599. #define EMAC_TS_UPDATE_FINE 0x00000002
  600. #define EMAC_TS_UPDATE_COARSE 0x00000000
  601. //*****************************************************************************
  602. //
  603. // Some register bit definitions relating to external PHYs. These are not
  604. // relevant (or available) when using the internal Ethernet PHY but having
  605. // the definitions here helps when using an external MII or RMII PHY.
  606. //
  607. //*****************************************************************************
  608. #define EPHY_SCR_INPOL_EXT 0x00000008
  609. #define EPHY_SCR_TINT_EXT 0x00000004
  610. #define EPHY_SCR_INTEN_EXT 0x00000002
  611. #define EPHY_SCR_INTOE_EXT 0x00000001
  612. //*****************************************************************************
  613. //
  614. // These interrupt sources may be passed to EMACIntEnable() and
  615. // EMACIntDisable() to enable or disable various Ethernet interrupt sources.
  616. //
  617. //*****************************************************************************
  618. //
  619. // Note that interrupts relating to timestamping and power management must be
  620. // independently enabled via calls to functions EMACTimestampTargetIntEnable
  621. // and EMACPowerManagementControlSet.
  622. //
  623. // EMAC_INT_PHY is deliberately set to a reserved bit in the MAC interrupt
  624. // register. We handle the fact that the PHY interrupt is controlled via an
  625. // independent register within the code. If we didn't do this, the app would
  626. // have to enable the MAC interrupt then enable the PHY interrupt via a
  627. // different API (since they share a vector). To further complicate matters,
  628. // they would have to call EMACIntStatus() and then, if it returned 0,
  629. // read the PHY interrupt status to see that it fired. This would be nasty
  630. // and unfriendly so we hide it inside DriverLib.
  631. //
  632. //*****************************************************************************
  633. #define EMAC_INT_PHY 0x80000000
  634. #define EMAC_INT_EARLY_RECEIVE 0x00004000
  635. #define EMAC_INT_BUS_ERROR 0x00002000
  636. #define EMAC_INT_EARLY_TRANSMIT 0x00000400
  637. #define EMAC_INT_RX_WATCHDOG 0x00000200
  638. #define EMAC_INT_RX_STOPPED 0x00000100
  639. #define EMAC_INT_RX_NO_BUFFER 0x00000080
  640. #define EMAC_INT_RECEIVE 0x00000040
  641. #define EMAC_INT_TX_UNDERFLOW 0x00000020
  642. #define EMAC_INT_RX_OVERFLOW 0x00000010
  643. #define EMAC_INT_TX_JABBER 0x00000008
  644. #define EMAC_INT_TX_NO_BUFFER 0x00000004
  645. #define EMAC_INT_TX_STOPPED 0x00000002
  646. #define EMAC_INT_TRANSMIT 0x00000001
  647. //
  648. // These interrupt sources are summary indicators. They are readable
  649. // using EMACIntStatus() and must be cleared using EMACIntClear(). They
  650. // may be enabled or disabled independently of the group of interrupts that
  651. // they are derived from but offer merely a simple way to be informed of a
  652. // normal or abnormal condition requiring software attention.
  653. //
  654. // EMAC_INT_NORMAL_INT is the logical OR of the masked state of
  655. // EMAC_INT_TRANSMIT | EMAC_INT_RECEIVE | EMAC_INT_TX_NO_BUFFER |
  656. // EMAC_INT_EARLY_RECEIVE.
  657. //
  658. // EMAC_INT_ABNORMAL_INT is the logical OR of the masked state of
  659. // EMAC_INT_TX_STOPPED | EMAC_INT_TX_JABBER | EMAC_INT_RX_OVERFLOW |
  660. // EMAC_INT_TX_UNDERFLOW | EMAC_INT_RX_NO_BUFFER | EMAC_INT_RX_STOPPED |
  661. // EMAC_INT_RX_WATCHDOG | EMAC_INT_EARLY_TRANSMIT | EMAC_INT_BUS_ERROR.
  662. //
  663. #define EMAC_INT_NORMAL_INT 0x00010000
  664. #define EMAC_INT_ABNORMAL_INT 0x00008000
  665. //
  666. // This interrupt source is readable using EMACIntStatus but must
  667. // be cleared by calling the EMACTimestampIntStatus().
  668. //
  669. #define EMAC_INT_TIMESTAMP 0x20000000
  670. //
  671. // Interrupt sources which may be returned from EMACTimestampIntStatus().
  672. //
  673. #define EMAC_TS_INT_TARGET_REACHED 0x00000002
  674. #define EMAC_TS_INT_TS_SEC_OVERFLOW 0x00000001
  675. //
  676. // This interrupt source is readable using EMACIntStatus but must
  677. // be cleared by calling EMACPowerManagementStatusGet().
  678. //
  679. #define EMAC_INT_POWER_MGMNT 0x10000000
  680. //*****************************************************************************
  681. //
  682. // Configuration flags that may be passed in the ui32FreqConfig parameter to
  683. // EMACTimestampPPSSimpleModeSet().
  684. //
  685. //*****************************************************************************
  686. #define EMAC_PPS_SINGLE_PULSE 0x00000000
  687. #define EMAC_PPS_1HZ 0x00000001
  688. #define EMAC_PPS_2HZ 0x00000002
  689. #define EMAC_PPS_4HZ 0x00000003
  690. #define EMAC_PPS_8HZ 0x00000004
  691. #define EMAC_PPS_16HZ 0x00000005
  692. #define EMAC_PPS_32HZ 0x00000006
  693. #define EMAC_PPS_64HZ 0x00000007
  694. #define EMAC_PPS_128HZ 0x00000008
  695. #define EMAC_PPS_256HZ 0x00000009
  696. #define EMAC_PPS_512HZ 0x0000000A
  697. #define EMAC_PPS_1024HZ 0x0000000B
  698. #define EMAC_PPS_2048HZ 0x0000000C
  699. #define EMAC_PPS_4096HZ 0x0000000D
  700. #define EMAC_PPS_8192HZ 0x0000000E
  701. #define EMAC_PPS_16384HZ 0x0000000F
  702. #define EMAC_PPS_32768HZ 0x00000010
  703. //*****************************************************************************
  704. //
  705. // Configuration flags that may be passed in the ui32Config parameter to
  706. // EMACTimestampPPSCommandModeSet().
  707. //
  708. //*****************************************************************************
  709. #define EMAC_PPS_TARGET_INT 0x00000000
  710. #define EMAC_PPS_TARGET_PPS 0x00000060
  711. #define EMAC_PPS_TARGET_BOTH 0x00000040
  712. //*****************************************************************************
  713. //
  714. // Commands which may be passed to EMACTimestampPPSCmd.
  715. //
  716. //*****************************************************************************
  717. #define EMAC_PPS_COMMAND_NONE 0x00
  718. #define EMAC_PPS_COMMAND_START_SINGLE 0x01
  719. #define EMAC_PPS_COMMAND_START_TRAIN 0x02
  720. #define EMAC_PPS_COMMAND_CANCEL_START 0x03
  721. #define EMAC_PPS_COMMAND_STOP_AT_TIME 0x04
  722. #define EMAC_PPS_COMMAND_STOP_NOW 0x05
  723. #define EMAC_PPS_COMMAND_CANCEL_STOP 0x06
  724. //*****************************************************************************
  725. //
  726. // Values which may be passed to EMACVLANRxConfigSet in the ui32Config
  727. // parameter and which may be returned from EMACVLANRxConfigGet.
  728. //
  729. //*****************************************************************************
  730. #define EMAC_VLAN_RX_HASH_ENABLE 0x00080000
  731. #define EMAC_VLAN_RX_HASH_DISABLE 0x00000000
  732. #define EMAC_VLAN_RX_SVLAN_ENABLE 0x00040000
  733. #define EMAC_VLAN_RX_SVLAN_DISABLE 0x00000000
  734. #define EMAC_VLAN_RX_NORMAL_MATCH 0x00000000
  735. #define EMAC_VLAN_RX_INVERSE_MATCH 0x00020000
  736. #define EMAC_VLAN_RX_12BIT_TAG 0x00010000
  737. #define EMAC_VLAN_RX_16BIT_TAG 0x00000000
  738. //*****************************************************************************
  739. //
  740. // Values which may be passed to EMACVLANTxConfigSet in the ui32Config
  741. // parameter and which may be returned from EMACVLANTxConfigGet.
  742. //
  743. //*****************************************************************************
  744. #define EMAC_VLAN_TX_CVLAN 0x00000000
  745. #define EMAC_VLAN_TX_SVLAN 0x00080000
  746. #define EMAC_VLAN_TX_USE_VLC 0x00040000
  747. #define EMAC_VLAN_TX_VLC_NONE 0x00000000
  748. #define EMAC_VLAN_TX_VLC_DELETE 0x00010000
  749. #define EMAC_VLAN_TX_VLC_INSERT 0x00020000
  750. #define EMAC_VLAN_TX_VLC_REPLACE 0x00030000
  751. #define EMAC_VLAN_TX_VLC_MASK 0x00030000
  752. #define EMAC_RWU_FILTER_ENABLE 1
  753. #define EMAC_RWU_FILTER_DISABLE 0
  754. #define EMAC_RWU_FILTER_MULTICAST 8
  755. #define EMAC_RWU_FILTER_UNICAST 0
  756. //*****************************************************************************
  757. //
  758. // The following structure fields must be packed.
  759. //
  760. //*****************************************************************************
  761. #ifdef ewarm
  762. #pragma pack(1)
  763. #endif
  764. //*****************************************************************************
  765. //
  766. //! This structure defines up to 4 filters that can be used to define specific
  767. //! frames which will cause the MAC to wake up from sleep mode.
  768. //
  769. //*****************************************************************************
  770. typedef struct
  771. {
  772. //
  773. //! A byte mask for each filter defining which bytes from a sequence of
  774. //! 31 (bit 31 must be clear in each mask) are used to filter incoming
  775. //! packets. A 1 indicates that the relevant byte is used to update the
  776. //! CRC16 for the filter, a 0 indicates that the byte is ignored.
  777. //
  778. uint32_t pui32ByteMask[4];
  779. //
  780. //! Defines whether each filter is enabled and, if so, whether it filters
  781. //! multicast or unicast frames. Valid values are one of
  782. //! EMAC_RWU_FILTER_ENABLE or EMAC_RWU_FILTER_DISABLE ORed with one of
  783. //! EMAC_RWU_FILTER_UNICAST or EMAC_RWU_FILTER_MULTICAST.
  784. //
  785. uint8_t pui8Command[4];
  786. //
  787. //! Determines the byte offset within the frame at which the filter starts
  788. //! examining bytes. The minimum value for each offset is 12. The first
  789. //! byte of a frame is offset 0.
  790. //
  791. uint8_t pui8Offset[4];
  792. //
  793. //! The CRC16 value that is expected for each filter if it passes. The
  794. //! CRC is calculated using all bytes indicated by the filter's mask.
  795. //
  796. uint16_t pui16CRC[4];
  797. }
  798. #if defined(ccs) || \
  799. defined(codered) || \
  800. defined(gcc) || \
  801. defined(rvmdk) || \
  802. defined(__ARMCC_VERSION) || \
  803. defined(sourcerygxx)
  804. __attribute__ ((packed)) tEMACWakeUpFrameFilter;
  805. #else
  806. tEMACWakeUpFrameFilter;
  807. #endif
  808. //*****************************************************************************
  809. //
  810. // Turn off structure packing again.
  811. //
  812. //*****************************************************************************
  813. #ifdef ewarm
  814. #pragma pack()
  815. #endif
  816. //*****************************************************************************
  817. //
  818. // Values which may be ORed together and used in the ui32Flags parameter to
  819. // EMACPowerManagementControlSet. These may also returned be from a call to
  820. // EMACPowerManagementControlGet.
  821. //
  822. //*****************************************************************************
  823. #define EMAC_PMT_GLOBAL_UNICAST_ENABLE 0x00000200
  824. #define EMAC_PMT_WAKEUP_PACKET_ENABLE 0x00000004
  825. #define EMAC_PMT_MAGIC_PACKET_ENABLE 0x00000002
  826. #define EMAC_PMT_POWER_DOWN 0x00000001
  827. //*****************************************************************************
  828. //
  829. // Values which may be ORed together and returned from a call to
  830. // EMACPowerManagementStatusGet. This call will also return
  831. // EMAC_PMT_POWER_DOWN if the MAC is in power-down mode.
  832. //
  833. //*****************************************************************************
  834. #define EMAC_PMT_WAKEUP_PACKET_RECEIVED 0x00000040
  835. #define EMAC_PMT_MAGIC_PACKET_RECEIVED 0x00000020
  836. //*****************************************************************************
  837. //
  838. // Close the Doxygen group.
  839. //! @}
  840. //
  841. //*****************************************************************************
  842. //*****************************************************************************
  843. //
  844. // Public function prototypes.
  845. //
  846. //*****************************************************************************
  847. extern void EMACInit(uint32_t ui32Base, uint32_t ui32SysClk,
  848. uint32_t ui32BusConfig, uint32_t ui32RxBurst,
  849. uint32_t ui32TxBurst, uint32_t ui32DescSkipSize);
  850. extern void EMACReset(uint32_t ui32Base);
  851. extern void EMACPHYConfigSet(uint32_t ui32Base, uint32_t ui32Config);
  852. extern void EMACConfigSet(uint32_t ui32Base, uint32_t ui32Config,
  853. uint32_t ui32ModeFlags,
  854. uint32_t ui32RxMaxFrameSize);
  855. extern void EMACFrameFilterSet(uint32_t ui32Base, uint32_t ui32FilterOpts);
  856. extern uint32_t EMACFrameFilterGet(uint32_t ui32Base);
  857. extern void EMACHashFilterSet(uint32_t ui32Base, uint32_t ui32HashHi,
  858. uint32_t ui32HashLo);
  859. extern void EMACHashFilterGet(uint32_t ui32Base, uint32_t *pui32HashHi,
  860. uint32_t *pui32HashLo);
  861. extern uint32_t EMACHashFilterBitCalculate(uint8_t *pui8MACAddr);
  862. extern void EMACTxDMAPollDemand(uint32_t ui32Base);
  863. extern void EMACRxDMAPollDemand(uint32_t ui32Base);
  864. extern void EMACRxDMADescriptorListSet(uint32_t ui32Base,
  865. tEMACDMADescriptor *pDescriptor);
  866. extern tEMACDMADescriptor *EMACRxDMADescriptorListGet(uint32_t ui32Base);
  867. extern tEMACDMADescriptor *EMACRxDMACurrentDescriptorGet(uint32_t ui32Base);
  868. extern uint8_t *EMACRxDMACurrentBufferGet(uint32_t ui32Base);
  869. extern void EMACTxDMADescriptorListSet(uint32_t ui32Base,
  870. tEMACDMADescriptor *pDescriptor);
  871. extern tEMACDMADescriptor *EMACTxDMADescriptorListGet(uint32_t ui32Base);
  872. extern tEMACDMADescriptor *EMACTxDMACurrentDescriptorGet(uint32_t ui32Base);
  873. extern uint8_t *EMACTxDMACurrentBufferGet(uint32_t ui32Base);
  874. extern void EMACConfigGet(uint32_t ui32Base, uint32_t *pui32Config,
  875. uint32_t *pui32Mode, uint32_t *pui32RxMaxFrameSize);
  876. extern void EMACAddrSet(uint32_t ui32Base, uint32_t ui32Index,
  877. const uint8_t *pui8MACAddr);
  878. extern void EMACAddrGet(uint32_t ui32Base, uint32_t ui32Index,
  879. uint8_t *pui8MACAddr);
  880. extern uint32_t EMACNumAddrGet(uint32_t ui32Base);
  881. extern void EMACAddrFilterSet(uint32_t ui32Base, uint32_t ui32Index,
  882. uint32_t ui32Config);
  883. extern uint32_t EMACAddrFilterGet(uint32_t ui32Base, uint32_t ui32Index);
  884. extern void EMACRxWatchdogTimerSet(uint32_t ui32Base, uint8_t ui8Timeout);
  885. extern uint32_t EMACStatusGet(uint32_t ui32Base);
  886. extern uint32_t EMACDMAStateGet(uint32_t ui32Base);
  887. extern void EMACTxFlush(uint32_t ui32Base);
  888. extern void EMACTxEnable(uint32_t ui32Base);
  889. extern void EMACTxDisable(uint32_t ui32Base);
  890. extern void EMACRxEnable(uint32_t ui32Base);
  891. extern void EMACRxDisable(uint32_t ui32Base);
  892. extern void EMACIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
  893. extern void EMACIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
  894. extern uint32_t EMACIntStatus(uint32_t ui32Base, bool bMasked);
  895. extern void EMACIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
  896. extern void EMACIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
  897. extern void EMACIntUnregister(uint32_t ui32Base);
  898. extern void EMACPHYWrite(uint32_t ui32Base, uint8_t ui8PhyAddr,
  899. uint8_t ui8RegAddr, uint16_t ui16Data);
  900. extern void EMACPHYExtendedWrite(uint32_t ui32Base, uint8_t ui8PhyAddr,
  901. uint16_t ui16RegAddr, uint16_t ui16Data);
  902. extern uint16_t EMACPHYRead(uint32_t ui32Base, uint8_t ui8PhyAddr,
  903. uint8_t ui8RegAddr);
  904. extern uint16_t EMACPHYExtendedRead(uint32_t ui32Base, uint8_t ui8PhyAddr,
  905. uint16_t ui16RegAddr);
  906. extern void EMACPHYPowerOff(uint32_t ui32Base, uint8_t ui8PhyAddr);
  907. extern void EMACPHYPowerOn(uint32_t ui32Base, uint8_t ui8PhyAddr);
  908. extern void EMACTimestampConfigSet(uint32_t ui32Base, uint32_t ui32Config,
  909. uint32_t ui32SubSecondInc);
  910. extern uint32_t EMACTimestampConfigGet(uint32_t ui32Base,
  911. uint32_t *pui32SubSecondInc);
  912. extern void EMACTimestampAddendSet(uint32_t ui32Base, uint32_t ui32Seconds);
  913. extern void EMACTimestampEnable(uint32_t ui32Base);
  914. extern void EMACTimestampDisable(uint32_t ui32Base);
  915. extern void EMACTimestampSysTimeSet(uint32_t ui32Base, uint32_t ui32Seconds,
  916. uint32_t ui32SubSeconds);
  917. extern void EMACTimestampSysTimeGet(uint32_t ui32Base, uint32_t *pui32Seconds,
  918. uint32_t *pui32SubSeconds);
  919. extern void EMACTimestampSysTimeUpdate(uint32_t ui32Base, uint32_t ui32Seconds,
  920. uint32_t ui32SubSeconds, bool bInc);
  921. extern void EMACTimestampTargetSet(uint32_t ui32Base, uint32_t ui32Seconds,
  922. uint32_t ui32Nanoseconds);
  923. extern void EMACTimestampTargetIntEnable(uint32_t ui32Base);
  924. extern void EMACTimestampTargetIntDisable(uint32_t ui32Base);
  925. extern uint32_t EMACTimestampIntStatus(uint32_t ui32Base);
  926. extern void EMACTimestampPPSSimpleModeSet(uint32_t ui32Base,
  927. uint32_t ui32FreqConfig);
  928. extern void EMACTimestampPPSCommandModeSet(uint32_t ui32Base,
  929. uint32_t ui32Config);
  930. extern void EMACTimestampPPSCommand(uint32_t ui32Base, uint8_t ui8Cmd);
  931. extern void EMACTimestampPPSPeriodSet(uint32_t ui32Base, uint32_t ui32Period,
  932. uint32_t ui32Width);
  933. extern void EMACVLANRxConfigSet(uint32_t ui32Base, uint16_t ui16Tag,
  934. uint32_t ui32Config);
  935. extern uint32_t EMACVLANRxConfigGet(uint32_t ui32Base, uint16_t *pui16Tag);
  936. extern void EMACVLANTxConfigSet(uint32_t ui32Base, uint16_t ui16Tag,
  937. uint32_t ui32Config);
  938. extern uint32_t EMACVLANTxConfigGet(uint32_t ui32Base, uint16_t *pui16Tag);
  939. extern uint32_t EMACVLANHashFilterBitCalculate(uint16_t ui16Tag);
  940. extern void EMACVLANHashFilterSet(uint32_t ui32Base, uint32_t ui32Hash);
  941. extern uint32_t EMACVLANHashFilterGet(uint32_t ui32Base);
  942. extern void EMACRemoteWakeUpFrameFilterSet(uint32_t ui32Base,
  943. const tEMACWakeUpFrameFilter *pFilter);
  944. extern void EMACRemoteWakeUpFrameFilterGet(uint32_t ui32Base,
  945. tEMACWakeUpFrameFilter *pFilter);
  946. extern void EMACPowerManagementControlSet(uint32_t ui32Base,
  947. uint32_t ui32Flags);
  948. extern uint32_t EMACPowerManagementControlGet(uint32_t ui32Base);
  949. extern uint32_t EMACPowerManagementStatusGet(uint32_t ui32Base);
  950. //*****************************************************************************
  951. //
  952. // Mark the end of the C bindings section for C++ compilers.
  953. //
  954. //*****************************************************************************
  955. #ifdef __cplusplus
  956. }
  957. #endif
  958. #endif // __DRIVERLIB_EMAC_H__