Lines Matching refs:mdma
120 struct mdc_dma *mdma; member
151 static inline u32 mdc_readl(struct mdc_dma *mdma, u32 reg) in mdc_readl() argument
153 return readl(mdma->regs + reg); in mdc_readl()
156 static inline void mdc_writel(struct mdc_dma *mdma, u32 val, u32 reg) in mdc_writel() argument
158 writel(val, mdma->regs + reg); in mdc_writel()
163 return mdc_readl(mchan->mdma, mchan->chan_nr * 0x040 + reg); in mdc_chan_readl()
168 mdc_writel(mchan->mdma, val, mchan->chan_nr * 0x040 + reg); in mdc_chan_writel()
183 static inline struct device *mdma2dev(struct mdc_dma *mdma) in mdma2dev() argument
185 return mdma->dma_dev.dev; in mdma2dev()
212 struct mdc_dma *mdma = mchan->mdma; in mdc_list_desc_config() local
231 if (IS_ALIGNED(dst, mdma->bus_width) && in mdc_list_desc_config()
232 IS_ALIGNED(src, mdma->bus_width)) in mdc_list_desc_config()
233 max_burst = mdma->bus_width * mdma->max_burst_mult; in mdc_list_desc_config()
235 max_burst = mdma->bus_width * (mdma->max_burst_mult - 1); in mdc_list_desc_config()
240 mdc_set_read_width(ldesc, mdma->bus_width); in mdc_list_desc_config()
248 mdc_set_write_width(ldesc, mdma->bus_width); in mdc_list_desc_config()
254 mdc_set_read_width(ldesc, mdma->bus_width); in mdc_list_desc_config()
255 mdc_set_write_width(ldesc, mdma->bus_width); in mdc_list_desc_config()
264 struct mdc_dma *mdma = mdesc->chan->mdma; in mdc_list_desc_free() local
273 dma_pool_free(mdma->desc_pool, curr, curr_phys); in mdc_list_desc_free()
292 struct mdc_dma *mdma = mchan->mdma; in mdc_prep_dma_memcpy() local
309 curr = dma_pool_alloc(mdma->desc_pool, GFP_NOWAIT, &curr_phys); in mdc_prep_dma_memcpy()
321 xfer_size = min_t(size_t, mdma->max_xfer_size, len); in mdc_prep_dma_memcpy()
363 if (width > mchan->mdma->bus_width) in mdc_check_slave_width()
375 struct mdc_dma *mdma = mchan->mdma; in mdc_prep_dma_cyclic() local
396 mdma->max_xfer_size); in mdc_prep_dma_cyclic()
404 curr = dma_pool_alloc(mdma->desc_pool, GFP_NOWAIT, in mdc_prep_dma_cyclic()
417 xfer_size = min_t(size_t, mdma->max_xfer_size, in mdc_prep_dma_cyclic()
457 struct mdc_dma *mdma = mchan->mdma; in mdc_prep_slave_sg() local
485 curr = dma_pool_alloc(mdma->desc_pool, GFP_NOWAIT, in mdc_prep_slave_sg()
498 xfer_size = min_t(size_t, mdma->max_xfer_size, in mdc_prep_slave_sg()
531 struct mdc_dma *mdma = mchan->mdma; in mdc_issue_desc() local
545 dev_dbg(mdma2dev(mdma), "Issuing descriptor on channel %d\n", in mdc_issue_desc()
548 mdma->soc->enable_chan(mchan); in mdc_issue_desc()
695 struct mdc_dma *mdma = mchan->mdma; in mdc_free_chan_resources() local
699 mdma->soc->disable_chan(mchan); in mdc_free_chan_resources()
733 dev_dbg(mdma2dev(mchan->mdma), "IRQ on channel %d\n", mchan->chan_nr); in mdc_chan_irq()
737 dev_warn(mdma2dev(mchan->mdma), in mdc_chan_irq()
776 struct mdc_dma *mdma = ofdma->of_dma_data; in mdc_of_xlate() local
782 list_for_each_entry(chan, &mdma->dma_dev.channels, device_node) { in mdc_of_xlate()
803 struct mdc_dma *mdma = mchan->mdma; in pistachio_mdc_enable_chan() local
805 regmap_update_bits(mdma->periph_regs, in pistachio_mdc_enable_chan()
815 struct mdc_dma *mdma = mchan->mdma; in pistachio_mdc_disable_chan() local
817 regmap_update_bits(mdma->periph_regs, in pistachio_mdc_disable_chan()
837 struct mdc_dma *mdma; in mdc_dma_probe() local
844 mdma = devm_kzalloc(&pdev->dev, sizeof(*mdma), GFP_KERNEL); in mdc_dma_probe()
845 if (!mdma) in mdc_dma_probe()
847 platform_set_drvdata(pdev, mdma); in mdc_dma_probe()
850 mdma->soc = match->data; in mdc_dma_probe()
853 mdma->regs = devm_ioremap_resource(&pdev->dev, res); in mdc_dma_probe()
854 if (IS_ERR(mdma->regs)) in mdc_dma_probe()
855 return PTR_ERR(mdma->regs); in mdc_dma_probe()
857 mdma->periph_regs = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in mdc_dma_probe()
859 if (IS_ERR(mdma->periph_regs)) in mdc_dma_probe()
860 return PTR_ERR(mdma->periph_regs); in mdc_dma_probe()
862 mdma->clk = devm_clk_get(&pdev->dev, "sys"); in mdc_dma_probe()
863 if (IS_ERR(mdma->clk)) in mdc_dma_probe()
864 return PTR_ERR(mdma->clk); in mdc_dma_probe()
866 ret = clk_prepare_enable(mdma->clk); in mdc_dma_probe()
870 dma_cap_zero(mdma->dma_dev.cap_mask); in mdc_dma_probe()
871 dma_cap_set(DMA_SLAVE, mdma->dma_dev.cap_mask); in mdc_dma_probe()
872 dma_cap_set(DMA_PRIVATE, mdma->dma_dev.cap_mask); in mdc_dma_probe()
873 dma_cap_set(DMA_CYCLIC, mdma->dma_dev.cap_mask); in mdc_dma_probe()
874 dma_cap_set(DMA_MEMCPY, mdma->dma_dev.cap_mask); in mdc_dma_probe()
876 val = mdc_readl(mdma, MDC_GLOBAL_CONFIG_A); in mdc_dma_probe()
877 mdma->nr_channels = (val >> MDC_GLOBAL_CONFIG_A_DMA_CONTEXTS_SHIFT) & in mdc_dma_probe()
879 mdma->nr_threads = in mdc_dma_probe()
882 mdma->bus_width = in mdc_dma_probe()
894 mdma->max_xfer_size = MDC_TRANSFER_SIZE_MASK + 1 - mdma->bus_width; in mdc_dma_probe()
897 &mdma->nr_channels); in mdc_dma_probe()
900 &mdma->max_burst_mult); in mdc_dma_probe()
904 mdma->dma_dev.dev = &pdev->dev; in mdc_dma_probe()
905 mdma->dma_dev.device_prep_slave_sg = mdc_prep_slave_sg; in mdc_dma_probe()
906 mdma->dma_dev.device_prep_dma_cyclic = mdc_prep_dma_cyclic; in mdc_dma_probe()
907 mdma->dma_dev.device_prep_dma_memcpy = mdc_prep_dma_memcpy; in mdc_dma_probe()
908 mdma->dma_dev.device_free_chan_resources = mdc_free_chan_resources; in mdc_dma_probe()
909 mdma->dma_dev.device_tx_status = mdc_tx_status; in mdc_dma_probe()
910 mdma->dma_dev.device_issue_pending = mdc_issue_pending; in mdc_dma_probe()
911 mdma->dma_dev.device_terminate_all = mdc_terminate_all; in mdc_dma_probe()
912 mdma->dma_dev.device_config = mdc_slave_config; in mdc_dma_probe()
914 mdma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); in mdc_dma_probe()
915 mdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; in mdc_dma_probe()
916 for (i = 1; i <= mdma->bus_width; i <<= 1) { in mdc_dma_probe()
917 mdma->dma_dev.src_addr_widths |= BIT(i); in mdc_dma_probe()
918 mdma->dma_dev.dst_addr_widths |= BIT(i); in mdc_dma_probe()
921 INIT_LIST_HEAD(&mdma->dma_dev.channels); in mdc_dma_probe()
922 for (i = 0; i < mdma->nr_channels; i++) { in mdc_dma_probe()
923 struct mdc_chan *mchan = &mdma->channels[i]; in mdc_dma_probe()
925 mchan->mdma = mdma; in mdc_dma_probe()
939 vchan_init(&mchan->vc, &mdma->dma_dev); in mdc_dma_probe()
942 mdma->desc_pool = dmam_pool_create(dev_name(&pdev->dev), &pdev->dev, in mdc_dma_probe()
945 if (!mdma->desc_pool) { in mdc_dma_probe()
950 ret = dma_async_device_register(&mdma->dma_dev); in mdc_dma_probe()
954 ret = of_dma_controller_register(pdev->dev.of_node, mdc_of_xlate, mdma); in mdc_dma_probe()
959 mdma->nr_channels, mdma->nr_threads); in mdc_dma_probe()
964 dma_async_device_unregister(&mdma->dma_dev); in mdc_dma_probe()
966 clk_disable_unprepare(mdma->clk); in mdc_dma_probe()
972 struct mdc_dma *mdma = platform_get_drvdata(pdev); in mdc_dma_remove() local
976 dma_async_device_unregister(&mdma->dma_dev); in mdc_dma_remove()
978 list_for_each_entry_safe(mchan, next, &mdma->dma_dev.channels, in mdc_dma_remove()
988 clk_disable_unprepare(mdma->clk); in mdc_dma_remove()