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
57 spin_lock_irqsave(&chan->lock, flags); in sf_pdma_alloc_desc()
59 if (chan->desc && !chan->desc->in_use) { in sf_pdma_alloc_desc()
60 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_alloc_desc()
61 return chan->desc; in sf_pdma_alloc_desc()
64 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_alloc_desc()
70 desc->chan = chan; in sf_pdma_alloc_desc()
84 static void sf_pdma_disclaim_chan(struct sf_pdma_chan *chan) in sf_pdma_disclaim_chan() argument
86 struct pdma_regs *regs = &chan->regs; in sf_pdma_disclaim_chan()
95 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_prep_dma_memcpy() local
99 if (chan && (!len || !dest || !src)) { in sf_pdma_prep_dma_memcpy()
100 dev_err(chan->pdma->dma_dev.dev, in sf_pdma_prep_dma_memcpy()
105 desc = sf_pdma_alloc_desc(chan); in sf_pdma_prep_dma_memcpy()
111 desc->async_tx = vchan_tx_prep(&chan->vchan, &desc->vdesc, flags); in sf_pdma_prep_dma_memcpy()
113 spin_lock_irqsave(&chan->vchan.lock, iflags); in sf_pdma_prep_dma_memcpy()
114 chan->desc = desc; in sf_pdma_prep_dma_memcpy()
116 spin_unlock_irqrestore(&chan->vchan.lock, iflags); in sf_pdma_prep_dma_memcpy()
124 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_slave_config() local
126 memcpy(&chan->cfg, cfg, sizeof(*cfg)); in sf_pdma_slave_config()
133 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_alloc_chan_resources() local
134 struct pdma_regs *regs = &chan->regs; in sf_pdma_alloc_chan_resources()
142 static void sf_pdma_disable_request(struct sf_pdma_chan *chan) in sf_pdma_disable_request() argument
144 struct pdma_regs *regs = &chan->regs; in sf_pdma_disable_request()
151 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_free_chan_resources() local
155 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_free_chan_resources()
156 sf_pdma_disable_request(chan); in sf_pdma_free_chan_resources()
157 kfree(chan->desc); in sf_pdma_free_chan_resources()
158 chan->desc = NULL; in sf_pdma_free_chan_resources()
159 vchan_get_all_descriptors(&chan->vchan, &head); in sf_pdma_free_chan_resources()
160 sf_pdma_disclaim_chan(chan); in sf_pdma_free_chan_resources()
161 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_free_chan_resources()
162 vchan_dma_desc_free_list(&chan->vchan, &head); in sf_pdma_free_chan_resources()
165 static size_t sf_pdma_desc_residue(struct sf_pdma_chan *chan, in sf_pdma_desc_residue() argument
169 struct pdma_regs *regs = &chan->regs; in sf_pdma_desc_residue()
175 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_desc_residue()
177 tx = &chan->desc->vdesc.tx; in sf_pdma_desc_residue()
178 if (cookie == tx->chan->completed_cookie) in sf_pdma_desc_residue()
184 vd = vchan_find_desc(&chan->vchan, cookie); in sf_pdma_desc_residue()
193 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_desc_residue()
202 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_tx_status() local
208 dma_set_residue(txstate, sf_pdma_desc_residue(chan, cookie)); in sf_pdma_tx_status()
215 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_terminate_all() local
219 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_terminate_all()
220 sf_pdma_disable_request(chan); in sf_pdma_terminate_all()
221 kfree(chan->desc); in sf_pdma_terminate_all()
222 chan->desc = NULL; in sf_pdma_terminate_all()
223 chan->xfer_err = false; in sf_pdma_terminate_all()
224 vchan_get_all_descriptors(&chan->vchan, &head); in sf_pdma_terminate_all()
225 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_terminate_all()
226 vchan_dma_desc_free_list(&chan->vchan, &head); in sf_pdma_terminate_all()
231 static void sf_pdma_enable_request(struct sf_pdma_chan *chan) in sf_pdma_enable_request() argument
233 struct pdma_regs *regs = &chan->regs; in sf_pdma_enable_request()
244 static void sf_pdma_xfer_desc(struct sf_pdma_chan *chan) in sf_pdma_xfer_desc() argument
246 struct sf_pdma_desc *desc = chan->desc; in sf_pdma_xfer_desc()
247 struct pdma_regs *regs = &chan->regs; in sf_pdma_xfer_desc()
250 dev_err(chan->pdma->dma_dev.dev, "NULL desc.\n"); in sf_pdma_xfer_desc()
259 chan->desc = desc; in sf_pdma_xfer_desc()
260 chan->status = DMA_IN_PROGRESS; in sf_pdma_xfer_desc()
261 sf_pdma_enable_request(chan); in sf_pdma_xfer_desc()
266 struct sf_pdma_chan *chan = to_sf_pdma_chan(dchan); in sf_pdma_issue_pending() local
269 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_issue_pending()
271 if (vchan_issue_pending(&chan->vchan) && chan->desc) in sf_pdma_issue_pending()
272 sf_pdma_xfer_desc(chan); in sf_pdma_issue_pending()
274 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_issue_pending()
287 struct sf_pdma_chan *chan = from_tasklet(chan, t, done_tasklet); in sf_pdma_donebh_tasklet() local
290 spin_lock_irqsave(&chan->lock, flags); in sf_pdma_donebh_tasklet()
291 if (chan->xfer_err) { in sf_pdma_donebh_tasklet()
292 chan->retries = MAX_RETRY; in sf_pdma_donebh_tasklet()
293 chan->status = DMA_COMPLETE; in sf_pdma_donebh_tasklet()
294 chan->xfer_err = false; in sf_pdma_donebh_tasklet()
296 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_donebh_tasklet()
298 spin_lock_irqsave(&chan->vchan.lock, flags); in sf_pdma_donebh_tasklet()
299 list_del(&chan->desc->vdesc.node); in sf_pdma_donebh_tasklet()
300 vchan_cookie_complete(&chan->desc->vdesc); in sf_pdma_donebh_tasklet()
301 spin_unlock_irqrestore(&chan->vchan.lock, flags); in sf_pdma_donebh_tasklet()
306 struct sf_pdma_chan *chan = from_tasklet(chan, t, err_tasklet); in sf_pdma_errbh_tasklet() local
307 struct sf_pdma_desc *desc = chan->desc; in sf_pdma_errbh_tasklet()
310 spin_lock_irqsave(&chan->lock, flags); in sf_pdma_errbh_tasklet()
311 if (chan->retries <= 0) { in sf_pdma_errbh_tasklet()
313 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_errbh_tasklet()
317 chan->retries--; in sf_pdma_errbh_tasklet()
318 chan->xfer_err = true; in sf_pdma_errbh_tasklet()
319 chan->status = DMA_ERROR; in sf_pdma_errbh_tasklet()
321 sf_pdma_enable_request(chan); in sf_pdma_errbh_tasklet()
322 spin_unlock_irqrestore(&chan->lock, flags); in sf_pdma_errbh_tasklet()
328 struct sf_pdma_chan *chan = dev_id; in sf_pdma_done_isr() local
329 struct pdma_regs *regs = &chan->regs; in sf_pdma_done_isr()
332 spin_lock(&chan->vchan.lock); in sf_pdma_done_isr()
337 tasklet_hi_schedule(&chan->done_tasklet); in sf_pdma_done_isr()
340 struct sf_pdma_desc *desc = chan->desc; in sf_pdma_done_isr()
346 sf_pdma_xfer_desc(chan); in sf_pdma_done_isr()
349 spin_unlock(&chan->vchan.lock); in sf_pdma_done_isr()
356 struct sf_pdma_chan *chan = dev_id; in sf_pdma_err_isr() local
357 struct pdma_regs *regs = &chan->regs; in sf_pdma_err_isr()
359 spin_lock(&chan->lock); in sf_pdma_err_isr()
361 spin_unlock(&chan->lock); in sf_pdma_err_isr()
363 tasklet_schedule(&chan->err_tasklet); in sf_pdma_err_isr()
386 struct sf_pdma_chan *chan; in sf_pdma_irq_init() local
389 chan = &pdma->chans[i]; in sf_pdma_irq_init()
398 dev_name(&pdev->dev), (void *)chan); in sf_pdma_irq_init()
404 chan->txirq = irq; in sf_pdma_irq_init()
413 dev_name(&pdev->dev), (void *)chan); in sf_pdma_irq_init()
419 chan->errirq = irq; in sf_pdma_irq_init()
440 struct sf_pdma_chan *chan; in sf_pdma_setup_chans() local
445 chan = &pdma->chans[i]; in sf_pdma_setup_chans()
447 chan->regs.ctrl = in sf_pdma_setup_chans()
449 chan->regs.xfer_type = in sf_pdma_setup_chans()
451 chan->regs.xfer_size = in sf_pdma_setup_chans()
453 chan->regs.dst_addr = in sf_pdma_setup_chans()
455 chan->regs.src_addr = in sf_pdma_setup_chans()
457 chan->regs.act_type = in sf_pdma_setup_chans()
459 chan->regs.residue = in sf_pdma_setup_chans()
461 chan->regs.cur_dst_addr = in sf_pdma_setup_chans()
463 chan->regs.cur_src_addr = in sf_pdma_setup_chans()
466 chan->pdma = pdma; in sf_pdma_setup_chans()
467 chan->pm_state = RUNNING; in sf_pdma_setup_chans()
468 chan->slave_id = i; in sf_pdma_setup_chans()
469 chan->xfer_err = false; in sf_pdma_setup_chans()
470 spin_lock_init(&chan->lock); in sf_pdma_setup_chans()
472 chan->vchan.desc_free = sf_pdma_free_desc; in sf_pdma_setup_chans()
473 vchan_init(&chan->vchan, &pdma->dma_dev); in sf_pdma_setup_chans()
475 writel(PDMA_CLEAR_CTRL, chan->regs.ctrl); in sf_pdma_setup_chans()
477 tasklet_setup(&chan->done_tasklet, sf_pdma_donebh_tasklet); in sf_pdma_setup_chans()
478 tasklet_setup(&chan->err_tasklet, sf_pdma_errbh_tasklet); in sf_pdma_setup_chans()
485 struct sf_pdma_chan *chan; in sf_pdma_probe() local
496 len = sizeof(*pdma) + sizeof(*chan) * chans; in sf_pdma_probe()
564 list_del(&ch->vchan.chan.device_node); in sf_pdma_remove()