Lines Matching +full:active +full:- +full:semi
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2006-2007 PA Semi, Inc
5 * Common functions for DMA access on PA Semi PWRficient
43 /* pasemi_read_iob_reg - read IOB register
52 /* pasemi_write_iob_reg - write IOB register
62 /* pasemi_read_mac_reg - read MAC register
72 /* pasemi_write_mac_reg - write MAC register
83 /* pasemi_read_dma_reg - read DMA register
92 /* pasemi_write_dma_reg - write DMA register
124 return -ENOSPC; in pasemi_alloc_tx_chan()
143 return -ENOSPC; in pasemi_alloc_rx_chan()
156 /* pasemi_dma_alloc_chan - Allocate a DMA channel
186 chan->priv = buf; in pasemi_dma_alloc_chan()
191 chan->chno = chno; in pasemi_dma_alloc_chan()
192 chan->irq = irq_create_mapping(NULL, in pasemi_dma_alloc_chan()
194 chan->status = &dma_status->rx_sta[chno]; in pasemi_dma_alloc_chan()
198 chan->chno = chno; in pasemi_dma_alloc_chan()
199 chan->irq = irq_create_mapping(NULL, base_hw_irq + chno); in pasemi_dma_alloc_chan()
200 chan->status = &dma_status->tx_sta[chno]; in pasemi_dma_alloc_chan()
204 chan->chan_type = type; in pasemi_dma_alloc_chan()
210 /* pasemi_dma_free_chan - Free a previously allocated channel
218 if (chan->ring_virt) in pasemi_dma_free_chan()
221 switch (chan->chan_type & (RXCHAN|TXCHAN)) { in pasemi_dma_free_chan()
223 pasemi_free_rx_chan(chan->chno); in pasemi_dma_free_chan()
226 pasemi_free_tx_chan(chan->chno); in pasemi_dma_free_chan()
230 kfree(chan->priv); in pasemi_dma_free_chan()
234 /* pasemi_dma_alloc_ring - Allocate descriptor ring for a channel
236 * @ring_size: Ring size in 64-bit (8-byte) words
244 BUG_ON(chan->ring_virt); in pasemi_dma_alloc_ring()
246 chan->ring_size = ring_size; in pasemi_dma_alloc_ring()
248 chan->ring_virt = dma_alloc_coherent(&dma_pdev->dev, in pasemi_dma_alloc_ring()
250 &chan->ring_dma, GFP_KERNEL); in pasemi_dma_alloc_ring()
252 if (!chan->ring_virt) in pasemi_dma_alloc_ring()
253 return -ENOMEM; in pasemi_dma_alloc_ring()
259 /* pasemi_dma_free_ring - Free an allocated descriptor ring for a channel
266 BUG_ON(!chan->ring_virt); in pasemi_dma_free_ring()
268 dma_free_coherent(&dma_pdev->dev, chan->ring_size * sizeof(u64), in pasemi_dma_free_ring()
269 chan->ring_virt, chan->ring_dma); in pasemi_dma_free_ring()
270 chan->ring_virt = NULL; in pasemi_dma_free_ring()
271 chan->ring_size = 0; in pasemi_dma_free_ring()
272 chan->ring_dma = 0; in pasemi_dma_free_ring()
276 /* pasemi_dma_start_chan - Start a DMA channel
284 if (chan->chan_type == RXCHAN) in pasemi_dma_start_chan()
285 pasemi_write_dma_reg(PAS_DMA_RXCHAN_CCMDSTA(chan->chno), in pasemi_dma_start_chan()
288 pasemi_write_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chno), in pasemi_dma_start_chan()
293 /* pasemi_dma_stop_chan - Stop a DMA channel
297 * CMDSTA register and waiting on the ACT (active) bit to clear, then
311 if (chan->chan_type == RXCHAN) { in pasemi_dma_stop_chan()
312 reg = PAS_DMA_RXCHAN_CCMDSTA(chan->chno); in pasemi_dma_stop_chan()
323 reg = PAS_DMA_TXCHAN_TCMDSTA(chan->chno); in pasemi_dma_stop_chan()
339 /* pasemi_dma_alloc_buf - Allocate a buffer to use for DMA
352 return dma_alloc_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL); in pasemi_dma_alloc_buf()
356 /* pasemi_dma_free_buf - Free a buffer used for DMA
366 dma_free_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL); in pasemi_dma_free_buf()
370 /* pasemi_dma_alloc_flag - Allocate a flag (event) for channel synchronization
373 * Returns allocated flag (0-63), < 0 on error.
382 return -ENOSPC; in pasemi_dma_alloc_flag()
391 /* pasemi_dma_free_flag - Deallocates a flag (event)
405 /* pasemi_dma_set_flag - Sets a flag (event) to 1
406 * @flag: Flag number to set active
420 /* pasemi_dma_clear_flag - Sets a flag (event) to 0
435 /* pasemi_dma_alloc_fun - Allocate a function engine
438 * Returns allocated engine (0-8), < 0 on error.
447 return -ENOSPC; in pasemi_dma_alloc_fun()
456 /* pasemi_dma_free_fun - Deallocates a function engine
487 * they are at well-known locations so we can just do the math here. in map_onedev()
489 return ioremap(0xe0000000 + (p->devfn << 12), 0x2000); in map_onedev()
492 /* pasemi_dma_init - Initialize the PA Semi DMA library
511 return -ENODEV; in pasemi_dma_init()
523 err = -ENODEV; in pasemi_dma_init()
532 err = -ENODEV; in pasemi_dma_init()
536 base_hw_irq = virq_to_hw(dma_pdev->irq); in pasemi_dma_init()
614 pr_info("PA Semi PWRficient DMA library initialized " in pasemi_dma_init()