• Home
  • Raw
  • Download

Lines Matching refs:chan

141 #define ZYNQMP_DMA_DESC_SIZE(chan)	(chan->desc_size)  argument
143 #define to_chan(chan) container_of(chan, struct zynqmp_dma_chan, \ argument
251 struct zynqmp_dma_chan *chan; member
256 static inline void zynqmp_dma_writeq(struct zynqmp_dma_chan *chan, u32 reg, in zynqmp_dma_writeq() argument
259 lo_hi_writeq(value, chan->regs + reg); in zynqmp_dma_writeq()
267 static void zynqmp_dma_update_desc_to_ctrlr(struct zynqmp_dma_chan *chan, in zynqmp_dma_update_desc_to_ctrlr() argument
273 zynqmp_dma_writeq(chan, ZYNQMP_DMA_SRC_START_LSB, addr); in zynqmp_dma_update_desc_to_ctrlr()
275 zynqmp_dma_writeq(chan, ZYNQMP_DMA_DST_START_LSB, addr); in zynqmp_dma_update_desc_to_ctrlr()
283 static void zynqmp_dma_desc_config_eod(struct zynqmp_dma_chan *chan, in zynqmp_dma_desc_config_eod() argument
302 static void zynqmp_dma_config_sg_ll_desc(struct zynqmp_dma_chan *chan, in zynqmp_dma_config_sg_ll_desc() argument
314 if (chan->is_dmacoherent) { in zynqmp_dma_config_sg_ll_desc()
320 dma_addr_t addr = chan->desc_pool_p + in zynqmp_dma_config_sg_ll_desc()
321 ((uintptr_t)sdesc - (uintptr_t)chan->desc_pool_v); in zynqmp_dma_config_sg_ll_desc()
324 ddesc->nxtdscraddr = addr + ZYNQMP_DMA_DESC_SIZE(chan); in zynqmp_dma_config_sg_ll_desc()
332 static void zynqmp_dma_init(struct zynqmp_dma_chan *chan) in zynqmp_dma_init() argument
336 writel(ZYNQMP_DMA_IDS_DEFAULT_MASK, chan->regs + ZYNQMP_DMA_IDS); in zynqmp_dma_init()
337 val = readl(chan->regs + ZYNQMP_DMA_ISR); in zynqmp_dma_init()
338 writel(val, chan->regs + ZYNQMP_DMA_ISR); in zynqmp_dma_init()
340 if (chan->is_dmacoherent) { in zynqmp_dma_init()
344 writel(val, chan->regs + ZYNQMP_DMA_DSCR_ATTR); in zynqmp_dma_init()
347 val = readl(chan->regs + ZYNQMP_DMA_DATA_ATTR); in zynqmp_dma_init()
348 if (chan->is_dmacoherent) { in zynqmp_dma_init()
354 writel(val, chan->regs + ZYNQMP_DMA_DATA_ATTR); in zynqmp_dma_init()
357 val = readl(chan->regs + ZYNQMP_DMA_IRQ_SRC_ACCT); in zynqmp_dma_init()
358 val = readl(chan->regs + ZYNQMP_DMA_IRQ_DST_ACCT); in zynqmp_dma_init()
360 chan->idle = true; in zynqmp_dma_init()
371 struct zynqmp_dma_chan *chan = to_chan(tx->chan); in zynqmp_dma_tx_submit() local
377 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_tx_submit()
380 if (!list_empty(&chan->pending_list)) { in zynqmp_dma_tx_submit()
381 desc = list_last_entry(&chan->pending_list, in zynqmp_dma_tx_submit()
392 list_add_tail(&new->node, &chan->pending_list); in zynqmp_dma_tx_submit()
393 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_tx_submit()
405 zynqmp_dma_get_descriptor(struct zynqmp_dma_chan *chan) in zynqmp_dma_get_descriptor() argument
410 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_get_descriptor()
411 desc = list_first_entry(&chan->free_list, in zynqmp_dma_get_descriptor()
414 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_get_descriptor()
418 memset((void *)desc->src_v, 0, ZYNQMP_DMA_DESC_SIZE(chan)); in zynqmp_dma_get_descriptor()
419 memset((void *)desc->dst_v, 0, ZYNQMP_DMA_DESC_SIZE(chan)); in zynqmp_dma_get_descriptor()
429 static void zynqmp_dma_free_descriptor(struct zynqmp_dma_chan *chan, in zynqmp_dma_free_descriptor() argument
434 chan->desc_free_cnt++; in zynqmp_dma_free_descriptor()
435 list_move_tail(&sdesc->node, &chan->free_list); in zynqmp_dma_free_descriptor()
437 chan->desc_free_cnt++; in zynqmp_dma_free_descriptor()
438 list_move_tail(&child->node, &chan->free_list); in zynqmp_dma_free_descriptor()
447 static void zynqmp_dma_free_desc_list(struct zynqmp_dma_chan *chan, in zynqmp_dma_free_desc_list() argument
453 zynqmp_dma_free_descriptor(chan, desc); in zynqmp_dma_free_desc_list()
464 struct zynqmp_dma_chan *chan = to_chan(dchan); in zynqmp_dma_alloc_chan_resources() local
468 ret = pm_runtime_resume_and_get(chan->dev); in zynqmp_dma_alloc_chan_resources()
472 chan->sw_desc_pool = kcalloc(ZYNQMP_DMA_NUM_DESCS, sizeof(*desc), in zynqmp_dma_alloc_chan_resources()
474 if (!chan->sw_desc_pool) in zynqmp_dma_alloc_chan_resources()
477 chan->idle = true; in zynqmp_dma_alloc_chan_resources()
478 chan->desc_free_cnt = ZYNQMP_DMA_NUM_DESCS; in zynqmp_dma_alloc_chan_resources()
480 INIT_LIST_HEAD(&chan->free_list); in zynqmp_dma_alloc_chan_resources()
483 desc = chan->sw_desc_pool + i; in zynqmp_dma_alloc_chan_resources()
484 dma_async_tx_descriptor_init(&desc->async_tx, &chan->common); in zynqmp_dma_alloc_chan_resources()
486 list_add_tail(&desc->node, &chan->free_list); in zynqmp_dma_alloc_chan_resources()
489 chan->desc_pool_v = dma_alloc_coherent(chan->dev, in zynqmp_dma_alloc_chan_resources()
490 (2 * ZYNQMP_DMA_DESC_SIZE(chan) * in zynqmp_dma_alloc_chan_resources()
492 &chan->desc_pool_p, GFP_KERNEL); in zynqmp_dma_alloc_chan_resources()
493 if (!chan->desc_pool_v) in zynqmp_dma_alloc_chan_resources()
497 desc = chan->sw_desc_pool + i; in zynqmp_dma_alloc_chan_resources()
498 desc->src_v = (struct zynqmp_dma_desc_ll *) (chan->desc_pool_v + in zynqmp_dma_alloc_chan_resources()
499 (i * ZYNQMP_DMA_DESC_SIZE(chan) * 2)); in zynqmp_dma_alloc_chan_resources()
501 desc->src_p = chan->desc_pool_p + in zynqmp_dma_alloc_chan_resources()
502 (i * ZYNQMP_DMA_DESC_SIZE(chan) * 2); in zynqmp_dma_alloc_chan_resources()
503 desc->dst_p = desc->src_p + ZYNQMP_DMA_DESC_SIZE(chan); in zynqmp_dma_alloc_chan_resources()
513 static void zynqmp_dma_start(struct zynqmp_dma_chan *chan) in zynqmp_dma_start() argument
515 writel(ZYNQMP_DMA_INT_EN_DEFAULT_MASK, chan->regs + ZYNQMP_DMA_IER); in zynqmp_dma_start()
516 writel(0, chan->regs + ZYNQMP_DMA_TOTAL_BYTE); in zynqmp_dma_start()
517 chan->idle = false; in zynqmp_dma_start()
518 writel(ZYNQMP_DMA_ENABLE, chan->regs + ZYNQMP_DMA_CTRL2); in zynqmp_dma_start()
526 static void zynqmp_dma_handle_ovfl_int(struct zynqmp_dma_chan *chan, u32 status) in zynqmp_dma_handle_ovfl_int() argument
529 writel(0, chan->regs + ZYNQMP_DMA_TOTAL_BYTE); in zynqmp_dma_handle_ovfl_int()
531 readl(chan->regs + ZYNQMP_DMA_IRQ_DST_ACCT); in zynqmp_dma_handle_ovfl_int()
533 readl(chan->regs + ZYNQMP_DMA_IRQ_SRC_ACCT); in zynqmp_dma_handle_ovfl_int()
536 static void zynqmp_dma_config(struct zynqmp_dma_chan *chan) in zynqmp_dma_config() argument
540 val = readl(chan->regs + ZYNQMP_DMA_CTRL0); in zynqmp_dma_config()
542 writel(val, chan->regs + ZYNQMP_DMA_CTRL0); in zynqmp_dma_config()
544 val = readl(chan->regs + ZYNQMP_DMA_DATA_ATTR); in zynqmp_dma_config()
545 burst_val = __ilog2_u32(chan->src_burst_len); in zynqmp_dma_config()
548 burst_val = __ilog2_u32(chan->dst_burst_len); in zynqmp_dma_config()
551 writel(val, chan->regs + ZYNQMP_DMA_DATA_ATTR); in zynqmp_dma_config()
564 struct zynqmp_dma_chan *chan = to_chan(dchan); in zynqmp_dma_device_config() local
566 chan->src_burst_len = clamp(config->src_maxburst, 1U, in zynqmp_dma_device_config()
568 chan->dst_burst_len = clamp(config->dst_maxburst, 1U, in zynqmp_dma_device_config()
578 static void zynqmp_dma_start_transfer(struct zynqmp_dma_chan *chan) in zynqmp_dma_start_transfer() argument
582 if (!chan->idle) in zynqmp_dma_start_transfer()
585 zynqmp_dma_config(chan); in zynqmp_dma_start_transfer()
587 desc = list_first_entry_or_null(&chan->pending_list, in zynqmp_dma_start_transfer()
592 list_splice_tail_init(&chan->pending_list, &chan->active_list); in zynqmp_dma_start_transfer()
593 zynqmp_dma_update_desc_to_ctrlr(chan, desc); in zynqmp_dma_start_transfer()
594 zynqmp_dma_start(chan); in zynqmp_dma_start_transfer()
602 static void zynqmp_dma_chan_desc_cleanup(struct zynqmp_dma_chan *chan) in zynqmp_dma_chan_desc_cleanup() argument
607 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_chan_desc_cleanup()
609 list_for_each_entry_safe(desc, next, &chan->done_list, node) { in zynqmp_dma_chan_desc_cleanup()
614 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_chan_desc_cleanup()
616 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_chan_desc_cleanup()
620 zynqmp_dma_free_descriptor(chan, desc); in zynqmp_dma_chan_desc_cleanup()
623 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_chan_desc_cleanup()
630 static void zynqmp_dma_complete_descriptor(struct zynqmp_dma_chan *chan) in zynqmp_dma_complete_descriptor() argument
634 desc = list_first_entry_or_null(&chan->active_list, in zynqmp_dma_complete_descriptor()
640 list_add_tail(&desc->node, &chan->done_list); in zynqmp_dma_complete_descriptor()
649 struct zynqmp_dma_chan *chan = to_chan(dchan); in zynqmp_dma_issue_pending() local
652 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_issue_pending()
653 zynqmp_dma_start_transfer(chan); in zynqmp_dma_issue_pending()
654 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_issue_pending()
661 static void zynqmp_dma_free_descriptors(struct zynqmp_dma_chan *chan) in zynqmp_dma_free_descriptors() argument
665 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_free_descriptors()
666 zynqmp_dma_free_desc_list(chan, &chan->active_list); in zynqmp_dma_free_descriptors()
667 zynqmp_dma_free_desc_list(chan, &chan->pending_list); in zynqmp_dma_free_descriptors()
668 zynqmp_dma_free_desc_list(chan, &chan->done_list); in zynqmp_dma_free_descriptors()
669 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_free_descriptors()
678 struct zynqmp_dma_chan *chan = to_chan(dchan); in zynqmp_dma_free_chan_resources() local
680 zynqmp_dma_free_descriptors(chan); in zynqmp_dma_free_chan_resources()
681 dma_free_coherent(chan->dev, in zynqmp_dma_free_chan_resources()
682 (2 * ZYNQMP_DMA_DESC_SIZE(chan) * ZYNQMP_DMA_NUM_DESCS), in zynqmp_dma_free_chan_resources()
683 chan->desc_pool_v, chan->desc_pool_p); in zynqmp_dma_free_chan_resources()
684 kfree(chan->sw_desc_pool); in zynqmp_dma_free_chan_resources()
685 pm_runtime_mark_last_busy(chan->dev); in zynqmp_dma_free_chan_resources()
686 pm_runtime_put_autosuspend(chan->dev); in zynqmp_dma_free_chan_resources()
693 static void zynqmp_dma_reset(struct zynqmp_dma_chan *chan) in zynqmp_dma_reset() argument
697 writel(ZYNQMP_DMA_IDS_DEFAULT_MASK, chan->regs + ZYNQMP_DMA_IDS); in zynqmp_dma_reset()
699 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_reset()
700 zynqmp_dma_complete_descriptor(chan); in zynqmp_dma_reset()
701 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_reset()
702 zynqmp_dma_chan_desc_cleanup(chan); in zynqmp_dma_reset()
703 zynqmp_dma_free_descriptors(chan); in zynqmp_dma_reset()
705 zynqmp_dma_init(chan); in zynqmp_dma_reset()
717 struct zynqmp_dma_chan *chan = (struct zynqmp_dma_chan *)data; in zynqmp_dma_irq_handler() local
721 isr = readl(chan->regs + ZYNQMP_DMA_ISR); in zynqmp_dma_irq_handler()
722 imr = readl(chan->regs + ZYNQMP_DMA_IMR); in zynqmp_dma_irq_handler()
725 writel(isr, chan->regs + ZYNQMP_DMA_ISR); in zynqmp_dma_irq_handler()
727 tasklet_schedule(&chan->tasklet); in zynqmp_dma_irq_handler()
732 chan->idle = true; in zynqmp_dma_irq_handler()
735 chan->err = true; in zynqmp_dma_irq_handler()
736 tasklet_schedule(&chan->tasklet); in zynqmp_dma_irq_handler()
737 dev_err(chan->dev, "Channel %p has errors\n", chan); in zynqmp_dma_irq_handler()
742 zynqmp_dma_handle_ovfl_int(chan, status); in zynqmp_dma_irq_handler()
743 dev_dbg(chan->dev, "Channel %p overflow interrupt\n", chan); in zynqmp_dma_irq_handler()
756 struct zynqmp_dma_chan *chan = from_tasklet(chan, t, tasklet); in zynqmp_dma_do_tasklet() local
760 if (chan->err) { in zynqmp_dma_do_tasklet()
761 zynqmp_dma_reset(chan); in zynqmp_dma_do_tasklet()
762 chan->err = false; in zynqmp_dma_do_tasklet()
766 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_do_tasklet()
767 count = readl(chan->regs + ZYNQMP_DMA_IRQ_DST_ACCT); in zynqmp_dma_do_tasklet()
769 zynqmp_dma_complete_descriptor(chan); in zynqmp_dma_do_tasklet()
772 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_do_tasklet()
774 zynqmp_dma_chan_desc_cleanup(chan); in zynqmp_dma_do_tasklet()
776 if (chan->idle) { in zynqmp_dma_do_tasklet()
777 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_do_tasklet()
778 zynqmp_dma_start_transfer(chan); in zynqmp_dma_do_tasklet()
779 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_do_tasklet()
791 struct zynqmp_dma_chan *chan = to_chan(dchan); in zynqmp_dma_device_terminate_all() local
793 writel(ZYNQMP_DMA_IDS_DEFAULT_MASK, chan->regs + ZYNQMP_DMA_IDS); in zynqmp_dma_device_terminate_all()
794 zynqmp_dma_free_descriptors(chan); in zynqmp_dma_device_terminate_all()
805 struct zynqmp_dma_chan *chan = to_chan(dchan); in zynqmp_dma_synchronize() local
807 tasklet_kill(&chan->tasklet); in zynqmp_dma_synchronize()
824 struct zynqmp_dma_chan *chan; in zynqmp_dma_prep_memcpy() local
831 chan = to_chan(dchan); in zynqmp_dma_prep_memcpy()
835 spin_lock_irqsave(&chan->lock, irqflags); in zynqmp_dma_prep_memcpy()
836 if (desc_cnt > chan->desc_free_cnt) { in zynqmp_dma_prep_memcpy()
837 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_prep_memcpy()
838 dev_dbg(chan->dev, "chan %p descs are not available\n", chan); in zynqmp_dma_prep_memcpy()
841 chan->desc_free_cnt = chan->desc_free_cnt - desc_cnt; in zynqmp_dma_prep_memcpy()
842 spin_unlock_irqrestore(&chan->lock, irqflags); in zynqmp_dma_prep_memcpy()
846 new = zynqmp_dma_get_descriptor(chan); in zynqmp_dma_prep_memcpy()
850 zynqmp_dma_config_sg_ll_desc(chan, desc, dma_src, in zynqmp_dma_prep_memcpy()
862 zynqmp_dma_desc_config_eod(chan, desc); in zynqmp_dma_prep_memcpy()
872 static void zynqmp_dma_chan_remove(struct zynqmp_dma_chan *chan) in zynqmp_dma_chan_remove() argument
874 if (!chan) in zynqmp_dma_chan_remove()
877 if (chan->irq) in zynqmp_dma_chan_remove()
878 devm_free_irq(chan->zdev->dev, chan->irq, chan); in zynqmp_dma_chan_remove()
879 tasklet_kill(&chan->tasklet); in zynqmp_dma_chan_remove()
880 list_del(&chan->common.device_node); in zynqmp_dma_chan_remove()
893 struct zynqmp_dma_chan *chan; in zynqmp_dma_chan_probe() local
897 chan = devm_kzalloc(zdev->dev, sizeof(*chan), GFP_KERNEL); in zynqmp_dma_chan_probe()
898 if (!chan) in zynqmp_dma_chan_probe()
900 chan->dev = zdev->dev; in zynqmp_dma_chan_probe()
901 chan->zdev = zdev; in zynqmp_dma_chan_probe()
903 chan->regs = devm_platform_ioremap_resource(pdev, 0); in zynqmp_dma_chan_probe()
904 if (IS_ERR(chan->regs)) in zynqmp_dma_chan_probe()
905 return PTR_ERR(chan->regs); in zynqmp_dma_chan_probe()
907 chan->bus_width = ZYNQMP_DMA_BUS_WIDTH_64; in zynqmp_dma_chan_probe()
908 chan->dst_burst_len = ZYNQMP_DMA_MAX_DST_BURST_LEN; in zynqmp_dma_chan_probe()
909 chan->src_burst_len = ZYNQMP_DMA_MAX_SRC_BURST_LEN; in zynqmp_dma_chan_probe()
910 err = of_property_read_u32(node, "xlnx,bus-width", &chan->bus_width); in zynqmp_dma_chan_probe()
916 if (chan->bus_width != ZYNQMP_DMA_BUS_WIDTH_64 && in zynqmp_dma_chan_probe()
917 chan->bus_width != ZYNQMP_DMA_BUS_WIDTH_128) { in zynqmp_dma_chan_probe()
922 chan->is_dmacoherent = of_property_read_bool(node, "dma-coherent"); in zynqmp_dma_chan_probe()
923 zdev->chan = chan; in zynqmp_dma_chan_probe()
924 tasklet_setup(&chan->tasklet, zynqmp_dma_do_tasklet); in zynqmp_dma_chan_probe()
925 spin_lock_init(&chan->lock); in zynqmp_dma_chan_probe()
926 INIT_LIST_HEAD(&chan->active_list); in zynqmp_dma_chan_probe()
927 INIT_LIST_HEAD(&chan->pending_list); in zynqmp_dma_chan_probe()
928 INIT_LIST_HEAD(&chan->done_list); in zynqmp_dma_chan_probe()
929 INIT_LIST_HEAD(&chan->free_list); in zynqmp_dma_chan_probe()
931 dma_cookie_init(&chan->common); in zynqmp_dma_chan_probe()
932 chan->common.device = &zdev->common; in zynqmp_dma_chan_probe()
933 list_add_tail(&chan->common.device_node, &zdev->common.channels); in zynqmp_dma_chan_probe()
935 zynqmp_dma_init(chan); in zynqmp_dma_chan_probe()
936 chan->irq = platform_get_irq(pdev, 0); in zynqmp_dma_chan_probe()
937 if (chan->irq < 0) in zynqmp_dma_chan_probe()
939 err = devm_request_irq(&pdev->dev, chan->irq, zynqmp_dma_irq_handler, 0, in zynqmp_dma_chan_probe()
940 "zynqmp-dma", chan); in zynqmp_dma_chan_probe()
944 chan->desc_size = sizeof(struct zynqmp_dma_desc_ll); in zynqmp_dma_chan_probe()
945 chan->idle = true; in zynqmp_dma_chan_probe()
961 return dma_get_slave_channel(&zdev->chan->common); in of_zynqmp_dma_xlate()
1113 p->dst_addr_widths = BIT(zdev->chan->bus_width / 8); in zynqmp_dma_probe()
1114 p->src_addr_widths = BIT(zdev->chan->bus_width / 8); in zynqmp_dma_probe()
1136 zynqmp_dma_chan_remove(zdev->chan); in zynqmp_dma_probe()
1157 zynqmp_dma_chan_remove(zdev->chan); in zynqmp_dma_remove()