Lines Matching refs:vic

31 struct vic {  struct
47 static inline struct vic *to_vic(struct tegra_drm_client *client) in to_vic() argument
49 return container_of(client, struct vic, client); in to_vic()
52 static void vic_writel(struct vic *vic, u32 value, unsigned int offset) in vic_writel() argument
54 writel(value, vic->regs + offset); in vic_writel()
57 static int vic_boot(struct vic *vic) in vic_boot() argument
63 if (vic->config->supports_sid && tegra_dev_iommu_get_stream_id(vic->dev, &stream_id)) { in vic_boot()
68 vic_writel(vic, value, VIC_TFBIF_TRANSCFG); in vic_boot()
78 vic_writel(vic, stream_id, VIC_THI_STREAMID0); in vic_boot()
81 vic_writel(vic, stream_id, VIC_THI_STREAMID1); in vic_boot()
85 vic_writel(vic, CG_IDLE_CG_DLY_CNT(4) | in vic_boot()
90 err = falcon_boot(&vic->falcon); in vic_boot()
94 hdr = vic->falcon.firmware.virt; in vic_boot()
99 hdr = vic->falcon.firmware.virt + in vic_boot()
103 falcon_execute_method(&vic->falcon, VIC_SET_FCE_UCODE_SIZE, in vic_boot()
106 &vic->falcon, VIC_SET_FCE_UCODE_OFFSET, in vic_boot()
107 (vic->falcon.firmware.iova + fce_bin_data_offset) >> 8); in vic_boot()
110 err = falcon_wait_idle(&vic->falcon); in vic_boot()
112 dev_err(vic->dev, in vic_boot()
125 struct vic *vic = to_vic(drm); in vic_init() local
130 dev_err(vic->dev, "failed to attach to domain: %d\n", err); in vic_init()
134 vic->channel = host1x_channel_request(client); in vic_init()
135 if (!vic->channel) { in vic_init()
168 host1x_channel_put(vic->channel); in vic_init()
180 struct vic *vic = to_vic(drm); in vic_exit() local
194 host1x_channel_put(vic->channel); in vic_exit()
197 vic->channel = NULL; in vic_exit()
200 dma_unmap_single(vic->dev, vic->falcon.firmware.phys, in vic_exit()
201 vic->falcon.firmware.size, DMA_TO_DEVICE); in vic_exit()
202 tegra_drm_free(tegra, vic->falcon.firmware.size, in vic_exit()
203 vic->falcon.firmware.virt, in vic_exit()
204 vic->falcon.firmware.iova); in vic_exit()
206 dma_free_coherent(vic->dev, vic->falcon.firmware.size, in vic_exit()
207 vic->falcon.firmware.virt, in vic_exit()
208 vic->falcon.firmware.iova); in vic_exit()
219 static int vic_load_firmware(struct vic *vic) in vic_load_firmware() argument
221 struct host1x_client *client = &vic->client.base; in vic_load_firmware()
222 struct tegra_drm *tegra = vic->client.drm; in vic_load_firmware()
232 if (vic->falcon.firmware.virt) { in vic_load_firmware()
237 err = falcon_read_firmware(&vic->falcon, vic->config->firmware); in vic_load_firmware()
241 size = vic->falcon.firmware.size; in vic_load_firmware()
244 virt = dma_alloc_coherent(vic->dev, size, &iova, GFP_KERNEL); in vic_load_firmware()
257 vic->falcon.firmware.virt = virt; in vic_load_firmware()
258 vic->falcon.firmware.iova = iova; in vic_load_firmware()
260 err = falcon_load_firmware(&vic->falcon); in vic_load_firmware()
272 phys = dma_map_single(vic->dev, virt, size, DMA_TO_DEVICE); in vic_load_firmware()
274 err = dma_mapping_error(vic->dev, phys); in vic_load_firmware()
278 vic->falcon.firmware.phys = phys; in vic_load_firmware()
287 if (!vic->config->supports_sid) { in vic_load_firmware()
288 vic->can_use_context = false; in vic_load_firmware()
294 vic->can_use_context = false; in vic_load_firmware()
295 dev_warn_once(vic->dev, "context isolation disabled due to old firmware\n"); in vic_load_firmware()
297 vic->can_use_context = true; in vic_load_firmware()
306 dma_free_coherent(vic->dev, size, virt, iova); in vic_load_firmware()
317 struct vic *vic = dev_get_drvdata(dev); in vic_runtime_resume() local
320 err = clk_prepare_enable(vic->clk); in vic_runtime_resume()
326 err = reset_control_deassert(vic->rst); in vic_runtime_resume()
332 err = vic_load_firmware(vic); in vic_runtime_resume()
336 err = vic_boot(vic); in vic_runtime_resume()
343 reset_control_assert(vic->rst); in vic_runtime_resume()
345 clk_disable_unprepare(vic->clk); in vic_runtime_resume()
351 struct vic *vic = dev_get_drvdata(dev); in vic_runtime_suspend() local
354 host1x_channel_stop(vic->channel); in vic_runtime_suspend()
356 err = reset_control_assert(vic->rst); in vic_runtime_suspend()
362 clk_disable_unprepare(vic->clk); in vic_runtime_suspend()
370 struct vic *vic = to_vic(client); in vic_open_channel() local
372 context->channel = host1x_channel_get(vic->channel); in vic_open_channel()
386 struct vic *vic = to_vic(client); in vic_can_use_memory_ctx() local
390 err = vic_load_firmware(vic); in vic_can_use_memory_ctx()
394 *supported = vic->can_use_context; in vic_can_use_memory_ctx()
461 struct vic *vic; in vic_probe() local
471 vic = devm_kzalloc(dev, sizeof(*vic), GFP_KERNEL); in vic_probe()
472 if (!vic) in vic_probe()
475 vic->config = of_device_get_match_data(dev); in vic_probe()
481 vic->regs = devm_platform_ioremap_resource(pdev, 0); in vic_probe()
482 if (IS_ERR(vic->regs)) in vic_probe()
483 return PTR_ERR(vic->regs); in vic_probe()
485 vic->clk = devm_clk_get(dev, NULL); in vic_probe()
486 if (IS_ERR(vic->clk)) { in vic_probe()
488 return PTR_ERR(vic->clk); in vic_probe()
491 err = clk_set_rate(vic->clk, ULONG_MAX); in vic_probe()
498 vic->rst = devm_reset_control_get(dev, "vic"); in vic_probe()
499 if (IS_ERR(vic->rst)) { in vic_probe()
501 return PTR_ERR(vic->rst); in vic_probe()
505 vic->falcon.dev = dev; in vic_probe()
506 vic->falcon.regs = vic->regs; in vic_probe()
508 err = falcon_init(&vic->falcon); in vic_probe()
512 platform_set_drvdata(pdev, vic); in vic_probe()
514 INIT_LIST_HEAD(&vic->client.base.list); in vic_probe()
515 vic->client.base.ops = &vic_client_ops; in vic_probe()
516 vic->client.base.dev = dev; in vic_probe()
517 vic->client.base.class = HOST1X_CLASS_VIC; in vic_probe()
518 vic->client.base.syncpts = syncpts; in vic_probe()
519 vic->client.base.num_syncpts = 1; in vic_probe()
520 vic->dev = dev; in vic_probe()
522 INIT_LIST_HEAD(&vic->client.list); in vic_probe()
523 vic->client.version = vic->config->version; in vic_probe()
524 vic->client.ops = &vic_ops; in vic_probe()
526 err = host1x_client_register(&vic->client.base); in vic_probe()
535 falcon_exit(&vic->falcon); in vic_probe()
542 struct vic *vic = platform_get_drvdata(pdev); in vic_remove() local
545 err = host1x_client_unregister(&vic->client.base); in vic_remove()
552 falcon_exit(&vic->falcon); in vic_remove()