Lines Matching full:nvdec

36 struct nvdec {  struct
55 static inline struct nvdec *to_nvdec(struct tegra_drm_client *client) in to_nvdec() argument
57 return container_of(client, struct nvdec, client); in to_nvdec()
60 static inline void nvdec_writel(struct nvdec *nvdec, u32 value, in nvdec_writel() argument
63 writel(value, nvdec->regs + offset); in nvdec_writel()
66 static int nvdec_boot_falcon(struct nvdec *nvdec) in nvdec_boot_falcon() argument
71 if (nvdec->config->supports_sid && tegra_dev_iommu_get_stream_id(nvdec->dev, &stream_id)) { in nvdec_boot_falcon()
75 nvdec_writel(nvdec, value, NVDEC_TFBIF_TRANSCFG); in nvdec_boot_falcon()
77 nvdec_writel(nvdec, stream_id, VIC_THI_STREAMID0); in nvdec_boot_falcon()
78 nvdec_writel(nvdec, stream_id, VIC_THI_STREAMID1); in nvdec_boot_falcon()
81 err = falcon_boot(&nvdec->falcon); in nvdec_boot_falcon()
85 err = falcon_wait_idle(&nvdec->falcon); in nvdec_boot_falcon()
87 dev_err(nvdec->dev, "falcon boot timed out\n"); in nvdec_boot_falcon()
94 static int nvdec_wait_debuginfo(struct nvdec *nvdec, const char *phase) in nvdec_wait_debuginfo() argument
99 err = readl_poll_timeout(nvdec->regs + NVDEC_FALCON_DEBUGINFO, val, val == 0x0, 10, 100000); in nvdec_wait_debuginfo()
101 dev_err(nvdec->dev, "failed to boot %s, debuginfo=0x%x\n", phase, val); in nvdec_wait_debuginfo()
108 static int nvdec_boot_riscv(struct nvdec *nvdec) in nvdec_boot_riscv() argument
112 err = reset_control_acquire(nvdec->reset); in nvdec_boot_riscv()
116 nvdec_writel(nvdec, 0xabcd1234, NVDEC_FALCON_DEBUGINFO); in nvdec_boot_riscv()
118 err = tegra_drm_riscv_boot_bootrom(&nvdec->riscv, nvdec->carveout_base, 1, in nvdec_boot_riscv()
119 &nvdec->riscv.bl_desc); in nvdec_boot_riscv()
121 dev_err(nvdec->dev, "failed to execute bootloader\n"); in nvdec_boot_riscv()
125 err = nvdec_wait_debuginfo(nvdec, "bootloader"); in nvdec_boot_riscv()
129 err = reset_control_reset(nvdec->reset); in nvdec_boot_riscv()
133 nvdec_writel(nvdec, 0xabcd1234, NVDEC_FALCON_DEBUGINFO); in nvdec_boot_riscv()
135 err = tegra_drm_riscv_boot_bootrom(&nvdec->riscv, nvdec->carveout_base, 1, in nvdec_boot_riscv()
136 &nvdec->riscv.os_desc); in nvdec_boot_riscv()
138 dev_err(nvdec->dev, "failed to execute firmware\n"); in nvdec_boot_riscv()
142 err = nvdec_wait_debuginfo(nvdec, "firmware"); in nvdec_boot_riscv()
147 reset_control_release(nvdec->reset); in nvdec_boot_riscv()
157 struct nvdec *nvdec = to_nvdec(drm); in nvdec_init() local
162 dev_err(nvdec->dev, "failed to attach to domain: %d\n", err); in nvdec_init()
166 nvdec->channel = host1x_channel_request(client); in nvdec_init()
167 if (!nvdec->channel) { in nvdec_init()
193 host1x_channel_put(nvdec->channel); in nvdec_init()
205 struct nvdec *nvdec = to_nvdec(drm); in nvdec_exit() local
219 host1x_channel_put(nvdec->channel); in nvdec_exit()
222 nvdec->channel = NULL; in nvdec_exit()
225 dma_unmap_single(nvdec->dev, nvdec->falcon.firmware.phys, in nvdec_exit()
226 nvdec->falcon.firmware.size, DMA_TO_DEVICE); in nvdec_exit()
227 tegra_drm_free(tegra, nvdec->falcon.firmware.size, in nvdec_exit()
228 nvdec->falcon.firmware.virt, in nvdec_exit()
229 nvdec->falcon.firmware.iova); in nvdec_exit()
231 dma_free_coherent(nvdec->dev, nvdec->falcon.firmware.size, in nvdec_exit()
232 nvdec->falcon.firmware.virt, in nvdec_exit()
233 nvdec->falcon.firmware.iova); in nvdec_exit()
244 static int nvdec_load_falcon_firmware(struct nvdec *nvdec) in nvdec_load_falcon_firmware() argument
246 struct host1x_client *client = &nvdec->client.base; in nvdec_load_falcon_firmware()
247 struct tegra_drm *tegra = nvdec->client.drm; in nvdec_load_falcon_firmware()
253 if (nvdec->falcon.firmware.virt) in nvdec_load_falcon_firmware()
256 err = falcon_read_firmware(&nvdec->falcon, nvdec->config->firmware); in nvdec_load_falcon_firmware()
260 size = nvdec->falcon.firmware.size; in nvdec_load_falcon_firmware()
263 virt = dma_alloc_coherent(nvdec->dev, size, &iova, GFP_KERNEL); in nvdec_load_falcon_firmware()
265 err = dma_mapping_error(nvdec->dev, iova); in nvdec_load_falcon_firmware()
274 nvdec->falcon.firmware.virt = virt; in nvdec_load_falcon_firmware()
275 nvdec->falcon.firmware.iova = iova; in nvdec_load_falcon_firmware()
277 err = falcon_load_firmware(&nvdec->falcon); in nvdec_load_falcon_firmware()
289 phys = dma_map_single(nvdec->dev, virt, size, DMA_TO_DEVICE); in nvdec_load_falcon_firmware()
291 err = dma_mapping_error(nvdec->dev, phys); in nvdec_load_falcon_firmware()
295 nvdec->falcon.firmware.phys = phys; in nvdec_load_falcon_firmware()
302 dma_free_coherent(nvdec->dev, size, virt, iova); in nvdec_load_falcon_firmware()
311 struct nvdec *nvdec = dev_get_drvdata(dev); in nvdec_runtime_resume() local
314 err = clk_bulk_prepare_enable(nvdec->num_clks, nvdec->clks); in nvdec_runtime_resume()
320 if (nvdec->config->has_riscv) { in nvdec_runtime_resume()
321 err = nvdec_boot_riscv(nvdec); in nvdec_runtime_resume()
325 err = nvdec_load_falcon_firmware(nvdec); in nvdec_runtime_resume()
329 err = nvdec_boot_falcon(nvdec); in nvdec_runtime_resume()
337 clk_bulk_disable_unprepare(nvdec->num_clks, nvdec->clks); in nvdec_runtime_resume()
343 struct nvdec *nvdec = dev_get_drvdata(dev); in nvdec_runtime_suspend() local
345 host1x_channel_stop(nvdec->channel); in nvdec_runtime_suspend()
347 clk_bulk_disable_unprepare(nvdec->num_clks, nvdec->clks); in nvdec_runtime_suspend()
355 struct nvdec *nvdec = to_nvdec(client); in nvdec_open_channel() local
357 context->channel = host1x_channel_get(nvdec->channel); in nvdec_open_channel()
384 #define NVIDIA_TEGRA_210_NVDEC_FIRMWARE "nvidia/tegra210/nvdec.bin"
392 #define NVIDIA_TEGRA_186_NVDEC_FIRMWARE "nvidia/tegra186/nvdec.bin"
400 #define NVIDIA_TEGRA_194_NVDEC_FIRMWARE "nvidia/tegra194/nvdec.bin"
416 { .compatible = "nvidia,tegra210-nvdec", .data = &nvdec_t210_config },
417 { .compatible = "nvidia,tegra186-nvdec", .data = &nvdec_t186_config },
418 { .compatible = "nvidia,tegra194-nvdec", .data = &nvdec_t194_config },
419 { .compatible = "nvidia,tegra234-nvdec", .data = &nvdec_t234_config },
428 struct nvdec *nvdec; in nvdec_probe() local
439 nvdec = devm_kzalloc(dev, sizeof(*nvdec), GFP_KERNEL); in nvdec_probe()
440 if (!nvdec) in nvdec_probe()
443 nvdec->config = of_device_get_match_data(dev); in nvdec_probe()
449 nvdec->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in nvdec_probe()
450 if (IS_ERR(nvdec->regs)) in nvdec_probe()
451 return PTR_ERR(nvdec->regs); in nvdec_probe()
453 nvdec->clks[0].id = "nvdec"; in nvdec_probe()
454 nvdec->num_clks = 1; in nvdec_probe()
456 if (nvdec->config->has_extra_clocks) { in nvdec_probe()
457 nvdec->num_clks = 3; in nvdec_probe()
458 nvdec->clks[1].id = "fuse"; in nvdec_probe()
459 nvdec->clks[2].id = "tsec_pka"; in nvdec_probe()
462 err = devm_clk_bulk_get(dev, nvdec->num_clks, nvdec->clks); in nvdec_probe()
468 err = clk_set_rate(nvdec->clks[0].clk, ULONG_MAX); in nvdec_probe()
478 if (nvdec->config->has_riscv) { in nvdec_probe()
488 err = tegra_mc_get_carveout_info(mc, 1, &nvdec->carveout_base, NULL); in nvdec_probe()
494 nvdec->reset = devm_reset_control_get_exclusive_released(dev, "nvdec"); in nvdec_probe()
495 if (IS_ERR(nvdec->reset)) { in nvdec_probe()
496 dev_err_probe(dev, PTR_ERR(nvdec->reset), "failed to get reset\n"); in nvdec_probe()
497 return PTR_ERR(nvdec->reset); in nvdec_probe()
500 nvdec->riscv.dev = dev; in nvdec_probe()
501 nvdec->riscv.regs = nvdec->regs; in nvdec_probe()
503 err = tegra_drm_riscv_read_descriptors(&nvdec->riscv); in nvdec_probe()
507 nvdec->falcon.dev = dev; in nvdec_probe()
508 nvdec->falcon.regs = nvdec->regs; in nvdec_probe()
510 err = falcon_init(&nvdec->falcon); in nvdec_probe()
515 platform_set_drvdata(pdev, nvdec); in nvdec_probe()
517 INIT_LIST_HEAD(&nvdec->client.base.list); in nvdec_probe()
518 nvdec->client.base.ops = &nvdec_client_ops; in nvdec_probe()
519 nvdec->client.base.dev = dev; in nvdec_probe()
520 nvdec->client.base.class = host_class; in nvdec_probe()
521 nvdec->client.base.syncpts = syncpts; in nvdec_probe()
522 nvdec->client.base.num_syncpts = 1; in nvdec_probe()
523 nvdec->dev = dev; in nvdec_probe()
525 INIT_LIST_HEAD(&nvdec->client.list); in nvdec_probe()
526 nvdec->client.version = nvdec->config->version; in nvdec_probe()
527 nvdec->client.ops = &nvdec_ops; in nvdec_probe()
529 err = host1x_client_register(&nvdec->client.base); in nvdec_probe()
542 falcon_exit(&nvdec->falcon); in nvdec_probe()
549 struct nvdec *nvdec = platform_get_drvdata(pdev); in nvdec_remove() local
552 host1x_client_unregister(&nvdec->client.base); in nvdec_remove()
553 falcon_exit(&nvdec->falcon); in nvdec_remove()
564 .name = "tegra-nvdec",