Lines Matching full:dmac

3  * Driver for the Analog Devices AXI-DMAC core
27 #include <dt-bindings/dma/axi-dmac.h>
33 * The AXI-DMAC is a soft IP core that is used in FPGA designs. The core has
209 struct axi_dmac *dmac = chan_to_axi_dmac(chan); in axi_dmac_start_transfer() local
216 val = axi_dmac_read(dmac, AXI_DMAC_REG_START_TRANSFER); in axi_dmac_start_transfer()
249 sg->id = axi_dmac_read(dmac, AXI_DMAC_REG_TRANSFER_ID); in axi_dmac_start_transfer()
252 axi_dmac_write(dmac, AXI_DMAC_REG_DEST_ADDRESS, sg->dest_addr); in axi_dmac_start_transfer()
253 axi_dmac_write(dmac, AXI_DMAC_REG_DEST_STRIDE, sg->dest_stride); in axi_dmac_start_transfer()
257 axi_dmac_write(dmac, AXI_DMAC_REG_SRC_ADDRESS, sg->src_addr); in axi_dmac_start_transfer()
258 axi_dmac_write(dmac, AXI_DMAC_REG_SRC_STRIDE, sg->src_stride); in axi_dmac_start_transfer()
273 axi_dmac_write(dmac, AXI_DMAC_REG_X_LENGTH, sg->x_len - 1); in axi_dmac_start_transfer()
274 axi_dmac_write(dmac, AXI_DMAC_REG_Y_LENGTH, sg->y_len - 1); in axi_dmac_start_transfer()
275 axi_dmac_write(dmac, AXI_DMAC_REG_FLAGS, flags); in axi_dmac_start_transfer()
276 axi_dmac_write(dmac, AXI_DMAC_REG_START_TRANSFER, 1); in axi_dmac_start_transfer()
296 struct axi_dmac *dmac = chan_to_axi_dmac(chan); in axi_dmac_dequeue_partial_xfers() local
303 len = axi_dmac_read(dmac, AXI_DMAC_REG_PARTIAL_XFER_LEN); in axi_dmac_dequeue_partial_xfers()
304 id = axi_dmac_read(dmac, AXI_DMAC_REG_PARTIAL_XFER_ID); in axi_dmac_dequeue_partial_xfers()
324 dev_dbg(dmac->dma_dev.dev, in axi_dmac_dequeue_partial_xfers()
328 dev_warn(dmac->dma_dev.dev, in axi_dmac_dequeue_partial_xfers()
334 xfer_done = axi_dmac_read(dmac, AXI_DMAC_REG_TRANSFER_DONE); in axi_dmac_dequeue_partial_xfers()
413 struct axi_dmac *dmac = devid; in axi_dmac_interrupt_handler() local
417 pending = axi_dmac_read(dmac, AXI_DMAC_REG_IRQ_PENDING); in axi_dmac_interrupt_handler()
421 axi_dmac_write(dmac, AXI_DMAC_REG_IRQ_PENDING, pending); in axi_dmac_interrupt_handler()
423 spin_lock(&dmac->chan.vchan.lock); in axi_dmac_interrupt_handler()
428 completed = axi_dmac_read(dmac, AXI_DMAC_REG_TRANSFER_DONE); in axi_dmac_interrupt_handler()
429 start_next = axi_dmac_transfer_done(&dmac->chan, completed); in axi_dmac_interrupt_handler()
433 axi_dmac_start_transfer(&dmac->chan); in axi_dmac_interrupt_handler()
434 spin_unlock(&dmac->chan.vchan.lock); in axi_dmac_interrupt_handler()
442 struct axi_dmac *dmac = chan_to_axi_dmac(chan); in axi_dmac_terminate_all() local
447 axi_dmac_write(dmac, AXI_DMAC_REG_CTRL, 0); in axi_dmac_terminate_all()
468 struct axi_dmac *dmac = chan_to_axi_dmac(chan); in axi_dmac_issue_pending() local
471 axi_dmac_write(dmac, AXI_DMAC_REG_CTRL, AXI_DMAC_CTRL_ENABLE); in axi_dmac_issue_pending()
795 static int axi_dmac_parse_dt(struct device *dev, struct axi_dmac *dmac) in axi_dmac_parse_dt() argument
805 ret = axi_dmac_parse_chan_dt(of_chan, &dmac->chan); in axi_dmac_parse_dt()
817 static int axi_dmac_read_chan_config(struct device *dev, struct axi_dmac *dmac) in axi_dmac_read_chan_config() argument
819 struct axi_dmac_chan *chan = &dmac->chan; in axi_dmac_read_chan_config()
822 desc = axi_dmac_read(dmac, AXI_DMAC_REG_INTERFACE_DESC); in axi_dmac_read_chan_config()
862 static int axi_dmac_detect_caps(struct axi_dmac *dmac, unsigned int version) in axi_dmac_detect_caps() argument
864 struct axi_dmac_chan *chan = &dmac->chan; in axi_dmac_detect_caps()
866 axi_dmac_write(dmac, AXI_DMAC_REG_FLAGS, AXI_DMAC_FLAG_CYCLIC); in axi_dmac_detect_caps()
867 if (axi_dmac_read(dmac, AXI_DMAC_REG_FLAGS) == AXI_DMAC_FLAG_CYCLIC) in axi_dmac_detect_caps()
870 axi_dmac_write(dmac, AXI_DMAC_REG_Y_LENGTH, 1); in axi_dmac_detect_caps()
871 if (axi_dmac_read(dmac, AXI_DMAC_REG_Y_LENGTH) == 1) in axi_dmac_detect_caps()
874 axi_dmac_write(dmac, AXI_DMAC_REG_X_LENGTH, 0xffffffff); in axi_dmac_detect_caps()
875 chan->max_length = axi_dmac_read(dmac, AXI_DMAC_REG_X_LENGTH); in axi_dmac_detect_caps()
879 axi_dmac_write(dmac, AXI_DMAC_REG_DEST_ADDRESS, 0xffffffff); in axi_dmac_detect_caps()
880 if (axi_dmac_read(dmac, AXI_DMAC_REG_DEST_ADDRESS) == 0 && in axi_dmac_detect_caps()
882 dev_err(dmac->dma_dev.dev, in axi_dmac_detect_caps()
887 axi_dmac_write(dmac, AXI_DMAC_REG_SRC_ADDRESS, 0xffffffff); in axi_dmac_detect_caps()
888 if (axi_dmac_read(dmac, AXI_DMAC_REG_SRC_ADDRESS) == 0 && in axi_dmac_detect_caps()
890 dev_err(dmac->dma_dev.dev, in axi_dmac_detect_caps()
899 axi_dmac_write(dmac, AXI_DMAC_REG_X_LENGTH, 0x00); in axi_dmac_detect_caps()
901 axi_dmac_read(dmac, AXI_DMAC_REG_X_LENGTH); in axi_dmac_detect_caps()
912 struct axi_dmac *dmac; in axi_dmac_probe() local
918 dmac = devm_kzalloc(&pdev->dev, sizeof(*dmac), GFP_KERNEL); in axi_dmac_probe()
919 if (!dmac) in axi_dmac_probe()
922 dmac->irq = platform_get_irq(pdev, 0); in axi_dmac_probe()
923 if (dmac->irq < 0) in axi_dmac_probe()
924 return dmac->irq; in axi_dmac_probe()
925 if (dmac->irq == 0) in axi_dmac_probe()
929 dmac->base = devm_ioremap_resource(&pdev->dev, res); in axi_dmac_probe()
930 if (IS_ERR(dmac->base)) in axi_dmac_probe()
931 return PTR_ERR(dmac->base); in axi_dmac_probe()
933 dmac->clk = devm_clk_get(&pdev->dev, NULL); in axi_dmac_probe()
934 if (IS_ERR(dmac->clk)) in axi_dmac_probe()
935 return PTR_ERR(dmac->clk); in axi_dmac_probe()
937 ret = clk_prepare_enable(dmac->clk); in axi_dmac_probe()
941 version = axi_dmac_read(dmac, ADI_AXI_REG_VERSION); in axi_dmac_probe()
944 ret = axi_dmac_read_chan_config(&pdev->dev, dmac); in axi_dmac_probe()
946 ret = axi_dmac_parse_dt(&pdev->dev, dmac); in axi_dmac_probe()
951 INIT_LIST_HEAD(&dmac->chan.active_descs); in axi_dmac_probe()
955 dma_dev = &dmac->dma_dev; in axi_dmac_probe()
969 dma_dev->src_addr_widths = BIT(dmac->chan.src_width); in axi_dmac_probe()
970 dma_dev->dst_addr_widths = BIT(dmac->chan.dest_width); in axi_dmac_probe()
971 dma_dev->directions = BIT(dmac->chan.direction); in axi_dmac_probe()
975 dmac->chan.vchan.desc_free = axi_dmac_desc_free; in axi_dmac_probe()
976 vchan_init(&dmac->chan.vchan, dma_dev); in axi_dmac_probe()
978 ret = axi_dmac_detect_caps(dmac, version); in axi_dmac_probe()
982 dma_dev->copy_align = (dmac->chan.address_align_mask + 1); in axi_dmac_probe()
984 axi_dmac_write(dmac, AXI_DMAC_REG_IRQ_MASK, 0x00); in axi_dmac_probe()
987 ret = axi_dmac_read(dmac, AXI_DMAC_REG_COHERENCY_DESC); in axi_dmac_probe()
991 dev_err(dmac->dma_dev.dev, in axi_dmac_probe()
1007 ret = request_irq(dmac->irq, axi_dmac_interrupt_handler, IRQF_SHARED, in axi_dmac_probe()
1008 dev_name(&pdev->dev), dmac); in axi_dmac_probe()
1012 platform_set_drvdata(pdev, dmac); in axi_dmac_probe()
1014 regmap = devm_regmap_init_mmio(&pdev->dev, dmac->base, in axi_dmac_probe()
1024 free_irq(dmac->irq, dmac); in axi_dmac_probe()
1028 dma_async_device_unregister(&dmac->dma_dev); in axi_dmac_probe()
1030 clk_disable_unprepare(dmac->clk); in axi_dmac_probe()
1037 struct axi_dmac *dmac = platform_get_drvdata(pdev); in axi_dmac_remove() local
1040 free_irq(dmac->irq, dmac); in axi_dmac_remove()
1041 tasklet_kill(&dmac->chan.vchan.task); in axi_dmac_remove()
1042 dma_async_device_unregister(&dmac->dma_dev); in axi_dmac_remove()
1043 clk_disable_unprepare(dmac->clk); in axi_dmac_remove()
1049 { .compatible = "adi,axi-dmac-1.00.a" },
1056 .name = "dma-axi-dmac",
1065 MODULE_DESCRIPTION("DMA controller driver for the AXI-DMAC controller");