emac.h 47 KB

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