1 /******************************************************************************
3 * Copyright (C) 2010 - 2016 Xilinx, Inc. All rights reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
31 ******************************************************************************/
32 /*****************************************************************************/
36 * @addtogroup emacps_v3_1
39 * This header file contains identifiers and low-level driver functions (or
40 * macros) that can be used to access the PS Ethernet MAC (XEmacPs) device.
41 * High-level driver functions are defined in xemacps.h.
46 * MODIFICATION HISTORY:
48 * Ver Who Date Changes
49 * ----- ---- -------- -------------------------------------------------------
50 * 1.00a wsy 01/10/10 First release.
51 * 1.02a asa 11/05/12 Added hash defines for DMACR burst length configuration.
52 * 1.05a kpc 28/06/13 Added XEmacPs_ResetHw function prototype
53 * 1.06a asa 11/02/13 Changed the value for XEMACPS_RXBUF_LEN_MASK from 0x3fff
54 * to 0x1fff. This fixes the CR#744902.
55 * 2.1 srt 07/15/14 Add support for Zynq Ultrascale Mp GEM specification.
56 * 3.0 kvn 12/16/14 Changed name of XEMACPS_NWCFG_LENGTHERRDSCRD_MASK to
57 * XEMACPS_NWCFG_LENERRDSCRD_MASK as it exceeds 31 characters.
58 * 3.0 kpc 1/23/15 Corrected the extended descriptor macro values.
59 * 3.0 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
60 * 3.0 hk 03/18/15 Added support for jumbo frames.
61 * Remove "used bit set" from TX error interrupt masks.
62 * 3.1 hk 08/10/15 Update upper 32 bit tx and rx queue ptr register offsets.
63 * 3.2 hk 02/22/16 Added SGMII support for Zynq Ultrascale+ MPSoC.
66 ******************************************************************************/
68 #ifndef XEMACPS_HW_H /* prevent circular inclusions */
69 #define XEMACPS_HW_H /* by using protection macros */
71 /***************************** Include Files *********************************/
73 #include "xil_types.h"
74 #include "xil_assert.h"
81 /************************** Constant Definitions *****************************/
83 #define XEMACPS_MAX_MAC_ADDR 4U /**< Maxmum number of mac address
85 #define XEMACPS_MAX_TYPE_ID 4U /**< Maxmum number of type id supported */
88 #define XEMACPS_BD_ALIGNMENT 64U /**< Minimum buffer descriptor alignment
92 #define XEMACPS_BD_ALIGNMENT 4U /**< Minimum buffer descriptor alignment
95 #define XEMACPS_RX_BUF_ALIGNMENT 4U /**< Minimum buffer alignment when using
96 options that impose alignment
97 restrictions on the buffer data on
100 /** @name Direction identifiers
102 * These are used by several functions and callbacks that need
103 * to specify whether an operation specifies a send or receive channel.
106 #define XEMACPS_SEND 1U /**< send direction */
107 #define XEMACPS_RECV 2U /**< receive direction */
110 /** @name MDC clock division
111 * currently supporting 8, 16, 32, 48, 64, 96, 128, 224.
114 typedef enum { MDC_DIV_8 = 0U, MDC_DIV_16, MDC_DIV_32, MDC_DIV_48,
115 MDC_DIV_64, MDC_DIV_96, MDC_DIV_128, MDC_DIV_224
120 #define XEMACPS_RX_BUF_SIZE 1536U /**< Specify the receive buffer size in
121 bytes, 64, 128, ... 10240 */
122 #define XEMACPS_RX_BUF_SIZE_JUMBO 10240U
124 #define XEMACPS_RX_BUF_UNIT 64U /**< Number of receive buffer bytes as a
125 unit, this is HW setup */
127 #define XEMACPS_MAX_RXBD 128U /**< Size of RX buffer descriptor queues */
128 #define XEMACPS_MAX_TXBD 128U /**< Size of TX buffer descriptor queues */
130 #define XEMACPS_MAX_HASH_BITS 64U /**< Maximum value for hash bits. 2**6 */
132 /* Register offset definitions. Unless otherwise noted, register access is
133 * 32 bit. Names are self explained here.
136 #define XEMACPS_NWCTRL_OFFSET 0x00000000U /**< Network Control reg */
137 #define XEMACPS_NWCFG_OFFSET 0x00000004U /**< Network Config reg */
138 #define XEMACPS_NWSR_OFFSET 0x00000008U /**< Network Status reg */
140 #define XEMACPS_DMACR_OFFSET 0x00000010U /**< DMA Control reg */
141 #define XEMACPS_TXSR_OFFSET 0x00000014U /**< TX Status reg */
142 #define XEMACPS_RXQBASE_OFFSET 0x00000018U /**< RX Q Base address reg */
143 #define XEMACPS_TXQBASE_OFFSET 0x0000001CU /**< TX Q Base address reg */
144 #define XEMACPS_RXSR_OFFSET 0x00000020U /**< RX Status reg */
146 #define XEMACPS_ISR_OFFSET 0x00000024U /**< Interrupt Status reg */
147 #define XEMACPS_IER_OFFSET 0x00000028U /**< Interrupt Enable reg */
148 #define XEMACPS_IDR_OFFSET 0x0000002CU /**< Interrupt Disable reg */
149 #define XEMACPS_IMR_OFFSET 0x00000030U /**< Interrupt Mask reg */
151 #define XEMACPS_PHYMNTNC_OFFSET 0x00000034U /**< Phy Maintaince reg */
152 #define XEMACPS_RXPAUSE_OFFSET 0x00000038U /**< RX Pause Time reg */
153 #define XEMACPS_TXPAUSE_OFFSET 0x0000003CU /**< TX Pause Time reg */
155 #define XEMACPS_JUMBOMAXLEN_OFFSET 0x00000048U /**< Jumbo max length reg */
157 #define XEMACPS_HASHL_OFFSET 0x00000080U /**< Hash Low address reg */
158 #define XEMACPS_HASHH_OFFSET 0x00000084U /**< Hash High address reg */
160 #define XEMACPS_LADDR1L_OFFSET 0x00000088U /**< Specific1 addr low reg */
161 #define XEMACPS_LADDR1H_OFFSET 0x0000008CU /**< Specific1 addr high reg */
162 #define XEMACPS_LADDR2L_OFFSET 0x00000090U /**< Specific2 addr low reg */
163 #define XEMACPS_LADDR2H_OFFSET 0x00000094U /**< Specific2 addr high reg */
164 #define XEMACPS_LADDR3L_OFFSET 0x00000098U /**< Specific3 addr low reg */
165 #define XEMACPS_LADDR3H_OFFSET 0x0000009CU /**< Specific3 addr high reg */
166 #define XEMACPS_LADDR4L_OFFSET 0x000000A0U /**< Specific4 addr low reg */
167 #define XEMACPS_LADDR4H_OFFSET 0x000000A4U /**< Specific4 addr high reg */
169 #define XEMACPS_MATCH1_OFFSET 0x000000A8U /**< Type ID1 Match reg */
170 #define XEMACPS_MATCH2_OFFSET 0x000000ACU /**< Type ID2 Match reg */
171 #define XEMACPS_MATCH3_OFFSET 0x000000B0U /**< Type ID3 Match reg */
172 #define XEMACPS_MATCH4_OFFSET 0x000000B4U /**< Type ID4 Match reg */
174 #define XEMACPS_STRETCH_OFFSET 0x000000BCU /**< IPG Stretch reg */
176 #define XEMACPS_OCTTXL_OFFSET 0x00000100U /**< Octects transmitted Low
178 #define XEMACPS_OCTTXH_OFFSET 0x00000104U /**< Octects transmitted High
181 #define XEMACPS_TXCNT_OFFSET 0x00000108U /**< Error-free Frmaes
182 transmitted counter */
183 #define XEMACPS_TXBCCNT_OFFSET 0x0000010CU /**< Error-free Broadcast
185 #define XEMACPS_TXMCCNT_OFFSET 0x00000110U /**< Error-free Multicast
187 #define XEMACPS_TXPAUSECNT_OFFSET 0x00000114U /**< Pause Frames Transmitted
189 #define XEMACPS_TX64CNT_OFFSET 0x00000118U /**< Error-free 64 byte Frames
190 Transmitted counter */
191 #define XEMACPS_TX65CNT_OFFSET 0x0000011CU /**< Error-free 65-127 byte
194 #define XEMACPS_TX128CNT_OFFSET 0x00000120U /**< Error-free 128-255 byte
197 #define XEMACPS_TX256CNT_OFFSET 0x00000124U /**< Error-free 256-511 byte
200 #define XEMACPS_TX512CNT_OFFSET 0x00000128U /**< Error-free 512-1023 byte
203 #define XEMACPS_TX1024CNT_OFFSET 0x0000012CU /**< Error-free 1024-1518 byte
206 #define XEMACPS_TX1519CNT_OFFSET 0x00000130U /**< Error-free larger than
208 transmitted counter */
209 #define XEMACPS_TXURUNCNT_OFFSET 0x00000134U /**< TX under run error
212 #define XEMACPS_SNGLCOLLCNT_OFFSET 0x00000138U /**< Single Collision Frame
214 #define XEMACPS_MULTICOLLCNT_OFFSET 0x0000013CU /**< Multiple Collision Frame
216 #define XEMACPS_EXCESSCOLLCNT_OFFSET 0x00000140U /**< Excessive Collision Frame
218 #define XEMACPS_LATECOLLCNT_OFFSET 0x00000144U /**< Late Collision Frame
220 #define XEMACPS_TXDEFERCNT_OFFSET 0x00000148U /**< Deferred Transmission
222 #define XEMACPS_TXCSENSECNT_OFFSET 0x0000014CU /**< Transmit Carrier Sense
225 #define XEMACPS_OCTRXL_OFFSET 0x00000150U /**< Octects Received register
227 #define XEMACPS_OCTRXH_OFFSET 0x00000154U /**< Octects Received register
230 #define XEMACPS_RXCNT_OFFSET 0x00000158U /**< Error-free Frames
232 #define XEMACPS_RXBROADCNT_OFFSET 0x0000015CU /**< Error-free Broadcast
233 Frames Received Counter */
234 #define XEMACPS_RXMULTICNT_OFFSET 0x00000160U /**< Error-free Multicast
235 Frames Received Counter */
236 #define XEMACPS_RXPAUSECNT_OFFSET 0x00000164U /**< Pause Frames
238 #define XEMACPS_RX64CNT_OFFSET 0x00000168U /**< Error-free 64 byte Frames
240 #define XEMACPS_RX65CNT_OFFSET 0x0000016CU /**< Error-free 65-127 byte
241 Frames Received Counter */
242 #define XEMACPS_RX128CNT_OFFSET 0x00000170U /**< Error-free 128-255 byte
243 Frames Received Counter */
244 #define XEMACPS_RX256CNT_OFFSET 0x00000174U /**< Error-free 256-512 byte
245 Frames Received Counter */
246 #define XEMACPS_RX512CNT_OFFSET 0x00000178U /**< Error-free 512-1023 byte
247 Frames Received Counter */
248 #define XEMACPS_RX1024CNT_OFFSET 0x0000017CU /**< Error-free 1024-1518 byte
249 Frames Received Counter */
250 #define XEMACPS_RX1519CNT_OFFSET 0x00000180U /**< Error-free 1519-max byte
251 Frames Received Counter */
252 #define XEMACPS_RXUNDRCNT_OFFSET 0x00000184U /**< Undersize Frames Received
254 #define XEMACPS_RXOVRCNT_OFFSET 0x00000188U /**< Oversize Frames Received
256 #define XEMACPS_RXJABCNT_OFFSET 0x0000018CU /**< Jabbers Received
258 #define XEMACPS_RXFCSCNT_OFFSET 0x00000190U /**< Frame Check Sequence
260 #define XEMACPS_RXLENGTHCNT_OFFSET 0x00000194U /**< Length Field Error
262 #define XEMACPS_RXSYMBCNT_OFFSET 0x00000198U /**< Symbol Error Counter */
263 #define XEMACPS_RXALIGNCNT_OFFSET 0x0000019CU /**< Alignment Error Counter */
264 #define XEMACPS_RXRESERRCNT_OFFSET 0x000001A0U /**< Receive Resource Error
266 #define XEMACPS_RXORCNT_OFFSET 0x000001A4U /**< Receive Overrun Counter */
267 #define XEMACPS_RXIPCCNT_OFFSET 0x000001A8U /**< IP header Checksum Error
269 #define XEMACPS_RXTCPCCNT_OFFSET 0x000001ACU /**< TCP Checksum Error
271 #define XEMACPS_RXUDPCCNT_OFFSET 0x000001B0U /**< UDP Checksum Error
273 #define XEMACPS_LAST_OFFSET 0x000001B4U /**< Last statistic counter
274 offset, for clearing */
276 #define XEMACPS_1588_SEC_OFFSET 0x000001D0U /**< 1588 second counter */
277 #define XEMACPS_1588_NANOSEC_OFFSET 0x000001D4U /**< 1588 nanosecond counter */
278 #define XEMACPS_1588_ADJ_OFFSET 0x000001D8U /**< 1588 nanosecond
279 adjustment counter */
280 #define XEMACPS_1588_INC_OFFSET 0x000001DCU /**< 1588 nanosecond
282 #define XEMACPS_PTP_TXSEC_OFFSET 0x000001E0U /**< 1588 PTP transmit second
284 #define XEMACPS_PTP_TXNANOSEC_OFFSET 0x000001E4U /**< 1588 PTP transmit
285 nanosecond counter */
286 #define XEMACPS_PTP_RXSEC_OFFSET 0x000001E8U /**< 1588 PTP receive second
288 #define XEMACPS_PTP_RXNANOSEC_OFFSET 0x000001ECU /**< 1588 PTP receive
289 nanosecond counter */
290 #define XEMACPS_PTPP_TXSEC_OFFSET 0x000001F0U /**< 1588 PTP peer transmit
292 #define XEMACPS_PTPP_TXNANOSEC_OFFSET 0x000001F4U /**< 1588 PTP peer transmit
293 nanosecond counter */
294 #define XEMACPS_PTPP_RXSEC_OFFSET 0x000001F8U /**< 1588 PTP peer receive
296 #define XEMACPS_PTPP_RXNANOSEC_OFFSET 0x000001FCU /**< 1588 PTP peer receive
297 nanosecond counter */
299 #define XEMACPS_INTQ1_STS_OFFSET 0x00000400U /**< Interrupt Q1 Status
301 #define XEMACPS_TXQ1BASE_OFFSET 0x00000440U /**< TX Q1 Base address
303 #define XEMACPS_RXQ1BASE_OFFSET 0x00000480U /**< RX Q1 Base address
305 #define XEMACPS_MSBBUF_TXQBASE_OFFSET 0x000004C8U /**< MSB Buffer TX Q Base
307 #define XEMACPS_MSBBUF_RXQBASE_OFFSET 0x000004D4U /**< MSB Buffer RX Q Base
309 #define XEMACPS_INTQ1_IER_OFFSET 0x00000600U /**< Interrupt Q1 Enable
311 #define XEMACPS_INTQ1_IDR_OFFSET 0x00000620U /**< Interrupt Q1 Disable
313 #define XEMACPS_INTQ1_IMR_OFFSET 0x00000640U /**< Interrupt Q1 Mask
316 /* Define some bit positions for registers. */
318 /** @name network control register bit definitions
321 #define XEMACPS_NWCTRL_FLUSH_DPRAM_MASK 0x00040000U /**< Flush a packet from
323 #define XEMACPS_NWCTRL_ZEROPAUSETX_MASK 0x00000800U /**< Transmit zero quantum
325 #define XEMACPS_NWCTRL_PAUSETX_MASK 0x00000800U /**< Transmit pause frame */
326 #define XEMACPS_NWCTRL_HALTTX_MASK 0x00000400U /**< Halt transmission
327 after current frame */
328 #define XEMACPS_NWCTRL_STARTTX_MASK 0x00000200U /**< Start tx (tx_go) */
330 #define XEMACPS_NWCTRL_STATWEN_MASK 0x00000080U /**< Enable writing to
332 #define XEMACPS_NWCTRL_STATINC_MASK 0x00000040U /**< Increment statistic
334 #define XEMACPS_NWCTRL_STATCLR_MASK 0x00000020U /**< Clear statistic
336 #define XEMACPS_NWCTRL_MDEN_MASK 0x00000010U /**< Enable MDIO port */
337 #define XEMACPS_NWCTRL_TXEN_MASK 0x00000008U /**< Enable transmit */
338 #define XEMACPS_NWCTRL_RXEN_MASK 0x00000004U /**< Enable receive */
339 #define XEMACPS_NWCTRL_LOOPEN_MASK 0x00000002U /**< local loopback */
342 /** @name network configuration register bit definitions
345 #define XEMACPS_NWCFG_BADPREAMBEN_MASK 0x20000000U /**< disable rejection of
346 non-standard preamble */
347 #define XEMACPS_NWCFG_IPDSTRETCH_MASK 0x10000000U /**< enable transmit IPG */
348 #define XEMACPS_NWCFG_SGMIIEN_MASK 0x08000000U /**< SGMII Enable */
349 #define XEMACPS_NWCFG_FCSIGNORE_MASK 0x04000000U /**< disable rejection of
351 #define XEMACPS_NWCFG_HDRXEN_MASK 0x02000000U /**< RX half duplex */
352 #define XEMACPS_NWCFG_RXCHKSUMEN_MASK 0x01000000U /**< enable RX checksum
354 #define XEMACPS_NWCFG_PAUSECOPYDI_MASK 0x00800000U /**< Do not copy pause
356 #define XEMACPS_NWCFG_DWIDTH_64_MASK 0x00200000U /**< 64 bit Data bus width */
357 #define XEMACPS_NWCFG_MDC_SHIFT_MASK 18U /**< shift bits for MDC */
358 #define XEMACPS_NWCFG_MDCCLKDIV_MASK 0x001C0000U /**< MDC Mask PCLK divisor */
359 #define XEMACPS_NWCFG_FCSREM_MASK 0x00020000U /**< Discard FCS from
361 #define XEMACPS_NWCFG_LENERRDSCRD_MASK 0x00010000U
362 /**< RX length error discard */
363 #define XEMACPS_NWCFG_RXOFFS_MASK 0x0000C000U /**< RX buffer offset */
364 #define XEMACPS_NWCFG_PAUSEEN_MASK 0x00002000U /**< Enable pause RX */
365 #define XEMACPS_NWCFG_RETRYTESTEN_MASK 0x00001000U /**< Retry test */
366 #define XEMACPS_NWCFG_XTADDMACHEN_MASK 0x00000200U
367 /**< External address match enable */
368 #define XEMACPS_NWCFG_PCSSEL_MASK 0x00000800U /**< PCS Select */
369 #define XEMACPS_NWCFG_1000_MASK 0x00000400U /**< 1000 Mbps */
370 #define XEMACPS_NWCFG_1536RXEN_MASK 0x00000100U /**< Enable 1536 byte
372 #define XEMACPS_NWCFG_UCASTHASHEN_MASK 0x00000080U /**< Receive unicast hash
374 #define XEMACPS_NWCFG_MCASTHASHEN_MASK 0x00000040U /**< Receive multicast hash
376 #define XEMACPS_NWCFG_BCASTDI_MASK 0x00000020U /**< Do not receive
378 #define XEMACPS_NWCFG_COPYALLEN_MASK 0x00000010U /**< Copy all frames */
379 #define XEMACPS_NWCFG_JUMBO_MASK 0x00000008U /**< Jumbo frames */
380 #define XEMACPS_NWCFG_NVLANDISC_MASK 0x00000004U /**< Receive only VLAN
382 #define XEMACPS_NWCFG_FDEN_MASK 0x00000002U/**< full duplex */
383 #define XEMACPS_NWCFG_100_MASK 0x00000001U /**< 100 Mbps */
384 #define XEMACPS_NWCFG_RESET_MASK 0x00080000U/**< reset value */
387 /** @name network status register bit definitaions
390 #define XEMACPS_NWSR_MDIOIDLE_MASK 0x00000004U /**< PHY management idle */
391 #define XEMACPS_NWSR_MDIO_MASK 0x00000002U /**< Status of mdio_in */
395 /** @name MAC address register word 1 mask
398 #define XEMACPS_LADDR_MACH_MASK 0x0000FFFFU /**< Address bits[47:32]
399 bit[31:0] are in BOTTOM */
403 /** @name DMA control register bit definitions
406 #define XEMACPS_DMACR_ADDR_WIDTH_64 0x40000000U /**< 64 bit address bus */
407 #define XEMACPS_DMACR_TXEXTEND_MASK 0x20000000U /**< Tx Extended desc mode */
408 #define XEMACPS_DMACR_RXEXTEND_MASK 0x10000000U /**< Rx Extended desc mode */
409 #define XEMACPS_DMACR_RXBUF_MASK 0x00FF0000U /**< Mask bit for RX buffer
411 #define XEMACPS_DMACR_RXBUF_SHIFT 16U /**< Shift bit for RX buffer
413 #define XEMACPS_DMACR_TCPCKSUM_MASK 0x00000800U /**< enable/disable TX
415 #define XEMACPS_DMACR_TXSIZE_MASK 0x00000400U /**< TX buffer memory size */
416 #define XEMACPS_DMACR_RXSIZE_MASK 0x00000300U /**< RX buffer memory size */
417 #define XEMACPS_DMACR_ENDIAN_MASK 0x00000080U /**< endian configuration */
418 #define XEMACPS_DMACR_BLENGTH_MASK 0x0000001FU /**< buffer burst length */
419 #define XEMACPS_DMACR_SINGLE_AHB_BURST 0x00000001U /**< single AHB bursts */
420 #define XEMACPS_DMACR_INCR4_AHB_BURST 0x00000004U /**< 4 bytes AHB bursts */
421 #define XEMACPS_DMACR_INCR8_AHB_BURST 0x00000008U /**< 8 bytes AHB bursts */
422 #define XEMACPS_DMACR_INCR16_AHB_BURST 0x00000010U /**< 16 bytes AHB bursts */
425 /** @name transmit status register bit definitions
428 #define XEMACPS_TXSR_HRESPNOK_MASK 0x00000100U /**< Transmit hresp not OK */
429 #define XEMACPS_TXSR_URUN_MASK 0x00000040U /**< Transmit underrun */
430 #define XEMACPS_TXSR_TXCOMPL_MASK 0x00000020U /**< Transmit completed OK */
431 #define XEMACPS_TXSR_BUFEXH_MASK 0x00000010U /**< Transmit buffs exhausted
433 #define XEMACPS_TXSR_TXGO_MASK 0x00000008U /**< Status of go flag */
434 #define XEMACPS_TXSR_RXOVR_MASK 0x00000004U /**< Retry limit exceeded */
435 #define XEMACPS_TXSR_FRAMERX_MASK 0x00000002U /**< Collision tx frame */
436 #define XEMACPS_TXSR_USEDREAD_MASK 0x00000001U /**< TX buffer used bit set */
438 #define XEMACPS_TXSR_ERROR_MASK ((u32)XEMACPS_TXSR_HRESPNOK_MASK | \
439 (u32)XEMACPS_TXSR_URUN_MASK | \
440 (u32)XEMACPS_TXSR_BUFEXH_MASK | \
441 (u32)XEMACPS_TXSR_RXOVR_MASK | \
442 (u32)XEMACPS_TXSR_FRAMERX_MASK | \
443 (u32)XEMACPS_TXSR_USEDREAD_MASK)
447 * @name receive status register bit definitions
450 #define XEMACPS_RXSR_HRESPNOK_MASK 0x00000008U /**< Receive hresp not OK */
451 #define XEMACPS_RXSR_RXOVR_MASK 0x00000004U /**< Receive overrun */
452 #define XEMACPS_RXSR_FRAMERX_MASK 0x00000002U /**< Frame received OK */
453 #define XEMACPS_RXSR_BUFFNA_MASK 0x00000001U /**< RX buffer used bit set */
455 #define XEMACPS_RXSR_ERROR_MASK ((u32)XEMACPS_RXSR_HRESPNOK_MASK | \
456 (u32)XEMACPS_RXSR_RXOVR_MASK | \
457 (u32)XEMACPS_RXSR_BUFFNA_MASK)
461 * @name Interrupt Q1 status register bit definitions
464 #define XEMACPS_INTQ1SR_TXCOMPL_MASK 0x00000080U /**< Transmit completed OK */
465 #define XEMACPS_INTQ1SR_TXERR_MASK 0x00000040U /**< Transmit AMBA Error */
467 #define XEMACPS_INTQ1_IXR_ALL_MASK ((u32)XEMACPS_INTQ1SR_TXCOMPL_MASK | \
468 (u32)XEMACPS_INTQ1SR_TXERR_MASK)
473 * @name interrupts bit definitions
474 * Bits definitions are same in XEMACPS_ISR_OFFSET,
475 * XEMACPS_IER_OFFSET, XEMACPS_IDR_OFFSET, and XEMACPS_IMR_OFFSET
478 #define XEMACPS_IXR_PTPPSTX_MASK 0x02000000U /**< PTP Psync transmitted */
479 #define XEMACPS_IXR_PTPPDRTX_MASK 0x01000000U /**< PTP Pdelay_req
481 #define XEMACPS_IXR_PTPSTX_MASK 0x00800000U /**< PTP Sync transmitted */
482 #define XEMACPS_IXR_PTPDRTX_MASK 0x00400000U /**< PTP Delay_req transmitted
484 #define XEMACPS_IXR_PTPPSRX_MASK 0x00200000U /**< PTP Psync received */
485 #define XEMACPS_IXR_PTPPDRRX_MASK 0x00100000U /**< PTP Pdelay_req received */
486 #define XEMACPS_IXR_PTPSRX_MASK 0x00080000U /**< PTP Sync received */
487 #define XEMACPS_IXR_PTPDRRX_MASK 0x00040000U /**< PTP Delay_req received */
488 #define XEMACPS_IXR_PAUSETX_MASK 0x00004000U /**< Pause frame transmitted */
489 #define XEMACPS_IXR_PAUSEZERO_MASK 0x00002000U /**< Pause time has reached
491 #define XEMACPS_IXR_PAUSENZERO_MASK 0x00001000U /**< Pause frame received */
492 #define XEMACPS_IXR_HRESPNOK_MASK 0x00000800U /**< hresp not ok */
493 #define XEMACPS_IXR_RXOVR_MASK 0x00000400U /**< Receive overrun occurred */
494 #define XEMACPS_IXR_TXCOMPL_MASK 0x00000080U /**< Frame transmitted ok */
495 #define XEMACPS_IXR_TXEXH_MASK 0x00000040U /**< Transmit err occurred or
497 #define XEMACPS_IXR_RETRY_MASK 0x00000020U /**< Retry limit exceeded */
498 #define XEMACPS_IXR_URUN_MASK 0x00000010U /**< Transmit underrun */
499 #define XEMACPS_IXR_TXUSED_MASK 0x00000008U /**< Tx buffer used bit read */
500 #define XEMACPS_IXR_RXUSED_MASK 0x00000004U /**< Rx buffer used bit read */
501 #define XEMACPS_IXR_FRAMERX_MASK 0x00000002U /**< Frame received ok */
502 #define XEMACPS_IXR_MGMNT_MASK 0x00000001U /**< PHY management complete */
503 #define XEMACPS_IXR_ALL_MASK 0x00007FFFU /**< Everything! */
505 #define XEMACPS_IXR_TX_ERR_MASK ((u32)XEMACPS_IXR_TXEXH_MASK | \
506 (u32)XEMACPS_IXR_RETRY_MASK | \
507 (u32)XEMACPS_IXR_URUN_MASK)
510 #define XEMACPS_IXR_RX_ERR_MASK ((u32)XEMACPS_IXR_HRESPNOK_MASK | \
511 (u32)XEMACPS_IXR_RXUSED_MASK | \
512 (u32)XEMACPS_IXR_RXOVR_MASK)
516 /** @name PHY Maintenance bit definitions
519 #define XEMACPS_PHYMNTNC_OP_MASK 0x40020000U /**< operation mask bits */
520 #define XEMACPS_PHYMNTNC_OP_R_MASK 0x20000000U /**< read operation */
521 #define XEMACPS_PHYMNTNC_OP_W_MASK 0x10000000U /**< write operation */
522 #define XEMACPS_PHYMNTNC_ADDR_MASK 0x0F800000U /**< Address bits */
523 #define XEMACPS_PHYMNTNC_REG_MASK 0x007C0000U /**< register bits */
524 #define XEMACPS_PHYMNTNC_DATA_MASK 0x00000FFFU /**< data bits */
525 #define XEMACPS_PHYMNTNC_PHAD_SHFT_MSK 23U /**< Shift bits for PHYAD */
526 #define XEMACPS_PHYMNTNC_PREG_SHFT_MSK 18U /**< Shift bits for PHREG */
529 /* Transmit buffer descriptor status words offset
532 #define XEMACPS_BD_ADDR_OFFSET 0x00000000U /**< word 0/addr of BDs */
533 #define XEMACPS_BD_STAT_OFFSET 0x00000004U /**< word 1/status of BDs */
534 #define XEMACPS_BD_ADDR_HI_OFFSET 0x00000008U /**< word 2/addr of BDs */
540 /* Transmit buffer descriptor status words bit positions.
541 * Transmit buffer descriptor consists of two 32-bit registers,
542 * the first - word0 contains a 32-bit address pointing to the location of
544 * The following register - word1, consists of various information to control
545 * the XEmacPs transmit process. After transmit, this is updated with status
546 * information, whether the frame was transmitted OK or why it had failed.
549 #define XEMACPS_TXBUF_USED_MASK 0x80000000U /**< Used bit. */
550 #define XEMACPS_TXBUF_WRAP_MASK 0x40000000U /**< Wrap bit, last descriptor */
551 #define XEMACPS_TXBUF_RETRY_MASK 0x20000000U /**< Retry limit exceeded */
552 #define XEMACPS_TXBUF_URUN_MASK 0x10000000U /**< Transmit underrun occurred */
553 #define XEMACPS_TXBUF_EXH_MASK 0x08000000U /**< Buffers exhausted */
554 #define XEMACPS_TXBUF_TCP_MASK 0x04000000U /**< Late collision. */
555 #define XEMACPS_TXBUF_NOCRC_MASK 0x00010000U /**< No CRC */
556 #define XEMACPS_TXBUF_LAST_MASK 0x00008000U /**< Last buffer */
557 #define XEMACPS_TXBUF_LEN_MASK 0x00003FFFU /**< Mask for length field */
562 /* Receive buffer descriptor status words bit positions.
563 * Receive buffer descriptor consists of two 32-bit registers,
564 * the first - word0 contains a 32-bit word aligned address pointing to the
565 * address of the buffer. The lower two bits make up the wrap bit indicating
566 * the last descriptor and the ownership bit to indicate it has been used by
568 * The following register - word1, contains status information regarding why
569 * the frame was received (the filter match condition) as well as other
573 #define XEMACPS_RXBUF_BCAST_MASK 0x80000000U /**< Broadcast frame */
574 #define XEMACPS_RXBUF_MULTIHASH_MASK 0x40000000U /**< Multicast hashed frame */
575 #define XEMACPS_RXBUF_UNIHASH_MASK 0x20000000U /**< Unicast hashed frame */
576 #define XEMACPS_RXBUF_EXH_MASK 0x08000000U /**< buffer exhausted */
577 #define XEMACPS_RXBUF_AMATCH_MASK 0x06000000U /**< Specific address
579 #define XEMACPS_RXBUF_IDFOUND_MASK 0x01000000U /**< Type ID matched */
580 #define XEMACPS_RXBUF_IDMATCH_MASK 0x00C00000U /**< ID matched mask */
581 #define XEMACPS_RXBUF_VLAN_MASK 0x00200000U /**< VLAN tagged */
582 #define XEMACPS_RXBUF_PRI_MASK 0x00100000U /**< Priority tagged */
583 #define XEMACPS_RXBUF_VPRI_MASK 0x000E0000U /**< Vlan priority */
584 #define XEMACPS_RXBUF_CFI_MASK 0x00010000U /**< CFI frame */
585 #define XEMACPS_RXBUF_EOF_MASK 0x00008000U /**< End of frame. */
586 #define XEMACPS_RXBUF_SOF_MASK 0x00004000U /**< Start of frame. */
587 #define XEMACPS_RXBUF_LEN_MASK 0x00001FFFU /**< Mask for length field */
588 #define XEMACPS_RXBUF_LEN_JUMBO_MASK 0x00003FFFU /**< Mask for jumbo length */
590 #define XEMACPS_RXBUF_WRAP_MASK 0x00000002U /**< Wrap bit, last BD */
591 #define XEMACPS_RXBUF_NEW_MASK 0x00000001U /**< Used bit.. */
592 #define XEMACPS_RXBUF_ADD_MASK 0xFFFFFFFCU /**< Mask for address */
598 * Define appropriate I/O access method to memory mapped I/O or other
599 * interface if necessary.
602 #define XEmacPs_In32 Xil_In32
603 #define XEmacPs_Out32 Xil_Out32
606 /****************************************************************************/
609 * Read the given register.
611 * @param BaseAddress is the base address of the device
612 * @param RegOffset is the register offset to be read
614 * @return The 32-bit value of the register
618 * u32 XEmacPs_ReadReg(u32 BaseAddress, u32 RegOffset)
620 *****************************************************************************/
621 #define XEmacPs_ReadReg(BaseAddress, RegOffset) \
622 XEmacPs_In32((BaseAddress) + (u32)(RegOffset))
625 /****************************************************************************/
628 * Write the given register.
630 * @param BaseAddress is the base address of the device
631 * @param RegOffset is the register offset to be written
632 * @param Data is the 32-bit value to write to the register
638 * void XEmacPs_WriteReg(u32 BaseAddress, u32 RegOffset,
641 *****************************************************************************/
642 #define XEmacPs_WriteReg(BaseAddress, RegOffset, Data) \
643 XEmacPs_Out32((BaseAddress) + (u32)(RegOffset), (u32)(Data))
645 /************************** Function Prototypes *****************************/
647 * Perform reset operation to the emacps interface
649 void XEmacPs_ResetHw(u32 BaseAddr);
655 #endif /* end of protection macro */