Lines Matching refs:dma
39 static int gmac_disable_dma(struct eth_dma *dma, int dir);
40 static int gmac_enable_dma(struct eth_dma *dma, int dir);
99 static void dma_tx_dump(struct eth_dma *dma) in dma_tx_dump() argument
116 descp = (dma64dd_t *)(dma->tx_desc_aligned) + i; in dma_tx_dump()
125 bufp = (uint8_t *)(dma->tx_buf + i * TX_BUF_SIZE_ALIGNED); in dma_tx_dump()
131 static void dma_rx_dump(struct eth_dma *dma) in dma_rx_dump() argument
148 descp = (dma64dd_t *)(dma->rx_desc_aligned) + i; in dma_rx_dump()
156 bufp = dma->rx_buf + i * RX_BUF_SIZE_ALIGNED; in dma_rx_dump()
163 static int dma_tx_init(struct eth_dma *dma) in dma_tx_init() argument
173 memset((void *)(dma->tx_desc_aligned), 0, in dma_tx_init()
175 memset(dma->tx_buf, 0, TX_BUF_NUM * TX_BUF_SIZE_ALIGNED); in dma_tx_init()
179 descp = (dma64dd_t *)(dma->tx_desc_aligned) + i; in dma_tx_init()
180 bufp = dma->tx_buf + i * TX_BUF_SIZE_ALIGNED; in dma_tx_init()
195 descp = dma->tx_desc_aligned; in dma_tx_init()
196 bufp = dma->tx_buf; in dma_tx_init()
205 writel((uint32_t)(dma->tx_desc_aligned), GMAC0_DMA_TX_ADDR_LOW_ADDR); in dma_tx_init()
209 writel(((uint32_t)(dma->tx_desc_aligned)) & D64_XP_LD_MASK, in dma_tx_init()
215 static int dma_rx_init(struct eth_dma *dma) in dma_rx_init() argument
226 memset((void *)(dma->rx_desc_aligned), 0, in dma_rx_init()
229 memset(dma->rx_buf, 0, RX_BUF_NUM * RX_BUF_SIZE_ALIGNED); in dma_rx_init()
233 descp = (dma64dd_t *)(dma->rx_desc_aligned) + i; in dma_rx_init()
234 bufp = dma->rx_buf + i * RX_BUF_SIZE_ALIGNED; in dma_rx_init()
248 descp = dma->rx_desc_aligned; in dma_rx_init()
249 bufp = dma->rx_buf; in dma_rx_init()
268 static int dma_init(struct eth_dma *dma) in dma_init() argument
285 dma_tx_init(dma); in dma_init()
286 dma_rx_init(dma); in dma_init()
296 static int dma_deinit(struct eth_dma *dma) in dma_deinit() argument
300 gmac_disable_dma(dma, MAC_DMA_RX); in dma_deinit()
301 gmac_disable_dma(dma, MAC_DMA_TX); in dma_deinit()
303 free(dma->tx_buf); in dma_deinit()
304 dma->tx_buf = NULL; in dma_deinit()
305 free(dma->tx_desc_aligned); in dma_deinit()
306 dma->tx_desc_aligned = NULL; in dma_deinit()
308 free(dma->rx_buf); in dma_deinit()
309 dma->rx_buf = NULL; in dma_deinit()
310 free(dma->rx_desc_aligned); in dma_deinit()
311 dma->rx_desc_aligned = NULL; in dma_deinit()
316 int gmac_tx_packet(struct eth_dma *dma, void *packet, int length) in gmac_tx_packet() argument
318 uint8_t *bufp = dma->tx_buf + dma->cur_tx_index * TX_BUF_SIZE_ALIGNED; in gmac_tx_packet()
322 int txout = dma->cur_tx_index; in gmac_tx_packet()
326 uint32_t last_desc = (((uint32_t)dma->tx_desc_aligned) + in gmac_tx_packet()
348 last_desc = ((uint32_t)(dma->tx_desc_aligned)) & D64_XP_LD_MASK; in gmac_tx_packet()
352 descp = ((dma64dd_t *)(dma->tx_desc_aligned)) + txout; in gmac_tx_packet()
359 flush_dcache_range((unsigned long)dma->tx_desc_aligned, in gmac_tx_packet()
360 (unsigned long)dma->tx_desc_aligned + in gmac_tx_packet()
371 dma->cur_tx_index = (txout + 1) & (TX_BUF_NUM - 1); in gmac_tx_packet()
376 bool gmac_check_tx_done(struct eth_dma *dma) in gmac_check_tx_done() argument
399 int gmac_check_rx_done(struct eth_dma *dma, uint8_t *buf) in gmac_check_rx_done() argument
420 index = dma->cur_rx_index; in gmac_check_rx_done()
421 offset = (uint32_t)(dma->rx_desc_aligned); in gmac_check_rx_done()
438 bufp = dma->rx_buf + index * RX_BUF_SIZE_ALIGNED; in gmac_check_rx_done()
440 descp = (dma64dd_t *)(dma->rx_desc_aligned) + index; in gmac_check_rx_done()
442 flush_dcache_range((unsigned long)dma->rx_desc_aligned, in gmac_check_rx_done()
443 (unsigned long)dma->rx_desc_aligned + in gmac_check_rx_done()
456 dma->cur_rx_index = (index + 1) & (RX_BUF_NUM - 1); in gmac_check_rx_done()
474 flush_dcache_range((unsigned long)dma->rx_desc_aligned, in gmac_check_rx_done()
475 (unsigned long)dma->rx_desc_aligned + in gmac_check_rx_done()
484 static int gmac_disable_dma(struct eth_dma *dma, int dir) in gmac_disable_dma() argument
529 static int gmac_enable_dma(struct eth_dma *dma, int dir) in gmac_enable_dma() argument
536 dma->cur_tx_index = 0; in gmac_enable_dma()
553 writel((uint32_t)(dma->tx_desc_aligned), in gmac_enable_dma()
557 dma->cur_rx_index = 0; in gmac_enable_dma()
586 writel(((uint32_t)(dma->rx_desc_aligned) + in gmac_enable_dma()
778 struct eth_dma *dma = &(eth->dma); in gmac_mac_init() local
826 if (dma_init(dma) < 0) { in gmac_mac_init()
896 dma_deinit(dma); in gmac_mac_init()
903 struct eth_dma *dma = &(eth->dma); in gmac_add() local
916 dma->tx_desc_aligned = (void *)tmp; in gmac_add()
918 dma->tx_desc_aligned, DESCP_SIZE_ALIGNED * TX_BUF_NUM); in gmac_add()
923 free(dma->tx_desc_aligned); in gmac_add()
926 dma->tx_buf = (uint8_t *)tmp; in gmac_add()
928 dma->tx_buf, TX_BUF_SIZE_ALIGNED * TX_BUF_NUM); in gmac_add()
934 free(dma->tx_desc_aligned); in gmac_add()
935 free(dma->tx_buf); in gmac_add()
938 dma->rx_desc_aligned = (void *)tmp; in gmac_add()
940 dma->rx_desc_aligned, DESCP_SIZE_ALIGNED * RX_BUF_NUM); in gmac_add()
945 free(dma->tx_desc_aligned); in gmac_add()
946 free(dma->tx_buf); in gmac_add()
947 free(dma->rx_desc_aligned); in gmac_add()
950 dma->rx_buf = (uint8_t *)tmp; in gmac_add()
952 dma->rx_buf, RX_BUF_SIZE_ALIGNED * RX_BUF_NUM); in gmac_add()
958 dma->tx_packet = gmac_tx_packet; in gmac_add()
959 dma->check_tx_done = gmac_check_tx_done; in gmac_add()
961 dma->check_rx_done = gmac_check_rx_done; in gmac_add()
963 dma->enable_dma = gmac_enable_dma; in gmac_add()
964 dma->disable_dma = gmac_disable_dma; in gmac_add()