Lines Matching +full:tegra124 +full:- +full:mc

1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2016-2017 Dmitry Osipenko <digetx@gmail.com>
10 #include <linux/dma-buf.h>
60 struct device *dev = vde->dev; in tegra_vde_alloc_bo()
66 return -ENOMEM; in tegra_vde_alloc_bo()
68 bo->vde = vde; in tegra_vde_alloc_bo()
69 bo->size = size; in tegra_vde_alloc_bo()
70 bo->dma_dir = dma_dir; in tegra_vde_alloc_bo()
71 bo->dma_attrs = DMA_ATTR_WRITE_COMBINE | in tegra_vde_alloc_bo()
74 if (!vde->domain) in tegra_vde_alloc_bo()
75 bo->dma_attrs |= DMA_ATTR_FORCE_CONTIGUOUS; in tegra_vde_alloc_bo()
77 bo->dma_cookie = dma_alloc_attrs(dev, bo->size, &bo->dma_handle, in tegra_vde_alloc_bo()
78 GFP_KERNEL, bo->dma_attrs); in tegra_vde_alloc_bo()
79 if (!bo->dma_cookie) { in tegra_vde_alloc_bo()
81 bo->size); in tegra_vde_alloc_bo()
82 err = -ENOMEM; in tegra_vde_alloc_bo()
86 err = dma_get_sgtable_attrs(dev, &bo->sgt, bo->dma_cookie, in tegra_vde_alloc_bo()
87 bo->dma_handle, bo->size, bo->dma_attrs); in tegra_vde_alloc_bo()
93 err = dma_map_sgtable(dev, &bo->sgt, bo->dma_dir, bo->dma_attrs); in tegra_vde_alloc_bo()
99 if (vde->domain) { in tegra_vde_alloc_bo()
100 err = tegra_vde_iommu_map(vde, &bo->sgt, &bo->iova, bo->size); in tegra_vde_alloc_bo()
106 bo->dma_addr = iova_dma_addr(&vde->iova, bo->iova); in tegra_vde_alloc_bo()
108 bo->dma_addr = sg_dma_address(bo->sgt.sgl); in tegra_vde_alloc_bo()
116 dma_unmap_sgtable(dev, &bo->sgt, bo->dma_dir, bo->dma_attrs); in tegra_vde_alloc_bo()
118 sg_free_table(&bo->sgt); in tegra_vde_alloc_bo()
120 dma_free_attrs(dev, bo->size, bo->dma_cookie, bo->dma_handle, in tegra_vde_alloc_bo()
121 bo->dma_attrs); in tegra_vde_alloc_bo()
130 struct tegra_vde *vde = bo->vde; in tegra_vde_free_bo()
131 struct device *dev = vde->dev; in tegra_vde_free_bo()
133 if (vde->domain) in tegra_vde_free_bo()
134 tegra_vde_iommu_unmap(vde, bo->iova); in tegra_vde_free_bo()
136 dma_unmap_sgtable(dev, &bo->sgt, bo->dma_dir, bo->dma_attrs); in tegra_vde_free_bo()
138 sg_free_table(&bo->sgt); in tegra_vde_free_bo()
140 dma_free_attrs(dev, bo->size, bo->dma_cookie, bo->dma_handle, in tegra_vde_free_bo()
141 bo->dma_attrs); in tegra_vde_free_bo()
149 if (completion_done(&vde->decode_completion)) in tegra_vde_isr()
152 tegra_vde_set_bits(vde, 0, vde->frameid, 0x208); in tegra_vde_isr()
153 complete(&vde->decode_completion); in tegra_vde_isr()
163 if (!dev->pm_domain) { in tegra_vde_runtime_suspend()
171 clk_disable_unprepare(vde->clk); in tegra_vde_runtime_suspend()
172 reset_control_release(vde->rst); in tegra_vde_runtime_suspend()
173 reset_control_release(vde->rst_mc); in tegra_vde_runtime_suspend()
183 err = reset_control_acquire(vde->rst_mc); in tegra_vde_runtime_resume()
185 dev_err(dev, "Failed to acquire mc reset: %d\n", err); in tegra_vde_runtime_resume()
189 err = reset_control_acquire(vde->rst); in tegra_vde_runtime_resume()
195 if (!dev->pm_domain) { in tegra_vde_runtime_resume()
197 vde->clk, vde->rst); in tegra_vde_runtime_resume()
207 err = clk_prepare_enable(vde->clk); in tegra_vde_runtime_resume()
217 reset_control_release(vde->rst); in tegra_vde_runtime_resume()
219 reset_control_release(vde->rst_mc); in tegra_vde_runtime_resume()
226 struct device *dev = &pdev->dev; in tegra_vde_probe()
232 return -ENOMEM; in tegra_vde_probe()
236 vde->soc = of_device_get_match_data(&pdev->dev); in tegra_vde_probe()
237 vde->dev = dev; in tegra_vde_probe()
239 vde->sxe = devm_platform_ioremap_resource_byname(pdev, "sxe"); in tegra_vde_probe()
240 if (IS_ERR(vde->sxe)) in tegra_vde_probe()
241 return PTR_ERR(vde->sxe); in tegra_vde_probe()
243 vde->bsev = devm_platform_ioremap_resource_byname(pdev, "bsev"); in tegra_vde_probe()
244 if (IS_ERR(vde->bsev)) in tegra_vde_probe()
245 return PTR_ERR(vde->bsev); in tegra_vde_probe()
247 vde->mbe = devm_platform_ioremap_resource_byname(pdev, "mbe"); in tegra_vde_probe()
248 if (IS_ERR(vde->mbe)) in tegra_vde_probe()
249 return PTR_ERR(vde->mbe); in tegra_vde_probe()
251 vde->ppe = devm_platform_ioremap_resource_byname(pdev, "ppe"); in tegra_vde_probe()
252 if (IS_ERR(vde->ppe)) in tegra_vde_probe()
253 return PTR_ERR(vde->ppe); in tegra_vde_probe()
255 vde->mce = devm_platform_ioremap_resource_byname(pdev, "mce"); in tegra_vde_probe()
256 if (IS_ERR(vde->mce)) in tegra_vde_probe()
257 return PTR_ERR(vde->mce); in tegra_vde_probe()
259 vde->tfe = devm_platform_ioremap_resource_byname(pdev, "tfe"); in tegra_vde_probe()
260 if (IS_ERR(vde->tfe)) in tegra_vde_probe()
261 return PTR_ERR(vde->tfe); in tegra_vde_probe()
263 vde->ppb = devm_platform_ioremap_resource_byname(pdev, "ppb"); in tegra_vde_probe()
264 if (IS_ERR(vde->ppb)) in tegra_vde_probe()
265 return PTR_ERR(vde->ppb); in tegra_vde_probe()
267 vde->vdma = devm_platform_ioremap_resource_byname(pdev, "vdma"); in tegra_vde_probe()
268 if (IS_ERR(vde->vdma)) in tegra_vde_probe()
269 return PTR_ERR(vde->vdma); in tegra_vde_probe()
271 vde->frameid = devm_platform_ioremap_resource_byname(pdev, "frameid"); in tegra_vde_probe()
272 if (IS_ERR(vde->frameid)) in tegra_vde_probe()
273 return PTR_ERR(vde->frameid); in tegra_vde_probe()
275 vde->clk = devm_clk_get(dev, NULL); in tegra_vde_probe()
276 if (IS_ERR(vde->clk)) { in tegra_vde_probe()
277 err = PTR_ERR(vde->clk); in tegra_vde_probe()
282 vde->rst = devm_reset_control_get_exclusive_released(dev, NULL); in tegra_vde_probe()
283 if (IS_ERR(vde->rst)) { in tegra_vde_probe()
284 err = PTR_ERR(vde->rst); in tegra_vde_probe()
289 vde->rst_mc = devm_reset_control_get_optional_exclusive_released(dev, "mc"); in tegra_vde_probe()
290 if (IS_ERR(vde->rst_mc)) { in tegra_vde_probe()
291 err = PTR_ERR(vde->rst_mc); in tegra_vde_probe()
292 dev_err(dev, "Could not get MC reset %d\n", err); in tegra_vde_probe()
296 irq = platform_get_irq_byname(pdev, "sync-token"); in tegra_vde_probe()
313 vde->iram_pool = of_gen_pool_get(dev->of_node, "iram", 0); in tegra_vde_probe()
314 if (!vde->iram_pool) { in tegra_vde_probe()
316 return -EPROBE_DEFER; in tegra_vde_probe()
319 vde->iram = gen_pool_dma_alloc(vde->iram_pool, in tegra_vde_probe()
320 gen_pool_size(vde->iram_pool), in tegra_vde_probe()
321 &vde->iram_lists_addr); in tegra_vde_probe()
322 if (!vde->iram) { in tegra_vde_probe()
324 return -ENOMEM; in tegra_vde_probe()
327 INIT_LIST_HEAD(&vde->map_list); in tegra_vde_probe()
328 mutex_init(&vde->map_lock); in tegra_vde_probe()
329 mutex_init(&vde->lock); in tegra_vde_probe()
330 init_completion(&vde->decode_completion); in tegra_vde_probe()
344 * power-cycle it in order to put hardware into a predictable lower in tegra_vde_probe()
353 err = tegra_vde_alloc_bo(vde, &vde->secure_bo, DMA_FROM_DEVICE, 4096); in tegra_vde_probe()
368 tegra_vde_free_bo(vde->secure_bo); in tegra_vde_probe()
376 gen_pool_free(vde->iram_pool, (unsigned long)vde->iram, in tegra_vde_probe()
377 gen_pool_size(vde->iram_pool)); in tegra_vde_probe()
385 struct device *dev = &pdev->dev; in tegra_vde_remove()
388 tegra_vde_free_bo(vde->secure_bo); in tegra_vde_remove()
401 * is clock-gated. It's safe to reboot machine now. in tegra_vde_remove()
404 clk_disable_unprepare(vde->clk); in tegra_vde_remove()
409 gen_pool_free(vde->iram_pool, (unsigned long)vde->iram, in tegra_vde_remove()
410 gen_pool_size(vde->iram_pool)); in tegra_vde_remove()
416 * On some devices bootloader isn't ready to a power-gated VDE on in tegra_vde_shutdown()
417 * a warm-reboot, machine will hang in that case. in tegra_vde_shutdown()
419 pm_runtime_get_sync(&pdev->dev); in tegra_vde_shutdown()
427 mutex_lock(&vde->lock); in tegra_vde_pm_suspend()
445 mutex_unlock(&vde->lock); in tegra_vde_pm_resume()
459 /* TBD: T124 supports only a non-standard Tegra tiled format */
528 { .compatible = "nvidia,tegra124-vde", .data = &tegra124_vde_soc },
529 { .compatible = "nvidia,tegra114-vde", .data = &tegra114_vde_soc },
530 { .compatible = "nvidia,tegra30-vde", .data = &tegra30_vde_soc },
531 { .compatible = "nvidia,tegra20-vde", .data = &tegra20_vde_soc },
541 .name = "tegra-vde",