Lines Matching refs:xor_dev
191 static void mv_xor_v2_set_data_buffers(struct mv_xor_v2_device *xor_dev, in mv_xor_v2_set_data_buffers() argument
227 static void mv_xor_v2_add_desc_to_desq(struct mv_xor_v2_device *xor_dev, in mv_xor_v2_add_desc_to_desq() argument
231 writel(num_of_desc, xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_ADD_OFF); in mv_xor_v2_add_desc_to_desq()
237 static void mv_xor_v2_free_desc_from_desq(struct mv_xor_v2_device *xor_dev, in mv_xor_v2_free_desc_from_desq() argument
241 writel(num_of_desc, xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_DEALLOC_OFF); in mv_xor_v2_free_desc_from_desq()
248 static int mv_xor_v2_set_desc_size(struct mv_xor_v2_device *xor_dev) in mv_xor_v2_set_desc_size() argument
251 xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_CTRL_OFF); in mv_xor_v2_set_desc_size()
260 void mv_xor_v2_enable_imsg_thrd(struct mv_xor_v2_device *xor_dev) in mv_xor_v2_enable_imsg_thrd() argument
265 reg = readl(xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_THRD_OFF); in mv_xor_v2_enable_imsg_thrd()
269 writel(reg, xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_THRD_OFF); in mv_xor_v2_enable_imsg_thrd()
272 reg = readl(xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_TMOT); in mv_xor_v2_enable_imsg_thrd()
275 writel(reg, xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_TMOT); in mv_xor_v2_enable_imsg_thrd()
280 struct mv_xor_v2_device *xor_dev = data; in mv_xor_v2_interrupt_handler() local
284 reg = readl(xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_DONE_OFF); in mv_xor_v2_interrupt_handler()
294 tasklet_schedule(&xor_dev->irq_tasklet); in mv_xor_v2_interrupt_handler()
309 struct mv_xor_v2_device *xor_dev = in mv_xor_v2_tx_submit() local
312 dev_dbg(xor_dev->dmadev.dev, in mv_xor_v2_tx_submit()
317 spin_lock_bh(&xor_dev->lock); in mv_xor_v2_tx_submit()
321 dest_hw_desc = xor_dev->hw_desq_virt + xor_dev->hw_queue_idx; in mv_xor_v2_tx_submit()
323 memcpy(dest_hw_desc, &sw_desc->hw_desc, xor_dev->desc_size); in mv_xor_v2_tx_submit()
325 xor_dev->npendings++; in mv_xor_v2_tx_submit()
326 xor_dev->hw_queue_idx++; in mv_xor_v2_tx_submit()
327 if (xor_dev->hw_queue_idx >= MV_XOR_V2_DESC_NUM) in mv_xor_v2_tx_submit()
328 xor_dev->hw_queue_idx = 0; in mv_xor_v2_tx_submit()
330 spin_unlock_bh(&xor_dev->lock); in mv_xor_v2_tx_submit()
339 mv_xor_v2_prep_sw_desc(struct mv_xor_v2_device *xor_dev) in mv_xor_v2_prep_sw_desc() argument
345 spin_lock_bh(&xor_dev->lock); in mv_xor_v2_prep_sw_desc()
347 if (list_empty(&xor_dev->free_sw_desc)) { in mv_xor_v2_prep_sw_desc()
348 spin_unlock_bh(&xor_dev->lock); in mv_xor_v2_prep_sw_desc()
350 tasklet_schedule(&xor_dev->irq_tasklet); in mv_xor_v2_prep_sw_desc()
354 list_for_each_entry(sw_desc, &xor_dev->free_sw_desc, free_list) { in mv_xor_v2_prep_sw_desc()
362 spin_unlock_bh(&xor_dev->lock); in mv_xor_v2_prep_sw_desc()
369 spin_unlock_bh(&xor_dev->lock); in mv_xor_v2_prep_sw_desc()
383 struct mv_xor_v2_device *xor_dev; in mv_xor_v2_prep_dma_memcpy() local
385 xor_dev = container_of(chan, struct mv_xor_v2_device, dmachan); in mv_xor_v2_prep_dma_memcpy()
387 dev_dbg(xor_dev->dmadev.dev, in mv_xor_v2_prep_dma_memcpy()
391 sw_desc = mv_xor_v2_prep_sw_desc(xor_dev); in mv_xor_v2_prep_dma_memcpy()
436 struct mv_xor_v2_device *xor_dev = in mv_xor_v2_prep_dma_xor() local
443 dev_dbg(xor_dev->dmadev.dev, in mv_xor_v2_prep_dma_xor()
447 sw_desc = mv_xor_v2_prep_sw_desc(xor_dev); in mv_xor_v2_prep_dma_xor()
469 mv_xor_v2_set_data_buffers(xor_dev, hw_descriptor, src[i], i); in mv_xor_v2_prep_dma_xor()
494 struct mv_xor_v2_device *xor_dev = in mv_xor_v2_prep_dma_interrupt() local
497 sw_desc = mv_xor_v2_prep_sw_desc(xor_dev); in mv_xor_v2_prep_dma_interrupt()
521 struct mv_xor_v2_device *xor_dev = in mv_xor_v2_issue_pending() local
524 spin_lock_bh(&xor_dev->lock); in mv_xor_v2_issue_pending()
530 mv_xor_v2_add_desc_to_desq(xor_dev, xor_dev->npendings); in mv_xor_v2_issue_pending()
531 xor_dev->npendings = 0; in mv_xor_v2_issue_pending()
533 spin_unlock_bh(&xor_dev->lock); in mv_xor_v2_issue_pending()
537 int mv_xor_v2_get_pending_params(struct mv_xor_v2_device *xor_dev, in mv_xor_v2_get_pending_params() argument
542 reg = readl(xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_DONE_OFF); in mv_xor_v2_get_pending_params()
558 struct mv_xor_v2_device *xor_dev = from_tasklet(xor_dev, t, in mv_xor_v2_tasklet() local
563 dev_dbg(xor_dev->dmadev.dev, "%s %d\n", __func__, __LINE__); in mv_xor_v2_tasklet()
566 num_of_pending = mv_xor_v2_get_pending_params(xor_dev, &pending_ptr); in mv_xor_v2_tasklet()
571 xor_dev->hw_desq_virt + pending_ptr; in mv_xor_v2_tasklet()
575 &xor_dev->sw_desq[next_pending_hw_desc->desc_id]; in mv_xor_v2_tasklet()
594 spin_lock_bh(&xor_dev->lock); in mv_xor_v2_tasklet()
598 &xor_dev->free_sw_desc); in mv_xor_v2_tasklet()
601 spin_unlock_bh(&xor_dev->lock); in mv_xor_v2_tasklet()
611 mv_xor_v2_free_desc_from_desq(xor_dev, num_of_pending); in mv_xor_v2_tasklet()
620 struct mv_xor_v2_device *xor_dev = dev_get_drvdata(desc->dev); in mv_xor_v2_set_msi_msg() local
623 xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_BALR_OFF); in mv_xor_v2_set_msi_msg()
625 xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_BAHR_OFF); in mv_xor_v2_set_msi_msg()
627 xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_CDAT_OFF); in mv_xor_v2_set_msi_msg()
630 static int mv_xor_v2_descq_init(struct mv_xor_v2_device *xor_dev) in mv_xor_v2_descq_init() argument
636 xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_SIZE_OFF); in mv_xor_v2_descq_init()
639 writel(lower_32_bits(xor_dev->hw_desq), in mv_xor_v2_descq_init()
640 xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_BALR_OFF); in mv_xor_v2_descq_init()
641 writel(upper_32_bits(xor_dev->hw_desq), in mv_xor_v2_descq_init()
642 xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_BAHR_OFF); in mv_xor_v2_descq_init()
653 reg = readl(xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_ARATTR_OFF); in mv_xor_v2_descq_init()
657 writel(reg, xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_ARATTR_OFF); in mv_xor_v2_descq_init()
659 reg = readl(xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_AWATTR_OFF); in mv_xor_v2_descq_init()
663 writel(reg, xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_AWATTR_OFF); in mv_xor_v2_descq_init()
680 writel(reg, xor_dev->glob_base + MV_XOR_V2_GLOB_BW_CTRL); in mv_xor_v2_descq_init()
683 reg = readl(xor_dev->glob_base + MV_XOR_V2_GLOB_PAUSE); in mv_xor_v2_descq_init()
685 writel(reg, xor_dev->glob_base + MV_XOR_V2_GLOB_PAUSE); in mv_xor_v2_descq_init()
688 writel(0, xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_STOP_OFF); in mv_xor_v2_descq_init()
695 struct mv_xor_v2_device *xor_dev = platform_get_drvdata(dev); in mv_xor_v2_suspend() local
698 writel(0x1, xor_dev->dma_base + MV_XOR_V2_DMA_DESQ_STOP_OFF); in mv_xor_v2_suspend()
705 struct mv_xor_v2_device *xor_dev = platform_get_drvdata(dev); in mv_xor_v2_resume() local
707 mv_xor_v2_set_desc_size(xor_dev); in mv_xor_v2_resume()
708 mv_xor_v2_enable_imsg_thrd(xor_dev); in mv_xor_v2_resume()
709 mv_xor_v2_descq_init(xor_dev); in mv_xor_v2_resume()
716 struct mv_xor_v2_device *xor_dev; in mv_xor_v2_probe() local
726 xor_dev = devm_kzalloc(&pdev->dev, sizeof(*xor_dev), GFP_KERNEL); in mv_xor_v2_probe()
727 if (!xor_dev) in mv_xor_v2_probe()
731 xor_dev->dma_base = devm_ioremap_resource(&pdev->dev, res); in mv_xor_v2_probe()
732 if (IS_ERR(xor_dev->dma_base)) in mv_xor_v2_probe()
733 return PTR_ERR(xor_dev->dma_base); in mv_xor_v2_probe()
736 xor_dev->glob_base = devm_ioremap_resource(&pdev->dev, res); in mv_xor_v2_probe()
737 if (IS_ERR(xor_dev->glob_base)) in mv_xor_v2_probe()
738 return PTR_ERR(xor_dev->glob_base); in mv_xor_v2_probe()
740 platform_set_drvdata(pdev, xor_dev); in mv_xor_v2_probe()
746 xor_dev->reg_clk = devm_clk_get(&pdev->dev, "reg"); in mv_xor_v2_probe()
747 if (PTR_ERR(xor_dev->reg_clk) != -ENOENT) { in mv_xor_v2_probe()
748 if (!IS_ERR(xor_dev->reg_clk)) { in mv_xor_v2_probe()
749 ret = clk_prepare_enable(xor_dev->reg_clk); in mv_xor_v2_probe()
753 return PTR_ERR(xor_dev->reg_clk); in mv_xor_v2_probe()
757 xor_dev->clk = devm_clk_get(&pdev->dev, NULL); in mv_xor_v2_probe()
758 if (PTR_ERR(xor_dev->clk) == -EPROBE_DEFER) { in mv_xor_v2_probe()
762 if (!IS_ERR(xor_dev->clk)) { in mv_xor_v2_probe()
763 ret = clk_prepare_enable(xor_dev->clk); in mv_xor_v2_probe()
778 xor_dev->msi_desc = msi_desc; in mv_xor_v2_probe()
782 dev_name(&pdev->dev), xor_dev); in mv_xor_v2_probe()
786 tasklet_setup(&xor_dev->irq_tasklet, mv_xor_v2_tasklet); in mv_xor_v2_probe()
788 xor_dev->desc_size = mv_xor_v2_set_desc_size(xor_dev); in mv_xor_v2_probe()
790 dma_cookie_init(&xor_dev->dmachan); in mv_xor_v2_probe()
797 xor_dev->hw_desq_virt = in mv_xor_v2_probe()
799 xor_dev->desc_size * MV_XOR_V2_DESC_NUM, in mv_xor_v2_probe()
800 &xor_dev->hw_desq, GFP_KERNEL); in mv_xor_v2_probe()
801 if (!xor_dev->hw_desq_virt) { in mv_xor_v2_probe()
807 xor_dev->sw_desq = devm_kcalloc(&pdev->dev, in mv_xor_v2_probe()
810 if (!xor_dev->sw_desq) { in mv_xor_v2_probe()
815 spin_lock_init(&xor_dev->lock); in mv_xor_v2_probe()
818 INIT_LIST_HEAD(&xor_dev->free_sw_desc); in mv_xor_v2_probe()
823 xor_dev->sw_desq + i; in mv_xor_v2_probe()
826 &xor_dev->dmachan); in mv_xor_v2_probe()
831 &xor_dev->free_sw_desc); in mv_xor_v2_probe()
834 dma_dev = &xor_dev->dmadev; in mv_xor_v2_probe()
855 xor_dev->dmachan.device = dma_dev; in mv_xor_v2_probe()
857 list_add_tail(&xor_dev->dmachan.device_node, in mv_xor_v2_probe()
860 mv_xor_v2_enable_imsg_thrd(xor_dev); in mv_xor_v2_probe()
862 mv_xor_v2_descq_init(xor_dev); in mv_xor_v2_probe()
874 xor_dev->desc_size * MV_XOR_V2_DESC_NUM, in mv_xor_v2_probe()
875 xor_dev->hw_desq_virt, xor_dev->hw_desq); in mv_xor_v2_probe()
879 clk_disable_unprepare(xor_dev->clk); in mv_xor_v2_probe()
881 clk_disable_unprepare(xor_dev->reg_clk); in mv_xor_v2_probe()
887 struct mv_xor_v2_device *xor_dev = platform_get_drvdata(pdev); in mv_xor_v2_remove() local
889 dma_async_device_unregister(&xor_dev->dmadev); in mv_xor_v2_remove()
892 xor_dev->desc_size * MV_XOR_V2_DESC_NUM, in mv_xor_v2_remove()
893 xor_dev->hw_desq_virt, xor_dev->hw_desq); in mv_xor_v2_remove()
895 devm_free_irq(&pdev->dev, xor_dev->msi_desc->irq, xor_dev); in mv_xor_v2_remove()
899 tasklet_kill(&xor_dev->irq_tasklet); in mv_xor_v2_remove()
901 clk_disable_unprepare(xor_dev->clk); in mv_xor_v2_remove()