Lines Matching refs:cqdma
163 static struct device *cqdma2dev(struct mtk_cqdma_device *cqdma) in cqdma2dev() argument
165 return cqdma->ddev.dev; in cqdma2dev()
387 struct mtk_cqdma_device *cqdma = devid; in mtk_cqdma_irq() local
393 for (i = 0; i < cqdma->dma_channels; ++i, schedule_tasklet = false) { in mtk_cqdma_irq()
394 spin_lock(&cqdma->pc[i]->lock); in mtk_cqdma_irq()
395 if (mtk_dma_read(cqdma->pc[i], in mtk_cqdma_irq()
398 mtk_dma_clr(cqdma->pc[i], MTK_CQDMA_INT_FLAG, in mtk_cqdma_irq()
404 spin_unlock(&cqdma->pc[i]->lock); in mtk_cqdma_irq()
408 disable_irq_nosync(cqdma->pc[i]->irq); in mtk_cqdma_irq()
411 tasklet_schedule(&cqdma->pc[i]->tasklet); in mtk_cqdma_irq()
614 struct mtk_cqdma_device *cqdma = to_cqdma_dev(c); in mtk_cqdma_alloc_chan_resources() local
621 for (i = 0; i < cqdma->dma_channels; ++i) { in mtk_cqdma_alloc_chan_resources()
622 refcnt = refcount_read(&cqdma->pc[i]->refcnt); in mtk_cqdma_alloc_chan_resources()
624 pc = cqdma->pc[i]; in mtk_cqdma_alloc_chan_resources()
688 static int mtk_cqdma_hw_init(struct mtk_cqdma_device *cqdma) in mtk_cqdma_hw_init() argument
694 pm_runtime_enable(cqdma2dev(cqdma)); in mtk_cqdma_hw_init()
695 pm_runtime_get_sync(cqdma2dev(cqdma)); in mtk_cqdma_hw_init()
697 err = clk_prepare_enable(cqdma->clk); in mtk_cqdma_hw_init()
700 pm_runtime_put_sync(cqdma2dev(cqdma)); in mtk_cqdma_hw_init()
701 pm_runtime_disable(cqdma2dev(cqdma)); in mtk_cqdma_hw_init()
706 for (i = 0; i < cqdma->dma_channels; ++i) { in mtk_cqdma_hw_init()
707 spin_lock_irqsave(&cqdma->pc[i]->lock, flags); in mtk_cqdma_hw_init()
708 if (mtk_cqdma_hard_reset(cqdma->pc[i]) < 0) { in mtk_cqdma_hw_init()
709 dev_err(cqdma2dev(cqdma), "cqdma hard reset timeout\n"); in mtk_cqdma_hw_init()
710 spin_unlock_irqrestore(&cqdma->pc[i]->lock, flags); in mtk_cqdma_hw_init()
712 clk_disable_unprepare(cqdma->clk); in mtk_cqdma_hw_init()
713 pm_runtime_put_sync(cqdma2dev(cqdma)); in mtk_cqdma_hw_init()
714 pm_runtime_disable(cqdma2dev(cqdma)); in mtk_cqdma_hw_init()
717 spin_unlock_irqrestore(&cqdma->pc[i]->lock, flags); in mtk_cqdma_hw_init()
723 static void mtk_cqdma_hw_deinit(struct mtk_cqdma_device *cqdma) in mtk_cqdma_hw_deinit() argument
729 for (i = 0; i < cqdma->dma_channels; ++i) { in mtk_cqdma_hw_deinit()
730 spin_lock_irqsave(&cqdma->pc[i]->lock, flags); in mtk_cqdma_hw_deinit()
731 if (mtk_cqdma_hard_reset(cqdma->pc[i]) < 0) in mtk_cqdma_hw_deinit()
732 dev_err(cqdma2dev(cqdma), "cqdma hard reset timeout\n"); in mtk_cqdma_hw_deinit()
733 spin_unlock_irqrestore(&cqdma->pc[i]->lock, flags); in mtk_cqdma_hw_deinit()
736 clk_disable_unprepare(cqdma->clk); in mtk_cqdma_hw_deinit()
738 pm_runtime_put_sync(cqdma2dev(cqdma)); in mtk_cqdma_hw_deinit()
739 pm_runtime_disable(cqdma2dev(cqdma)); in mtk_cqdma_hw_deinit()
750 struct mtk_cqdma_device *cqdma; in mtk_cqdma_probe() local
756 cqdma = devm_kzalloc(&pdev->dev, sizeof(*cqdma), GFP_KERNEL); in mtk_cqdma_probe()
757 if (!cqdma) in mtk_cqdma_probe()
760 dd = &cqdma->ddev; in mtk_cqdma_probe()
762 cqdma->clk = devm_clk_get(&pdev->dev, "cqdma"); in mtk_cqdma_probe()
763 if (IS_ERR(cqdma->clk)) { in mtk_cqdma_probe()
766 return PTR_ERR(cqdma->clk); in mtk_cqdma_probe()
787 &cqdma->dma_requests)) { in mtk_cqdma_probe()
792 cqdma->dma_requests = MTK_CQDMA_NR_VCHANS; in mtk_cqdma_probe()
797 &cqdma->dma_channels)) { in mtk_cqdma_probe()
802 cqdma->dma_channels = MTK_CQDMA_NR_PCHANS; in mtk_cqdma_probe()
805 cqdma->pc = devm_kcalloc(&pdev->dev, cqdma->dma_channels, in mtk_cqdma_probe()
806 sizeof(*cqdma->pc), GFP_KERNEL); in mtk_cqdma_probe()
807 if (!cqdma->pc) in mtk_cqdma_probe()
811 for (i = 0; i < cqdma->dma_channels; ++i) { in mtk_cqdma_probe()
812 cqdma->pc[i] = devm_kcalloc(&pdev->dev, 1, in mtk_cqdma_probe()
813 sizeof(**cqdma->pc), GFP_KERNEL); in mtk_cqdma_probe()
814 if (!cqdma->pc[i]) in mtk_cqdma_probe()
817 INIT_LIST_HEAD(&cqdma->pc[i]->queue); in mtk_cqdma_probe()
818 spin_lock_init(&cqdma->pc[i]->lock); in mtk_cqdma_probe()
819 refcount_set(&cqdma->pc[i]->refcnt, 0); in mtk_cqdma_probe()
820 cqdma->pc[i]->base = devm_platform_ioremap_resource(pdev, i); in mtk_cqdma_probe()
821 if (IS_ERR(cqdma->pc[i]->base)) in mtk_cqdma_probe()
822 return PTR_ERR(cqdma->pc[i]->base); in mtk_cqdma_probe()
828 cqdma->pc[i]->irq = err; in mtk_cqdma_probe()
830 err = devm_request_irq(&pdev->dev, cqdma->pc[i]->irq, in mtk_cqdma_probe()
832 cqdma); in mtk_cqdma_probe()
841 cqdma->vc = devm_kcalloc(&pdev->dev, cqdma->dma_requests, in mtk_cqdma_probe()
842 sizeof(*cqdma->vc), GFP_KERNEL); in mtk_cqdma_probe()
843 if (!cqdma->vc) in mtk_cqdma_probe()
846 for (i = 0; i < cqdma->dma_requests; i++) { in mtk_cqdma_probe()
847 vc = &cqdma->vc[i]; in mtk_cqdma_probe()
858 of_dma_xlate_by_chan_id, cqdma); in mtk_cqdma_probe()
865 err = mtk_cqdma_hw_init(cqdma); in mtk_cqdma_probe()
872 platform_set_drvdata(pdev, cqdma); in mtk_cqdma_probe()
875 for (i = 0; i < cqdma->dma_channels; ++i) in mtk_cqdma_probe()
876 tasklet_setup(&cqdma->pc[i]->tasklet, mtk_cqdma_tasklet_cb); in mtk_cqdma_probe()
890 struct mtk_cqdma_device *cqdma = platform_get_drvdata(pdev); in mtk_cqdma_remove() local
896 for (i = 0; i < cqdma->dma_requests; i++) { in mtk_cqdma_remove()
897 vc = &cqdma->vc[i]; in mtk_cqdma_remove()
904 for (i = 0; i < cqdma->dma_channels; i++) { in mtk_cqdma_remove()
905 spin_lock_irqsave(&cqdma->pc[i]->lock, flags); in mtk_cqdma_remove()
906 mtk_dma_clr(cqdma->pc[i], MTK_CQDMA_INT_EN, in mtk_cqdma_remove()
908 spin_unlock_irqrestore(&cqdma->pc[i]->lock, flags); in mtk_cqdma_remove()
911 synchronize_irq(cqdma->pc[i]->irq); in mtk_cqdma_remove()
913 tasklet_kill(&cqdma->pc[i]->tasklet); in mtk_cqdma_remove()
917 mtk_cqdma_hw_deinit(cqdma); in mtk_cqdma_remove()
919 dma_async_device_unregister(&cqdma->ddev); in mtk_cqdma_remove()