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 INIT_LIST_HEAD(&priv->txlisthd); in sgdma_initialize()
75 INIT_LIST_HEAD(&priv->rxlisthd); in sgdma_initialize()
77 priv->rxdescphys = (dma_addr_t) 0; in sgdma_initialize()
78 priv->txdescphys = (dma_addr_t) 0; in sgdma_initialize()
80 priv->rxdescphys = dma_map_single(priv->device, in sgdma_initialize()
81 (void __force *)priv->rx_dma_desc, in sgdma_initialize()
82 priv->rxdescmem, DMA_BIDIRECTIONAL); in sgdma_initialize()
84 if (dma_mapping_error(priv->device, priv->rxdescphys)) { in sgdma_initialize()
85 sgdma_uninitialize(priv); in sgdma_initialize()
86 netdev_err(priv->dev, "error mapping rx descriptor memory\n"); in sgdma_initialize()
90 priv->txdescphys = dma_map_single(priv->device, in sgdma_initialize()
91 (void __force *)priv->tx_dma_desc, in sgdma_initialize()
92 priv->txdescmem, DMA_TO_DEVICE); in sgdma_initialize()
94 if (dma_mapping_error(priv->device, priv->txdescphys)) { in sgdma_initialize()
95 sgdma_uninitialize(priv); in sgdma_initialize()
96 netdev_err(priv->dev, "error mapping tx descriptor memory\n"); in sgdma_initialize()
101 memset_io(priv->tx_dma_desc, 0, priv->txdescmem); in sgdma_initialize()
102 memset_io(priv->rx_dma_desc, 0, priv->rxdescmem); in sgdma_initialize()
104 dma_sync_single_for_device(priv->device, priv->txdescphys, in sgdma_initialize()
105 priv->txdescmem, DMA_TO_DEVICE); in sgdma_initialize()
107 dma_sync_single_for_device(priv->device, priv->rxdescphys, in sgdma_initialize()
108 priv->rxdescmem, DMA_TO_DEVICE); in sgdma_initialize()
113 void sgdma_uninitialize(struct altera_tse_private *priv) in sgdma_uninitialize() argument
115 if (priv->rxdescphys) in sgdma_uninitialize()
116 dma_unmap_single(priv->device, priv->rxdescphys, in sgdma_uninitialize()
117 priv->rxdescmem, DMA_BIDIRECTIONAL); in sgdma_uninitialize()
119 if (priv->txdescphys) in sgdma_uninitialize()
120 dma_unmap_single(priv->device, priv->txdescphys, in sgdma_uninitialize()
121 priv->txdescmem, DMA_TO_DEVICE); in sgdma_uninitialize()
127 void sgdma_reset(struct altera_tse_private *priv) in sgdma_reset() argument
130 memset_io(priv->tx_dma_desc, 0, priv->txdescmem); in sgdma_reset()
131 memset_io(priv->rx_dma_desc, 0, priv->rxdescmem); in sgdma_reset()
133 csrwr32(SGDMA_CTRLREG_RESET, priv->tx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
134 csrwr32(0, priv->tx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
136 csrwr32(SGDMA_CTRLREG_RESET, priv->rx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
137 csrwr32(0, priv->rx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
145 void sgdma_enable_rxirq(struct altera_tse_private *priv) in sgdma_enable_rxirq() argument
149 void sgdma_enable_txirq(struct altera_tse_private *priv) in sgdma_enable_txirq() argument
153 void sgdma_disable_rxirq(struct altera_tse_private *priv) in sgdma_disable_rxirq() argument
157 void sgdma_disable_txirq(struct altera_tse_private *priv) in sgdma_disable_txirq() argument
161 void sgdma_clear_rxirq(struct altera_tse_private *priv) in sgdma_clear_rxirq() argument
163 tse_set_bit(priv->rx_dma_csr, sgdma_csroffs(control), in sgdma_clear_rxirq()
167 void sgdma_clear_txirq(struct altera_tse_private *priv) in sgdma_clear_txirq() argument
169 tse_set_bit(priv->tx_dma_csr, sgdma_csroffs(control), in sgdma_clear_txirq()
178 int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer) in sgdma_tx_buffer() argument
181 (struct sgdma_descrip __iomem *)priv->tx_dma_desc; in sgdma_tx_buffer()
187 if (sgdma_txbusy(priv)) in sgdma_tx_buffer()
192 sgdma_txphysaddr(priv, ndesc), in sgdma_tx_buffer()
200 sgdma_async_write(priv, cdesc); in sgdma_tx_buffer()
203 queue_tx(priv, buffer); in sgdma_tx_buffer()
211 u32 sgdma_tx_completions(struct altera_tse_private *priv) in sgdma_tx_completions() argument
215 if (!sgdma_txbusy(priv) && in sgdma_tx_completions()
216 ((csrrd8(priv->tx_dma_desc, sgdma_descroffs(control)) in sgdma_tx_completions()
218 (dequeue_tx(priv))) { in sgdma_tx_completions()
225 void sgdma_start_rxdma(struct altera_tse_private *priv) in sgdma_start_rxdma() argument
227 sgdma_async_read(priv); in sgdma_start_rxdma()
230 void sgdma_add_rx_desc(struct altera_tse_private *priv, in sgdma_add_rx_desc() argument
233 queue_rx(priv, rxbuffer); in sgdma_add_rx_desc()
239 u32 sgdma_rx_status(struct altera_tse_private *priv) in sgdma_rx_status() argument
242 (struct sgdma_descrip __iomem *)priv->rx_dma_desc; in sgdma_rx_status()
247 u32 sts = csrrd32(priv->rx_dma_csr, sgdma_csroffs(status)); in sgdma_rx_status()
253 dma_sync_single_for_cpu(priv->device, in sgdma_rx_status()
254 priv->rxdescphys, in sgdma_rx_status()
267 rxbuffer = dequeue_rx(priv); in sgdma_rx_status()
269 netdev_info(priv->dev, in sgdma_rx_status()
273 csrwr32(0, priv->rx_dma_csr, sgdma_csroffs(control)); in sgdma_rx_status()
275 csrwr32(0xf, priv->rx_dma_csr, sgdma_csroffs(status)); in sgdma_rx_status()
278 sgdma_async_read(priv); in sgdma_rx_status()
290 netdev_err(priv->dev, in sgdma_rx_status()
296 sgdma_async_read(priv); in sgdma_rx_status()
347 static int sgdma_async_read(struct altera_tse_private *priv) in sgdma_async_read() argument
350 (struct sgdma_descrip __iomem *)priv->rx_dma_desc; in sgdma_async_read()
356 if (!sgdma_rxbusy(priv)) { in sgdma_async_read()
357 rxbuffer = queue_rx_peekhead(priv); in sgdma_async_read()
359 netdev_err(priv->dev, "no rx buffers available\n"); in sgdma_async_read()
365 sgdma_rxphysaddr(priv, ndesc), in sgdma_async_read()
373 dma_sync_single_for_device(priv->device, in sgdma_async_read()
374 priv->rxdescphys, in sgdma_async_read()
378 csrwr32(lower_32_bits(sgdma_rxphysaddr(priv, cdesc)), in sgdma_async_read()
379 priv->rx_dma_csr, in sgdma_async_read()
382 csrwr32((priv->rxctrlreg | SGDMA_CTRLREG_START), in sgdma_async_read()
383 priv->rx_dma_csr, in sgdma_async_read()
392 static int sgdma_async_write(struct altera_tse_private *priv, in sgdma_async_write() argument
395 if (sgdma_txbusy(priv)) in sgdma_async_write()
399 csrwr32(0, priv->tx_dma_csr, sgdma_csroffs(control)); in sgdma_async_write()
400 csrwr32(0x1f, priv->tx_dma_csr, sgdma_csroffs(status)); in sgdma_async_write()
402 dma_sync_single_for_device(priv->device, priv->txdescphys, in sgdma_async_write()
405 csrwr32(lower_32_bits(sgdma_txphysaddr(priv, desc)), in sgdma_async_write()
406 priv->tx_dma_csr, in sgdma_async_write()
409 csrwr32((priv->txctrlreg | SGDMA_CTRLREG_START), in sgdma_async_write()
410 priv->tx_dma_csr, in sgdma_async_write()
417 sgdma_txphysaddr(struct altera_tse_private *priv, in sgdma_txphysaddr() argument
420 dma_addr_t paddr = priv->txdescmem_busaddr; in sgdma_txphysaddr()
421 uintptr_t offs = (uintptr_t)desc - (uintptr_t)priv->tx_dma_desc; in sgdma_txphysaddr()
426 sgdma_rxphysaddr(struct altera_tse_private *priv, in sgdma_rxphysaddr() argument
429 dma_addr_t paddr = priv->rxdescmem_busaddr; in sgdma_rxphysaddr()
430 uintptr_t offs = (uintptr_t)desc - (uintptr_t)priv->rx_dma_desc; in sgdma_rxphysaddr()
456 queue_tx(struct altera_tse_private *priv, struct tse_buffer *buffer) in queue_tx() argument
458 list_add_tail(&buffer->lh, &priv->txlisthd); in queue_tx()
467 queue_rx(struct altera_tse_private *priv, struct tse_buffer *buffer) in queue_rx() argument
469 list_add_tail(&buffer->lh, &priv->rxlisthd); in queue_rx()
478 dequeue_tx(struct altera_tse_private *priv) in dequeue_tx() argument
481 list_remove_head(&priv->txlisthd, buffer, struct tse_buffer, lh); in dequeue_tx()
491 dequeue_rx(struct altera_tse_private *priv) in dequeue_rx() argument
494 list_remove_head(&priv->rxlisthd, buffer, struct tse_buffer, lh); in dequeue_rx()
505 queue_rx_peekhead(struct altera_tse_private *priv) in queue_rx_peekhead() argument
508 list_peek_head(&priv->rxlisthd, buffer, struct tse_buffer, lh); in queue_rx_peekhead()
514 static int sgdma_rxbusy(struct altera_tse_private *priv) in sgdma_rxbusy() argument
516 return csrrd32(priv->rx_dma_csr, sgdma_csroffs(status)) in sgdma_rxbusy()
523 static int sgdma_txbusy(struct altera_tse_private *priv) in sgdma_txbusy() argument
528 while ((csrrd32(priv->tx_dma_csr, sgdma_csroffs(status)) in sgdma_txbusy()
532 if (csrrd32(priv->tx_dma_csr, sgdma_csroffs(status)) in sgdma_txbusy()
534 netdev_err(priv->dev, "timeout waiting for tx dma\n"); in sgdma_txbusy()