Lines Matching refs:mxs_dma

38 #define dma_is_apbh(mxs_dma)	((mxs_dma)->type == MXS_DMA_APBH)  argument
39 #define apbh_is_old(mxs_dma) ((mxs_dma)->dev_id == IMX23_DMA) argument
109 struct mxs_dma_engine *mxs_dma; member
186 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_reset_chan() local
199 } else if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma)) { in mxs_dma_reset_chan()
201 mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); in mxs_dma_reset_chan()
205 void __iomem *reg_dbg1 = mxs_dma->base + in mxs_dma_reset_chan()
206 HW_APBX_CHn_DEBUG1(mxs_dma, chan_id); in mxs_dma_reset_chan()
221 dev_err(&mxs_chan->mxs_dma->pdev->dev, in mxs_dma_reset_chan()
226 mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_SET); in mxs_dma_reset_chan()
235 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_enable_chan() local
240 mxs_dma->base + HW_APBHX_CHn_NXTCMDAR(mxs_dma, chan_id)); in mxs_dma_enable_chan()
248 writel(2, mxs_dma->base + HW_APBHX_CHn_SEMA(mxs_dma, chan_id)); in mxs_dma_enable_chan()
250 writel(1, mxs_dma->base + HW_APBHX_CHn_SEMA(mxs_dma, chan_id)); in mxs_dma_enable_chan()
265 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_pause_chan() local
269 if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma)) in mxs_dma_pause_chan()
271 mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); in mxs_dma_pause_chan()
274 mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_SET); in mxs_dma_pause_chan()
283 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_resume_chan() local
287 if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma)) in mxs_dma_resume_chan()
289 mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_CLR); in mxs_dma_resume_chan()
292 mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_CLR); in mxs_dma_resume_chan()
310 static int mxs_dma_irq_to_chan(struct mxs_dma_engine *mxs_dma, int irq) in mxs_dma_irq_to_chan() argument
314 for (i = 0; i != mxs_dma->nr_channels; ++i) in mxs_dma_irq_to_chan()
315 if (mxs_dma->mxs_chans[i].chan_irq == irq) in mxs_dma_irq_to_chan()
323 struct mxs_dma_engine *mxs_dma = dev_id; in mxs_dma_int_handler() local
327 int chan = mxs_dma_irq_to_chan(mxs_dma, irq); in mxs_dma_int_handler()
333 completed = readl(mxs_dma->base + HW_APBHX_CTRL1); in mxs_dma_int_handler()
338 mxs_dma->base + HW_APBHX_CTRL1 + STMP_OFFSET_REG_CLR); in mxs_dma_int_handler()
341 err = readl(mxs_dma->base + HW_APBHX_CTRL2); in mxs_dma_int_handler()
353 mxs_dma->base + HW_APBHX_CTRL2 + STMP_OFFSET_REG_CLR); in mxs_dma_int_handler()
364 mxs_chan = &mxs_dma->mxs_chans[chan]; in mxs_dma_int_handler()
367 dev_dbg(mxs_dma->dma_device.dev, in mxs_dma_int_handler()
376 writel(1, mxs_dma->base + in mxs_dma_int_handler()
377 HW_APBHX_CHn_SEMA(mxs_dma, chan)); in mxs_dma_int_handler()
398 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_alloc_chan_resources() local
401 mxs_chan->ccw = dma_alloc_coherent(mxs_dma->dma_device.dev, in mxs_dma_alloc_chan_resources()
410 0, "mxs-dma", mxs_dma); in mxs_dma_alloc_chan_resources()
414 ret = clk_prepare_enable(mxs_dma->clk); in mxs_dma_alloc_chan_resources()
429 free_irq(mxs_chan->chan_irq, mxs_dma); in mxs_dma_alloc_chan_resources()
431 dma_free_coherent(mxs_dma->dma_device.dev, CCW_BLOCK_SIZE, in mxs_dma_alloc_chan_resources()
440 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_free_chan_resources() local
444 free_irq(mxs_chan->chan_irq, mxs_dma); in mxs_dma_free_chan_resources()
446 dma_free_coherent(mxs_dma->dma_device.dev, CCW_BLOCK_SIZE, in mxs_dma_free_chan_resources()
449 clk_disable_unprepare(mxs_dma->clk); in mxs_dma_free_chan_resources()
480 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_prep_slave_sg() local
491 dev_err(mxs_dma->dma_device.dev, in mxs_dma_prep_slave_sg()
536 dev_err(mxs_dma->dma_device.dev, "maximum bytes for sg entry exceeded: %d > %d\n", in mxs_dma_prep_slave_sg()
579 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_prep_dma_cyclic() local
591 dev_err(mxs_dma->dma_device.dev, in mxs_dma_prep_dma_cyclic()
598 dev_err(mxs_dma->dma_device.dev, in mxs_dma_prep_dma_cyclic()
650 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_tx_status() local
661 bar = readl(mxs_dma->base + in mxs_dma_tx_status()
662 HW_APBHX_CHn_BAR(mxs_dma, chan->chan_id)); in mxs_dma_tx_status()
672 static int mxs_dma_init(struct mxs_dma_engine *mxs_dma) in mxs_dma_init() argument
676 ret = clk_prepare_enable(mxs_dma->clk); in mxs_dma_init()
680 ret = stmp_reset_block(mxs_dma->base); in mxs_dma_init()
685 if (dma_is_apbh(mxs_dma)) { in mxs_dma_init()
687 mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); in mxs_dma_init()
689 mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); in mxs_dma_init()
694 mxs_dma->base + HW_APBHX_CTRL1 + STMP_OFFSET_REG_SET); in mxs_dma_init()
697 clk_disable_unprepare(mxs_dma->clk); in mxs_dma_init()
709 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; in mxs_dma_filter_fn() local
715 chan_irq = platform_get_irq(mxs_dma->pdev, param->chan_id); in mxs_dma_filter_fn()
727 struct mxs_dma_engine *mxs_dma = ofdma->of_dma_data; in mxs_dma_xlate() local
728 dma_cap_mask_t mask = mxs_dma->dma_device.cap_mask; in mxs_dma_xlate()
736 if (param.chan_id >= mxs_dma->nr_channels) in mxs_dma_xlate()
747 struct mxs_dma_engine *mxs_dma; in mxs_dma_probe() local
750 mxs_dma = devm_kzalloc(&pdev->dev, sizeof(*mxs_dma), GFP_KERNEL); in mxs_dma_probe()
751 if (!mxs_dma) in mxs_dma_probe()
754 ret = of_property_read_u32(np, "dma-channels", &mxs_dma->nr_channels); in mxs_dma_probe()
761 mxs_dma->type = dma_type->type; in mxs_dma_probe()
762 mxs_dma->dev_id = dma_type->id; in mxs_dma_probe()
764 mxs_dma->base = devm_platform_ioremap_resource(pdev, 0); in mxs_dma_probe()
765 if (IS_ERR(mxs_dma->base)) in mxs_dma_probe()
766 return PTR_ERR(mxs_dma->base); in mxs_dma_probe()
768 mxs_dma->clk = devm_clk_get(&pdev->dev, NULL); in mxs_dma_probe()
769 if (IS_ERR(mxs_dma->clk)) in mxs_dma_probe()
770 return PTR_ERR(mxs_dma->clk); in mxs_dma_probe()
772 dma_cap_set(DMA_SLAVE, mxs_dma->dma_device.cap_mask); in mxs_dma_probe()
773 dma_cap_set(DMA_CYCLIC, mxs_dma->dma_device.cap_mask); in mxs_dma_probe()
775 INIT_LIST_HEAD(&mxs_dma->dma_device.channels); in mxs_dma_probe()
779 struct mxs_dma_chan *mxs_chan = &mxs_dma->mxs_chans[i]; in mxs_dma_probe()
781 mxs_chan->mxs_dma = mxs_dma; in mxs_dma_probe()
782 mxs_chan->chan.device = &mxs_dma->dma_device; in mxs_dma_probe()
790 &mxs_dma->dma_device.channels); in mxs_dma_probe()
793 ret = mxs_dma_init(mxs_dma); in mxs_dma_probe()
797 mxs_dma->pdev = pdev; in mxs_dma_probe()
798 mxs_dma->dma_device.dev = &pdev->dev; in mxs_dma_probe()
801 dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES); in mxs_dma_probe()
803 mxs_dma->dma_device.device_alloc_chan_resources = mxs_dma_alloc_chan_resources; in mxs_dma_probe()
804 mxs_dma->dma_device.device_free_chan_resources = mxs_dma_free_chan_resources; in mxs_dma_probe()
805 mxs_dma->dma_device.device_tx_status = mxs_dma_tx_status; in mxs_dma_probe()
806 mxs_dma->dma_device.device_prep_slave_sg = mxs_dma_prep_slave_sg; in mxs_dma_probe()
807 mxs_dma->dma_device.device_prep_dma_cyclic = mxs_dma_prep_dma_cyclic; in mxs_dma_probe()
808 mxs_dma->dma_device.device_pause = mxs_dma_pause_chan; in mxs_dma_probe()
809 mxs_dma->dma_device.device_resume = mxs_dma_resume_chan; in mxs_dma_probe()
810 mxs_dma->dma_device.device_terminate_all = mxs_dma_terminate_all; in mxs_dma_probe()
811 mxs_dma->dma_device.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); in mxs_dma_probe()
812 mxs_dma->dma_device.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); in mxs_dma_probe()
813 mxs_dma->dma_device.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); in mxs_dma_probe()
814 mxs_dma->dma_device.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; in mxs_dma_probe()
815 mxs_dma->dma_device.device_issue_pending = mxs_dma_enable_chan; in mxs_dma_probe()
817 ret = dmaenginem_async_device_register(&mxs_dma->dma_device); in mxs_dma_probe()
819 dev_err(mxs_dma->dma_device.dev, "unable to register\n"); in mxs_dma_probe()
823 ret = of_dma_controller_register(np, mxs_dma_xlate, mxs_dma); in mxs_dma_probe()
825 dev_err(mxs_dma->dma_device.dev, in mxs_dma_probe()
829 dev_info(mxs_dma->dma_device.dev, "initialized\n"); in mxs_dma_probe()