Lines Matching full:mdev

206  * @mdev: Pointer to the Altera mSGDMA device structure
210 static struct msgdma_sw_desc *msgdma_get_descriptor(struct msgdma_device *mdev) in msgdma_get_descriptor() argument
215 spin_lock_irqsave(&mdev->lock, flags); in msgdma_get_descriptor()
216 desc = list_first_entry(&mdev->free_list, struct msgdma_sw_desc, node); in msgdma_get_descriptor()
218 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_get_descriptor()
227 * @mdev: Pointer to the Altera mSGDMA device structure
230 static void msgdma_free_descriptor(struct msgdma_device *mdev, in msgdma_free_descriptor() argument
235 mdev->desc_free_cnt++; in msgdma_free_descriptor()
236 list_move_tail(&desc->node, &mdev->free_list); in msgdma_free_descriptor()
238 mdev->desc_free_cnt++; in msgdma_free_descriptor()
239 list_move_tail(&child->node, &mdev->free_list); in msgdma_free_descriptor()
245 * @mdev: Pointer to the Altera mSGDMA device structure
248 static void msgdma_free_desc_list(struct msgdma_device *mdev, in msgdma_free_desc_list() argument
254 msgdma_free_descriptor(mdev, desc); in msgdma_free_desc_list()
306 struct msgdma_device *mdev = to_mdev(tx->chan); in msgdma_tx_submit() local
312 spin_lock_irqsave(&mdev->lock, flags); in msgdma_tx_submit()
315 list_add_tail(&new->node, &mdev->pending_list); in msgdma_tx_submit()
316 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_tx_submit()
335 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_prep_memcpy() local
344 spin_lock_irqsave(&mdev->lock, irqflags); in msgdma_prep_memcpy()
345 if (desc_cnt > mdev->desc_free_cnt) { in msgdma_prep_memcpy()
346 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_prep_memcpy()
347 dev_dbg(mdev->dev, "mdev %p descs are not available\n", mdev); in msgdma_prep_memcpy()
350 mdev->desc_free_cnt -= desc_cnt; in msgdma_prep_memcpy()
351 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_prep_memcpy()
355 new = msgdma_get_descriptor(mdev); in msgdma_prep_memcpy()
393 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_prep_slave_sg() local
394 struct dma_slave_config *cfg = &mdev->slave_cfg; in msgdma_prep_slave_sg()
405 spin_lock_irqsave(&mdev->lock, irqflags); in msgdma_prep_slave_sg()
406 if (desc_cnt > mdev->desc_free_cnt) { in msgdma_prep_slave_sg()
407 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_prep_slave_sg()
408 dev_dbg(mdev->dev, "mdev %p descs are not available\n", mdev); in msgdma_prep_slave_sg()
411 mdev->desc_free_cnt -= desc_cnt; in msgdma_prep_slave_sg()
412 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_prep_slave_sg()
419 new = msgdma_get_descriptor(mdev); in msgdma_prep_slave_sg()
462 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_dma_config() local
464 memcpy(&mdev->slave_cfg, config, sizeof(*config)); in msgdma_dma_config()
469 static void msgdma_reset(struct msgdma_device *mdev) in msgdma_reset() argument
475 iowrite32(MSGDMA_CSR_STAT_MASK, mdev->csr + MSGDMA_CSR_STATUS); in msgdma_reset()
476 iowrite32(MSGDMA_CSR_CTL_RESET, mdev->csr + MSGDMA_CSR_CONTROL); in msgdma_reset()
478 ret = readl_poll_timeout(mdev->csr + MSGDMA_CSR_STATUS, val, in msgdma_reset()
482 dev_err(mdev->dev, "DMA channel did not reset\n"); in msgdma_reset()
485 iowrite32(MSGDMA_CSR_STAT_MASK, mdev->csr + MSGDMA_CSR_STATUS); in msgdma_reset()
489 MSGDMA_CSR_CTL_GLOBAL_INTR, mdev->csr + MSGDMA_CSR_CONTROL); in msgdma_reset()
491 mdev->idle = true; in msgdma_reset()
494 static void msgdma_copy_one(struct msgdma_device *mdev, in msgdma_copy_one() argument
497 void __iomem *hw_desc = mdev->desc; in msgdma_copy_one()
503 while (ioread32(mdev->csr + MSGDMA_CSR_STATUS) & in msgdma_copy_one()
520 mdev->idle = false; in msgdma_copy_one()
529 * @mdev: Pointer to the Altera mSGDMA device structure
532 static void msgdma_copy_desc_to_fifo(struct msgdma_device *mdev, in msgdma_copy_desc_to_fifo() argument
537 msgdma_copy_one(mdev, desc); in msgdma_copy_desc_to_fifo()
540 msgdma_copy_one(mdev, sdesc); in msgdma_copy_desc_to_fifo()
545 * @mdev: Pointer to the Altera mSGDMA device structure
547 static void msgdma_start_transfer(struct msgdma_device *mdev) in msgdma_start_transfer() argument
551 if (!mdev->idle) in msgdma_start_transfer()
554 desc = list_first_entry_or_null(&mdev->pending_list, in msgdma_start_transfer()
559 list_splice_tail_init(&mdev->pending_list, &mdev->active_list); in msgdma_start_transfer()
560 msgdma_copy_desc_to_fifo(mdev, desc); in msgdma_start_transfer()
569 struct msgdma_device *mdev = to_mdev(chan); in msgdma_issue_pending() local
572 spin_lock_irqsave(&mdev->lock, flags); in msgdma_issue_pending()
573 msgdma_start_transfer(mdev); in msgdma_issue_pending()
574 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_issue_pending()
579 * @mdev: Pointer to the Altera mSGDMA device structure
581 static void msgdma_chan_desc_cleanup(struct msgdma_device *mdev) in msgdma_chan_desc_cleanup() argument
586 spin_lock_irqsave(&mdev->lock, irqflags); in msgdma_chan_desc_cleanup()
588 list_for_each_entry_safe(desc, next, &mdev->done_list, node) { in msgdma_chan_desc_cleanup()
593 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_chan_desc_cleanup()
595 spin_lock_irqsave(&mdev->lock, irqflags); in msgdma_chan_desc_cleanup()
599 msgdma_free_descriptor(mdev, desc); in msgdma_chan_desc_cleanup()
602 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_chan_desc_cleanup()
607 * @mdev: Pointer to the Altera mSGDMA device structure
609 static void msgdma_complete_descriptor(struct msgdma_device *mdev) in msgdma_complete_descriptor() argument
613 desc = list_first_entry_or_null(&mdev->active_list, in msgdma_complete_descriptor()
619 list_add_tail(&desc->node, &mdev->done_list); in msgdma_complete_descriptor()
624 * @mdev: Pointer to the Altera mSGDMA device structure
626 static void msgdma_free_descriptors(struct msgdma_device *mdev) in msgdma_free_descriptors() argument
628 msgdma_free_desc_list(mdev, &mdev->active_list); in msgdma_free_descriptors()
629 msgdma_free_desc_list(mdev, &mdev->pending_list); in msgdma_free_descriptors()
630 msgdma_free_desc_list(mdev, &mdev->done_list); in msgdma_free_descriptors()
639 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_free_chan_resources() local
642 spin_lock_irqsave(&mdev->lock, flags); in msgdma_free_chan_resources()
643 msgdma_free_descriptors(mdev); in msgdma_free_chan_resources()
644 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_free_chan_resources()
645 kfree(mdev->sw_desq); in msgdma_free_chan_resources()
656 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_alloc_chan_resources() local
660 mdev->sw_desq = kzalloc_objs(*desc, MSGDMA_DESC_NUM, GFP_NOWAIT); in msgdma_alloc_chan_resources()
661 if (!mdev->sw_desq) in msgdma_alloc_chan_resources()
664 mdev->idle = true; in msgdma_alloc_chan_resources()
665 mdev->desc_free_cnt = MSGDMA_DESC_NUM; in msgdma_alloc_chan_resources()
667 INIT_LIST_HEAD(&mdev->free_list); in msgdma_alloc_chan_resources()
670 desc = mdev->sw_desq + i; in msgdma_alloc_chan_resources()
671 dma_async_tx_descriptor_init(&desc->async_tx, &mdev->dmachan); in msgdma_alloc_chan_resources()
673 list_add_tail(&desc->node, &mdev->free_list); in msgdma_alloc_chan_resources()
685 struct msgdma_device *mdev = from_tasklet(mdev, t, irq_tasklet); in msgdma_tasklet() local
691 spin_lock_irqsave(&mdev->lock, flags); in msgdma_tasklet()
693 if (mdev->resp) { in msgdma_tasklet()
695 count = ioread32(mdev->csr + MSGDMA_CSR_RESP_FILL_LEVEL); in msgdma_tasklet()
696 dev_dbg(mdev->dev, "%s (%d): response count=%d\n", in msgdma_tasklet()
709 if (mdev->resp) { in msgdma_tasklet()
710 size = ioread32(mdev->resp + in msgdma_tasklet()
712 status = ioread32(mdev->resp + in msgdma_tasklet()
716 msgdma_complete_descriptor(mdev); in msgdma_tasklet()
719 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_tasklet()
721 msgdma_chan_desc_cleanup(mdev); in msgdma_tasklet()
733 struct msgdma_device *mdev = data; in msgdma_irq_handler() local
736 status = ioread32(mdev->csr + MSGDMA_CSR_STATUS); in msgdma_irq_handler()
739 spin_lock(&mdev->lock); in msgdma_irq_handler()
740 mdev->idle = true; in msgdma_irq_handler()
741 msgdma_start_transfer(mdev); in msgdma_irq_handler()
742 spin_unlock(&mdev->lock); in msgdma_irq_handler()
745 tasklet_schedule(&mdev->irq_tasklet); in msgdma_irq_handler()
748 iowrite32(MSGDMA_CSR_STAT_IRQ, mdev->csr + MSGDMA_CSR_STATUS); in msgdma_irq_handler()
755 * @mdev: Pointer to the Altera mSGDMA device structure
757 static void msgdma_dev_remove(struct msgdma_device *mdev) in msgdma_dev_remove() argument
759 if (!mdev) in msgdma_dev_remove()
762 devm_free_irq(mdev->dev, mdev->irq, mdev); in msgdma_dev_remove()
763 tasklet_kill(&mdev->irq_tasklet); in msgdma_dev_remove()
764 list_del(&mdev->dmachan.device_node); in msgdma_dev_remove()
811 struct msgdma_device *mdev; in msgdma_probe() local
816 mdev = devm_kzalloc(&pdev->dev, sizeof(*mdev), GFP_NOWAIT); in msgdma_probe()
817 if (!mdev) in msgdma_probe()
820 mdev->dev = &pdev->dev; in msgdma_probe()
823 ret = request_and_map(pdev, "csr", &dma_res, &mdev->csr, false); in msgdma_probe()
828 ret = request_and_map(pdev, "desc", &dma_res, &mdev->desc, false); in msgdma_probe()
833 ret = request_and_map(pdev, "resp", &dma_res, &mdev->resp, true); in msgdma_probe()
837 platform_set_drvdata(pdev, mdev); in msgdma_probe()
840 mdev->irq = platform_get_irq(pdev, 0); in msgdma_probe()
841 if (mdev->irq < 0) in msgdma_probe()
844 ret = devm_request_irq(&pdev->dev, mdev->irq, msgdma_irq_handler, in msgdma_probe()
845 0, dev_name(&pdev->dev), mdev); in msgdma_probe()
849 tasklet_setup(&mdev->irq_tasklet, msgdma_tasklet); in msgdma_probe()
851 dma_cookie_init(&mdev->dmachan); in msgdma_probe()
853 spin_lock_init(&mdev->lock); in msgdma_probe()
855 INIT_LIST_HEAD(&mdev->active_list); in msgdma_probe()
856 INIT_LIST_HEAD(&mdev->pending_list); in msgdma_probe()
857 INIT_LIST_HEAD(&mdev->done_list); in msgdma_probe()
858 INIT_LIST_HEAD(&mdev->free_list); in msgdma_probe()
860 dma_dev = &mdev->dmadev; in msgdma_probe()
889 mdev->dmachan.device = dma_dev; in msgdma_probe()
890 list_add_tail(&mdev->dmachan.device_node, &dma_dev->channels); in msgdma_probe()
899 msgdma_reset(mdev); in msgdma_probe()
917 msgdma_dev_remove(mdev); in msgdma_probe()
930 struct msgdma_device *mdev = platform_get_drvdata(pdev); in msgdma_remove() local
934 dma_async_device_unregister(&mdev->dmadev); in msgdma_remove()
935 msgdma_dev_remove(mdev); in msgdma_remove()