Lines Matching +full:tegra186 +full:- +full:pmc

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2015-2021, NVIDIA Corporation.
8 #include <linux/dma-mapping.h>
19 #include <soc/tegra/pmc.h>
54 writel(value, nvdec->regs + offset); in nvdec_writel()
60 struct iommu_fwspec *spec = dev_iommu_fwspec_get(nvdec->dev); in nvdec_boot()
65 if (nvdec->config->supports_sid && spec) { in nvdec_boot()
71 if (spec->num_ids > 0) { in nvdec_boot()
72 value = spec->ids[0] & 0xffff; in nvdec_boot()
80 err = falcon_boot(&nvdec->falcon); in nvdec_boot()
84 err = falcon_wait_idle(&nvdec->falcon); in nvdec_boot()
86 dev_err(nvdec->dev, "falcon boot timed out\n"); in nvdec_boot()
96 struct drm_device *dev = dev_get_drvdata(client->host); in nvdec_init()
97 struct tegra_drm *tegra = dev->dev_private; in nvdec_init()
102 if (err < 0 && err != -ENODEV) { in nvdec_init()
103 dev_err(nvdec->dev, "failed to attach to domain: %d\n", err); in nvdec_init()
107 nvdec->channel = host1x_channel_request(client); in nvdec_init()
108 if (!nvdec->channel) { in nvdec_init()
109 err = -ENOMEM; in nvdec_init()
113 client->syncpts[0] = host1x_syncpt_request(client, 0); in nvdec_init()
114 if (!client->syncpts[0]) { in nvdec_init()
115 err = -ENOMEM; in nvdec_init()
119 pm_runtime_enable(client->dev); in nvdec_init()
120 pm_runtime_use_autosuspend(client->dev); in nvdec_init()
121 pm_runtime_set_autosuspend_delay(client->dev, 500); in nvdec_init()
131 client->dev->dma_parms = client->host->dma_parms; in nvdec_init()
136 pm_runtime_dont_use_autosuspend(client->dev); in nvdec_init()
137 pm_runtime_force_suspend(client->dev); in nvdec_init()
139 host1x_syncpt_put(client->syncpts[0]); in nvdec_init()
141 host1x_channel_put(nvdec->channel); in nvdec_init()
151 struct drm_device *dev = dev_get_drvdata(client->host); in nvdec_exit()
152 struct tegra_drm *tegra = dev->dev_private; in nvdec_exit()
157 client->dev->dma_parms = NULL; in nvdec_exit()
163 pm_runtime_dont_use_autosuspend(client->dev); in nvdec_exit()
164 pm_runtime_force_suspend(client->dev); in nvdec_exit()
166 host1x_syncpt_put(client->syncpts[0]); in nvdec_exit()
167 host1x_channel_put(nvdec->channel); in nvdec_exit()
170 nvdec->channel = NULL; in nvdec_exit()
172 if (client->group) { in nvdec_exit()
173 dma_unmap_single(nvdec->dev, nvdec->falcon.firmware.phys, in nvdec_exit()
174 nvdec->falcon.firmware.size, DMA_TO_DEVICE); in nvdec_exit()
175 tegra_drm_free(tegra, nvdec->falcon.firmware.size, in nvdec_exit()
176 nvdec->falcon.firmware.virt, in nvdec_exit()
177 nvdec->falcon.firmware.iova); in nvdec_exit()
179 dma_free_coherent(nvdec->dev, nvdec->falcon.firmware.size, in nvdec_exit()
180 nvdec->falcon.firmware.virt, in nvdec_exit()
181 nvdec->falcon.firmware.iova); in nvdec_exit()
194 struct host1x_client *client = &nvdec->client.base; in nvdec_load_firmware()
195 struct tegra_drm *tegra = nvdec->client.drm; in nvdec_load_firmware()
201 if (nvdec->falcon.firmware.virt) in nvdec_load_firmware()
204 err = falcon_read_firmware(&nvdec->falcon, nvdec->config->firmware); in nvdec_load_firmware()
208 size = nvdec->falcon.firmware.size; in nvdec_load_firmware()
210 if (!client->group) { in nvdec_load_firmware()
211 virt = dma_alloc_coherent(nvdec->dev, size, &iova, GFP_KERNEL); in nvdec_load_firmware()
213 err = dma_mapping_error(nvdec->dev, iova); in nvdec_load_firmware()
220 nvdec->falcon.firmware.virt = virt; in nvdec_load_firmware()
221 nvdec->falcon.firmware.iova = iova; in nvdec_load_firmware()
223 err = falcon_load_firmware(&nvdec->falcon); in nvdec_load_firmware()
232 if (client->group) { in nvdec_load_firmware()
235 phys = dma_map_single(nvdec->dev, virt, size, DMA_TO_DEVICE); in nvdec_load_firmware()
237 err = dma_mapping_error(nvdec->dev, phys); in nvdec_load_firmware()
241 nvdec->falcon.firmware.phys = phys; in nvdec_load_firmware()
247 if (!client->group) in nvdec_load_firmware()
248 dma_free_coherent(nvdec->dev, size, virt, iova); in nvdec_load_firmware()
261 err = clk_prepare_enable(nvdec->clk); in nvdec_runtime_resume()
278 clk_disable_unprepare(nvdec->clk); in nvdec_runtime_resume()
286 host1x_channel_stop(nvdec->channel); in nvdec_runtime_suspend()
288 clk_disable_unprepare(nvdec->clk); in nvdec_runtime_suspend()
298 context->channel = host1x_channel_get(nvdec->channel); in nvdec_open_channel()
299 if (!context->channel) in nvdec_open_channel()
300 return -ENOMEM; in nvdec_open_channel()
307 host1x_channel_put(context->channel); in nvdec_close_channel()
333 #define NVIDIA_TEGRA_186_NVDEC_FIRMWARE "nvidia/tegra186/nvdec.bin"
350 { .compatible = "nvidia,tegra210-nvdec", .data = &nvdec_t210_config },
351 { .compatible = "nvidia,tegra186-nvdec", .data = &nvdec_t186_config },
352 { .compatible = "nvidia,tegra194-nvdec", .data = &nvdec_t194_config },
359 struct device *dev = &pdev->dev; in nvdec_probe()
366 err = dma_coerce_mask_and_coherent(dev, *dev->parent->dma_mask); in nvdec_probe()
368 dev_err(&pdev->dev, "failed to set DMA mask: %d\n", err); in nvdec_probe()
374 return -ENOMEM; in nvdec_probe()
376 nvdec->config = of_device_get_match_data(dev); in nvdec_probe()
380 return -ENOMEM; in nvdec_probe()
382 nvdec->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in nvdec_probe()
383 if (IS_ERR(nvdec->regs)) in nvdec_probe()
384 return PTR_ERR(nvdec->regs); in nvdec_probe()
386 nvdec->clk = devm_clk_get(dev, NULL); in nvdec_probe()
387 if (IS_ERR(nvdec->clk)) { in nvdec_probe()
388 dev_err(&pdev->dev, "failed to get clock\n"); in nvdec_probe()
389 return PTR_ERR(nvdec->clk); in nvdec_probe()
392 err = clk_set_rate(nvdec->clk, ULONG_MAX); in nvdec_probe()
394 dev_err(&pdev->dev, "failed to set clock rate\n"); in nvdec_probe()
398 err = of_property_read_u32(dev->of_node, "nvidia,host1x-class", &host_class); in nvdec_probe()
402 nvdec->falcon.dev = dev; in nvdec_probe()
403 nvdec->falcon.regs = nvdec->regs; in nvdec_probe()
405 err = falcon_init(&nvdec->falcon); in nvdec_probe()
411 INIT_LIST_HEAD(&nvdec->client.base.list); in nvdec_probe()
412 nvdec->client.base.ops = &nvdec_client_ops; in nvdec_probe()
413 nvdec->client.base.dev = dev; in nvdec_probe()
414 nvdec->client.base.class = host_class; in nvdec_probe()
415 nvdec->client.base.syncpts = syncpts; in nvdec_probe()
416 nvdec->client.base.num_syncpts = 1; in nvdec_probe()
417 nvdec->dev = dev; in nvdec_probe()
419 INIT_LIST_HEAD(&nvdec->client.list); in nvdec_probe()
420 nvdec->client.version = nvdec->config->version; in nvdec_probe()
421 nvdec->client.ops = &nvdec_ops; in nvdec_probe()
423 err = host1x_client_register(&nvdec->client.base); in nvdec_probe()
432 falcon_exit(&nvdec->falcon); in nvdec_probe()
442 err = host1x_client_unregister(&nvdec->client.base); in nvdec_remove()
444 dev_err(&pdev->dev, "failed to unregister host1x client: %d\n", in nvdec_remove()
449 falcon_exit(&nvdec->falcon); in nvdec_remove()
462 .name = "tegra-nvdec",