1 /* 2 * Copyright (c) 2010-2013 Xilinx, Inc. All rights reserved. 3 * 4 * Xilinx, Inc. 5 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A 6 * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS 7 * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR 8 * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION 9 * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE 10 * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. 11 * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO 12 * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO 13 * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE 14 * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY 15 * AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 */ 18 19 #ifndef __NETIF_XEMACPSIF_H__ 20 #define __NETIF_XEMACPSIF_H__ 21 22 #include <stdint.h> 23 24 #include "xstatus.h" 25 #include "xparameters.h" 26 #include "xparameters_ps.h" /* defines XPAR values */ 27 #include "xil_types.h" 28 #include "xil_assert.h" 29 #include "xil_io.h" 30 #include "xil_exception.h" 31 #include "xpseudo_asm.h" 32 #include "xil_cache.h" 33 #include "xuartps.h" 34 #include "xscugic.h" 35 #include "xemacps.h" /* defines XEmacPs API */ 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 #define XPAR_PS7_ETHERNET_1_DEVICE_ID 1 42 #define XPAR_PS7_ETHERNET_1_BASEADDR 0xE000C000 43 44 extern XEmacPs_Config mac_configs[ XPAR_XEMACPS_NUM_INSTANCES ]; 45 46 47 void xemacpsif_setmac( uint32_t index, 48 uint8_t * addr ); 49 uint8_t * xemacpsif_getmac( uint32_t index ); 50 51 #ifdef NOTNOW_BHILL 52 unsigned get_IEEE_phy_speed( XLlTemac * xlltemacp ); 53 #endif 54 55 /* xaxiemacif_hw.c */ 56 void xemacps_error_handler( XEmacPs * Temac ); 57 58 struct xBD_TYPE 59 { 60 uint32_t address; 61 uint32_t flags; 62 }; 63 64 /* 65 * Missing declaration in 'src/xemacps_hw.h' : 66 * When set, the GEM DMA will automatically 67 * discard receive packets from the receiver packet 68 * buffer memory when no AHB resource is 69 * available. 70 * When low, then received packets will remain to be 71 * stored in the SRAM based packet buffer until 72 * AHB buffer resource next becomes available. 73 */ 74 #define XEMACPS_DMACR_DISC_WHEN_NO_AHB_MASK 0x01000000 75 76 #define EMAC_IF_RX_EVENT 1 77 #define EMAC_IF_TX_EVENT 2 78 #define EMAC_IF_ERR_EVENT 4 79 #define EMAC_IF_ALL_EVENT 7 80 81 /* structure within each netif, encapsulating all information required for 82 * using a particular temac instance 83 */ 84 typedef struct 85 { 86 XEmacPs emacps; 87 88 /* pointers to memory holding buffer descriptors (used only with SDMA) */ 89 struct xBD_TYPE * rxSegments; 90 struct xBD_TYPE * txSegments; 91 92 unsigned char * tx_space; 93 unsigned uTxUnitSize; 94 95 char * remain_mem; 96 unsigned remain_siz; 97 98 volatile int rxHead, rxTail; 99 volatile int txHead, txTail; 100 101 volatile int txBusy; 102 103 volatile uint32_t isr_events; 104 105 unsigned int last_rx_frms_cntr; 106 } xemacpsif_s; 107 108 /*extern xemacpsif_s xemacpsif; */ 109 110 int is_tx_space_available( xemacpsif_s * emac ); 111 112 /* xaxiemacif_dma.c */ 113 114 struct xNETWORK_BUFFER; 115 116 int emacps_check_rx( xemacpsif_s * xemacpsif, 117 NetworkInterface_t * pxInterface ); 118 void emacps_check_tx( xemacpsif_s * xemacpsif ); 119 int emacps_check_errors( xemacpsif_s * xemacps ); 120 void emacps_set_rx_buffers( xemacpsif_s * xemacpsif, 121 u32 ulCount ); 122 123 extern XStatus emacps_send_message( xemacpsif_s * xemacpsif, 124 struct xNETWORK_BUFFER * pxBuffer, 125 int iReleaseAfterSend ); 126 extern unsigned Phy_Setup( XEmacPs * xemacpsp ); 127 extern void setup_isr( xemacpsif_s * xemacpsif ); 128 extern XStatus init_dma( xemacpsif_s * xemacpsif ); 129 extern void start_emacps( xemacpsif_s * xemacpsif ); 130 131 void EmacEnableIntr( int xEMACIndex ); 132 void EmacDisableIntr( int xEMACIndex ); 133 134 XStatus init_axi_dma( xemacpsif_s * xemacpsif ); 135 void process_sent_bds( xemacpsif_s * xemacpsif ); 136 137 void emacps_send_handler( void * arg ); 138 void emacps_recv_handler( void * arg ); 139 void emacps_error_handler( void * arg, 140 u8 Direction, 141 u32 ErrorWord ); 142 void HandleTxErrors( xemacpsif_s * xemacpsif ); 143 XEmacPs_Config * xemacps_lookup_config( unsigned mac_base ); 144 145 void clean_dma_txdescs( xemacpsif_s * xemacpsif ); 146 void resetrx_on_no_rxdata( xemacpsif_s * xemacpsif ); 147 148 /** 149 * @brief Initialise the interface number 'xIndex'. Do not call directly. 150 */ 151 void vInitialiseOnIndex( BaseType_t xIndex ); 152 153 #ifdef __cplusplus 154 } 155 #endif 156 157 #endif /* __NETIF_XAXIEMACIF_H__ */ 158