Lines Matching refs:mdma

117 	struct mdc_dma *mdma;  member
148 static inline u32 mdc_readl(struct mdc_dma *mdma, u32 reg) in mdc_readl() argument
150 return readl(mdma->regs + reg); in mdc_readl()
153 static inline void mdc_writel(struct mdc_dma *mdma, u32 val, u32 reg) in mdc_writel() argument
155 writel(val, mdma->regs + reg); in mdc_writel()
160 return mdc_readl(mchan->mdma, mchan->chan_nr * 0x040 + reg); in mdc_chan_readl()
165 mdc_writel(mchan->mdma, val, mchan->chan_nr * 0x040 + reg); in mdc_chan_writel()
180 static inline struct device *mdma2dev(struct mdc_dma *mdma) in mdma2dev() argument
182 return mdma->dma_dev.dev; in mdma2dev()
209 struct mdc_dma *mdma = mchan->mdma; in mdc_list_desc_config() local
228 if (IS_ALIGNED(dst, mdma->bus_width) && in mdc_list_desc_config()
229 IS_ALIGNED(src, mdma->bus_width)) in mdc_list_desc_config()
230 max_burst = mdma->bus_width * mdma->max_burst_mult; in mdc_list_desc_config()
232 max_burst = mdma->bus_width * (mdma->max_burst_mult - 1); in mdc_list_desc_config()
237 mdc_set_read_width(ldesc, mdma->bus_width); in mdc_list_desc_config()
245 mdc_set_write_width(ldesc, mdma->bus_width); in mdc_list_desc_config()
251 mdc_set_read_width(ldesc, mdma->bus_width); in mdc_list_desc_config()
252 mdc_set_write_width(ldesc, mdma->bus_width); in mdc_list_desc_config()
261 struct mdc_dma *mdma = mdesc->chan->mdma; in mdc_list_desc_free() local
270 dma_pool_free(mdma->desc_pool, curr, curr_phys); in mdc_list_desc_free()
289 struct mdc_dma *mdma = mchan->mdma; in mdc_prep_dma_memcpy() local
306 curr = dma_pool_alloc(mdma->desc_pool, GFP_NOWAIT, &curr_phys); in mdc_prep_dma_memcpy()
318 xfer_size = min_t(size_t, mdma->max_xfer_size, len); in mdc_prep_dma_memcpy()
359 if (width > mchan->mdma->bus_width) in mdc_check_slave_width()
371 struct mdc_dma *mdma = mchan->mdma; in mdc_prep_dma_cyclic() local
392 mdma->max_xfer_size); in mdc_prep_dma_cyclic()
400 curr = dma_pool_alloc(mdma->desc_pool, GFP_NOWAIT, in mdc_prep_dma_cyclic()
413 xfer_size = min_t(size_t, mdma->max_xfer_size, in mdc_prep_dma_cyclic()
452 struct mdc_dma *mdma = mchan->mdma; in mdc_prep_slave_sg() local
480 curr = dma_pool_alloc(mdma->desc_pool, GFP_NOWAIT, in mdc_prep_slave_sg()
493 xfer_size = min_t(size_t, mdma->max_xfer_size, in mdc_prep_slave_sg()
525 struct mdc_dma *mdma = mchan->mdma; in mdc_issue_desc() local
539 dev_dbg(mdma2dev(mdma), "Issuing descriptor on channel %d\n", in mdc_issue_desc()
542 mdma->soc->enable_chan(mchan); in mdc_issue_desc()
739 struct device *dev = mdma2dev(mchan->mdma); in mdc_alloc_chan_resources()
747 struct mdc_dma *mdma = mchan->mdma; in mdc_free_chan_resources() local
748 struct device *dev = mdma2dev(mdma); in mdc_free_chan_resources()
751 mdma->soc->disable_chan(mchan); in mdc_free_chan_resources()
763 dev_dbg(mdma2dev(mchan->mdma), "IRQ on channel %d\n", mchan->chan_nr); in mdc_chan_irq()
772 dev_warn(mdma2dev(mchan->mdma), in mdc_chan_irq()
810 struct mdc_dma *mdma = ofdma->of_dma_data; in mdc_of_xlate() local
816 list_for_each_entry(chan, &mdma->dma_dev.channels, device_node) { in mdc_of_xlate()
837 struct mdc_dma *mdma = mchan->mdma; in pistachio_mdc_enable_chan() local
839 regmap_update_bits(mdma->periph_regs, in pistachio_mdc_enable_chan()
849 struct mdc_dma *mdma = mchan->mdma; in pistachio_mdc_disable_chan() local
851 regmap_update_bits(mdma->periph_regs, in pistachio_mdc_disable_chan()
871 struct mdc_dma *mdma = dev_get_drvdata(dev); in img_mdc_runtime_suspend() local
873 clk_disable_unprepare(mdma->clk); in img_mdc_runtime_suspend()
880 struct mdc_dma *mdma = dev_get_drvdata(dev); in img_mdc_runtime_resume() local
882 return clk_prepare_enable(mdma->clk); in img_mdc_runtime_resume()
887 struct mdc_dma *mdma; in mdc_dma_probe() local
892 mdma = devm_kzalloc(&pdev->dev, sizeof(*mdma), GFP_KERNEL); in mdc_dma_probe()
893 if (!mdma) in mdc_dma_probe()
895 platform_set_drvdata(pdev, mdma); in mdc_dma_probe()
897 mdma->soc = of_device_get_match_data(&pdev->dev); in mdc_dma_probe()
899 mdma->regs = devm_platform_ioremap_resource(pdev, 0); in mdc_dma_probe()
900 if (IS_ERR(mdma->regs)) in mdc_dma_probe()
901 return PTR_ERR(mdma->regs); in mdc_dma_probe()
903 mdma->periph_regs = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in mdc_dma_probe()
905 if (IS_ERR(mdma->periph_regs)) in mdc_dma_probe()
906 return PTR_ERR(mdma->periph_regs); in mdc_dma_probe()
908 mdma->clk = devm_clk_get(&pdev->dev, "sys"); in mdc_dma_probe()
909 if (IS_ERR(mdma->clk)) in mdc_dma_probe()
910 return PTR_ERR(mdma->clk); in mdc_dma_probe()
912 dma_cap_zero(mdma->dma_dev.cap_mask); in mdc_dma_probe()
913 dma_cap_set(DMA_SLAVE, mdma->dma_dev.cap_mask); in mdc_dma_probe()
914 dma_cap_set(DMA_PRIVATE, mdma->dma_dev.cap_mask); in mdc_dma_probe()
915 dma_cap_set(DMA_CYCLIC, mdma->dma_dev.cap_mask); in mdc_dma_probe()
916 dma_cap_set(DMA_MEMCPY, mdma->dma_dev.cap_mask); in mdc_dma_probe()
918 val = mdc_readl(mdma, MDC_GLOBAL_CONFIG_A); in mdc_dma_probe()
919 mdma->nr_channels = (val >> MDC_GLOBAL_CONFIG_A_DMA_CONTEXTS_SHIFT) & in mdc_dma_probe()
921 mdma->nr_threads = in mdc_dma_probe()
924 mdma->bus_width = in mdc_dma_probe()
936 mdma->max_xfer_size = MDC_TRANSFER_SIZE_MASK + 1 - mdma->bus_width; in mdc_dma_probe()
939 &mdma->nr_channels); in mdc_dma_probe()
942 &mdma->max_burst_mult); in mdc_dma_probe()
946 mdma->dma_dev.dev = &pdev->dev; in mdc_dma_probe()
947 mdma->dma_dev.device_prep_slave_sg = mdc_prep_slave_sg; in mdc_dma_probe()
948 mdma->dma_dev.device_prep_dma_cyclic = mdc_prep_dma_cyclic; in mdc_dma_probe()
949 mdma->dma_dev.device_prep_dma_memcpy = mdc_prep_dma_memcpy; in mdc_dma_probe()
950 mdma->dma_dev.device_alloc_chan_resources = mdc_alloc_chan_resources; in mdc_dma_probe()
951 mdma->dma_dev.device_free_chan_resources = mdc_free_chan_resources; in mdc_dma_probe()
952 mdma->dma_dev.device_tx_status = mdc_tx_status; in mdc_dma_probe()
953 mdma->dma_dev.device_issue_pending = mdc_issue_pending; in mdc_dma_probe()
954 mdma->dma_dev.device_terminate_all = mdc_terminate_all; in mdc_dma_probe()
955 mdma->dma_dev.device_synchronize = mdc_synchronize; in mdc_dma_probe()
956 mdma->dma_dev.device_config = mdc_slave_config; in mdc_dma_probe()
958 mdma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); in mdc_dma_probe()
959 mdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; in mdc_dma_probe()
960 for (i = 1; i <= mdma->bus_width; i <<= 1) { in mdc_dma_probe()
961 mdma->dma_dev.src_addr_widths |= BIT(i); in mdc_dma_probe()
962 mdma->dma_dev.dst_addr_widths |= BIT(i); in mdc_dma_probe()
965 INIT_LIST_HEAD(&mdma->dma_dev.channels); in mdc_dma_probe()
966 for (i = 0; i < mdma->nr_channels; i++) { in mdc_dma_probe()
967 struct mdc_chan *mchan = &mdma->channels[i]; in mdc_dma_probe()
969 mchan->mdma = mdma; in mdc_dma_probe()
982 vchan_init(&mchan->vc, &mdma->dma_dev); in mdc_dma_probe()
985 mdma->desc_pool = dmam_pool_create(dev_name(&pdev->dev), &pdev->dev, in mdc_dma_probe()
988 if (!mdma->desc_pool) in mdc_dma_probe()
998 ret = dma_async_device_register(&mdma->dma_dev); in mdc_dma_probe()
1002 ret = of_dma_controller_register(pdev->dev.of_node, mdc_of_xlate, mdma); in mdc_dma_probe()
1007 mdma->nr_channels, mdma->nr_threads); in mdc_dma_probe()
1012 dma_async_device_unregister(&mdma->dma_dev); in mdc_dma_probe()
1022 struct mdc_dma *mdma = platform_get_drvdata(pdev); in mdc_dma_remove() local
1026 dma_async_device_unregister(&mdma->dma_dev); in mdc_dma_remove()
1028 list_for_each_entry_safe(mchan, next, &mdma->dma_dev.channels, in mdc_dma_remove()
1045 struct mdc_dma *mdma = dev_get_drvdata(dev); in img_mdc_suspend_late() local
1049 for (i = 0; i < mdma->nr_channels; i++) { in img_mdc_suspend_late()
1050 struct mdc_chan *mchan = &mdma->channels[i]; in img_mdc_suspend_late()