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
41 /* pasemi_read_iob_reg - read IOB register
50 /* pasemi_write_iob_reg - write IOB register
60 /* pasemi_read_mac_reg - read MAC register
70 /* pasemi_write_mac_reg - write MAC register
81 /* pasemi_read_dma_reg - read DMA register
90 /* pasemi_write_dma_reg - write DMA register
122 return -ENOSPC; in pasemi_alloc_tx_chan()
141 return -ENOSPC; in pasemi_alloc_rx_chan()
154 /* pasemi_dma_alloc_chan - Allocate a DMA channel
184 chan->priv = buf; in pasemi_dma_alloc_chan()
189 chan->chno = chno; in pasemi_dma_alloc_chan()
190 chan->irq = irq_create_mapping(NULL, in pasemi_dma_alloc_chan()
192 chan->status = &dma_status->rx_sta[chno]; in pasemi_dma_alloc_chan()
196 chan->chno = chno; in pasemi_dma_alloc_chan()
197 chan->irq = irq_create_mapping(NULL, base_hw_irq + chno); in pasemi_dma_alloc_chan()
198 chan->status = &dma_status->tx_sta[chno]; in pasemi_dma_alloc_chan()
202 chan->chan_type = type; in pasemi_dma_alloc_chan()
208 /* pasemi_dma_free_chan - Free a previously allocated channel
216 if (chan->ring_virt) in pasemi_dma_free_chan()
219 switch (chan->chan_type & (RXCHAN|TXCHAN)) { in pasemi_dma_free_chan()
221 pasemi_free_rx_chan(chan->chno); in pasemi_dma_free_chan()
224 pasemi_free_tx_chan(chan->chno); in pasemi_dma_free_chan()
228 kfree(chan->priv); in pasemi_dma_free_chan()
232 /* pasemi_dma_alloc_ring - Allocate descriptor ring for a channel
234 * @ring_size: Ring size in 64-bit (8-byte) words
242 BUG_ON(chan->ring_virt); in pasemi_dma_alloc_ring()
244 chan->ring_size = ring_size; in pasemi_dma_alloc_ring()
246 chan->ring_virt = dma_alloc_coherent(&dma_pdev->dev, in pasemi_dma_alloc_ring()
248 &chan->ring_dma, GFP_KERNEL); in pasemi_dma_alloc_ring()
250 if (!chan->ring_virt) in pasemi_dma_alloc_ring()
251 return -ENOMEM; in pasemi_dma_alloc_ring()
257 /* pasemi_dma_free_ring - Free an allocated descriptor ring for a channel
264 BUG_ON(!chan->ring_virt); in pasemi_dma_free_ring()
266 dma_free_coherent(&dma_pdev->dev, chan->ring_size * sizeof(u64), in pasemi_dma_free_ring()
267 chan->ring_virt, chan->ring_dma); in pasemi_dma_free_ring()
268 chan->ring_virt = NULL; in pasemi_dma_free_ring()
269 chan->ring_size = 0; in pasemi_dma_free_ring()
270 chan->ring_dma = 0; in pasemi_dma_free_ring()
274 /* pasemi_dma_start_chan - Start a DMA channel
282 if (chan->chan_type == RXCHAN) in pasemi_dma_start_chan()
283 pasemi_write_dma_reg(PAS_DMA_RXCHAN_CCMDSTA(chan->chno), in pasemi_dma_start_chan()
286 pasemi_write_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chno), in pasemi_dma_start_chan()
291 /* pasemi_dma_stop_chan - Stop a DMA channel
295 * CMDSTA register and waiting on the ACT (active) bit to clear, then
309 if (chan->chan_type == RXCHAN) { in pasemi_dma_stop_chan()
310 reg = PAS_DMA_RXCHAN_CCMDSTA(chan->chno); in pasemi_dma_stop_chan()
321 reg = PAS_DMA_TXCHAN_TCMDSTA(chan->chno); in pasemi_dma_stop_chan()
337 /* pasemi_dma_alloc_buf - Allocate a buffer to use for DMA
350 return dma_alloc_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL); in pasemi_dma_alloc_buf()
354 /* pasemi_dma_free_buf - Free a buffer used for DMA
364 dma_free_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL); in pasemi_dma_free_buf()
368 /* pasemi_dma_alloc_flag - Allocate a flag (event) for channel synchronization
371 * Returns allocated flag (0-63), < 0 on error.
380 return -ENOSPC; in pasemi_dma_alloc_flag()
389 /* pasemi_dma_free_flag - Deallocates a flag (event)
403 /* pasemi_dma_set_flag - Sets a flag (event) to 1
404 * @flag: Flag number to set active
418 /* pasemi_dma_clear_flag - Sets a flag (event) to 0
433 /* pasemi_dma_alloc_fun - Allocate a function engine
436 * Returns allocated engine (0-8), < 0 on error.
445 return -ENOSPC; in pasemi_dma_alloc_fun()
454 /* pasemi_dma_free_fun - Deallocates a function engine
485 * they are at well-known locations so we can just do the math here. in map_onedev()
487 return ioremap(0xe0000000 + (p->devfn << 12), 0x2000); in map_onedev()
490 /* pasemi_dma_init - Initialize the PA Semi DMA library
509 return -ENODEV; in pasemi_dma_init()
521 err = -ENODEV; in pasemi_dma_init()
530 err = -ENODEV; in pasemi_dma_init()
534 base_hw_irq = virq_to_hw(dma_pdev->irq); in pasemi_dma_init()
612 pr_info("PA Semi PWRficient DMA library initialized " in pasemi_dma_init()