Lines Matching refs:dma

40 static int gmac_disable_dma(struct eth_dma *dma, int dir);
41 static int gmac_enable_dma(struct eth_dma *dma, int dir);
100 static void dma_tx_dump(struct eth_dma *dma)
117 descp = (dma64dd_t *)(dma->tx_desc_aligned) + i;
126 bufp = (uint8_t *)(dma->tx_buf + i * TX_BUF_SIZE_ALIGNED);
132 static void dma_rx_dump(struct eth_dma *dma)
149 descp = (dma64dd_t *)(dma->rx_desc_aligned) + i;
157 bufp = dma->rx_buf + i * RX_BUF_SIZE_ALIGNED;
164 static int dma_tx_init(struct eth_dma *dma)
174 memset((void *)(dma->tx_desc_aligned), 0,
176 memset(dma->tx_buf, 0, TX_BUF_NUM * TX_BUF_SIZE_ALIGNED);
180 descp = (dma64dd_t *)(dma->tx_desc_aligned) + i;
181 bufp = dma->tx_buf + i * TX_BUF_SIZE_ALIGNED;
196 descp = dma->tx_desc_aligned;
197 bufp = dma->tx_buf;
206 writel((uint32_t)(dma->tx_desc_aligned), GMAC0_DMA_TX_ADDR_LOW_ADDR);
209 /* now update the dma last descriptor */
210 writel(((uint32_t)(dma->tx_desc_aligned)) & D64_XP_LD_MASK,
216 static int dma_rx_init(struct eth_dma *dma)
227 memset((void *)(dma->rx_desc_aligned), 0,
230 memset(dma->rx_buf, 0, RX_BUF_NUM * RX_BUF_SIZE_ALIGNED);
234 descp = (dma64dd_t *)(dma->rx_desc_aligned) + i;
235 bufp = dma->rx_buf + i * RX_BUF_SIZE_ALIGNED;
249 descp = dma->rx_desc_aligned;
250 bufp = dma->rx_buf;
263 /* now update the dma last descriptor */
269 static int dma_init(struct eth_dma *dma)
286 dma_tx_init(dma);
287 dma_rx_init(dma);
297 static int dma_deinit(struct eth_dma *dma)
301 gmac_disable_dma(dma, MAC_DMA_RX);
302 gmac_disable_dma(dma, MAC_DMA_TX);
304 free(dma->tx_buf);
305 dma->tx_buf = NULL;
306 free(dma->tx_desc_aligned);
307 dma->tx_desc_aligned = NULL;
309 free(dma->rx_buf);
310 dma->rx_buf = NULL;
311 free(dma->rx_desc_aligned);
312 dma->rx_desc_aligned = NULL;
317 int gmac_tx_packet(struct eth_dma *dma, void *packet, int length)
319 uint8_t *bufp = dma->tx_buf + dma->cur_tx_index * TX_BUF_SIZE_ALIGNED;
321 /* kick off the dma */
323 int txout = dma->cur_tx_index;
327 uint32_t last_desc = (((uint32_t)dma->tx_desc_aligned) +
349 last_desc = ((uint32_t)(dma->tx_desc_aligned)) & D64_XP_LD_MASK;
353 descp = ((dma64dd_t *)(dma->tx_desc_aligned)) + txout;
360 flush_dcache_range((unsigned long)dma->tx_desc_aligned,
361 (unsigned long)dma->tx_desc_aligned +
366 /* now update the dma last descriptor */
369 /* tx dma should be enabled so packet should go out */
372 dma->cur_tx_index = (txout + 1) & (TX_BUF_NUM - 1);
377 bool gmac_check_tx_done(struct eth_dma *dma)
400 int gmac_check_rx_done(struct eth_dma *dma, uint8_t *buf)
421 index = dma->cur_rx_index;
422 offset = (uint32_t)(dma->rx_desc_aligned);
439 bufp = dma->rx_buf + index * RX_BUF_SIZE_ALIGNED;
441 descp = (dma64dd_t *)(dma->rx_desc_aligned) + index;
443 flush_dcache_range((unsigned long)dma->rx_desc_aligned,
444 (unsigned long)dma->rx_desc_aligned +
457 dma->cur_rx_index = (index + 1) & (RX_BUF_NUM - 1);
475 flush_dcache_range((unsigned long)dma->rx_desc_aligned,
476 (unsigned long)dma->rx_desc_aligned +
485 static int gmac_disable_dma(struct eth_dma *dma, int dir)
530 static int gmac_enable_dma(struct eth_dma *dma, int dir)
537 dma->cur_tx_index = 0;
554 writel((uint32_t)(dma->tx_desc_aligned),
558 dma->cur_rx_index = 0;
587 writel(((uint32_t)(dma->rx_desc_aligned) +
779 struct eth_dma *dma = &(eth->dma);
827 if (dma_init(dma) < 0) {
897 dma_deinit(dma);
904 struct eth_dma *dma = &(eth->dma);
917 dma->tx_desc_aligned = (void *)tmp;
919 dma->tx_desc_aligned, DESCP_SIZE_ALIGNED * TX_BUF_NUM);
924 free(dma->tx_desc_aligned);
927 dma->tx_buf = (uint8_t *)tmp;
929 dma->tx_buf, TX_BUF_SIZE_ALIGNED * TX_BUF_NUM);
935 free(dma->tx_desc_aligned);
936 free(dma->tx_buf);
939 dma->rx_desc_aligned = (void *)tmp;
941 dma->rx_desc_aligned, DESCP_SIZE_ALIGNED * RX_BUF_NUM);
946 free(dma->tx_desc_aligned);
947 free(dma->tx_buf);
948 free(dma->rx_desc_aligned);
951 dma->rx_buf = (uint8_t *)tmp;
953 dma->rx_buf, RX_BUF_SIZE_ALIGNED * RX_BUF_NUM);
959 dma->tx_packet = gmac_tx_packet;
960 dma->check_tx_done = gmac_check_tx_done;
962 dma->check_rx_done = gmac_check_rx_done;
964 dma->enable_dma = gmac_enable_dma;
965 dma->disable_dma = gmac_disable_dma;