Lines Matching refs:priv

33 static int sgdma_async_write(struct altera_tse_private *priv,
36 static int sgdma_async_read(struct altera_tse_private *priv);
39 sgdma_txphysaddr(struct altera_tse_private *priv,
43 sgdma_rxphysaddr(struct altera_tse_private *priv,
46 static int sgdma_txbusy(struct altera_tse_private *priv);
48 static int sgdma_rxbusy(struct altera_tse_private *priv);
51 queue_tx(struct altera_tse_private *priv, struct tse_buffer *buffer);
54 queue_rx(struct altera_tse_private *priv, struct tse_buffer *buffer);
57 dequeue_tx(struct altera_tse_private *priv);
60 dequeue_rx(struct altera_tse_private *priv);
63 queue_rx_peekhead(struct altera_tse_private *priv);
65 int sgdma_initialize(struct altera_tse_private *priv) in sgdma_initialize() argument
67 priv->txctrlreg = SGDMA_CTRLREG_ILASTD | in sgdma_initialize()
70 priv->rxctrlreg = SGDMA_CTRLREG_IDESCRIP | in sgdma_initialize()
74 priv->sgdmadesclen = sizeof(struct sgdma_descrip); in sgdma_initialize()
76 INIT_LIST_HEAD(&priv->txlisthd); in sgdma_initialize()
77 INIT_LIST_HEAD(&priv->rxlisthd); in sgdma_initialize()
79 priv->rxdescphys = (dma_addr_t) 0; in sgdma_initialize()
80 priv->txdescphys = (dma_addr_t) 0; in sgdma_initialize()
82 priv->rxdescphys = dma_map_single(priv->device, in sgdma_initialize()
83 (void __force *)priv->rx_dma_desc, in sgdma_initialize()
84 priv->rxdescmem, DMA_BIDIRECTIONAL); in sgdma_initialize()
86 if (dma_mapping_error(priv->device, priv->rxdescphys)) { in sgdma_initialize()
87 sgdma_uninitialize(priv); in sgdma_initialize()
88 netdev_err(priv->dev, "error mapping rx descriptor memory\n"); in sgdma_initialize()
92 priv->txdescphys = dma_map_single(priv->device, in sgdma_initialize()
93 (void __force *)priv->tx_dma_desc, in sgdma_initialize()
94 priv->txdescmem, DMA_TO_DEVICE); in sgdma_initialize()
96 if (dma_mapping_error(priv->device, priv->txdescphys)) { in sgdma_initialize()
97 sgdma_uninitialize(priv); in sgdma_initialize()
98 netdev_err(priv->dev, "error mapping tx descriptor memory\n"); in sgdma_initialize()
103 memset_io(priv->tx_dma_desc, 0, priv->txdescmem); in sgdma_initialize()
104 memset_io(priv->rx_dma_desc, 0, priv->rxdescmem); in sgdma_initialize()
106 dma_sync_single_for_device(priv->device, priv->txdescphys, in sgdma_initialize()
107 priv->txdescmem, DMA_TO_DEVICE); in sgdma_initialize()
109 dma_sync_single_for_device(priv->device, priv->rxdescphys, in sgdma_initialize()
110 priv->rxdescmem, DMA_TO_DEVICE); in sgdma_initialize()
115 void sgdma_uninitialize(struct altera_tse_private *priv) in sgdma_uninitialize() argument
117 if (priv->rxdescphys) in sgdma_uninitialize()
118 dma_unmap_single(priv->device, priv->rxdescphys, in sgdma_uninitialize()
119 priv->rxdescmem, DMA_BIDIRECTIONAL); in sgdma_uninitialize()
121 if (priv->txdescphys) in sgdma_uninitialize()
122 dma_unmap_single(priv->device, priv->txdescphys, in sgdma_uninitialize()
123 priv->txdescmem, DMA_TO_DEVICE); in sgdma_uninitialize()
129 void sgdma_reset(struct altera_tse_private *priv) in sgdma_reset() argument
132 memset_io(priv->tx_dma_desc, 0, priv->txdescmem); in sgdma_reset()
133 memset_io(priv->rx_dma_desc, 0, priv->rxdescmem); in sgdma_reset()
135 csrwr32(SGDMA_CTRLREG_RESET, priv->tx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
136 csrwr32(0, priv->tx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
138 csrwr32(SGDMA_CTRLREG_RESET, priv->rx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
139 csrwr32(0, priv->rx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
147 void sgdma_enable_rxirq(struct altera_tse_private *priv) in sgdma_enable_rxirq() argument
151 void sgdma_enable_txirq(struct altera_tse_private *priv) in sgdma_enable_txirq() argument
155 void sgdma_disable_rxirq(struct altera_tse_private *priv) in sgdma_disable_rxirq() argument
159 void sgdma_disable_txirq(struct altera_tse_private *priv) in sgdma_disable_txirq() argument
163 void sgdma_clear_rxirq(struct altera_tse_private *priv) in sgdma_clear_rxirq() argument
165 tse_set_bit(priv->rx_dma_csr, sgdma_csroffs(control), in sgdma_clear_rxirq()
169 void sgdma_clear_txirq(struct altera_tse_private *priv) in sgdma_clear_txirq() argument
171 tse_set_bit(priv->tx_dma_csr, sgdma_csroffs(control), in sgdma_clear_txirq()
180 int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer) in sgdma_tx_buffer() argument
183 (struct sgdma_descrip __iomem *)priv->tx_dma_desc; in sgdma_tx_buffer()
189 if (sgdma_txbusy(priv)) in sgdma_tx_buffer()
194 sgdma_txphysaddr(priv, ndesc), in sgdma_tx_buffer()
202 sgdma_async_write(priv, cdesc); in sgdma_tx_buffer()
205 queue_tx(priv, buffer); in sgdma_tx_buffer()
213 u32 sgdma_tx_completions(struct altera_tse_private *priv) in sgdma_tx_completions() argument
217 if (!sgdma_txbusy(priv) && in sgdma_tx_completions()
218 ((csrrd8(priv->tx_dma_desc, sgdma_descroffs(control)) in sgdma_tx_completions()
220 (dequeue_tx(priv))) { in sgdma_tx_completions()
227 void sgdma_start_rxdma(struct altera_tse_private *priv) in sgdma_start_rxdma() argument
229 sgdma_async_read(priv); in sgdma_start_rxdma()
232 void sgdma_add_rx_desc(struct altera_tse_private *priv, in sgdma_add_rx_desc() argument
235 queue_rx(priv, rxbuffer); in sgdma_add_rx_desc()
241 u32 sgdma_rx_status(struct altera_tse_private *priv) in sgdma_rx_status() argument
244 (struct sgdma_descrip __iomem *)priv->rx_dma_desc; in sgdma_rx_status()
249 u32 sts = csrrd32(priv->rx_dma_csr, sgdma_csroffs(status)); in sgdma_rx_status()
255 dma_sync_single_for_cpu(priv->device, in sgdma_rx_status()
256 priv->rxdescphys, in sgdma_rx_status()
257 priv->sgdmadesclen, in sgdma_rx_status()
269 rxbuffer = dequeue_rx(priv); in sgdma_rx_status()
271 netdev_info(priv->dev, in sgdma_rx_status()
275 csrwr32(0, priv->rx_dma_csr, sgdma_csroffs(control)); in sgdma_rx_status()
277 csrwr32(0xf, priv->rx_dma_csr, sgdma_csroffs(status)); in sgdma_rx_status()
280 sgdma_async_read(priv); in sgdma_rx_status()
292 netdev_err(priv->dev, in sgdma_rx_status()
298 sgdma_async_read(priv); in sgdma_rx_status()
349 static int sgdma_async_read(struct altera_tse_private *priv) in sgdma_async_read() argument
352 (struct sgdma_descrip __iomem *)priv->rx_dma_desc; in sgdma_async_read()
358 if (!sgdma_rxbusy(priv)) { in sgdma_async_read()
359 rxbuffer = queue_rx_peekhead(priv); in sgdma_async_read()
361 netdev_err(priv->dev, "no rx buffers available\n"); in sgdma_async_read()
367 sgdma_rxphysaddr(priv, ndesc), in sgdma_async_read()
375 dma_sync_single_for_device(priv->device, in sgdma_async_read()
376 priv->rxdescphys, in sgdma_async_read()
377 priv->sgdmadesclen, in sgdma_async_read()
380 csrwr32(lower_32_bits(sgdma_rxphysaddr(priv, cdesc)), in sgdma_async_read()
381 priv->rx_dma_csr, in sgdma_async_read()
384 csrwr32((priv->rxctrlreg | SGDMA_CTRLREG_START), in sgdma_async_read()
385 priv->rx_dma_csr, in sgdma_async_read()
394 static int sgdma_async_write(struct altera_tse_private *priv, in sgdma_async_write() argument
397 if (sgdma_txbusy(priv)) in sgdma_async_write()
401 csrwr32(0, priv->tx_dma_csr, sgdma_csroffs(control)); in sgdma_async_write()
402 csrwr32(0x1f, priv->tx_dma_csr, sgdma_csroffs(status)); in sgdma_async_write()
404 dma_sync_single_for_device(priv->device, priv->txdescphys, in sgdma_async_write()
405 priv->sgdmadesclen, DMA_TO_DEVICE); in sgdma_async_write()
407 csrwr32(lower_32_bits(sgdma_txphysaddr(priv, desc)), in sgdma_async_write()
408 priv->tx_dma_csr, in sgdma_async_write()
411 csrwr32((priv->txctrlreg | SGDMA_CTRLREG_START), in sgdma_async_write()
412 priv->tx_dma_csr, in sgdma_async_write()
419 sgdma_txphysaddr(struct altera_tse_private *priv, in sgdma_txphysaddr() argument
422 dma_addr_t paddr = priv->txdescmem_busaddr; in sgdma_txphysaddr()
423 uintptr_t offs = (uintptr_t)desc - (uintptr_t)priv->tx_dma_desc; in sgdma_txphysaddr()
428 sgdma_rxphysaddr(struct altera_tse_private *priv, in sgdma_rxphysaddr() argument
431 dma_addr_t paddr = priv->rxdescmem_busaddr; in sgdma_rxphysaddr()
432 uintptr_t offs = (uintptr_t)desc - (uintptr_t)priv->rx_dma_desc; in sgdma_rxphysaddr()
458 queue_tx(struct altera_tse_private *priv, struct tse_buffer *buffer) in queue_tx() argument
460 list_add_tail(&buffer->lh, &priv->txlisthd); in queue_tx()
469 queue_rx(struct altera_tse_private *priv, struct tse_buffer *buffer) in queue_rx() argument
471 list_add_tail(&buffer->lh, &priv->rxlisthd); in queue_rx()
480 dequeue_tx(struct altera_tse_private *priv) in dequeue_tx() argument
483 list_remove_head(&priv->txlisthd, buffer, struct tse_buffer, lh); in dequeue_tx()
493 dequeue_rx(struct altera_tse_private *priv) in dequeue_rx() argument
496 list_remove_head(&priv->rxlisthd, buffer, struct tse_buffer, lh); in dequeue_rx()
507 queue_rx_peekhead(struct altera_tse_private *priv) in queue_rx_peekhead() argument
510 list_peek_head(&priv->rxlisthd, buffer, struct tse_buffer, lh); in queue_rx_peekhead()
516 static int sgdma_rxbusy(struct altera_tse_private *priv) in sgdma_rxbusy() argument
518 return csrrd32(priv->rx_dma_csr, sgdma_csroffs(status)) in sgdma_rxbusy()
525 static int sgdma_txbusy(struct altera_tse_private *priv) in sgdma_txbusy() argument
530 while ((csrrd32(priv->tx_dma_csr, sgdma_csroffs(status)) in sgdma_txbusy()
534 if (csrrd32(priv->tx_dma_csr, sgdma_csroffs(status)) in sgdma_txbusy()
536 netdev_err(priv->dev, "timeout waiting for tx dma\n"); in sgdma_txbusy()