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