Lines Matching refs:tdma
133 struct tegra_adma *tdma; member
170 static inline void tdma_write(struct tegra_adma *tdma, u32 reg, u32 val) in tdma_write() argument
172 writel(val, tdma->base_addr + tdma->cdata->global_reg_offset + reg); in tdma_write()
175 static inline u32 tdma_read(struct tegra_adma *tdma, u32 reg) in tdma_read() argument
177 return readl(tdma->base_addr + tdma->cdata->global_reg_offset + reg); in tdma_read()
203 return tdc->tdma->dev; in tdc2dev()
221 static int tegra_adma_init(struct tegra_adma *tdma) in tegra_adma_init() argument
227 tdma_write(tdma, tdma->cdata->global_int_clear, 0x1); in tegra_adma_init()
230 tdma_write(tdma, ADMA_GLOBAL_SOFT_RESET, 0x1); in tegra_adma_init()
234 tdma->base_addr + in tegra_adma_init()
235 tdma->cdata->global_reg_offset + in tegra_adma_init()
242 tdma_write(tdma, ADMA_GLOBAL_CMD, 1); in tegra_adma_init()
250 struct tegra_adma *tdma = tdc->tdma; in tegra_adma_request_alloc() local
256 if (sreq_index > tdma->cdata->ch_req_max) { in tegra_adma_request_alloc()
257 dev_err(tdma->dev, "invalid DMA request\n"); in tegra_adma_request_alloc()
263 if (test_and_set_bit(sreq_index, &tdma->tx_requests_reserved)) { in tegra_adma_request_alloc()
264 dev_err(tdma->dev, "DMA request reserved\n"); in tegra_adma_request_alloc()
270 if (test_and_set_bit(sreq_index, &tdma->rx_requests_reserved)) { in tegra_adma_request_alloc()
271 dev_err(tdma->dev, "DMA request reserved\n"); in tegra_adma_request_alloc()
277 dev_WARN(tdma->dev, "channel %s has invalid transfer type\n", in tegra_adma_request_alloc()
290 struct tegra_adma *tdma = tdc->tdma; in tegra_adma_request_free() local
297 clear_bit(tdc->sreq_index, &tdma->tx_requests_reserved); in tegra_adma_request_free()
301 clear_bit(tdc->sreq_index, &tdma->rx_requests_reserved); in tegra_adma_request_free()
305 dev_WARN(tdma->dev, "channel %s has invalid transfer type\n", in tegra_adma_request_free()
563 const struct tegra_adma_chip_data *cdata = tdc->tdma->cdata; in tegra_adma_set_xfer_params()
687 struct tegra_adma *tdma = ofdma->of_dma_data; in tegra_dma_of_xlate() local
698 dev_err(tdma->dev, "DMA request must not be 0\n"); in tegra_dma_of_xlate()
702 chan = dma_get_any_slave_channel(&tdma->dma_dev); in tegra_dma_of_xlate()
714 struct tegra_adma *tdma = dev_get_drvdata(dev); in tegra_adma_runtime_suspend() local
719 tdma->global_cmd = tdma_read(tdma, ADMA_GLOBAL_CMD); in tegra_adma_runtime_suspend()
720 if (!tdma->global_cmd) in tegra_adma_runtime_suspend()
723 for (i = 0; i < tdma->nr_channels; i++) { in tegra_adma_runtime_suspend()
724 tdc = &tdma->channels[i]; in tegra_adma_runtime_suspend()
739 clk_disable_unprepare(tdma->ahub_clk); in tegra_adma_runtime_suspend()
746 struct tegra_adma *tdma = dev_get_drvdata(dev); in tegra_adma_runtime_resume() local
751 ret = clk_prepare_enable(tdma->ahub_clk); in tegra_adma_runtime_resume()
756 tdma_write(tdma, ADMA_GLOBAL_CMD, tdma->global_cmd); in tegra_adma_runtime_resume()
758 if (!tdma->global_cmd) in tegra_adma_runtime_resume()
761 for (i = 0; i < tdma->nr_channels; i++) { in tegra_adma_runtime_resume()
762 tdc = &tdma->channels[i]; in tegra_adma_runtime_resume()
819 struct tegra_adma *tdma; in tegra_adma_probe() local
829 tdma = devm_kzalloc(&pdev->dev, in tegra_adma_probe()
830 struct_size(tdma, channels, cdata->nr_channels), in tegra_adma_probe()
832 if (!tdma) in tegra_adma_probe()
835 tdma->dev = &pdev->dev; in tegra_adma_probe()
836 tdma->cdata = cdata; in tegra_adma_probe()
837 tdma->nr_channels = cdata->nr_channels; in tegra_adma_probe()
838 platform_set_drvdata(pdev, tdma); in tegra_adma_probe()
841 tdma->base_addr = devm_ioremap_resource(&pdev->dev, res); in tegra_adma_probe()
842 if (IS_ERR(tdma->base_addr)) in tegra_adma_probe()
843 return PTR_ERR(tdma->base_addr); in tegra_adma_probe()
845 tdma->ahub_clk = devm_clk_get(&pdev->dev, "d_audio"); in tegra_adma_probe()
846 if (IS_ERR(tdma->ahub_clk)) { in tegra_adma_probe()
848 return PTR_ERR(tdma->ahub_clk); in tegra_adma_probe()
851 INIT_LIST_HEAD(&tdma->dma_dev.channels); in tegra_adma_probe()
852 for (i = 0; i < tdma->nr_channels; i++) { in tegra_adma_probe()
853 struct tegra_adma_chan *tdc = &tdma->channels[i]; in tegra_adma_probe()
855 tdc->chan_addr = tdma->base_addr + cdata->ch_base_offset in tegra_adma_probe()
864 vchan_init(&tdc->vc, &tdma->dma_dev); in tegra_adma_probe()
866 tdc->tdma = tdma; in tegra_adma_probe()
875 ret = tegra_adma_init(tdma); in tegra_adma_probe()
879 dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask); in tegra_adma_probe()
880 dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask); in tegra_adma_probe()
881 dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask); in tegra_adma_probe()
883 tdma->dma_dev.dev = &pdev->dev; in tegra_adma_probe()
884 tdma->dma_dev.device_alloc_chan_resources = in tegra_adma_probe()
886 tdma->dma_dev.device_free_chan_resources = in tegra_adma_probe()
888 tdma->dma_dev.device_issue_pending = tegra_adma_issue_pending; in tegra_adma_probe()
889 tdma->dma_dev.device_prep_dma_cyclic = tegra_adma_prep_dma_cyclic; in tegra_adma_probe()
890 tdma->dma_dev.device_config = tegra_adma_slave_config; in tegra_adma_probe()
891 tdma->dma_dev.device_tx_status = tegra_adma_tx_status; in tegra_adma_probe()
892 tdma->dma_dev.device_terminate_all = tegra_adma_terminate_all; in tegra_adma_probe()
893 tdma->dma_dev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); in tegra_adma_probe()
894 tdma->dma_dev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); in tegra_adma_probe()
895 tdma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); in tegra_adma_probe()
896 tdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; in tegra_adma_probe()
897 tdma->dma_dev.device_pause = tegra_adma_pause; in tegra_adma_probe()
898 tdma->dma_dev.device_resume = tegra_adma_resume; in tegra_adma_probe()
900 ret = dma_async_device_register(&tdma->dma_dev); in tegra_adma_probe()
907 tegra_dma_of_xlate, tdma); in tegra_adma_probe()
916 tdma->nr_channels); in tegra_adma_probe()
921 dma_async_device_unregister(&tdma->dma_dev); in tegra_adma_probe()
928 irq_dispose_mapping(tdma->channels[i].irq); in tegra_adma_probe()
935 struct tegra_adma *tdma = platform_get_drvdata(pdev); in tegra_adma_remove() local
939 dma_async_device_unregister(&tdma->dma_dev); in tegra_adma_remove()
941 for (i = 0; i < tdma->nr_channels; ++i) in tegra_adma_remove()
942 irq_dispose_mapping(tdma->channels[i].irq); in tegra_adma_remove()