Lines Matching refs:mdev
208 static struct msgdma_sw_desc *msgdma_get_descriptor(struct msgdma_device *mdev) in msgdma_get_descriptor() argument
213 spin_lock_irqsave(&mdev->lock, flags); in msgdma_get_descriptor()
214 desc = list_first_entry(&mdev->free_list, struct msgdma_sw_desc, node); in msgdma_get_descriptor()
216 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_get_descriptor()
228 static void msgdma_free_descriptor(struct msgdma_device *mdev, in msgdma_free_descriptor() argument
233 mdev->desc_free_cnt++; in msgdma_free_descriptor()
234 list_add_tail(&desc->node, &mdev->free_list); in msgdma_free_descriptor()
236 mdev->desc_free_cnt++; in msgdma_free_descriptor()
237 list_move_tail(&child->node, &mdev->free_list); in msgdma_free_descriptor()
246 static void msgdma_free_desc_list(struct msgdma_device *mdev, in msgdma_free_desc_list() argument
252 msgdma_free_descriptor(mdev, desc); in msgdma_free_desc_list()
303 struct msgdma_device *mdev = to_mdev(tx->chan); in msgdma_tx_submit() local
309 spin_lock_irqsave(&mdev->lock, flags); in msgdma_tx_submit()
312 list_add_tail(&new->node, &mdev->pending_list); in msgdma_tx_submit()
313 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_tx_submit()
332 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_prep_memcpy() local
341 spin_lock_irqsave(&mdev->lock, irqflags); in msgdma_prep_memcpy()
342 if (desc_cnt > mdev->desc_free_cnt) { in msgdma_prep_memcpy()
343 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_prep_memcpy()
344 dev_dbg(mdev->dev, "mdev %p descs are not available\n", mdev); in msgdma_prep_memcpy()
347 mdev->desc_free_cnt -= desc_cnt; in msgdma_prep_memcpy()
348 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_prep_memcpy()
352 new = msgdma_get_descriptor(mdev); in msgdma_prep_memcpy()
390 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_prep_slave_sg() local
391 struct dma_slave_config *cfg = &mdev->slave_cfg; in msgdma_prep_slave_sg()
404 spin_lock_irqsave(&mdev->lock, irqflags); in msgdma_prep_slave_sg()
405 if (desc_cnt > mdev->desc_free_cnt) { in msgdma_prep_slave_sg()
406 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_prep_slave_sg()
407 dev_dbg(mdev->dev, "mdev %p descs are not available\n", mdev); in msgdma_prep_slave_sg()
410 mdev->desc_free_cnt -= desc_cnt; in msgdma_prep_slave_sg()
411 spin_unlock_irqrestore(&mdev->lock, irqflags); in msgdma_prep_slave_sg()
418 new = msgdma_get_descriptor(mdev); in msgdma_prep_slave_sg()
461 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_dma_config() local
463 memcpy(&mdev->slave_cfg, config, sizeof(*config)); in msgdma_dma_config()
468 static void msgdma_reset(struct msgdma_device *mdev) in msgdma_reset() argument
474 iowrite32(MSGDMA_CSR_STAT_MASK, mdev->csr + MSGDMA_CSR_STATUS); in msgdma_reset()
475 iowrite32(MSGDMA_CSR_CTL_RESET, mdev->csr + MSGDMA_CSR_CONTROL); in msgdma_reset()
477 ret = readl_poll_timeout(mdev->csr + MSGDMA_CSR_STATUS, val, in msgdma_reset()
481 dev_err(mdev->dev, "DMA channel did not reset\n"); in msgdma_reset()
484 iowrite32(MSGDMA_CSR_STAT_MASK, mdev->csr + MSGDMA_CSR_STATUS); in msgdma_reset()
488 MSGDMA_CSR_CTL_GLOBAL_INTR, mdev->csr + MSGDMA_CSR_CONTROL); in msgdma_reset()
490 mdev->idle = true; in msgdma_reset()
493 static void msgdma_copy_one(struct msgdma_device *mdev, in msgdma_copy_one() argument
496 void __iomem *hw_desc = mdev->desc; in msgdma_copy_one()
502 while (ioread32(mdev->csr + MSGDMA_CSR_STATUS) & in msgdma_copy_one()
519 mdev->idle = false; in msgdma_copy_one()
531 static void msgdma_copy_desc_to_fifo(struct msgdma_device *mdev, in msgdma_copy_desc_to_fifo() argument
536 msgdma_copy_one(mdev, desc); in msgdma_copy_desc_to_fifo()
539 msgdma_copy_one(mdev, sdesc); in msgdma_copy_desc_to_fifo()
546 static void msgdma_start_transfer(struct msgdma_device *mdev) in msgdma_start_transfer() argument
550 if (!mdev->idle) in msgdma_start_transfer()
553 desc = list_first_entry_or_null(&mdev->pending_list, in msgdma_start_transfer()
558 list_splice_tail_init(&mdev->pending_list, &mdev->active_list); in msgdma_start_transfer()
559 msgdma_copy_desc_to_fifo(mdev, desc); in msgdma_start_transfer()
568 struct msgdma_device *mdev = to_mdev(chan); in msgdma_issue_pending() local
571 spin_lock_irqsave(&mdev->lock, flags); in msgdma_issue_pending()
572 msgdma_start_transfer(mdev); in msgdma_issue_pending()
573 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_issue_pending()
580 static void msgdma_chan_desc_cleanup(struct msgdma_device *mdev) in msgdma_chan_desc_cleanup() argument
584 list_for_each_entry_safe(desc, next, &mdev->done_list, node) { in msgdma_chan_desc_cleanup()
593 spin_unlock(&mdev->lock); in msgdma_chan_desc_cleanup()
595 spin_lock(&mdev->lock); in msgdma_chan_desc_cleanup()
599 msgdma_free_descriptor(mdev, desc); in msgdma_chan_desc_cleanup()
607 static void msgdma_complete_descriptor(struct msgdma_device *mdev) in msgdma_complete_descriptor() argument
611 desc = list_first_entry_or_null(&mdev->active_list, in msgdma_complete_descriptor()
617 list_add_tail(&desc->node, &mdev->done_list); in msgdma_complete_descriptor()
624 static void msgdma_free_descriptors(struct msgdma_device *mdev) in msgdma_free_descriptors() argument
626 msgdma_free_desc_list(mdev, &mdev->active_list); in msgdma_free_descriptors()
627 msgdma_free_desc_list(mdev, &mdev->pending_list); in msgdma_free_descriptors()
628 msgdma_free_desc_list(mdev, &mdev->done_list); in msgdma_free_descriptors()
637 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_free_chan_resources() local
640 spin_lock_irqsave(&mdev->lock, flags); in msgdma_free_chan_resources()
641 msgdma_free_descriptors(mdev); in msgdma_free_chan_resources()
642 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_free_chan_resources()
643 kfree(mdev->sw_desq); in msgdma_free_chan_resources()
654 struct msgdma_device *mdev = to_mdev(dchan); in msgdma_alloc_chan_resources() local
658 mdev->sw_desq = kcalloc(MSGDMA_DESC_NUM, sizeof(*desc), GFP_NOWAIT); in msgdma_alloc_chan_resources()
659 if (!mdev->sw_desq) in msgdma_alloc_chan_resources()
662 mdev->idle = true; in msgdma_alloc_chan_resources()
663 mdev->desc_free_cnt = MSGDMA_DESC_NUM; in msgdma_alloc_chan_resources()
665 INIT_LIST_HEAD(&mdev->free_list); in msgdma_alloc_chan_resources()
668 desc = mdev->sw_desq + i; in msgdma_alloc_chan_resources()
669 dma_async_tx_descriptor_init(&desc->async_tx, &mdev->dmachan); in msgdma_alloc_chan_resources()
671 list_add_tail(&desc->node, &mdev->free_list); in msgdma_alloc_chan_resources()
683 struct msgdma_device *mdev = (struct msgdma_device *)data; in msgdma_tasklet() local
689 spin_lock_irqsave(&mdev->lock, flags); in msgdma_tasklet()
692 count = ioread32(mdev->csr + MSGDMA_CSR_RESP_FILL_LEVEL); in msgdma_tasklet()
693 dev_dbg(mdev->dev, "%s (%d): response count=%d\n", in msgdma_tasklet()
703 size = ioread32(mdev->resp + MSGDMA_RESP_BYTES_TRANSFERRED); in msgdma_tasklet()
704 status = ioread32(mdev->resp + MSGDMA_RESP_STATUS); in msgdma_tasklet()
706 msgdma_complete_descriptor(mdev); in msgdma_tasklet()
707 msgdma_chan_desc_cleanup(mdev); in msgdma_tasklet()
710 spin_unlock_irqrestore(&mdev->lock, flags); in msgdma_tasklet()
722 struct msgdma_device *mdev = data; in msgdma_irq_handler() local
725 status = ioread32(mdev->csr + MSGDMA_CSR_STATUS); in msgdma_irq_handler()
728 spin_lock(&mdev->lock); in msgdma_irq_handler()
729 mdev->idle = true; in msgdma_irq_handler()
730 msgdma_start_transfer(mdev); in msgdma_irq_handler()
731 spin_unlock(&mdev->lock); in msgdma_irq_handler()
734 tasklet_schedule(&mdev->irq_tasklet); in msgdma_irq_handler()
737 iowrite32(MSGDMA_CSR_STAT_IRQ, mdev->csr + MSGDMA_CSR_STATUS); in msgdma_irq_handler()
746 static void msgdma_dev_remove(struct msgdma_device *mdev) in msgdma_dev_remove() argument
748 if (!mdev) in msgdma_dev_remove()
751 devm_free_irq(mdev->dev, mdev->irq, mdev); in msgdma_dev_remove()
752 tasklet_kill(&mdev->irq_tasklet); in msgdma_dev_remove()
753 list_del(&mdev->dmachan.device_node); in msgdma_dev_remove()
793 struct msgdma_device *mdev; in msgdma_probe() local
798 mdev = devm_kzalloc(&pdev->dev, sizeof(*mdev), GFP_NOWAIT); in msgdma_probe()
799 if (!mdev) in msgdma_probe()
802 mdev->dev = &pdev->dev; in msgdma_probe()
805 ret = request_and_map(pdev, "csr", &dma_res, &mdev->csr); in msgdma_probe()
810 ret = request_and_map(pdev, "desc", &dma_res, &mdev->desc); in msgdma_probe()
815 ret = request_and_map(pdev, "resp", &dma_res, &mdev->resp); in msgdma_probe()
819 platform_set_drvdata(pdev, mdev); in msgdma_probe()
822 mdev->irq = platform_get_irq(pdev, 0); in msgdma_probe()
823 if (mdev->irq < 0) in msgdma_probe()
826 ret = devm_request_irq(&pdev->dev, mdev->irq, msgdma_irq_handler, in msgdma_probe()
827 0, dev_name(&pdev->dev), mdev); in msgdma_probe()
831 tasklet_init(&mdev->irq_tasklet, msgdma_tasklet, (unsigned long)mdev); in msgdma_probe()
833 dma_cookie_init(&mdev->dmachan); in msgdma_probe()
835 spin_lock_init(&mdev->lock); in msgdma_probe()
837 INIT_LIST_HEAD(&mdev->active_list); in msgdma_probe()
838 INIT_LIST_HEAD(&mdev->pending_list); in msgdma_probe()
839 INIT_LIST_HEAD(&mdev->done_list); in msgdma_probe()
840 INIT_LIST_HEAD(&mdev->free_list); in msgdma_probe()
842 dma_dev = &mdev->dmadev; in msgdma_probe()
871 mdev->dmachan.device = dma_dev; in msgdma_probe()
872 list_add_tail(&mdev->dmachan.device_node, &dma_dev->channels); in msgdma_probe()
883 msgdma_reset(mdev); in msgdma_probe()
894 msgdma_dev_remove(mdev); in msgdma_probe()
907 struct msgdma_device *mdev = platform_get_drvdata(pdev); in msgdma_remove() local
909 dma_async_device_unregister(&mdev->dmadev); in msgdma_remove()
910 msgdma_dev_remove(mdev); in msgdma_remove()