1 /******************************************************************************
3 * Copyright (C) 2010 - 2015 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 /*****************************************************************************/
37 * This header file contains identifiers and low-level driver functions (or
38 * macros) that can be used to access the PS Ethernet MAC (XEmacPs) device.
39 * High-level driver functions are defined in xemacps.h.
44 * MODIFICATION HISTORY:
46 * Ver Who Date Changes
47 * ----- ---- -------- -------------------------------------------------------
48 * 1.00a wsy 01/10/10 First release.
49 * 1.02a asa 11/05/12 Added hash defines for DMACR burst length configuration.
50 * 1.05a kpc 28/06/13 Added XEmacPs_ResetHw function prototype
51 * 1.06a asa 11/02/13 Changed the value for XEMACPS_RXBUF_LEN_MASK from 0x3fff
52 * to 0x1fff. This fixes the CR#744902.
53 * 2.1 srt 07/15/14 Add support for Zynq Ultrascale Mp GEM specification.
54 * 3.0 kvn 12/16/14 Changed name of XEMACPS_NWCFG_LENGTHERRDSCRD_MASK to
55 * XEMACPS_NWCFG_LENERRDSCRD_MASK as it exceeds 31 characters.
56 * 3.0 kpc 1/23/15 Corrected the extended descriptor macro values.
57 * 3.0 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
58 * 3.0 hk 03/18/15 Added support for jumbo frames.
59 * Remove "used bit set" from TX error interrupt masks.
62 ******************************************************************************/
64 #ifndef XEMACPS_HW_H /* prevent circular inclusions */
65 #define XEMACPS_HW_H /* by using protection macros */
67 /***************************** Include Files *********************************/
69 #include "xil_types.h"
70 #include "xil_assert.h"
77 /************************** Constant Definitions *****************************/
79 #define XEMACPS_MAX_MAC_ADDR 4U /**< Maxmum number of mac address
81 #define XEMACPS_MAX_TYPE_ID 4U /**< Maxmum number of type id supported */
84 #define XEMACPS_BD_ALIGNMENT 64U /**< Minimum buffer descriptor alignment
88 #define XEMACPS_BD_ALIGNMENT 4U /**< Minimum buffer descriptor alignment
91 #define XEMACPS_RX_BUF_ALIGNMENT 4U /**< Minimum buffer alignment when using
92 options that impose alignment
93 restrictions on the buffer data on
96 /** @name Direction identifiers
98 * These are used by several functions and callbacks that need
99 * to specify whether an operation specifies a send or receive channel.
102 #define XEMACPS_SEND 1U /**< send direction */
103 #define XEMACPS_RECV 2U /**< receive direction */
106 /** @name MDC clock division
107 * currently supporting 8, 16, 32, 48, 64, 96, 128, 224.
110 typedef enum { MDC_DIV_8 = 0U, MDC_DIV_16, MDC_DIV_32, MDC_DIV_48,
111 MDC_DIV_64, MDC_DIV_96, MDC_DIV_128, MDC_DIV_224
116 #define XEMACPS_RX_BUF_SIZE 1536U /**< Specify the receive buffer size in
117 bytes, 64, 128, ... 10240 */
118 #define XEMACPS_RX_BUF_SIZE_JUMBO 10240U
120 #define XEMACPS_RX_BUF_UNIT 64U /**< Number of receive buffer bytes as a
121 unit, this is HW setup */
123 #define XEMACPS_MAX_RXBD 128U /**< Size of RX buffer descriptor queues */
124 #define XEMACPS_MAX_TXBD 128U /**< Size of TX buffer descriptor queues */
126 #define XEMACPS_MAX_HASH_BITS 64U /**< Maximum value for hash bits. 2**6 */
128 /* Register offset definitions. Unless otherwise noted, register access is
129 * 32 bit. Names are self explained here.
132 #define XEMACPS_NWCTRL_OFFSET 0x00000000U /**< Network Control reg */
133 #define XEMACPS_NWCFG_OFFSET 0x00000004U /**< Network Config reg */
134 #define XEMACPS_NWSR_OFFSET 0x00000008U /**< Network Status reg */
136 #define XEMACPS_DMACR_OFFSET 0x00000010U /**< DMA Control reg */
137 #define XEMACPS_TXSR_OFFSET 0x00000014U /**< TX Status reg */
138 #define XEMACPS_RXQBASE_OFFSET 0x00000018U /**< RX Q Base address reg */
139 #define XEMACPS_TXQBASE_OFFSET 0x0000001CU /**< TX Q Base address reg */
140 #define XEMACPS_RXSR_OFFSET 0x00000020U /**< RX Status reg */
142 #define XEMACPS_ISR_OFFSET 0x00000024U /**< Interrupt Status reg */
143 #define XEMACPS_IER_OFFSET 0x00000028U /**< Interrupt Enable reg */
144 #define XEMACPS_IDR_OFFSET 0x0000002CU /**< Interrupt Disable reg */
145 #define XEMACPS_IMR_OFFSET 0x00000030U /**< Interrupt Mask reg */
147 #define XEMACPS_PHYMNTNC_OFFSET 0x00000034U /**< Phy Maintaince reg */
148 #define XEMACPS_RXPAUSE_OFFSET 0x00000038U /**< RX Pause Time reg */
149 #define XEMACPS_TXPAUSE_OFFSET 0x0000003CU /**< TX Pause Time reg */
151 #define XEMACPS_JUMBOMAXLEN_OFFSET 0x00000048U /**< Jumbo max length reg */
153 #define XEMACPS_HASHL_OFFSET 0x00000080U /**< Hash Low address reg */
154 #define XEMACPS_HASHH_OFFSET 0x00000084U /**< Hash High address reg */
156 #define XEMACPS_LADDR1L_OFFSET 0x00000088U /**< Specific1 addr low reg */
157 #define XEMACPS_LADDR1H_OFFSET 0x0000008CU /**< Specific1 addr high reg */
158 #define XEMACPS_LADDR2L_OFFSET 0x00000090U /**< Specific2 addr low reg */
159 #define XEMACPS_LADDR2H_OFFSET 0x00000094U /**< Specific2 addr high reg */
160 #define XEMACPS_LADDR3L_OFFSET 0x00000098U /**< Specific3 addr low reg */
161 #define XEMACPS_LADDR3H_OFFSET 0x0000009CU /**< Specific3 addr high reg */
162 #define XEMACPS_LADDR4L_OFFSET 0x000000A0U /**< Specific4 addr low reg */
163 #define XEMACPS_LADDR4H_OFFSET 0x000000A4U /**< Specific4 addr high reg */
165 #define XEMACPS_MATCH1_OFFSET 0x000000A8U /**< Type ID1 Match reg */
166 #define XEMACPS_MATCH2_OFFSET 0x000000ACU /**< Type ID2 Match reg */
167 #define XEMACPS_MATCH3_OFFSET 0x000000B0U /**< Type ID3 Match reg */
168 #define XEMACPS_MATCH4_OFFSET 0x000000B4U /**< Type ID4 Match reg */
170 #define XEMACPS_STRETCH_OFFSET 0x000000BCU /**< IPG Stretch reg */
172 #define XEMACPS_OCTTXL_OFFSET 0x00000100U /**< Octects transmitted Low
174 #define XEMACPS_OCTTXH_OFFSET 0x00000104U /**< Octects transmitted High
177 #define XEMACPS_TXCNT_OFFSET 0x00000108U /**< Error-free Frmaes
178 transmitted counter */
179 #define XEMACPS_TXBCCNT_OFFSET 0x0000010CU /**< Error-free Broadcast
181 #define XEMACPS_TXMCCNT_OFFSET 0x00000110U /**< Error-free Multicast
183 #define XEMACPS_TXPAUSECNT_OFFSET 0x00000114U /**< Pause Frames Transmitted
185 #define XEMACPS_TX64CNT_OFFSET 0x00000118U /**< Error-free 64 byte Frames
186 Transmitted counter */
187 #define XEMACPS_TX65CNT_OFFSET 0x0000011CU /**< Error-free 65-127 byte
190 #define XEMACPS_TX128CNT_OFFSET 0x00000120U /**< Error-free 128-255 byte
193 #define XEMACPS_TX256CNT_OFFSET 0x00000124U /**< Error-free 256-511 byte
196 #define XEMACPS_TX512CNT_OFFSET 0x00000128U /**< Error-free 512-1023 byte
199 #define XEMACPS_TX1024CNT_OFFSET 0x0000012CU /**< Error-free 1024-1518 byte
202 #define XEMACPS_TX1519CNT_OFFSET 0x00000130U /**< Error-free larger than
204 transmitted counter */
205 #define XEMACPS_TXURUNCNT_OFFSET 0x00000134U /**< TX under run error
208 #define XEMACPS_SNGLCOLLCNT_OFFSET 0x00000138U /**< Single Collision Frame
210 #define XEMACPS_MULTICOLLCNT_OFFSET 0x0000013CU /**< Multiple Collision Frame
212 #define XEMACPS_EXCESSCOLLCNT_OFFSET 0x00000140U /**< Excessive Collision Frame
214 #define XEMACPS_LATECOLLCNT_OFFSET 0x00000144U /**< Late Collision Frame
216 #define XEMACPS_TXDEFERCNT_OFFSET 0x00000148U /**< Deferred Transmission
218 #define XEMACPS_TXCSENSECNT_OFFSET 0x0000014CU /**< Transmit Carrier Sense
221 #define XEMACPS_OCTRXL_OFFSET 0x00000150U /**< Octects Received register
223 #define XEMACPS_OCTRXH_OFFSET 0x00000154U /**< Octects Received register
226 #define XEMACPS_RXCNT_OFFSET 0x00000158U /**< Error-free Frames
228 #define XEMACPS_RXBROADCNT_OFFSET 0x0000015CU /**< Error-free Broadcast
229 Frames Received Counter */
230 #define XEMACPS_RXMULTICNT_OFFSET 0x00000160U /**< Error-free Multicast
231 Frames Received Counter */
232 #define XEMACPS_RXPAUSECNT_OFFSET 0x00000164U /**< Pause Frames
234 #define XEMACPS_RX64CNT_OFFSET 0x00000168U /**< Error-free 64 byte Frames
236 #define XEMACPS_RX65CNT_OFFSET 0x0000016CU /**< Error-free 65-127 byte
237 Frames Received Counter */
238 #define XEMACPS_RX128CNT_OFFSET 0x00000170U /**< Error-free 128-255 byte
239 Frames Received Counter */
240 #define XEMACPS_RX256CNT_OFFSET 0x00000174U /**< Error-free 256-512 byte
241 Frames Received Counter */
242 #define XEMACPS_RX512CNT_OFFSET 0x00000178U /**< Error-free 512-1023 byte
243 Frames Received Counter */
244 #define XEMACPS_RX1024CNT_OFFSET 0x0000017CU /**< Error-free 1024-1518 byte
245 Frames Received Counter */
246 #define XEMACPS_RX1519CNT_OFFSET 0x00000180U /**< Error-free 1519-max byte
247 Frames Received Counter */
248 #define XEMACPS_RXUNDRCNT_OFFSET 0x00000184U /**< Undersize Frames Received
250 #define XEMACPS_RXOVRCNT_OFFSET 0x00000188U /**< Oversize Frames Received
252 #define XEMACPS_RXJABCNT_OFFSET 0x0000018CU /**< Jabbers Received
254 #define XEMACPS_RXFCSCNT_OFFSET 0x00000190U /**< Frame Check Sequence
256 #define XEMACPS_RXLENGTHCNT_OFFSET 0x00000194U /**< Length Field Error
258 #define XEMACPS_RXSYMBCNT_OFFSET 0x00000198U /**< Symbol Error Counter */
259 #define XEMACPS_RXALIGNCNT_OFFSET 0x0000019CU /**< Alignment Error Counter */
260 #define XEMACPS_RXRESERRCNT_OFFSET 0x000001A0U /**< Receive Resource Error
262 #define XEMACPS_RXORCNT_OFFSET 0x000001A4U /**< Receive Overrun Counter */
263 #define XEMACPS_RXIPCCNT_OFFSET 0x000001A8U /**< IP header Checksum Error
265 #define XEMACPS_RXTCPCCNT_OFFSET 0x000001ACU /**< TCP Checksum Error
267 #define XEMACPS_RXUDPCCNT_OFFSET 0x000001B0U /**< UDP Checksum Error
269 #define XEMACPS_LAST_OFFSET 0x000001B4U /**< Last statistic counter
270 offset, for clearing */
272 #define XEMACPS_1588_SEC_OFFSET 0x000001D0U /**< 1588 second counter */
273 #define XEMACPS_1588_NANOSEC_OFFSET 0x000001D4U /**< 1588 nanosecond counter */
274 #define XEMACPS_1588_ADJ_OFFSET 0x000001D8U /**< 1588 nanosecond
275 adjustment counter */
276 #define XEMACPS_1588_INC_OFFSET 0x000001DCU /**< 1588 nanosecond
278 #define XEMACPS_PTP_TXSEC_OFFSET 0x000001E0U /**< 1588 PTP transmit second
280 #define XEMACPS_PTP_TXNANOSEC_OFFSET 0x000001E4U /**< 1588 PTP transmit
281 nanosecond counter */
282 #define XEMACPS_PTP_RXSEC_OFFSET 0x000001E8U /**< 1588 PTP receive second
284 #define XEMACPS_PTP_RXNANOSEC_OFFSET 0x000001ECU /**< 1588 PTP receive
285 nanosecond counter */
286 #define XEMACPS_PTPP_TXSEC_OFFSET 0x000001F0U /**< 1588 PTP peer transmit
288 #define XEMACPS_PTPP_TXNANOSEC_OFFSET 0x000001F4U /**< 1588 PTP peer transmit
289 nanosecond counter */
290 #define XEMACPS_PTPP_RXSEC_OFFSET 0x000001F8U /**< 1588 PTP peer receive
292 #define XEMACPS_PTPP_RXNANOSEC_OFFSET 0x000001FCU /**< 1588 PTP peer receive
293 nanosecond counter */
295 #define XEMACPS_INTQ1_STS_OFFSET 0x00000400U /**< Interrupt Q1 Status
297 #define XEMACPS_TXQ1BASE_OFFSET 0x00000440U /**< TX Q1 Base address
299 #define XEMACPS_RXQ1BASE_OFFSET 0x00000480U /**< RX Q1 Base address
301 #define XEMACPS_MSBBUF_QBASE_OFFSET 0x000004C8U /**< MSB Buffer Q Base
303 #define XEMACPS_INTQ1_IER_OFFSET 0x00000600U /**< Interrupt Q1 Enable
305 #define XEMACPS_INTQ1_IDR_OFFSET 0x00000620U /**< Interrupt Q1 Disable
307 #define XEMACPS_INTQ1_IMR_OFFSET 0x00000640U /**< Interrupt Q1 Mask
310 /* Define some bit positions for registers. */
312 /** @name network control register bit definitions
315 #define XEMACPS_NWCTRL_FLUSH_DPRAM_MASK 0x00040000U /**< Flush a packet from
317 #define XEMACPS_NWCTRL_ZEROPAUSETX_MASK 0x00000800U /**< Transmit zero quantum
319 #define XEMACPS_NWCTRL_PAUSETX_MASK 0x00000800U /**< Transmit pause frame */
320 #define XEMACPS_NWCTRL_HALTTX_MASK 0x00000400U /**< Halt transmission
321 after current frame */
322 #define XEMACPS_NWCTRL_STARTTX_MASK 0x00000200U /**< Start tx (tx_go) */
324 #define XEMACPS_NWCTRL_STATWEN_MASK 0x00000080U /**< Enable writing to
326 #define XEMACPS_NWCTRL_STATINC_MASK 0x00000040U /**< Increment statistic
328 #define XEMACPS_NWCTRL_STATCLR_MASK 0x00000020U /**< Clear statistic
330 #define XEMACPS_NWCTRL_MDEN_MASK 0x00000010U /**< Enable MDIO port */
331 #define XEMACPS_NWCTRL_TXEN_MASK 0x00000008U /**< Enable transmit */
332 #define XEMACPS_NWCTRL_RXEN_MASK 0x00000004U /**< Enable receive */
333 #define XEMACPS_NWCTRL_LOOPEN_MASK 0x00000002U /**< local loopback */
336 /** @name network configuration register bit definitions
339 #define XEMACPS_NWCFG_BADPREAMBEN_MASK 0x20000000U /**< disable rejection of
340 non-standard preamble */
341 #define XEMACPS_NWCFG_IPDSTRETCH_MASK 0x10000000U /**< enable transmit IPG */
342 #define XEMACPS_NWCFG_FCSIGNORE_MASK 0x04000000U /**< disable rejection of
344 #define XEMACPS_NWCFG_HDRXEN_MASK 0x02000000U /**< RX half duplex */
345 #define XEMACPS_NWCFG_RXCHKSUMEN_MASK 0x01000000U /**< enable RX checksum
347 #define XEMACPS_NWCFG_PAUSECOPYDI_MASK 0x00800000U /**< Do not copy pause
349 #define XEMACPS_NWCFG_DWIDTH_64_MASK 0x00200000U /**< 64 bit Data bus width */
350 #define XEMACPS_NWCFG_MDC_SHIFT_MASK 18U /**< shift bits for MDC */
351 #define XEMACPS_NWCFG_MDCCLKDIV_MASK 0x001C0000U /**< MDC Mask PCLK divisor */
352 #define XEMACPS_NWCFG_FCSREM_MASK 0x00020000U /**< Discard FCS from
354 #define XEMACPS_NWCFG_LENERRDSCRD_MASK 0x00010000U
355 /**< RX length error discard */
356 #define XEMACPS_NWCFG_RXOFFS_MASK 0x0000C000U /**< RX buffer offset */
357 #define XEMACPS_NWCFG_PAUSEEN_MASK 0x00002000U /**< Enable pause RX */
358 #define XEMACPS_NWCFG_RETRYTESTEN_MASK 0x00001000U /**< Retry test */
359 #define XEMACPS_NWCFG_XTADDMACHEN_MASK 0x00000200U
360 /**< External address match enable */
361 #define XEMACPS_NWCFG_1000_MASK 0x00000400U /**< 1000 Mbps */
362 #define XEMACPS_NWCFG_1536RXEN_MASK 0x00000100U /**< Enable 1536 byte
364 #define XEMACPS_NWCFG_UCASTHASHEN_MASK 0x00000080U /**< Receive unicast hash
366 #define XEMACPS_NWCFG_MCASTHASHEN_MASK 0x00000040U /**< Receive multicast hash
368 #define XEMACPS_NWCFG_BCASTDI_MASK 0x00000020U /**< Do not receive
370 #define XEMACPS_NWCFG_COPYALLEN_MASK 0x00000010U /**< Copy all frames */
371 #define XEMACPS_NWCFG_JUMBO_MASK 0x00000008U /**< Jumbo frames */
372 #define XEMACPS_NWCFG_NVLANDISC_MASK 0x00000004U /**< Receive only VLAN
374 #define XEMACPS_NWCFG_FDEN_MASK 0x00000002U/**< full duplex */
375 #define XEMACPS_NWCFG_100_MASK 0x00000001U /**< 100 Mbps */
376 #define XEMACPS_NWCFG_RESET_MASK 0x00080000U/**< reset value */
379 /** @name network status register bit definitaions
382 #define XEMACPS_NWSR_MDIOIDLE_MASK 0x00000004U /**< PHY management idle */
383 #define XEMACPS_NWSR_MDIO_MASK 0x00000002U /**< Status of mdio_in */
387 /** @name MAC address register word 1 mask
390 #define XEMACPS_LADDR_MACH_MASK 0x0000FFFFU /**< Address bits[47:32]
391 bit[31:0] are in BOTTOM */
395 /** @name DMA control register bit definitions
398 #define XEMACPS_DMACR_ADDR_WIDTH_64 0x40000000U /**< 64 bit address bus */
399 #define XEMACPS_DMACR_TXEXTEND_MASK 0x20000000U /**< Tx Extended desc mode */
400 #define XEMACPS_DMACR_RXEXTEND_MASK 0x10000000U /**< Rx Extended desc mode */
401 #define XEMACPS_DMACR_RXBUF_MASK 0x00FF0000U /**< Mask bit for RX buffer
403 #define XEMACPS_DMACR_RXBUF_SHIFT 16U /**< Shift bit for RX buffer
405 #define XEMACPS_DMACR_TCPCKSUM_MASK 0x00000800U /**< enable/disable TX
407 #define XEMACPS_DMACR_TXSIZE_MASK 0x00000400U /**< TX buffer memory size */
408 #define XEMACPS_DMACR_RXSIZE_MASK 0x00000300U /**< RX buffer memory size */
409 #define XEMACPS_DMACR_ENDIAN_MASK 0x00000080U /**< endian configuration */
410 #define XEMACPS_DMACR_BLENGTH_MASK 0x0000001FU /**< buffer burst length */
411 #define XEMACPS_DMACR_SINGLE_AHB_BURST 0x00000001U /**< single AHB bursts */
412 #define XEMACPS_DMACR_INCR4_AHB_BURST 0x00000004U /**< 4 bytes AHB bursts */
413 #define XEMACPS_DMACR_INCR8_AHB_BURST 0x00000008U /**< 8 bytes AHB bursts */
414 #define XEMACPS_DMACR_INCR16_AHB_BURST 0x00000010U /**< 16 bytes AHB bursts */
417 /** @name transmit status register bit definitions
420 #define XEMACPS_TXSR_HRESPNOK_MASK 0x00000100U /**< Transmit hresp not OK */
421 #define XEMACPS_TXSR_URUN_MASK 0x00000040U /**< Transmit underrun */
422 #define XEMACPS_TXSR_TXCOMPL_MASK 0x00000020U /**< Transmit completed OK */
423 #define XEMACPS_TXSR_BUFEXH_MASK 0x00000010U /**< Transmit buffs exhausted
425 #define XEMACPS_TXSR_TXGO_MASK 0x00000008U /**< Status of go flag */
426 #define XEMACPS_TXSR_RXOVR_MASK 0x00000004U /**< Retry limit exceeded */
427 #define XEMACPS_TXSR_FRAMERX_MASK 0x00000002U /**< Collision tx frame */
428 #define XEMACPS_TXSR_USEDREAD_MASK 0x00000001U /**< TX buffer used bit set */
430 #define XEMACPS_TXSR_ERROR_MASK ((u32)XEMACPS_TXSR_HRESPNOK_MASK | \
431 (u32)XEMACPS_TXSR_URUN_MASK | \
432 (u32)XEMACPS_TXSR_BUFEXH_MASK | \
433 (u32)XEMACPS_TXSR_RXOVR_MASK | \
434 (u32)XEMACPS_TXSR_FRAMERX_MASK | \
435 (u32)XEMACPS_TXSR_USEDREAD_MASK)
439 * @name receive status register bit definitions
442 #define XEMACPS_RXSR_HRESPNOK_MASK 0x00000008U /**< Receive hresp not OK */
443 #define XEMACPS_RXSR_RXOVR_MASK 0x00000004U /**< Receive overrun */
444 #define XEMACPS_RXSR_FRAMERX_MASK 0x00000002U /**< Frame received OK */
445 #define XEMACPS_RXSR_BUFFNA_MASK 0x00000001U /**< RX buffer used bit set */
447 #define XEMACPS_RXSR_ERROR_MASK ((u32)XEMACPS_RXSR_HRESPNOK_MASK | \
448 (u32)XEMACPS_RXSR_RXOVR_MASK | \
449 (u32)XEMACPS_RXSR_BUFFNA_MASK)
453 * @name Interrupt Q1 status register bit definitions
456 #define XEMACPS_INTQ1SR_TXCOMPL_MASK 0x00000080U /**< Transmit completed OK */
457 #define XEMACPS_INTQ1SR_TXERR_MASK 0x00000040U /**< Transmit AMBA Error */
459 #define XEMACPS_INTQ1_IXR_ALL_MASK ((u32)XEMACPS_INTQ1SR_TXCOMPL_MASK | \
460 (u32)XEMACPS_INTQ1SR_TXERR_MASK)
465 * @name interrupts bit definitions
466 * Bits definitions are same in XEMACPS_ISR_OFFSET,
467 * XEMACPS_IER_OFFSET, XEMACPS_IDR_OFFSET, and XEMACPS_IMR_OFFSET
470 #define XEMACPS_IXR_PTPPSTX_MASK 0x02000000U /**< PTP Psync transmitted */
471 #define XEMACPS_IXR_PTPPDRTX_MASK 0x01000000U /**< PTP Pdelay_req
473 #define XEMACPS_IXR_PTPSTX_MASK 0x00800000U /**< PTP Sync transmitted */
474 #define XEMACPS_IXR_PTPDRTX_MASK 0x00400000U /**< PTP Delay_req transmitted
476 #define XEMACPS_IXR_PTPPSRX_MASK 0x00200000U /**< PTP Psync received */
477 #define XEMACPS_IXR_PTPPDRRX_MASK 0x00100000U /**< PTP Pdelay_req received */
478 #define XEMACPS_IXR_PTPSRX_MASK 0x00080000U /**< PTP Sync received */
479 #define XEMACPS_IXR_PTPDRRX_MASK 0x00040000U /**< PTP Delay_req received */
480 #define XEMACPS_IXR_PAUSETX_MASK 0x00004000U /**< Pause frame transmitted */
481 #define XEMACPS_IXR_PAUSEZERO_MASK 0x00002000U /**< Pause time has reached
483 #define XEMACPS_IXR_PAUSENZERO_MASK 0x00001000U /**< Pause frame received */
484 #define XEMACPS_IXR_HRESPNOK_MASK 0x00000800U /**< hresp not ok */
485 #define XEMACPS_IXR_RXOVR_MASK 0x00000400U /**< Receive overrun occurred */
486 #define XEMACPS_IXR_TXCOMPL_MASK 0x00000080U /**< Frame transmitted ok */
487 #define XEMACPS_IXR_TXEXH_MASK 0x00000040U /**< Transmit err occurred or
489 #define XEMACPS_IXR_RETRY_MASK 0x00000020U /**< Retry limit exceeded */
490 #define XEMACPS_IXR_URUN_MASK 0x00000010U /**< Transmit underrun */
491 #define XEMACPS_IXR_TXUSED_MASK 0x00000008U /**< Tx buffer used bit read */
492 #define XEMACPS_IXR_RXUSED_MASK 0x00000004U /**< Rx buffer used bit read */
493 #define XEMACPS_IXR_FRAMERX_MASK 0x00000002U /**< Frame received ok */
494 #define XEMACPS_IXR_MGMNT_MASK 0x00000001U /**< PHY management complete */
495 #define XEMACPS_IXR_ALL_MASK 0x00007FFFU /**< Everything! */
497 #define XEMACPS_IXR_TX_ERR_MASK ((u32)XEMACPS_IXR_TXEXH_MASK | \
498 (u32)XEMACPS_IXR_RETRY_MASK | \
499 (u32)XEMACPS_IXR_URUN_MASK)
502 #define XEMACPS_IXR_RX_ERR_MASK ((u32)XEMACPS_IXR_HRESPNOK_MASK | \
503 (u32)XEMACPS_IXR_RXUSED_MASK | \
504 (u32)XEMACPS_IXR_RXOVR_MASK)
508 /** @name PHY Maintenance bit definitions
511 #define XEMACPS_PHYMNTNC_OP_MASK 0x40020000U /**< operation mask bits */
512 #define XEMACPS_PHYMNTNC_OP_R_MASK 0x20000000U /**< read operation */
513 #define XEMACPS_PHYMNTNC_OP_W_MASK 0x10000000U /**< write operation */
514 #define XEMACPS_PHYMNTNC_ADDR_MASK 0x0F800000U /**< Address bits */
515 #define XEMACPS_PHYMNTNC_REG_MASK 0x007C0000U /**< register bits */
516 #define XEMACPS_PHYMNTNC_DATA_MASK 0x00000FFFU /**< data bits */
517 #define XEMACPS_PHYMNTNC_PHAD_SHFT_MSK 23U /**< Shift bits for PHYAD */
518 #define XEMACPS_PHYMNTNC_PREG_SHFT_MSK 18U /**< Shift bits for PHREG */
521 /* Transmit buffer descriptor status words offset
524 #define XEMACPS_BD_ADDR_OFFSET 0x00000000U /**< word 0/addr of BDs */
525 #define XEMACPS_BD_STAT_OFFSET 0x00000004U /**< word 1/status of BDs */
526 #define XEMACPS_BD_ADDR_HI_OFFSET 0x00000008U /**< word 2/addr of BDs */
532 /* Transmit buffer descriptor status words bit positions.
533 * Transmit buffer descriptor consists of two 32-bit registers,
534 * the first - word0 contains a 32-bit address pointing to the location of
536 * The following register - word1, consists of various information to control
537 * the XEmacPs transmit process. After transmit, this is updated with status
538 * information, whether the frame was transmitted OK or why it had failed.
541 #define XEMACPS_TXBUF_USED_MASK 0x80000000U /**< Used bit. */
542 #define XEMACPS_TXBUF_WRAP_MASK 0x40000000U /**< Wrap bit, last descriptor */
543 #define XEMACPS_TXBUF_RETRY_MASK 0x20000000U /**< Retry limit exceeded */
544 #define XEMACPS_TXBUF_URUN_MASK 0x10000000U /**< Transmit underrun occurred */
545 #define XEMACPS_TXBUF_EXH_MASK 0x08000000U /**< Buffers exhausted */
546 #define XEMACPS_TXBUF_TCP_MASK 0x04000000U /**< Late collision. */
547 #define XEMACPS_TXBUF_NOCRC_MASK 0x00010000U /**< No CRC */
548 #define XEMACPS_TXBUF_LAST_MASK 0x00008000U /**< Last buffer */
549 #define XEMACPS_TXBUF_LEN_MASK 0x00003FFFU /**< Mask for length field */
554 /* Receive buffer descriptor status words bit positions.
555 * Receive buffer descriptor consists of two 32-bit registers,
556 * the first - word0 contains a 32-bit word aligned address pointing to the
557 * address of the buffer. The lower two bits make up the wrap bit indicating
558 * the last descriptor and the ownership bit to indicate it has been used by
560 * The following register - word1, contains status information regarding why
561 * the frame was received (the filter match condition) as well as other
565 #define XEMACPS_RXBUF_BCAST_MASK 0x80000000U /**< Broadcast frame */
566 #define XEMACPS_RXBUF_MULTIHASH_MASK 0x40000000U /**< Multicast hashed frame */
567 #define XEMACPS_RXBUF_UNIHASH_MASK 0x20000000U /**< Unicast hashed frame */
568 #define XEMACPS_RXBUF_EXH_MASK 0x08000000U /**< buffer exhausted */
569 #define XEMACPS_RXBUF_AMATCH_MASK 0x06000000U /**< Specific address
571 #define XEMACPS_RXBUF_IDFOUND_MASK 0x01000000U /**< Type ID matched */
572 #define XEMACPS_RXBUF_IDMATCH_MASK 0x00C00000U /**< ID matched mask */
573 #define XEMACPS_RXBUF_VLAN_MASK 0x00200000U /**< VLAN tagged */
574 #define XEMACPS_RXBUF_PRI_MASK 0x00100000U /**< Priority tagged */
575 #define XEMACPS_RXBUF_VPRI_MASK 0x000E0000U /**< Vlan priority */
576 #define XEMACPS_RXBUF_CFI_MASK 0x00010000U /**< CFI frame */
577 #define XEMACPS_RXBUF_EOF_MASK 0x00008000U /**< End of frame. */
578 #define XEMACPS_RXBUF_SOF_MASK 0x00004000U /**< Start of frame. */
579 #define XEMACPS_RXBUF_LEN_MASK 0x00001FFFU /**< Mask for length field */
580 #define XEMACPS_RXBUF_LEN_JUMBO_MASK 0x00003FFFU /**< Mask for jumbo length */
582 #define XEMACPS_RXBUF_WRAP_MASK 0x00000002U /**< Wrap bit, last BD */
583 #define XEMACPS_RXBUF_NEW_MASK 0x00000001U /**< Used bit.. */
584 #define XEMACPS_RXBUF_ADD_MASK 0xFFFFFFFCU /**< Mask for address */
590 * Define appropriate I/O access method to memory mapped I/O or other
591 * interface if necessary.
594 #define XEmacPs_In32 Xil_In32
595 #define XEmacPs_Out32 Xil_Out32
598 /****************************************************************************/
601 * Read the given register.
603 * @param BaseAddress is the base address of the device
604 * @param RegOffset is the register offset to be read
606 * @return The 32-bit value of the register
610 * u32 XEmacPs_ReadReg(u32 BaseAddress, u32 RegOffset)
612 *****************************************************************************/
613 #define XEmacPs_ReadReg(BaseAddress, RegOffset) \
614 XEmacPs_In32((BaseAddress) + (u32)(RegOffset))
617 /****************************************************************************/
620 * Write the given register.
622 * @param BaseAddress is the base address of the device
623 * @param RegOffset is the register offset to be written
624 * @param Data is the 32-bit value to write to the register
630 * void XEmacPs_WriteReg(u32 BaseAddress, u32 RegOffset,
633 *****************************************************************************/
634 #define XEmacPs_WriteReg(BaseAddress, RegOffset, Data) \
635 XEmacPs_Out32((BaseAddress) + (u32)(RegOffset), (u32)(Data))
637 /************************** Function Prototypes *****************************/
639 * Perform reset operation to the emacps interface
641 void XEmacPs_ResetHw(u32 BaseAddr);
647 #endif /* end of protection macro */