Lines Matching full:pch

1559 	struct dma_pl330_chan *pch;  in dma_pl330_rqcb()  local
1565 pch = desc->pchan; in dma_pl330_rqcb()
1568 if (!pch) in dma_pl330_rqcb()
1571 spin_lock_irqsave(&pch->lock, flags); in dma_pl330_rqcb()
1575 spin_unlock_irqrestore(&pch->lock, flags); in dma_pl330_rqcb()
1577 tasklet_schedule(&pch->task); in dma_pl330_rqcb()
2042 static inline void fill_queue(struct dma_pl330_chan *pch) in fill_queue() argument
2047 list_for_each_entry(desc, &pch->work_list, node) { in fill_queue()
2053 ret = pl330_submit_req(pch->thread, desc); in fill_queue()
2062 dev_err(pch->dmac->ddma.dev, "%s:%d Bad Desc(%d)\n", in fill_queue()
2064 tasklet_schedule(&pch->task); in fill_queue()
2071 struct dma_pl330_chan *pch = from_tasklet(pch, t, task); in pl330_tasklet() local
2076 spin_lock_irqsave(&pch->lock, flags); in pl330_tasklet()
2079 list_for_each_entry_safe(desc, _dt, &pch->work_list, node) in pl330_tasklet()
2081 if (!pch->cyclic) in pl330_tasklet()
2083 list_move_tail(&desc->node, &pch->completed_list); in pl330_tasklet()
2087 fill_queue(pch); in pl330_tasklet()
2089 if (list_empty(&pch->work_list)) { in pl330_tasklet()
2090 spin_lock(&pch->thread->dmac->lock); in pl330_tasklet()
2091 _stop(pch->thread); in pl330_tasklet()
2092 spin_unlock(&pch->thread->dmac->lock); in pl330_tasklet()
2094 pch->active = false; in pl330_tasklet()
2097 spin_lock(&pch->thread->dmac->lock); in pl330_tasklet()
2098 pl330_start_thread(pch->thread); in pl330_tasklet()
2099 spin_unlock(&pch->thread->dmac->lock); in pl330_tasklet()
2102 while (!list_empty(&pch->completed_list)) { in pl330_tasklet()
2105 desc = list_first_entry(&pch->completed_list, in pl330_tasklet()
2110 if (pch->cyclic) { in pl330_tasklet()
2112 list_move_tail(&desc->node, &pch->work_list); in pl330_tasklet()
2114 pch->active = true; in pl330_tasklet()
2115 spin_lock(&pch->thread->dmac->lock); in pl330_tasklet()
2116 pl330_start_thread(pch->thread); in pl330_tasklet()
2117 spin_unlock(&pch->thread->dmac->lock); in pl330_tasklet()
2122 list_move_tail(&desc->node, &pch->dmac->desc_pool); in pl330_tasklet()
2128 spin_unlock_irqrestore(&pch->lock, flags); in pl330_tasklet()
2130 spin_lock_irqsave(&pch->lock, flags); in pl330_tasklet()
2133 spin_unlock_irqrestore(&pch->lock, flags); in pl330_tasklet()
2137 pm_runtime_mark_last_busy(pch->dmac->ddma.dev); in pl330_tasklet()
2138 pm_runtime_put_autosuspend(pch->dmac->ddma.dev); in pl330_tasklet()
2164 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_alloc_chan_resources() local
2165 struct pl330_dmac *pl330 = pch->dmac; in pl330_alloc_chan_resources()
2171 pch->cyclic = false; in pl330_alloc_chan_resources()
2173 pch->thread = pl330_request_channel(pl330); in pl330_alloc_chan_resources()
2174 if (!pch->thread) { in pl330_alloc_chan_resources()
2179 tasklet_setup(&pch->task, pl330_tasklet); in pl330_alloc_chan_resources()
2205 static void pl330_unprep_slave_fifo(struct dma_pl330_chan *pch) in pl330_unprep_slave_fifo() argument
2207 if (pch->dir != DMA_NONE) in pl330_unprep_slave_fifo()
2208 dma_unmap_resource(pch->chan.device->dev, pch->fifo_dma, in pl330_unprep_slave_fifo()
2209 1 << pch->burst_sz, pch->dir, 0); in pl330_unprep_slave_fifo()
2210 pch->dir = DMA_NONE; in pl330_unprep_slave_fifo()
2214 static bool pl330_prep_slave_fifo(struct dma_pl330_chan *pch, in pl330_prep_slave_fifo() argument
2217 struct device *dev = pch->chan.device->dev; in pl330_prep_slave_fifo()
2221 if (pch->dir == dma_dir) in pl330_prep_slave_fifo()
2224 pl330_unprep_slave_fifo(pch); in pl330_prep_slave_fifo()
2225 pch->fifo_dma = dma_map_resource(dev, pch->fifo_addr, in pl330_prep_slave_fifo()
2226 1 << pch->burst_sz, dma_dir, 0); in pl330_prep_slave_fifo()
2227 if (dma_mapping_error(dev, pch->fifo_dma)) in pl330_prep_slave_fifo()
2230 pch->dir = dma_dir; in pl330_prep_slave_fifo()
2248 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_config_write() local
2250 pl330_unprep_slave_fifo(pch); in pl330_config_write()
2253 pch->fifo_addr = slave_config->dst_addr; in pl330_config_write()
2255 pch->burst_sz = __ffs(slave_config->dst_addr_width); in pl330_config_write()
2256 pch->burst_len = fixup_burst_len(slave_config->dst_maxburst, in pl330_config_write()
2257 pch->dmac->quirks); in pl330_config_write()
2260 pch->fifo_addr = slave_config->src_addr; in pl330_config_write()
2262 pch->burst_sz = __ffs(slave_config->src_addr_width); in pl330_config_write()
2263 pch->burst_len = fixup_burst_len(slave_config->src_maxburst, in pl330_config_write()
2264 pch->dmac->quirks); in pl330_config_write()
2273 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_config() local
2275 memcpy(&pch->slave_config, slave_config, sizeof(*slave_config)); in pl330_config()
2282 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_terminate_all() local
2285 struct pl330_dmac *pl330 = pch->dmac; in pl330_terminate_all()
2289 spin_lock_irqsave(&pch->lock, flags); in pl330_terminate_all()
2292 _stop(pch->thread); in pl330_terminate_all()
2293 pch->thread->req[0].desc = NULL; in pl330_terminate_all()
2294 pch->thread->req[1].desc = NULL; in pl330_terminate_all()
2295 pch->thread->req_running = -1; in pl330_terminate_all()
2298 power_down = pch->active; in pl330_terminate_all()
2299 pch->active = false; in pl330_terminate_all()
2302 list_for_each_entry(desc, &pch->submitted_list, node) { in pl330_terminate_all()
2307 list_for_each_entry(desc, &pch->work_list , node) { in pl330_terminate_all()
2312 list_splice_tail_init(&pch->submitted_list, &pl330->desc_pool); in pl330_terminate_all()
2313 list_splice_tail_init(&pch->work_list, &pl330->desc_pool); in pl330_terminate_all()
2314 list_splice_tail_init(&pch->completed_list, &pl330->desc_pool); in pl330_terminate_all()
2315 spin_unlock_irqrestore(&pch->lock, flags); in pl330_terminate_all()
2333 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_pause() local
2334 struct pl330_dmac *pl330 = pch->dmac; in pl330_pause()
2339 spin_lock_irqsave(&pch->lock, flags); in pl330_pause()
2342 _stop(pch->thread); in pl330_pause()
2345 list_for_each_entry(desc, &pch->work_list, node) { in pl330_pause()
2349 spin_unlock_irqrestore(&pch->lock, flags); in pl330_pause()
2358 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_free_chan_resources() local
2359 struct pl330_dmac *pl330 = pch->dmac; in pl330_free_chan_resources()
2362 tasklet_kill(&pch->task); in pl330_free_chan_resources()
2364 pm_runtime_get_sync(pch->dmac->ddma.dev); in pl330_free_chan_resources()
2367 pl330_release_channel(pch->thread); in pl330_free_chan_resources()
2368 pch->thread = NULL; in pl330_free_chan_resources()
2370 if (pch->cyclic) in pl330_free_chan_resources()
2371 list_splice_tail_init(&pch->work_list, &pch->dmac->desc_pool); in pl330_free_chan_resources()
2374 pm_runtime_mark_last_busy(pch->dmac->ddma.dev); in pl330_free_chan_resources()
2375 pm_runtime_put_autosuspend(pch->dmac->ddma.dev); in pl330_free_chan_resources()
2376 pl330_unprep_slave_fifo(pch); in pl330_free_chan_resources()
2379 static int pl330_get_current_xferred_count(struct dma_pl330_chan *pch, in pl330_get_current_xferred_count() argument
2382 struct pl330_thread *thrd = pch->thread; in pl330_get_current_xferred_count()
2383 struct pl330_dmac *pl330 = pch->dmac; in pl330_get_current_xferred_count()
2396 pm_runtime_mark_last_busy(pch->dmac->ddma.dev); in pl330_get_current_xferred_count()
2413 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_tx_status() local
2424 spin_lock_irqsave(&pch->lock, flags); in pl330_tx_status()
2425 spin_lock(&pch->thread->dmac->lock); in pl330_tx_status()
2427 if (pch->thread->req_running != -1) in pl330_tx_status()
2428 running = pch->thread->req[pch->thread->req_running].desc; in pl330_tx_status()
2430 last_enq = pch->thread->req[pch->thread->lstenq].desc; in pl330_tx_status()
2433 list_for_each_entry(desc, &pch->work_list, node) { in pl330_tx_status()
2438 pl330_get_current_xferred_count(pch, desc); in pl330_tx_status()
2471 spin_unlock(&pch->thread->dmac->lock); in pl330_tx_status()
2472 spin_unlock_irqrestore(&pch->lock, flags); in pl330_tx_status()
2482 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_issue_pending() local
2485 spin_lock_irqsave(&pch->lock, flags); in pl330_issue_pending()
2486 if (list_empty(&pch->work_list)) { in pl330_issue_pending()
2492 WARN_ON(list_empty(&pch->submitted_list)); in pl330_issue_pending()
2493 pch->active = true; in pl330_issue_pending()
2494 pm_runtime_get_sync(pch->dmac->ddma.dev); in pl330_issue_pending()
2496 list_splice_tail_init(&pch->submitted_list, &pch->work_list); in pl330_issue_pending()
2497 spin_unlock_irqrestore(&pch->lock, flags); in pl330_issue_pending()
2499 pl330_tasklet(&pch->task); in pl330_issue_pending()
2510 struct dma_pl330_chan *pch = to_pchan(tx->chan); in pl330_tx_submit() local
2514 spin_lock_irqsave(&pch->lock, flags); in pl330_tx_submit()
2519 if (pch->cyclic) { in pl330_tx_submit()
2527 list_move_tail(&desc->node, &pch->submitted_list); in pl330_tx_submit()
2532 list_add_tail(&last->node, &pch->submitted_list); in pl330_tx_submit()
2533 spin_unlock_irqrestore(&pch->lock, flags); in pl330_tx_submit()
2595 static struct dma_pl330_desc *pl330_get_desc(struct dma_pl330_chan *pch) in pl330_get_desc() argument
2597 struct pl330_dmac *pl330 = pch->dmac; in pl330_get_desc()
2598 u8 *peri_id = pch->chan.private; in pl330_get_desc()
2617 desc->pchan = pch; in pl330_get_desc()
2621 desc->peri = peri_id ? pch->chan.chan_id : 0; in pl330_get_desc()
2622 desc->rqcfg.pcfg = &pch->dmac->pcfg; in pl330_get_desc()
2624 dma_async_tx_descriptor_init(&desc->txd, &pch->chan); in pl330_get_desc()
2638 __pl330_prep_dma_memcpy(struct dma_pl330_chan *pch, dma_addr_t dst, in __pl330_prep_dma_memcpy() argument
2641 struct dma_pl330_desc *desc = pl330_get_desc(pch); in __pl330_prep_dma_memcpy()
2644 dev_err(pch->dmac->ddma.dev, "%s:%d Unable to fetch desc\n", in __pl330_prep_dma_memcpy()
2667 struct dma_pl330_chan *pch = desc->pchan; in get_burst_len() local
2668 struct pl330_dmac *pl330 = pch->dmac; in get_burst_len()
2688 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_prep_dma_cyclic() local
2689 struct pl330_dmac *pl330 = pch->dmac; in pl330_prep_dma_cyclic()
2698 dev_err(pch->dmac->ddma.dev, "%s:%d Invalid dma direction\n", in pl330_prep_dma_cyclic()
2703 pl330_config_write(chan, &pch->slave_config, direction); in pl330_prep_dma_cyclic()
2705 if (!pl330_prep_slave_fifo(pch, direction)) in pl330_prep_dma_cyclic()
2709 desc = pl330_get_desc(pch); in pl330_prep_dma_cyclic()
2713 dev_err(pch->dmac->ddma.dev, "%s:%d Unable to fetch desc\n", in pl330_prep_dma_cyclic()
2739 dst = pch->fifo_dma; in pl330_prep_dma_cyclic()
2744 src = pch->fifo_dma; in pl330_prep_dma_cyclic()
2752 desc->rqcfg.brst_size = pch->burst_sz; in pl330_prep_dma_cyclic()
2753 desc->rqcfg.brst_len = pch->burst_len; in pl330_prep_dma_cyclic()
2768 pch->cyclic = true; in pl330_prep_dma_cyclic()
2778 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_prep_dma_memcpy() local
2782 if (unlikely(!pch || !len)) in pl330_prep_dma_memcpy()
2785 pl330 = pch->dmac; in pl330_prep_dma_memcpy()
2787 desc = __pl330_prep_dma_memcpy(pch, dst, src, len); in pl330_prep_dma_memcpy()
2851 struct dma_pl330_chan *pch = to_pchan(chan); in pl330_prep_slave_sg() local
2855 if (unlikely(!pch || !sgl || !sg_len)) in pl330_prep_slave_sg()
2858 pl330_config_write(chan, &pch->slave_config, direction); in pl330_prep_slave_sg()
2860 if (!pl330_prep_slave_fifo(pch, direction)) in pl330_prep_slave_sg()
2867 desc = pl330_get_desc(pch); in pl330_prep_slave_sg()
2869 struct pl330_dmac *pl330 = pch->dmac; in pl330_prep_slave_sg()
2871 dev_err(pch->dmac->ddma.dev, in pl330_prep_slave_sg()
2887 fill_px(&desc->px, pch->fifo_dma, sg_dma_address(sg), in pl330_prep_slave_sg()
2892 fill_px(&desc->px, sg_dma_address(sg), pch->fifo_dma, in pl330_prep_slave_sg()
2896 desc->rqcfg.brst_size = pch->burst_sz; in pl330_prep_slave_sg()
2897 desc->rqcfg.brst_len = pch->burst_len; in pl330_prep_slave_sg()
2938 struct dma_pl330_chan *pch = &pl330->peripherals[pr]; in pl330_debugfs_show() local
2940 if (!pch->thread || thrd->id != pch->thread->id) in pl330_debugfs_show()
3009 struct dma_pl330_chan *pch, *_p; in pl330_probe() local
3100 pl330->peripherals = kcalloc(num_chan, sizeof(*pch), GFP_KERNEL); in pl330_probe()
3107 pch = &pl330->peripherals[i]; in pl330_probe()
3109 pch->chan.private = adev->dev.of_node; in pl330_probe()
3110 INIT_LIST_HEAD(&pch->submitted_list); in pl330_probe()
3111 INIT_LIST_HEAD(&pch->work_list); in pl330_probe()
3112 INIT_LIST_HEAD(&pch->completed_list); in pl330_probe()
3113 spin_lock_init(&pch->lock); in pl330_probe()
3114 pch->thread = NULL; in pl330_probe()
3115 pch->chan.device = pd; in pl330_probe()
3116 pch->dmac = pl330; in pl330_probe()
3117 pch->dir = DMA_NONE; in pl330_probe()
3120 list_add_tail(&pch->chan.device_node, &pd->channels); in pl330_probe()
3187 list_for_each_entry_safe(pch, _p, &pl330->ddma.channels, in pl330_probe()
3191 list_del(&pch->chan.device_node); in pl330_probe()
3194 if (pch->thread) { in pl330_probe()
3195 pl330_terminate_all(&pch->chan); in pl330_probe()
3196 pl330_free_chan_resources(&pch->chan); in pl330_probe()
3213 struct dma_pl330_chan *pch, *_p; in pl330_remove() local
3230 list_for_each_entry_safe(pch, _p, &pl330->ddma.channels, in pl330_remove()
3234 list_del(&pch->chan.device_node); in pl330_remove()
3237 if (pch->thread) { in pl330_remove()
3238 pl330_terminate_all(&pch->chan); in pl330_remove()
3239 pl330_free_chan_resources(&pch->chan); in pl330_remove()