Lines Matching refs:chan
44 return container_of(dchan, struct sf_pdma_chan, vchan.chan); in to_sf_pdma_chan()
52 static struct sf_pdma_desc *sf_pdma_alloc_desc(struct sf_pdma_chan *chan) in sf_pdma_alloc_desc() argument
60 desc->chan = chan; in sf_pdma_alloc_desc()
74 static void sf_pdma_disclaim_chan(struct sf_pdma_chan *chan) in sf_pdma_disclaim_chan() argument
76 struct pdma_regs *regs = &chan->regs; in sf_pdma_disclaim_chan()
85 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_prep_dma_memcpy() local
89 if (chan && (!len || !dest || !src)) { in sf_pdma_prep_dma_memcpy()
90 dev_err(chan->pdma->dma_dev.dev, in sf_pdma_prep_dma_memcpy()
95 desc = sf_pdma_alloc_desc(chan); in sf_pdma_prep_dma_memcpy()
100 desc->async_tx = vchan_tx_prep(&chan->vchan, &desc->vdesc, flags); in sf_pdma_prep_dma_memcpy()
102 spin_lock_irqsave(&chan->vchan.lock, iflags); in sf_pdma_prep_dma_memcpy()
104 spin_unlock_irqrestore(&chan->vchan.lock, iflags); in sf_pdma_prep_dma_memcpy()
112 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_slave_config() local
114 memcpy(&chan->cfg, cfg, sizeof(*cfg)); in sf_pdma_slave_config()
121 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_alloc_chan_resources() local
122 struct pdma_regs *regs = &chan->regs; in sf_pdma_alloc_chan_resources()
130 static void sf_pdma_disable_request(struct sf_pdma_chan *chan) in sf_pdma_disable_request() argument
132 struct pdma_regs *regs = &chan->regs; in sf_pdma_disable_request()
139 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_free_chan_resources() local
143 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_free_chan_resources()
144 sf_pdma_disable_request(chan); in sf_pdma_free_chan_resources()
145 kfree(chan->desc); in sf_pdma_free_chan_resources()
146 chan->desc = NULL; in sf_pdma_free_chan_resources()
147 vchan_get_all_descriptors(&chan->vchan, &head); in sf_pdma_free_chan_resources()
148 sf_pdma_disclaim_chan(chan); in sf_pdma_free_chan_resources()
149 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_free_chan_resources()
150 vchan_dma_desc_free_list(&chan->vchan, &head); in sf_pdma_free_chan_resources()
153 static size_t sf_pdma_desc_residue(struct sf_pdma_chan *chan, in sf_pdma_desc_residue() argument
157 struct pdma_regs *regs = &chan->regs; in sf_pdma_desc_residue()
163 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_desc_residue()
165 list_for_each_entry(vd, &chan->vchan.desc_submitted, node) in sf_pdma_desc_residue()
172 if (cookie == tx->chan->completed_cookie) in sf_pdma_desc_residue()
178 vd = vchan_find_desc(&chan->vchan, cookie); in sf_pdma_desc_residue()
187 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_desc_residue()
196 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_tx_status() local
202 dma_set_residue(txstate, sf_pdma_desc_residue(chan, cookie)); in sf_pdma_tx_status()
209 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_terminate_all() local
213 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_terminate_all()
214 sf_pdma_disable_request(chan); in sf_pdma_terminate_all()
215 kfree(chan->desc); in sf_pdma_terminate_all()
216 chan->desc = NULL; in sf_pdma_terminate_all()
217 chan->xfer_err = false; in sf_pdma_terminate_all()
218 vchan_get_all_descriptors(&chan->vchan, &head); in sf_pdma_terminate_all()
219 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_terminate_all()
220 vchan_dma_desc_free_list(&chan->vchan, &head); in sf_pdma_terminate_all()
225 static void sf_pdma_enable_request(struct sf_pdma_chan *chan) in sf_pdma_enable_request() argument
227 struct pdma_regs *regs = &chan->regs; in sf_pdma_enable_request()
238 static struct sf_pdma_desc *sf_pdma_get_first_pending_desc(struct sf_pdma_chan *chan) in sf_pdma_get_first_pending_desc() argument
240 struct virt_dma_chan *vchan = &chan->vchan; in sf_pdma_get_first_pending_desc()
251 static void sf_pdma_xfer_desc(struct sf_pdma_chan *chan) in sf_pdma_xfer_desc() argument
253 struct sf_pdma_desc *desc = chan->desc; in sf_pdma_xfer_desc()
254 struct pdma_regs *regs = &chan->regs; in sf_pdma_xfer_desc()
257 dev_err(chan->pdma->dma_dev.dev, "NULL desc.\n"); in sf_pdma_xfer_desc()
266 chan->desc = desc; in sf_pdma_xfer_desc()
267 chan->status = DMA_IN_PROGRESS; in sf_pdma_xfer_desc()
268 sf_pdma_enable_request(chan); in sf_pdma_xfer_desc()
273 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_issue_pending() local
276 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_issue_pending()
278 if (!chan->desc && vchan_issue_pending(&chan->vchan)) { in sf_pdma_issue_pending()
280 chan->desc = sf_pdma_get_first_pending_desc(chan); in sf_pdma_issue_pending()
281 sf_pdma_xfer_desc(chan); in sf_pdma_issue_pending()
284 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_issue_pending()
297 struct sf_pdma_chan *chan = from_tasklet(chan, t, done_tasklet); in sf_pdma_donebh_tasklet() local
300 spin_lock_irqsave(&chan->lock, flags); in sf_pdma_donebh_tasklet()
301 if (chan->xfer_err) { in sf_pdma_donebh_tasklet()
302 chan->retries = MAX_RETRY; in sf_pdma_donebh_tasklet()
303 chan->status = DMA_COMPLETE; in sf_pdma_donebh_tasklet()
304 chan->xfer_err = false; in sf_pdma_donebh_tasklet()
306 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_donebh_tasklet()
308 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_donebh_tasklet()
309 list_del(&chan->desc->vdesc.node); in sf_pdma_donebh_tasklet()
310 vchan_cookie_complete(&chan->desc->vdesc); in sf_pdma_donebh_tasklet()
312 chan->desc = sf_pdma_get_first_pending_desc(chan); in sf_pdma_donebh_tasklet()
313 if (chan->desc) in sf_pdma_donebh_tasklet()
314 sf_pdma_xfer_desc(chan); in sf_pdma_donebh_tasklet()
316 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_donebh_tasklet()
321 struct sf_pdma_chan *chan = from_tasklet(chan, t, err_tasklet); in sf_pdma_errbh_tasklet() local
322 struct sf_pdma_desc *desc = chan->desc; in sf_pdma_errbh_tasklet()
325 spin_lock_irqsave(&chan->lock, flags); in sf_pdma_errbh_tasklet()
326 if (chan->retries <= 0) { in sf_pdma_errbh_tasklet()
328 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_errbh_tasklet()
332 chan->retries--; in sf_pdma_errbh_tasklet()
333 chan->xfer_err = true; in sf_pdma_errbh_tasklet()
334 chan->status = DMA_ERROR; in sf_pdma_errbh_tasklet()
336 sf_pdma_enable_request(chan); in sf_pdma_errbh_tasklet()
337 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_errbh_tasklet()
343 struct sf_pdma_chan *chan = dev_id; in sf_pdma_done_isr() local
344 struct pdma_regs *regs = &chan->regs; in sf_pdma_done_isr()
347 spin_lock(&chan->vchan.lock); in sf_pdma_done_isr()
352 tasklet_hi_schedule(&chan->done_tasklet); in sf_pdma_done_isr()
355 struct sf_pdma_desc *desc = chan->desc; in sf_pdma_done_isr()
361 sf_pdma_xfer_desc(chan); in sf_pdma_done_isr()
364 spin_unlock(&chan->vchan.lock); in sf_pdma_done_isr()
371 struct sf_pdma_chan *chan = dev_id; in sf_pdma_err_isr() local
372 struct pdma_regs *regs = &chan->regs; in sf_pdma_err_isr()
374 spin_lock(&chan->lock); in sf_pdma_err_isr()
376 spin_unlock(&chan->lock); in sf_pdma_err_isr()
378 tasklet_schedule(&chan->err_tasklet); in sf_pdma_err_isr()
401 struct sf_pdma_chan *chan; in sf_pdma_irq_init() local
404 chan = &pdma->chans[i]; in sf_pdma_irq_init()
411 dev_name(&pdev->dev), (void *)chan); in sf_pdma_irq_init()
417 chan->txirq = irq; in sf_pdma_irq_init()
424 dev_name(&pdev->dev), (void *)chan); in sf_pdma_irq_init()
430 chan->errirq = irq; in sf_pdma_irq_init()
451 struct sf_pdma_chan *chan; in sf_pdma_setup_chans() local
456 chan = &pdma->chans[i]; in sf_pdma_setup_chans()
458 chan->regs.ctrl = in sf_pdma_setup_chans()
460 chan->regs.xfer_type = in sf_pdma_setup_chans()
462 chan->regs.xfer_size = in sf_pdma_setup_chans()
464 chan->regs.dst_addr = in sf_pdma_setup_chans()
466 chan->regs.src_addr = in sf_pdma_setup_chans()
468 chan->regs.act_type = in sf_pdma_setup_chans()
470 chan->regs.residue = in sf_pdma_setup_chans()
472 chan->regs.cur_dst_addr = in sf_pdma_setup_chans()
474 chan->regs.cur_src_addr = in sf_pdma_setup_chans()
477 chan->pdma = pdma; in sf_pdma_setup_chans()
478 chan->pm_state = RUNNING; in sf_pdma_setup_chans()
479 chan->slave_id = i; in sf_pdma_setup_chans()
480 chan->xfer_err = false; in sf_pdma_setup_chans()
481 spin_lock_init(&chan->lock); in sf_pdma_setup_chans()
483 chan->vchan.desc_free = sf_pdma_free_desc; in sf_pdma_setup_chans()
484 vchan_init(&chan->vchan, &pdma->dma_dev); in sf_pdma_setup_chans()
486 writel(PDMA_CLEAR_CTRL, chan->regs.ctrl); in sf_pdma_setup_chans()
488 tasklet_setup(&chan->done_tasklet, sf_pdma_donebh_tasklet); in sf_pdma_setup_chans()
489 tasklet_setup(&chan->err_tasklet, sf_pdma_errbh_tasklet); in sf_pdma_setup_chans()
580 list_del(&ch->vchan.chan.device_node); in sf_pdma_remove()