Lines Matching refs:dma
117 struct knav_dma_device *dma; member
264 static void dma_hw_enable_all(struct knav_dma_device *dma) in dma_hw_enable_all() argument
268 for (i = 0; i < dma->max_tx_chan; i++) { in dma_hw_enable_all()
269 writel_relaxed(0, &dma->reg_tx_chan[i].mode); in dma_hw_enable_all()
270 writel_relaxed(DMA_ENABLE, &dma->reg_tx_chan[i].control); in dma_hw_enable_all()
275 static void knav_dma_hw_init(struct knav_dma_device *dma) in knav_dma_hw_init() argument
280 spin_lock(&dma->lock); in knav_dma_hw_init()
281 v = dma->loopback ? DMA_LOOPBACK : 0; in knav_dma_hw_init()
282 writel_relaxed(v, &dma->reg_global->emulation_control); in knav_dma_hw_init()
284 v = readl_relaxed(&dma->reg_global->perf_control); in knav_dma_hw_init()
285 v |= ((dma->rx_timeout & DMA_RX_TIMEOUT_MASK) << DMA_RX_TIMEOUT_SHIFT); in knav_dma_hw_init()
286 writel_relaxed(v, &dma->reg_global->perf_control); in knav_dma_hw_init()
288 v = ((dma->tx_priority << DMA_TX_PRIO_SHIFT) | in knav_dma_hw_init()
289 (dma->rx_priority << DMA_RX_PRIO_SHIFT)); in knav_dma_hw_init()
291 writel_relaxed(v, &dma->reg_global->priority_control); in knav_dma_hw_init()
294 for (i = 0; i < dma->max_rx_chan; i++) in knav_dma_hw_init()
295 writel_relaxed(DMA_ENABLE, &dma->reg_rx_chan[i].control); in knav_dma_hw_init()
297 for (i = 0; i < dma->logical_queue_managers; i++) in knav_dma_hw_init()
298 writel_relaxed(dma->qm_base_address[i], in knav_dma_hw_init()
299 &dma->reg_global->qm_base_address[i]); in knav_dma_hw_init()
300 spin_unlock(&dma->lock); in knav_dma_hw_init()
303 static void knav_dma_hw_destroy(struct knav_dma_device *dma) in knav_dma_hw_destroy() argument
308 spin_lock(&dma->lock); in knav_dma_hw_destroy()
311 for (i = 0; i < dma->max_rx_chan; i++) in knav_dma_hw_destroy()
312 writel_relaxed(v, &dma->reg_rx_chan[i].control); in knav_dma_hw_destroy()
314 for (i = 0; i < dma->max_tx_chan; i++) in knav_dma_hw_destroy()
315 writel_relaxed(v, &dma->reg_tx_chan[i].control); in knav_dma_hw_destroy()
316 spin_unlock(&dma->lock); in knav_dma_hw_destroy()
348 struct knav_dma_device *dma) in dma_debug_show_devices() argument
352 list_for_each_entry(chan, &dma->chan_list, list) { in dma_debug_show_devices()
360 struct knav_dma_device *dma; in knav_dma_debug_show() local
362 list_for_each_entry(dma, &kdev->list, list) { in knav_dma_debug_show()
363 if (atomic_read(&dma->ref_count)) { in knav_dma_debug_show()
365 dma->name, dma->max_tx_chan, dma->max_rx_flow); in knav_dma_debug_show()
366 dma_debug_show_devices(s, dma); in knav_dma_debug_show()
419 struct knav_dma_device *dma; in knav_dma_open_channel() local
447 list_for_each_entry(dma, &kdev->list, list) { in knav_dma_open_channel()
448 if (!strcmp(dma->name, instance)) { in knav_dma_open_channel()
460 list_for_each_entry(chan, &dma->chan_list, list) { in knav_dma_open_channel()
487 if (atomic_inc_return(&chan->dma->ref_count) <= 1) in knav_dma_open_channel()
488 knav_dma_hw_init(chan->dma); in knav_dma_open_channel()
518 if (atomic_dec_return(&chan->dma->ref_count) <= 0) in knav_dma_close_channel()
519 knav_dma_hw_destroy(chan->dma); in knav_dma_close_channel()
522 chan->channel, chan->flow, chan->dma->name); in knav_dma_close_channel()
526 static void __iomem *pktdma_get_regs(struct knav_dma_device *dma, in pktdma_get_regs() argument
554 struct knav_dma_device *dma = chan->dma; in pktdma_init_rx_chan() local
557 chan->reg_rx_flow = dma->reg_rx_flow + flow; in pktdma_init_rx_chan()
566 struct knav_dma_device *dma = chan->dma; in pktdma_init_tx_chan() local
569 chan->reg_chan = dma->reg_tx_chan + channel; in pktdma_init_tx_chan()
570 chan->reg_tx_sched = dma->reg_tx_sched + channel; in pktdma_init_tx_chan()
577 static int pktdma_init_chan(struct knav_dma_device *dma, in pktdma_init_chan() argument
590 chan->dma = dma; in pktdma_init_chan()
605 list_add_tail(&chan->list, &dma->chan_list); in pktdma_init_chan()
614 struct knav_dma_device *dma; in dma_init() local
620 dma = devm_kzalloc(kdev->dev, sizeof(*dma), GFP_KERNEL); in dma_init()
621 if (!dma) { in dma_init()
625 INIT_LIST_HEAD(&dma->list); in dma_init()
626 INIT_LIST_HEAD(&dma->chan_list); in dma_init()
633 dma->logical_queue_managers = len / sizeof(u32); in dma_init()
634 if (dma->logical_queue_managers > DMA_MAX_QMS) { in dma_init()
636 dma->logical_queue_managers); in dma_init()
637 dma->logical_queue_managers = DMA_MAX_QMS; in dma_init()
641 dma->qm_base_address, in dma_init()
642 dma->logical_queue_managers); in dma_init()
648 dma->reg_global = pktdma_get_regs(dma, node, 0, &size); in dma_init()
649 if (!dma->reg_global) in dma_init()
656 dma->reg_tx_chan = pktdma_get_regs(dma, node, 1, &size); in dma_init()
657 if (!dma->reg_tx_chan) in dma_init()
661 dma->reg_rx_chan = pktdma_get_regs(dma, node, 2, &size); in dma_init()
662 if (!dma->reg_rx_chan) in dma_init()
666 dma->reg_tx_sched = pktdma_get_regs(dma, node, 3, &size); in dma_init()
667 if (!dma->reg_tx_sched) in dma_init()
671 dma->reg_rx_flow = pktdma_get_regs(dma, node, 4, &size); in dma_init()
672 if (!dma->reg_rx_flow) in dma_init()
676 dma->rx_priority = DMA_PRIO_DEFAULT; in dma_init()
677 dma->tx_priority = DMA_PRIO_DEFAULT; in dma_init()
679 dma->enable_all = (of_get_property(node, "ti,enable-all", NULL) != NULL); in dma_init()
680 dma->loopback = (of_get_property(node, "ti,loop-back", NULL) != NULL); in dma_init()
689 dma->rx_timeout = timeout; in dma_init()
690 dma->max_rx_chan = max_rx_chan; in dma_init()
691 dma->max_rx_flow = max_rx_flow; in dma_init()
692 dma->max_tx_chan = min(max_tx_chan, max_tx_sched); in dma_init()
693 atomic_set(&dma->ref_count, 0); in dma_init()
694 strcpy(dma->name, node->name); in dma_init()
695 spin_lock_init(&dma->lock); in dma_init()
697 for (i = 0; i < dma->max_tx_chan; i++) { in dma_init()
698 if (pktdma_init_chan(dma, DMA_MEM_TO_DEV, i) >= 0) in dma_init()
702 for (i = 0; i < dma->max_rx_flow; i++) { in dma_init()
703 if (pktdma_init_chan(dma, DMA_DEV_TO_MEM, i) >= 0) in dma_init()
707 list_add_tail(&dma->list, &kdev->list); in dma_init()
713 if (dma->enable_all) { in dma_init()
714 atomic_inc(&dma->ref_count); in dma_init()
715 knav_dma_hw_init(dma); in dma_init()
716 dma_hw_enable_all(dma); in dma_init()
720 dma->name, num_chan, dma->max_rx_flow, in dma_init()
721 dma->max_tx_chan, dma->max_rx_chan, in dma_init()
722 dma->loopback ? ", loopback" : ""); in dma_init()
789 struct knav_dma_device *dma; in knav_dma_remove() local
791 list_for_each_entry(dma, &kdev->list, list) { in knav_dma_remove()
792 if (atomic_dec_return(&dma->ref_count) == 0) in knav_dma_remove()
793 knav_dma_hw_destroy(dma); in knav_dma_remove()