Lines Matching refs:chan

47 	return container_of(dchan, struct sf_pdma_chan, vchan.chan);  in to_sf_pdma_chan()
55 static struct sf_pdma_desc *sf_pdma_alloc_desc(struct sf_pdma_chan *chan) in sf_pdma_alloc_desc() argument
63 desc->chan = chan; in sf_pdma_alloc_desc()
71 desc->xfer_type = desc->chan->pdma->transfer_type; in sf_pdma_fill_desc()
77 static void sf_pdma_disclaim_chan(struct sf_pdma_chan *chan) in sf_pdma_disclaim_chan() argument
79 struct pdma_regs *regs = &chan->regs; in sf_pdma_disclaim_chan()
88 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_prep_dma_memcpy() local
92 if (chan && (!len || !dest || !src)) { in sf_pdma_prep_dma_memcpy()
93 dev_err(chan->pdma->dma_dev.dev, in sf_pdma_prep_dma_memcpy()
98 desc = sf_pdma_alloc_desc(chan); in sf_pdma_prep_dma_memcpy()
103 desc->async_tx = vchan_tx_prep(&chan->vchan, &desc->vdesc, flags); in sf_pdma_prep_dma_memcpy()
105 spin_lock_irqsave(&chan->vchan.lock, iflags); in sf_pdma_prep_dma_memcpy()
107 spin_unlock_irqrestore(&chan->vchan.lock, iflags); in sf_pdma_prep_dma_memcpy()
115 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_slave_config() local
117 memcpy(&chan->cfg, cfg, sizeof(*cfg)); in sf_pdma_slave_config()
124 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_alloc_chan_resources() local
125 struct pdma_regs *regs = &chan->regs; in sf_pdma_alloc_chan_resources()
133 static void sf_pdma_disable_request(struct sf_pdma_chan *chan) in sf_pdma_disable_request() argument
135 struct pdma_regs *regs = &chan->regs; in sf_pdma_disable_request()
142 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_free_chan_resources() local
146 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_free_chan_resources()
147 sf_pdma_disable_request(chan); in sf_pdma_free_chan_resources()
148 kfree(chan->desc); in sf_pdma_free_chan_resources()
149 chan->desc = NULL; in sf_pdma_free_chan_resources()
150 vchan_get_all_descriptors(&chan->vchan, &head); in sf_pdma_free_chan_resources()
151 sf_pdma_disclaim_chan(chan); in sf_pdma_free_chan_resources()
152 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_free_chan_resources()
153 vchan_dma_desc_free_list(&chan->vchan, &head); in sf_pdma_free_chan_resources()
156 static size_t sf_pdma_desc_residue(struct sf_pdma_chan *chan, in sf_pdma_desc_residue() argument
160 struct pdma_regs *regs = &chan->regs; in sf_pdma_desc_residue()
166 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_desc_residue()
168 list_for_each_entry(vd, &chan->vchan.desc_submitted, node) in sf_pdma_desc_residue()
175 if (cookie == tx->chan->completed_cookie) in sf_pdma_desc_residue()
181 vd = vchan_find_desc(&chan->vchan, cookie); in sf_pdma_desc_residue()
190 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_desc_residue()
199 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_tx_status() local
205 dma_set_residue(txstate, sf_pdma_desc_residue(chan, cookie)); in sf_pdma_tx_status()
212 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_terminate_all() local
216 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_terminate_all()
217 sf_pdma_disable_request(chan); in sf_pdma_terminate_all()
218 kfree(chan->desc); in sf_pdma_terminate_all()
219 chan->desc = NULL; in sf_pdma_terminate_all()
220 chan->xfer_err = false; in sf_pdma_terminate_all()
221 vchan_get_all_descriptors(&chan->vchan, &head); in sf_pdma_terminate_all()
222 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_terminate_all()
223 vchan_dma_desc_free_list(&chan->vchan, &head); in sf_pdma_terminate_all()
228 static void sf_pdma_enable_request(struct sf_pdma_chan *chan) in sf_pdma_enable_request() argument
230 struct pdma_regs *regs = &chan->regs; in sf_pdma_enable_request()
241 static struct sf_pdma_desc *sf_pdma_get_first_pending_desc(struct sf_pdma_chan *chan) in sf_pdma_get_first_pending_desc() argument
243 struct virt_dma_chan *vchan = &chan->vchan; in sf_pdma_get_first_pending_desc()
254 static void sf_pdma_xfer_desc(struct sf_pdma_chan *chan) in sf_pdma_xfer_desc() argument
256 struct sf_pdma_desc *desc = chan->desc; in sf_pdma_xfer_desc()
257 struct pdma_regs *regs = &chan->regs; in sf_pdma_xfer_desc()
260 dev_err(chan->pdma->dma_dev.dev, "NULL desc.\n"); in sf_pdma_xfer_desc()
269 chan->desc = desc; in sf_pdma_xfer_desc()
270 chan->status = DMA_IN_PROGRESS; in sf_pdma_xfer_desc()
271 sf_pdma_enable_request(chan); in sf_pdma_xfer_desc()
276 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_issue_pending() local
279 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_issue_pending()
281 if (!chan->desc && vchan_issue_pending(&chan->vchan)) { in sf_pdma_issue_pending()
283 chan->desc = sf_pdma_get_first_pending_desc(chan); in sf_pdma_issue_pending()
284 sf_pdma_xfer_desc(chan); in sf_pdma_issue_pending()
287 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_issue_pending()
300 struct sf_pdma_chan *chan = from_tasklet(chan, t, done_tasklet); in sf_pdma_donebh_tasklet() local
303 spin_lock_irqsave(&chan->lock, flags); in sf_pdma_donebh_tasklet()
304 if (chan->xfer_err) { in sf_pdma_donebh_tasklet()
305 chan->retries = MAX_RETRY; in sf_pdma_donebh_tasklet()
306 chan->status = DMA_COMPLETE; in sf_pdma_donebh_tasklet()
307 chan->xfer_err = false; in sf_pdma_donebh_tasklet()
309 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_donebh_tasklet()
311 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_donebh_tasklet()
312 list_del(&chan->desc->vdesc.node); in sf_pdma_donebh_tasklet()
313 vchan_cookie_complete(&chan->desc->vdesc); in sf_pdma_donebh_tasklet()
315 chan->desc = sf_pdma_get_first_pending_desc(chan); in sf_pdma_donebh_tasklet()
316 if (chan->desc) in sf_pdma_donebh_tasklet()
317 sf_pdma_xfer_desc(chan); in sf_pdma_donebh_tasklet()
319 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_donebh_tasklet()
324 struct sf_pdma_chan *chan = from_tasklet(chan, t, err_tasklet); in sf_pdma_errbh_tasklet() local
325 struct sf_pdma_desc *desc = chan->desc; in sf_pdma_errbh_tasklet()
328 spin_lock_irqsave(&chan->lock, flags); in sf_pdma_errbh_tasklet()
329 if (chan->retries <= 0) { in sf_pdma_errbh_tasklet()
331 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_errbh_tasklet()
335 chan->retries--; in sf_pdma_errbh_tasklet()
336 chan->xfer_err = true; in sf_pdma_errbh_tasklet()
337 chan->status = DMA_ERROR; in sf_pdma_errbh_tasklet()
339 sf_pdma_enable_request(chan); in sf_pdma_errbh_tasklet()
340 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_errbh_tasklet()
346 struct sf_pdma_chan *chan = dev_id; in sf_pdma_done_isr() local
347 struct pdma_regs *regs = &chan->regs; in sf_pdma_done_isr()
350 spin_lock(&chan->vchan.lock); in sf_pdma_done_isr()
355 tasklet_hi_schedule(&chan->done_tasklet); in sf_pdma_done_isr()
358 struct sf_pdma_desc *desc = chan->desc; in sf_pdma_done_isr()
364 sf_pdma_xfer_desc(chan); in sf_pdma_done_isr()
367 spin_unlock(&chan->vchan.lock); in sf_pdma_done_isr()
374 struct sf_pdma_chan *chan = dev_id; in sf_pdma_err_isr() local
375 struct pdma_regs *regs = &chan->regs; in sf_pdma_err_isr()
377 spin_lock(&chan->lock); in sf_pdma_err_isr()
379 spin_unlock(&chan->lock); in sf_pdma_err_isr()
381 tasklet_schedule(&chan->err_tasklet); in sf_pdma_err_isr()
404 struct sf_pdma_chan *chan; in sf_pdma_irq_init() local
407 chan = &pdma->chans[i]; in sf_pdma_irq_init()
414 dev_name(&pdev->dev), (void *)chan); in sf_pdma_irq_init()
420 chan->txirq = irq; in sf_pdma_irq_init()
427 dev_name(&pdev->dev), (void *)chan); in sf_pdma_irq_init()
433 chan->errirq = irq; in sf_pdma_irq_init()
454 struct sf_pdma_chan *chan; in sf_pdma_setup_chans() local
459 chan = &pdma->chans[i]; in sf_pdma_setup_chans()
461 chan->regs.ctrl = in sf_pdma_setup_chans()
463 chan->regs.xfer_type = in sf_pdma_setup_chans()
465 chan->regs.xfer_size = in sf_pdma_setup_chans()
467 chan->regs.dst_addr = in sf_pdma_setup_chans()
469 chan->regs.src_addr = in sf_pdma_setup_chans()
471 chan->regs.act_type = in sf_pdma_setup_chans()
473 chan->regs.residue = in sf_pdma_setup_chans()
475 chan->regs.cur_dst_addr = in sf_pdma_setup_chans()
477 chan->regs.cur_src_addr = in sf_pdma_setup_chans()
480 chan->pdma = pdma; in sf_pdma_setup_chans()
481 chan->pm_state = RUNNING; in sf_pdma_setup_chans()
482 chan->slave_id = i; in sf_pdma_setup_chans()
483 chan->xfer_err = false; in sf_pdma_setup_chans()
484 spin_lock_init(&chan->lock); in sf_pdma_setup_chans()
486 chan->vchan.desc_free = sf_pdma_free_desc; in sf_pdma_setup_chans()
487 vchan_init(&chan->vchan, &pdma->dma_dev); in sf_pdma_setup_chans()
489 writel(PDMA_CLEAR_CTRL, chan->regs.ctrl); in sf_pdma_setup_chans()
491 tasklet_setup(&chan->done_tasklet, sf_pdma_donebh_tasklet); in sf_pdma_setup_chans()
492 tasklet_setup(&chan->err_tasklet, sf_pdma_errbh_tasklet); in sf_pdma_setup_chans()
605 list_del(&ch->vchan.chan.device_node); in sf_pdma_remove()