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 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #include <stdint.h> 27 28 #include "xstatus.h" 29 #include "sleep.h" 30 #include "xparameters.h" 31 #include "xparameters_ps.h" /* defines XPAR values */ 32 #include "xil_types.h" 33 #include "xil_assert.h" 34 #include "xil_io.h" 35 #include "xil_exception.h" 36 #include "xpseudo_asm.h" 37 #include "xil_cache.h" 38 #include "xuartps.h" 39 #include "xscugic.h" 40 #include "xemacps.h" /* defines XEmacPs API */ 41 42 /*#include "netif/xpqueue.h" */ 43 /*#include "xlwipconfig.h" */ 44 45 void xemacpsif_setmac( uint32_t index, 46 uint8_t * addr ); 47 uint8_t * xemacpsif_getmac( uint32_t index ); 48 /*int xemacpsif_init(struct netif *netif); */ 49 /*int xemacpsif_input(struct netif *netif); */ 50 #ifdef NOTNOW_BHILL 51 unsigned get_IEEE_phy_speed( XLlTemac * xlltemacp ); 52 #endif 53 54 /* xaxiemacif_hw.c */ 55 void xemacps_error_handler( XEmacPs * Temac ); 56 57 struct xBD_TYPE 58 { 59 uint32_t address; 60 uint32_t flags; 61 #ifdef __aarch64__ 62 /* Fill it up so the struct gets a size of 16 bytes. */ 63 uint32_t address_high; 64 uint32_t reserved; 65 #endif 66 }; 67 68 /* 69 * Missing declaration in 'src/xemacps_hw.h' : 70 * When set, the GEM DMA will automatically 71 * discard receive packets from the receiver packet 72 * buffer memory when no AHB resource is 73 * available. 74 * When low, then received packets will remain to be 75 * stored in the SRAM based packet buffer until 76 * AHB buffer resource next becomes available. 77 */ 78 #define XEMACPS_DMACR_DISC_WHEN_NO_AHB_MASK 0x01000000 79 80 #define EMAC_IF_RX_EVENT 1 81 #define EMAC_IF_TX_EVENT 2 82 #define EMAC_IF_ERR_EVENT 4 83 #define EMAC_IF_ALL_EVENT 7 84 85 /* structure within each netif, encapsulating all information required for 86 * using a particular temac instance 87 */ 88 typedef struct 89 { 90 XEmacPs emacps; 91 92 /* pointers to memory holding buffer descriptors (used only with SDMA) */ 93 struct xBD_TYPE * rxSegments; 94 struct xBD_TYPE * txSegments; 95 96 struct xBD_TYPE * rxBdTerminator; 97 struct xBD_TYPE * txBdTerminator; 98 99 unsigned char * tx_space; 100 unsigned uTxUnitSize; 101 102 char * remain_mem; 103 unsigned remain_siz; 104 105 volatile int rxHead, rxTail; 106 volatile int txHead, txTail; 107 108 volatile int txBusy; 109 110 volatile uint32_t isr_events; 111 112 unsigned int last_rx_frms_cntr; 113 } xemacpsif_s; 114 115 /*extern xemacpsif_s xemacpsif; */ 116 117 int is_tx_space_available( xemacpsif_s * emac ); 118 119 /* xaxiemacif_dma.c */ 120 121 struct xNETWORK_BUFFER; 122 123 int emacps_check_rx( xemacpsif_s * xemacpsif ); 124 void emacps_check_tx( xemacpsif_s * xemacpsif ); 125 int emacps_check_errors( xemacpsif_s * xemacps ); 126 void emacps_set_rx_buffers( xemacpsif_s * xemacpsif, 127 u32 ulCount ); 128 129 extern XStatus emacps_send_message( xemacpsif_s * xemacpsif, 130 struct xNETWORK_BUFFER * pxBuffer, 131 int iReleaseAfterSend ); 132 extern unsigned Phy_Setup( XEmacPs * xemacpsp ); 133 extern uint32_t Phy_Setup_US( XEmacPs * xemacpsp, 134 uint32_t phy_addr ); 135 extern void setup_isr( xemacpsif_s * xemacpsif ); 136 extern XStatus init_dma( xemacpsif_s * xemacpsif ); 137 extern void start_emacps( xemacpsif_s * xemacpsif ); 138 139 void EmacEnableIntr( void ); 140 void EmacDisableIntr( void ); 141 142 XStatus init_axi_dma( xemacpsif_s * xemacpsif ); 143 void process_sent_bds( xemacpsif_s * xemacpsif ); 144 145 void emacps_send_handler( void * arg ); 146 void emacps_recv_handler( void * arg ); 147 void emacps_error_handler( void * arg, 148 u8 Direction, 149 u32 ErrorWord ); 150 void HandleTxErrors( xemacpsif_s * xemacpsif ); 151 XEmacPs_Config * xemacps_lookup_config( unsigned mac_base ); 152 153 void clean_dma_txdescs( xemacpsif_s * xemacpsif ); 154 void resetrx_on_no_rxdata( xemacpsif_s * xemacpsif ); 155 156 #ifdef __cplusplus 157 } 158 #endif 159 160 #endif /* __NETIF_XAXIEMACIF_H__ */ 161