Lines Matching refs:jzchan
177 struct jz4780_dma_chan *jzchan) in jz4780_dma_chan_parent() argument
179 return container_of(jzchan->vchan.chan.device, struct jz4780_dma_dev, in jz4780_dma_chan_parent()
231 jz4780_dma_desc_alloc(struct jz4780_dma_chan *jzchan, unsigned int count, in jz4780_dma_desc_alloc() argument
244 desc->desc = dma_pool_alloc(jzchan->desc_pool, GFP_NOWAIT, in jz4780_dma_desc_alloc()
255 desc->transfer_type = jzchan->transfer_type_rx; in jz4780_dma_desc_alloc()
257 desc->transfer_type = jzchan->transfer_type_tx; in jz4780_dma_desc_alloc()
265 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(vdesc->tx.chan); in jz4780_dma_desc_free() local
267 dma_pool_free(jzchan->desc_pool, desc->desc, desc->desc_phys); in jz4780_dma_desc_free()
271 static u32 jz4780_dma_transfer_size(struct jz4780_dma_chan *jzchan, in jz4780_dma_transfer_size() argument
274 struct jz4780_dma_dev *jzdma = jz4780_dma_chan_parent(jzchan); in jz4780_dma_transfer_size()
309 static int jz4780_dma_setup_hwdesc(struct jz4780_dma_chan *jzchan, in jz4780_dma_setup_hwdesc() argument
313 struct dma_slave_config *config = &jzchan->config; in jz4780_dma_setup_hwdesc()
339 tsz = jz4780_dma_transfer_size(jzchan, addr | len | (width * maxburst), in jz4780_dma_setup_hwdesc()
340 &jzchan->transfer_shift); in jz4780_dma_setup_hwdesc()
357 desc->dtc = len >> jzchan->transfer_shift; in jz4780_dma_setup_hwdesc()
366 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_prep_slave_sg() local
367 struct jz4780_dma_dev *jzdma = jz4780_dma_chan_parent(jzchan); in jz4780_dma_prep_slave_sg()
372 desc = jz4780_dma_desc_alloc(jzchan, sg_len, DMA_SLAVE, direction); in jz4780_dma_prep_slave_sg()
377 err = jz4780_dma_setup_hwdesc(jzchan, &desc->desc[i], in jz4780_dma_prep_slave_sg()
382 jz4780_dma_desc_free(&jzchan->desc->vdesc); in jz4780_dma_prep_slave_sg()
403 return vchan_tx_prep(&jzchan->vchan, &desc->vdesc, flags); in jz4780_dma_prep_slave_sg()
411 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_prep_dma_cyclic() local
421 desc = jz4780_dma_desc_alloc(jzchan, periods, DMA_CYCLIC, direction); in jz4780_dma_prep_dma_cyclic()
426 err = jz4780_dma_setup_hwdesc(jzchan, &desc->desc[i], buf_addr, in jz4780_dma_prep_dma_cyclic()
429 jz4780_dma_desc_free(&jzchan->desc->vdesc); in jz4780_dma_prep_dma_cyclic()
455 return vchan_tx_prep(&jzchan->vchan, &desc->vdesc, flags); in jz4780_dma_prep_dma_cyclic()
462 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_prep_dma_memcpy() local
466 desc = jz4780_dma_desc_alloc(jzchan, 1, DMA_MEMCPY, 0); in jz4780_dma_prep_dma_memcpy()
470 tsz = jz4780_dma_transfer_size(jzchan, dest | src | len, in jz4780_dma_prep_dma_memcpy()
471 &jzchan->transfer_shift); in jz4780_dma_prep_dma_memcpy()
481 desc->desc[0].dtc = len >> jzchan->transfer_shift; in jz4780_dma_prep_dma_memcpy()
483 return vchan_tx_prep(&jzchan->vchan, &desc->vdesc, flags); in jz4780_dma_prep_dma_memcpy()
486 static void jz4780_dma_begin(struct jz4780_dma_chan *jzchan) in jz4780_dma_begin() argument
488 struct jz4780_dma_dev *jzdma = jz4780_dma_chan_parent(jzchan); in jz4780_dma_begin()
493 if (!jzchan->desc) { in jz4780_dma_begin()
494 vdesc = vchan_next_desc(&jzchan->vchan); in jz4780_dma_begin()
500 jzchan->desc = to_jz4780_dma_desc(vdesc); in jz4780_dma_begin()
501 jzchan->curr_hwdesc = 0; in jz4780_dma_begin()
503 if (jzchan->desc->type == DMA_CYCLIC && vdesc->tx.callback) { in jz4780_dma_begin()
518 for (i = 0; i < jzchan->desc->count; i++) in jz4780_dma_begin()
519 jzchan->desc->desc[i].dcm &= ~JZ_DMA_DCM_LINK; in jz4780_dma_begin()
527 jzchan->curr_hwdesc = in jz4780_dma_begin()
528 (jzchan->curr_hwdesc + 1) % jzchan->desc->count; in jz4780_dma_begin()
532 jz4780_dma_chan_enable(jzdma, jzchan->id); in jz4780_dma_begin()
535 jz4780_dma_chn_writel(jzdma, jzchan->id, JZ_DMA_REG_DCS, 0); in jz4780_dma_begin()
538 jz4780_dma_chn_writel(jzdma, jzchan->id, JZ_DMA_REG_DRT, in jz4780_dma_begin()
539 jzchan->desc->transfer_type); in jz4780_dma_begin()
547 jz4780_dma_chn_writel(jzdma, jzchan->id, JZ_DMA_REG_DTC, in jz4780_dma_begin()
548 jzchan->desc->desc[jzchan->curr_hwdesc].dtc); in jz4780_dma_begin()
551 desc_phys = jzchan->desc->desc_phys + in jz4780_dma_begin()
552 (jzchan->curr_hwdesc * sizeof(*jzchan->desc->desc)); in jz4780_dma_begin()
553 jz4780_dma_chn_writel(jzdma, jzchan->id, JZ_DMA_REG_DDA, desc_phys); in jz4780_dma_begin()
554 jz4780_dma_ctrl_writel(jzdma, JZ_DMA_REG_DDRS, BIT(jzchan->id)); in jz4780_dma_begin()
557 jz4780_dma_chn_writel(jzdma, jzchan->id, JZ_DMA_REG_DCS, in jz4780_dma_begin()
563 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_issue_pending() local
566 spin_lock_irqsave(&jzchan->vchan.lock, flags); in jz4780_dma_issue_pending()
568 if (vchan_issue_pending(&jzchan->vchan) && !jzchan->desc) in jz4780_dma_issue_pending()
569 jz4780_dma_begin(jzchan); in jz4780_dma_issue_pending()
571 spin_unlock_irqrestore(&jzchan->vchan.lock, flags); in jz4780_dma_issue_pending()
576 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_terminate_all() local
577 struct jz4780_dma_dev *jzdma = jz4780_dma_chan_parent(jzchan); in jz4780_dma_terminate_all()
581 spin_lock_irqsave(&jzchan->vchan.lock, flags); in jz4780_dma_terminate_all()
584 jz4780_dma_chn_writel(jzdma, jzchan->id, JZ_DMA_REG_DCS, 0); in jz4780_dma_terminate_all()
585 if (jzchan->desc) { in jz4780_dma_terminate_all()
586 vchan_terminate_vdesc(&jzchan->desc->vdesc); in jz4780_dma_terminate_all()
587 jzchan->desc = NULL; in jz4780_dma_terminate_all()
590 jz4780_dma_chan_disable(jzdma, jzchan->id); in jz4780_dma_terminate_all()
592 vchan_get_all_descriptors(&jzchan->vchan, &head); in jz4780_dma_terminate_all()
594 spin_unlock_irqrestore(&jzchan->vchan.lock, flags); in jz4780_dma_terminate_all()
596 vchan_dma_desc_free_list(&jzchan->vchan, &head); in jz4780_dma_terminate_all()
602 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_synchronize() local
603 struct jz4780_dma_dev *jzdma = jz4780_dma_chan_parent(jzchan); in jz4780_dma_synchronize()
605 vchan_synchronize(&jzchan->vchan); in jz4780_dma_synchronize()
606 jz4780_dma_chan_disable(jzdma, jzchan->id); in jz4780_dma_synchronize()
612 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_config() local
619 memcpy(&jzchan->config, config, sizeof(jzchan->config)); in jz4780_dma_config()
624 static size_t jz4780_dma_desc_residue(struct jz4780_dma_chan *jzchan, in jz4780_dma_desc_residue() argument
627 struct jz4780_dma_dev *jzdma = jz4780_dma_chan_parent(jzchan); in jz4780_dma_desc_residue()
635 count += jz4780_dma_chn_readl(jzdma, jzchan->id, in jz4780_dma_desc_residue()
638 return count << jzchan->transfer_shift; in jz4780_dma_desc_residue()
644 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_tx_status() local
650 spin_lock_irqsave(&jzchan->vchan.lock, flags); in jz4780_dma_tx_status()
656 vdesc = vchan_find_desc(&jzchan->vchan, cookie); in jz4780_dma_tx_status()
659 residue = jz4780_dma_desc_residue(jzchan, in jz4780_dma_tx_status()
661 } else if (cookie == jzchan->desc->vdesc.tx.cookie) { in jz4780_dma_tx_status()
662 residue = jz4780_dma_desc_residue(jzchan, jzchan->desc, in jz4780_dma_tx_status()
663 jzchan->curr_hwdesc + 1); in jz4780_dma_tx_status()
667 if (vdesc && jzchan->desc && vdesc == &jzchan->desc->vdesc in jz4780_dma_tx_status()
668 && jzchan->desc->status & (JZ_DMA_DCS_AR | JZ_DMA_DCS_HLT)) in jz4780_dma_tx_status()
672 spin_unlock_irqrestore(&jzchan->vchan.lock, flags); in jz4780_dma_tx_status()
677 struct jz4780_dma_chan *jzchan) in jz4780_dma_chan_irq() argument
680 struct jz4780_dma_desc *desc = jzchan->desc; in jz4780_dma_chan_irq()
684 spin_lock(&jzchan->vchan.lock); in jz4780_dma_chan_irq()
686 dcs = jz4780_dma_chn_readl(jzdma, jzchan->id, JZ_DMA_REG_DCS); in jz4780_dma_chan_irq()
687 jz4780_dma_chn_writel(jzdma, jzchan->id, JZ_DMA_REG_DCS, 0); in jz4780_dma_chan_irq()
690 dev_warn(&jzchan->vchan.chan.dev->device, in jz4780_dma_chan_irq()
695 dev_warn(&jzchan->vchan.chan.dev->device, in jz4780_dma_chan_irq()
699 if (jzchan->desc) { in jz4780_dma_chan_irq()
700 jzchan->desc->status = dcs; in jz4780_dma_chan_irq()
703 if (jzchan->desc->type == DMA_CYCLIC) { in jz4780_dma_chan_irq()
704 vchan_cyclic_callback(&jzchan->desc->vdesc); in jz4780_dma_chan_irq()
706 jz4780_dma_begin(jzchan); in jz4780_dma_chan_irq()
709 (jzchan->curr_hwdesc + 1 == desc->count)) { in jz4780_dma_chan_irq()
711 jzchan->desc = NULL; in jz4780_dma_chan_irq()
714 jz4780_dma_begin(jzchan); in jz4780_dma_chan_irq()
718 jz4780_dma_chn_writel(jzdma, jzchan->id, in jz4780_dma_chan_irq()
724 dev_err(&jzchan->vchan.chan.dev->device, in jz4780_dma_chan_irq()
728 spin_unlock(&jzchan->vchan.lock); in jz4780_dma_chan_irq()
761 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_alloc_chan_resources() local
763 jzchan->desc_pool = dma_pool_create(dev_name(&chan->dev->device), in jz4780_dma_alloc_chan_resources()
767 if (!jzchan->desc_pool) { in jz4780_dma_alloc_chan_resources()
778 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_free_chan_resources() local
780 vchan_free_chan_resources(&jzchan->vchan); in jz4780_dma_free_chan_resources()
781 dma_pool_destroy(jzchan->desc_pool); in jz4780_dma_free_chan_resources()
782 jzchan->desc_pool = NULL; in jz4780_dma_free_chan_resources()
787 struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan); in jz4780_dma_filter_fn() local
788 struct jz4780_dma_dev *jzdma = jz4780_dma_chan_parent(jzchan); in jz4780_dma_filter_fn()
793 if (data->channel != jzchan->id) in jz4780_dma_filter_fn()
795 } else if (jzdma->chan_reserved & BIT(jzchan->id)) { in jz4780_dma_filter_fn()
799 jzchan->transfer_type_tx = data->transfer_type_tx; in jz4780_dma_filter_fn()
800 jzchan->transfer_type_rx = data->transfer_type_rx; in jz4780_dma_filter_fn()
856 struct jz4780_dma_chan *jzchan; in jz4780_dma_probe() local
958 jzchan = &jzdma->chan[i]; in jz4780_dma_probe()
959 jzchan->id = i; in jz4780_dma_probe()
961 vchan_init(&jzchan->vchan, dd); in jz4780_dma_probe()
962 jzchan->vchan.desc_free = jz4780_dma_desc_free; in jz4780_dma_probe()