Lines Matching +full:tegra186 +full:- +full:pmc
1 // SPDX-License-Identifier: GPL-2.0-only
8 #include <linux/dma-mapping.h>
19 #include <soc/tegra/pmc.h>
54 writel(value, vic->regs + offset); in vic_writel()
60 struct iommu_fwspec *spec = dev_iommu_fwspec_get(vic->dev); in vic_boot()
67 if (vic->config->supports_sid && spec) { in vic_boot()
74 if (spec->num_ids > 0) { in vic_boot()
75 value = spec->ids[0] & 0xffff; in vic_boot()
101 err = falcon_boot(&vic->falcon); in vic_boot()
105 hdr = vic->falcon.firmware.virt; in vic_boot()
110 hdr = vic->falcon.firmware.virt + in vic_boot()
114 falcon_execute_method(&vic->falcon, VIC_SET_FCE_UCODE_SIZE, in vic_boot()
117 &vic->falcon, VIC_SET_FCE_UCODE_OFFSET, in vic_boot()
118 (vic->falcon.firmware.iova + fce_bin_data_offset) >> 8); in vic_boot()
121 err = falcon_wait_idle(&vic->falcon); in vic_boot()
123 dev_err(vic->dev, in vic_boot()
134 struct drm_device *dev = dev_get_drvdata(client->host); in vic_init()
135 struct tegra_drm *tegra = dev->dev_private; in vic_init()
140 if (err < 0 && err != -ENODEV) { in vic_init()
141 dev_err(vic->dev, "failed to attach to domain: %d\n", err); in vic_init()
145 vic->channel = host1x_channel_request(client); in vic_init()
146 if (!vic->channel) { in vic_init()
147 err = -ENOMEM; in vic_init()
151 client->syncpts[0] = host1x_syncpt_request(client, 0); in vic_init()
152 if (!client->syncpts[0]) { in vic_init()
153 err = -ENOMEM; in vic_init()
157 pm_runtime_enable(client->dev); in vic_init()
158 pm_runtime_use_autosuspend(client->dev); in vic_init()
159 pm_runtime_set_autosuspend_delay(client->dev, 500); in vic_init()
169 client->dev->dma_parms = client->host->dma_parms; in vic_init()
174 pm_runtime_dont_use_autosuspend(client->dev); in vic_init()
175 pm_runtime_force_suspend(client->dev); in vic_init()
177 host1x_syncpt_put(client->syncpts[0]); in vic_init()
179 host1x_channel_put(vic->channel); in vic_init()
189 struct drm_device *dev = dev_get_drvdata(client->host); in vic_exit()
190 struct tegra_drm *tegra = dev->dev_private; in vic_exit()
195 client->dev->dma_parms = NULL; in vic_exit()
201 pm_runtime_dont_use_autosuspend(client->dev); in vic_exit()
202 pm_runtime_force_suspend(client->dev); in vic_exit()
204 host1x_syncpt_put(client->syncpts[0]); in vic_exit()
205 host1x_channel_put(vic->channel); in vic_exit()
208 vic->channel = NULL; in vic_exit()
210 if (client->group) { in vic_exit()
211 dma_unmap_single(vic->dev, vic->falcon.firmware.phys, in vic_exit()
212 vic->falcon.firmware.size, DMA_TO_DEVICE); in vic_exit()
213 tegra_drm_free(tegra, vic->falcon.firmware.size, in vic_exit()
214 vic->falcon.firmware.virt, in vic_exit()
215 vic->falcon.firmware.iova); in vic_exit()
217 dma_free_coherent(vic->dev, vic->falcon.firmware.size, in vic_exit()
218 vic->falcon.firmware.virt, in vic_exit()
219 vic->falcon.firmware.iova); in vic_exit()
232 struct host1x_client *client = &vic->client.base; in vic_load_firmware()
233 struct tegra_drm *tegra = vic->client.drm; in vic_load_firmware()
243 if (vic->falcon.firmware.virt) { in vic_load_firmware()
248 err = falcon_read_firmware(&vic->falcon, vic->config->firmware); in vic_load_firmware()
252 size = vic->falcon.firmware.size; in vic_load_firmware()
254 if (!client->group) { in vic_load_firmware()
255 virt = dma_alloc_coherent(vic->dev, size, &iova, GFP_KERNEL); in vic_load_firmware()
257 err = -ENOMEM; in vic_load_firmware()
268 vic->falcon.firmware.virt = virt; in vic_load_firmware()
269 vic->falcon.firmware.iova = iova; in vic_load_firmware()
271 err = falcon_load_firmware(&vic->falcon); in vic_load_firmware()
280 if (client->group) { in vic_load_firmware()
283 phys = dma_map_single(vic->dev, virt, size, DMA_TO_DEVICE); in vic_load_firmware()
285 err = dma_mapping_error(vic->dev, phys); in vic_load_firmware()
289 vic->falcon.firmware.phys = phys; in vic_load_firmware()
298 if (!vic->config->supports_sid) { in vic_load_firmware()
299 vic->can_use_context = false; in vic_load_firmware()
305 vic->can_use_context = false; in vic_load_firmware()
306 dev_warn_once(vic->dev, "context isolation disabled due to old firmware\n"); in vic_load_firmware()
308 vic->can_use_context = true; in vic_load_firmware()
316 if (!client->group) in vic_load_firmware()
317 dma_free_coherent(vic->dev, size, virt, iova); in vic_load_firmware()
331 err = clk_prepare_enable(vic->clk); in vic_runtime_resume()
337 err = reset_control_deassert(vic->rst); in vic_runtime_resume()
354 reset_control_assert(vic->rst); in vic_runtime_resume()
356 clk_disable_unprepare(vic->clk); in vic_runtime_resume()
365 host1x_channel_stop(vic->channel); in vic_runtime_suspend()
367 err = reset_control_assert(vic->rst); in vic_runtime_suspend()
373 clk_disable_unprepare(vic->clk); in vic_runtime_suspend()
383 context->channel = host1x_channel_get(vic->channel); in vic_open_channel()
384 if (!context->channel) in vic_open_channel()
385 return -ENOMEM; in vic_open_channel()
392 host1x_channel_put(context->channel); in vic_close_channel()
405 *supported = vic->can_use_context; in vic_can_use_memory_ctx()
434 #define NVIDIA_TEGRA_186_VIC_FIRMWARE "nvidia/tegra186/vic04_ucode.bin"
459 { .compatible = "nvidia,tegra124-vic", .data = &vic_t124_config },
460 { .compatible = "nvidia,tegra210-vic", .data = &vic_t210_config },
461 { .compatible = "nvidia,tegra186-vic", .data = &vic_t186_config },
462 { .compatible = "nvidia,tegra194-vic", .data = &vic_t194_config },
463 { .compatible = "nvidia,tegra234-vic", .data = &vic_t234_config },
470 struct device *dev = &pdev->dev; in vic_probe()
476 err = dma_coerce_mask_and_coherent(dev, *dev->parent->dma_mask); in vic_probe()
478 dev_err(&pdev->dev, "failed to set DMA mask: %d\n", err); in vic_probe()
484 return -ENOMEM; in vic_probe()
486 vic->config = of_device_get_match_data(dev); in vic_probe()
490 return -ENOMEM; in vic_probe()
492 vic->regs = devm_platform_ioremap_resource(pdev, 0); in vic_probe()
493 if (IS_ERR(vic->regs)) in vic_probe()
494 return PTR_ERR(vic->regs); in vic_probe()
496 vic->clk = devm_clk_get(dev, NULL); in vic_probe()
497 if (IS_ERR(vic->clk)) { in vic_probe()
498 dev_err(&pdev->dev, "failed to get clock\n"); in vic_probe()
499 return PTR_ERR(vic->clk); in vic_probe()
502 err = clk_set_rate(vic->clk, ULONG_MAX); in vic_probe()
504 dev_err(&pdev->dev, "failed to set clock rate\n"); in vic_probe()
508 if (!dev->pm_domain) { in vic_probe()
509 vic->rst = devm_reset_control_get(dev, "vic"); in vic_probe()
510 if (IS_ERR(vic->rst)) { in vic_probe()
511 dev_err(&pdev->dev, "failed to get reset\n"); in vic_probe()
512 return PTR_ERR(vic->rst); in vic_probe()
516 vic->falcon.dev = dev; in vic_probe()
517 vic->falcon.regs = vic->regs; in vic_probe()
519 err = falcon_init(&vic->falcon); in vic_probe()
525 INIT_LIST_HEAD(&vic->client.base.list); in vic_probe()
526 vic->client.base.ops = &vic_client_ops; in vic_probe()
527 vic->client.base.dev = dev; in vic_probe()
528 vic->client.base.class = HOST1X_CLASS_VIC; in vic_probe()
529 vic->client.base.syncpts = syncpts; in vic_probe()
530 vic->client.base.num_syncpts = 1; in vic_probe()
531 vic->dev = dev; in vic_probe()
533 INIT_LIST_HEAD(&vic->client.list); in vic_probe()
534 vic->client.version = vic->config->version; in vic_probe()
535 vic->client.ops = &vic_ops; in vic_probe()
537 err = host1x_client_register(&vic->client.base); in vic_probe()
546 falcon_exit(&vic->falcon); in vic_probe()
556 err = host1x_client_unregister(&vic->client.base); in vic_remove()
558 dev_err(&pdev->dev, "failed to unregister host1x client: %d\n", in vic_remove()
563 falcon_exit(&vic->falcon); in vic_remove()
575 .name = "tegra-vic",