emac.h 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
  1. //*****************************************************************************
  2. //
  3. // emac.h - Defines and Macros for the Ethernet module on Snowflake-class
  4. // devices.
  5. //
  6. // Copyright (c) 2012-2020 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.2.0.295 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 EMACEEEStatus().
  668. //
  669. #define EMAC_INT_LPI 0x40000000
  670. //
  671. // This interrupt source is readable using EMACIntStatus but must
  672. // be cleared by calling the EMACTimestampIntStatus().
  673. //
  674. #define EMAC_INT_TIMESTAMP 0x20000000
  675. //
  676. // Interrupt sources which may be returned from EMACTimestampIntStatus().
  677. //
  678. #define EMAC_TS_INT_TARGET_REACHED 0x00000002
  679. #define EMAC_TS_INT_TS_SEC_OVERFLOW 0x00000001
  680. //
  681. // This interrupt source is readable using EMACIntStatus but must
  682. // be cleared by calling EMACPowerManagementStatusGet().
  683. //
  684. #define EMAC_INT_POWER_MGMNT 0x10000000
  685. //*****************************************************************************
  686. //
  687. // Configuration flags that may be passed in the ui32FreqConfig parameter to
  688. // EMACTimestampPPSSimpleModeSet().
  689. //
  690. //*****************************************************************************
  691. #define EMAC_PPS_SINGLE_PULSE 0x00000000
  692. #define EMAC_PPS_1HZ 0x00000001
  693. #define EMAC_PPS_2HZ 0x00000002
  694. #define EMAC_PPS_4HZ 0x00000003
  695. #define EMAC_PPS_8HZ 0x00000004
  696. #define EMAC_PPS_16HZ 0x00000005
  697. #define EMAC_PPS_32HZ 0x00000006
  698. #define EMAC_PPS_64HZ 0x00000007
  699. #define EMAC_PPS_128HZ 0x00000008
  700. #define EMAC_PPS_256HZ 0x00000009
  701. #define EMAC_PPS_512HZ 0x0000000A
  702. #define EMAC_PPS_1024HZ 0x0000000B
  703. #define EMAC_PPS_2048HZ 0x0000000C
  704. #define EMAC_PPS_4096HZ 0x0000000D
  705. #define EMAC_PPS_8192HZ 0x0000000E
  706. #define EMAC_PPS_16384HZ 0x0000000F
  707. #define EMAC_PPS_32768HZ 0x00000010
  708. //*****************************************************************************
  709. //
  710. // Configuration flags that may be passed in the ui32Config parameter to
  711. // EMACTimestampPPSCommandModeSet().
  712. //
  713. //*****************************************************************************
  714. #define EMAC_PPS_TARGET_INT 0x00000000
  715. #define EMAC_PPS_TARGET_PPS 0x00000060
  716. #define EMAC_PPS_TARGET_BOTH 0x00000040
  717. //*****************************************************************************
  718. //
  719. // Commands which may be passed to EMACTimestampPPSCmd.
  720. //
  721. //*****************************************************************************
  722. #define EMAC_PPS_COMMAND_NONE 0x00
  723. #define EMAC_PPS_COMMAND_START_SINGLE 0x01
  724. #define EMAC_PPS_COMMAND_START_TRAIN 0x02
  725. #define EMAC_PPS_COMMAND_CANCEL_START 0x03
  726. #define EMAC_PPS_COMMAND_STOP_AT_TIME 0x04
  727. #define EMAC_PPS_COMMAND_STOP_NOW 0x05
  728. #define EMAC_PPS_COMMAND_CANCEL_STOP 0x06
  729. //*****************************************************************************
  730. //
  731. // Values which may be passed to EMACVLANRxConfigSet in the ui32Config
  732. // parameter and which may be returned from EMACVLANRxConfigGet.
  733. //
  734. //*****************************************************************************
  735. #define EMAC_VLAN_RX_HASH_ENABLE 0x00080000
  736. #define EMAC_VLAN_RX_HASH_DISABLE 0x00000000
  737. #define EMAC_VLAN_RX_SVLAN_ENABLE 0x00040000
  738. #define EMAC_VLAN_RX_SVLAN_DISABLE 0x00000000
  739. #define EMAC_VLAN_RX_NORMAL_MATCH 0x00000000
  740. #define EMAC_VLAN_RX_INVERSE_MATCH 0x00020000
  741. #define EMAC_VLAN_RX_12BIT_TAG 0x00010000
  742. #define EMAC_VLAN_RX_16BIT_TAG 0x00000000
  743. //*****************************************************************************
  744. //
  745. // Values which may be passed to EMACVLANTxConfigSet in the ui32Config
  746. // parameter and which may be returned from EMACVLANTxConfigGet.
  747. //
  748. //*****************************************************************************
  749. #define EMAC_VLAN_TX_CVLAN 0x00000000
  750. #define EMAC_VLAN_TX_SVLAN 0x00080000
  751. #define EMAC_VLAN_TX_USE_VLC 0x00040000
  752. #define EMAC_VLAN_TX_VLC_NONE 0x00000000
  753. #define EMAC_VLAN_TX_VLC_DELETE 0x00010000
  754. #define EMAC_VLAN_TX_VLC_INSERT 0x00020000
  755. #define EMAC_VLAN_TX_VLC_REPLACE 0x00030000
  756. #define EMAC_VLAN_TX_VLC_MASK 0x00030000
  757. #define EMAC_RWU_FILTER_ENABLE 1
  758. #define EMAC_RWU_FILTER_DISABLE 0
  759. #define EMAC_RWU_FILTER_MULTICAST 8
  760. #define EMAC_RWU_FILTER_UNICAST 0
  761. //*****************************************************************************
  762. //
  763. // The following structure fields must be packed.
  764. //
  765. //*****************************************************************************
  766. #ifdef ewarm
  767. #pragma pack(1)
  768. #endif
  769. //*****************************************************************************
  770. //
  771. //! This structure defines up to 4 filters that can be used to define specific
  772. //! frames which will cause the MAC to wake up from sleep mode.
  773. //
  774. //*****************************************************************************
  775. typedef struct
  776. {
  777. //
  778. //! A byte mask for each filter defining which bytes from a sequence of
  779. //! 31 (bit 31 must be clear in each mask) are used to filter incoming
  780. //! packets. A 1 indicates that the relevant byte is used to update the
  781. //! CRC16 for the filter, a 0 indicates that the byte is ignored.
  782. //
  783. uint32_t pui32ByteMask[4];
  784. //
  785. //! Defines whether each filter is enabled and, if so, whether it filters
  786. //! multicast or unicast frames. Valid values are one of
  787. //! EMAC_RWU_FILTER_ENABLE or EMAC_RWU_FILTER_DISABLE ORed with one of
  788. //! EMAC_RWU_FILTER_UNICAST or EMAC_RWU_FILTER_MULTICAST.
  789. //
  790. uint8_t pui8Command[4];
  791. //
  792. //! Determines the byte offset within the frame at which the filter starts
  793. //! examining bytes. The minimum value for each offset is 12. The first
  794. //! byte of a frame is offset 0.
  795. //
  796. uint8_t pui8Offset[4];
  797. //
  798. //! The CRC16 value that is expected for each filter if it passes. The
  799. //! CRC is calculated using all bytes indicated by the filter's mask.
  800. //
  801. uint16_t pui16CRC[4];
  802. }
  803. #if defined(ccs) || \
  804. defined(codered) || \
  805. defined(gcc) || \
  806. defined(rvmdk) || \
  807. defined(__ARMCC_VERSION) || \
  808. defined(sourcerygxx)
  809. __attribute__ ((packed)) tEMACWakeUpFrameFilter;
  810. #else
  811. tEMACWakeUpFrameFilter;
  812. #endif
  813. //*****************************************************************************
  814. //
  815. // Turn off structure packing again.
  816. //
  817. //*****************************************************************************
  818. #ifdef ewarm
  819. #pragma pack()
  820. #endif
  821. //*****************************************************************************
  822. //
  823. // Values which may be ORed together and used in the ui32Flags parameter to
  824. // EMACPowerManagementControlSet. These may also returned be from a call to
  825. // EMACPowerManagementControlGet.
  826. //
  827. //*****************************************************************************
  828. #define EMAC_PMT_GLOBAL_UNICAST_ENABLE 0x00000200
  829. #define EMAC_PMT_WAKEUP_PACKET_ENABLE 0x00000004
  830. #define EMAC_PMT_MAGIC_PACKET_ENABLE 0x00000002
  831. #define EMAC_PMT_POWER_DOWN 0x00000001
  832. //*****************************************************************************
  833. //
  834. // Values which may be ORed together and returned from a call to
  835. // EMACPowerManagementStatusGet. This call will also return
  836. // EMAC_PMT_POWER_DOWN if the MAC is in power-down mode.
  837. //
  838. //*****************************************************************************
  839. #define EMAC_PMT_WAKEUP_PACKET_RECEIVED 0x00000040
  840. #define EMAC_PMT_MAGIC_PACKET_RECEIVED 0x00000020
  841. //*****************************************************************************
  842. //
  843. // Close the Doxygen group.
  844. //! @}
  845. //
  846. //*****************************************************************************
  847. //*****************************************************************************
  848. //
  849. // Public function prototypes.
  850. //
  851. //*****************************************************************************
  852. extern void EMACInit(uint32_t ui32Base, uint32_t ui32SysClk,
  853. uint32_t ui32BusConfig, uint32_t ui32RxBurst,
  854. uint32_t ui32TxBurst, uint32_t ui32DescSkipSize);
  855. extern void EMACReset(uint32_t ui32Base);
  856. extern void EMACPHYConfigSet(uint32_t ui32Base, uint32_t ui32Config);
  857. extern void EMACConfigSet(uint32_t ui32Base, uint32_t ui32Config,
  858. uint32_t ui32ModeFlags,
  859. uint32_t ui32RxMaxFrameSize);
  860. extern void EMACFrameFilterSet(uint32_t ui32Base, uint32_t ui32FilterOpts);
  861. extern uint32_t EMACFrameFilterGet(uint32_t ui32Base);
  862. extern void EMACHashFilterSet(uint32_t ui32Base, uint32_t ui32HashHi,
  863. uint32_t ui32HashLo);
  864. extern void EMACHashFilterGet(uint32_t ui32Base, uint32_t *pui32HashHi,
  865. uint32_t *pui32HashLo);
  866. extern uint32_t EMACHashFilterBitCalculate(uint8_t *pui8MACAddr);
  867. extern void EMACTxDMAPollDemand(uint32_t ui32Base);
  868. extern void EMACRxDMAPollDemand(uint32_t ui32Base);
  869. extern void EMACRxDMADescriptorListSet(uint32_t ui32Base,
  870. tEMACDMADescriptor *pDescriptor);
  871. extern tEMACDMADescriptor *EMACRxDMADescriptorListGet(uint32_t ui32Base);
  872. extern tEMACDMADescriptor *EMACRxDMACurrentDescriptorGet(uint32_t ui32Base);
  873. extern uint8_t *EMACRxDMACurrentBufferGet(uint32_t ui32Base);
  874. extern void EMACTxDMADescriptorListSet(uint32_t ui32Base,
  875. tEMACDMADescriptor *pDescriptor);
  876. extern tEMACDMADescriptor *EMACTxDMADescriptorListGet(uint32_t ui32Base);
  877. extern tEMACDMADescriptor *EMACTxDMACurrentDescriptorGet(uint32_t ui32Base);
  878. extern uint8_t *EMACTxDMACurrentBufferGet(uint32_t ui32Base);
  879. extern void EMACConfigGet(uint32_t ui32Base, uint32_t *pui32Config,
  880. uint32_t *pui32Mode, uint32_t *pui32RxMaxFrameSize);
  881. extern void EMACAddrSet(uint32_t ui32Base, uint32_t ui32Index,
  882. const uint8_t *pui8MACAddr);
  883. extern void EMACAddrGet(uint32_t ui32Base, uint32_t ui32Index,
  884. uint8_t *pui8MACAddr);
  885. extern uint32_t EMACNumAddrGet(uint32_t ui32Base);
  886. extern void EMACAddrFilterSet(uint32_t ui32Base, uint32_t ui32Index,
  887. uint32_t ui32Config);
  888. extern uint32_t EMACAddrFilterGet(uint32_t ui32Base, uint32_t ui32Index);
  889. extern void EMACRxWatchdogTimerSet(uint32_t ui32Base, uint8_t ui8Timeout);
  890. extern uint32_t EMACStatusGet(uint32_t ui32Base);
  891. extern uint32_t EMACDMAStateGet(uint32_t ui32Base);
  892. extern void EMACTxFlush(uint32_t ui32Base);
  893. extern void EMACTxEnable(uint32_t ui32Base);
  894. extern void EMACTxDisable(uint32_t ui32Base);
  895. extern void EMACRxEnable(uint32_t ui32Base);
  896. extern void EMACRxDisable(uint32_t ui32Base);
  897. extern void EMACIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
  898. extern void EMACIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
  899. extern uint32_t EMACIntStatus(uint32_t ui32Base, bool bMasked);
  900. extern void EMACIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
  901. extern void EMACIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
  902. extern void EMACIntUnregister(uint32_t ui32Base);
  903. extern void EMACPHYWrite(uint32_t ui32Base, uint8_t ui8PhyAddr,
  904. uint8_t ui8RegAddr, uint16_t ui16Data);
  905. extern void EMACPHYExtendedWrite(uint32_t ui32Base, uint8_t ui8PhyAddr,
  906. uint16_t ui16RegAddr, uint16_t ui16Data);
  907. extern uint16_t EMACPHYRead(uint32_t ui32Base, uint8_t ui8PhyAddr,
  908. uint8_t ui8RegAddr);
  909. extern uint16_t EMACPHYExtendedRead(uint32_t ui32Base, uint8_t ui8PhyAddr,
  910. uint16_t ui16RegAddr);
  911. extern void EMACPHYPowerOff(uint32_t ui32Base, uint8_t ui8PhyAddr);
  912. extern void EMACPHYPowerOn(uint32_t ui32Base, uint8_t ui8PhyAddr);
  913. extern void EMACTimestampConfigSet(uint32_t ui32Base, uint32_t ui32Config,
  914. uint32_t ui32SubSecondInc);
  915. extern uint32_t EMACTimestampConfigGet(uint32_t ui32Base,
  916. uint32_t *pui32SubSecondInc);
  917. extern void EMACTimestampAddendSet(uint32_t ui32Base, uint32_t ui32Seconds);
  918. extern void EMACTimestampEnable(uint32_t ui32Base);
  919. extern void EMACTimestampDisable(uint32_t ui32Base);
  920. extern void EMACTimestampSysTimeSet(uint32_t ui32Base, uint32_t ui32Seconds,
  921. uint32_t ui32SubSeconds);
  922. extern void EMACTimestampSysTimeGet(uint32_t ui32Base, uint32_t *pui32Seconds,
  923. uint32_t *pui32SubSeconds);
  924. extern void EMACTimestampSysTimeUpdate(uint32_t ui32Base, uint32_t ui32Seconds,
  925. uint32_t ui32SubSeconds, bool bInc);
  926. extern void EMACTimestampTargetSet(uint32_t ui32Base, uint32_t ui32Seconds,
  927. uint32_t ui32Nanoseconds);
  928. extern void EMACTimestampTargetIntEnable(uint32_t ui32Base);
  929. extern void EMACTimestampTargetIntDisable(uint32_t ui32Base);
  930. extern uint32_t EMACTimestampIntStatus(uint32_t ui32Base);
  931. extern void EMACTimestampPPSSimpleModeSet(uint32_t ui32Base,
  932. uint32_t ui32FreqConfig);
  933. extern void EMACTimestampPPSCommandModeSet(uint32_t ui32Base,
  934. uint32_t ui32Config);
  935. extern void EMACTimestampPPSCommand(uint32_t ui32Base, uint8_t ui8Cmd);
  936. extern void EMACTimestampPPSPeriodSet(uint32_t ui32Base, uint32_t ui32Period,
  937. uint32_t ui32Width);
  938. extern void EMACVLANRxConfigSet(uint32_t ui32Base, uint16_t ui16Tag,
  939. uint32_t ui32Config);
  940. extern uint32_t EMACVLANRxConfigGet(uint32_t ui32Base, uint16_t *pui16Tag);
  941. extern void EMACVLANTxConfigSet(uint32_t ui32Base, uint16_t ui16Tag,
  942. uint32_t ui32Config);
  943. extern uint32_t EMACVLANTxConfigGet(uint32_t ui32Base, uint16_t *pui16Tag);
  944. extern uint32_t EMACVLANHashFilterBitCalculate(uint16_t ui16Tag);
  945. extern void EMACVLANHashFilterSet(uint32_t ui32Base, uint32_t ui32Hash);
  946. extern uint32_t EMACVLANHashFilterGet(uint32_t ui32Base);
  947. extern void EMACRemoteWakeUpFrameFilterSet(uint32_t ui32Base,
  948. const tEMACWakeUpFrameFilter *pFilter);
  949. extern void EMACRemoteWakeUpFrameFilterGet(uint32_t ui32Base,
  950. tEMACWakeUpFrameFilter *pFilter);
  951. extern void EMACPowerManagementControlSet(uint32_t ui32Base,
  952. uint32_t ui32Flags);
  953. extern uint32_t EMACPowerManagementControlGet(uint32_t ui32Base);
  954. extern uint32_t EMACPowerManagementStatusGet(uint32_t ui32Base);
  955. extern void EMACWoLEnter(uint32_t ui32Base);
  956. extern void EMACLPIConfig(uint32_t ui32Base, bool bLPIConfig,
  957. uint16_t ui16LPILSTimer, uint16_t ui16LPITWTimer);
  958. extern void EMACLPIEnter(uint32_t ui32Base);
  959. extern uint16_t EMACLPIStatus(uint32_t ui32Base);
  960. extern void EMACLPILinkSet(uint32_t ui32Base);
  961. extern void EMACLPILinkClear(uint32_t ui32Base);
  962. extern void EMACPHYMMDWrite(uint32_t ui32Base, uint8_t ui8PhyAddr,
  963. uint16_t ui16RegAddr, uint16_t ui16Data);
  964. extern uint16_t EMACPHYMMDRead(uint32_t ui32Base, uint8_t ui8PhyAddr,
  965. uint16_t ui16RegAddr);
  966. //*****************************************************************************
  967. //
  968. // Mark the end of the C bindings section for C++ compilers.
  969. //
  970. //*****************************************************************************
  971. #ifdef __cplusplus
  972. }
  973. #endif
  974. #endif // __DRIVERLIB_EMAC_H__