Lines Matching +full:host1x +full:- +full:class

1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <linux/host1x.h>
61 struct drm_device *dev = dev_get_drvdata(client->host); in gr3d_init()
66 gr3d->channel = host1x_channel_request(client); in gr3d_init()
67 if (!gr3d->channel) in gr3d_init()
68 return -ENOMEM; in gr3d_init()
70 client->syncpts[0] = host1x_syncpt_request(client, flags); in gr3d_init()
71 if (!client->syncpts[0]) { in gr3d_init()
72 err = -ENOMEM; in gr3d_init()
73 dev_err(client->dev, "failed to request syncpoint: %d\n", err); in gr3d_init()
79 dev_err(client->dev, "failed to attach to domain: %d\n", err); in gr3d_init()
83 pm_runtime_enable(client->dev); in gr3d_init()
84 pm_runtime_use_autosuspend(client->dev); in gr3d_init()
85 pm_runtime_set_autosuspend_delay(client->dev, 200); in gr3d_init()
87 err = tegra_drm_register_client(dev->dev_private, drm); in gr3d_init()
89 dev_err(client->dev, "failed to register client: %d\n", err); in gr3d_init()
96 pm_runtime_dont_use_autosuspend(client->dev); in gr3d_init()
97 pm_runtime_force_suspend(client->dev); in gr3d_init()
101 host1x_syncpt_put(client->syncpts[0]); in gr3d_init()
103 host1x_channel_put(gr3d->channel); in gr3d_init()
110 struct drm_device *dev = dev_get_drvdata(client->host); in gr3d_exit()
114 err = tegra_drm_unregister_client(dev->dev_private, drm); in gr3d_exit()
118 pm_runtime_dont_use_autosuspend(client->dev); in gr3d_exit()
119 pm_runtime_force_suspend(client->dev); in gr3d_exit()
122 host1x_syncpt_put(client->syncpts[0]); in gr3d_exit()
123 host1x_channel_put(gr3d->channel); in gr3d_exit()
125 gr3d->channel = NULL; in gr3d_exit()
140 context->channel = host1x_channel_get(gr3d->channel); in gr3d_open_channel()
141 if (!context->channel) in gr3d_open_channel()
142 return -ENOMEM; in gr3d_open_channel()
149 host1x_channel_put(context->channel); in gr3d_close_channel()
152 static int gr3d_is_addr_reg(struct device *dev, u32 class, u32 offset) in gr3d_is_addr_reg() argument
156 switch (class) { in gr3d_is_addr_reg()
167 if (test_bit(offset, gr3d->addr_regs)) in gr3d_is_addr_reg()
202 { .compatible = "nvidia,tegra114-gr3d", .data = &tegra114_gr3d_soc },
203 { .compatible = "nvidia,tegra30-gr3d", .data = &tegra30_gr3d_soc },
204 { .compatible = "nvidia,tegra20-gr3d", .data = &tegra20_gr3d_soc },
324 * Tegra20 device-tree doesn't specify 3d clock name and there is only in gr3d_power_up_legacy_domain()
325 * one clock for Tegra20. Tegra30+ device-trees always specified names in gr3d_power_up_legacy_domain()
328 if (gr3d->nclocks == 1) { in gr3d_power_up_legacy_domain()
332 clk = gr3d->clocks[0].clk; in gr3d_power_up_legacy_domain()
334 for (i = 0; i < gr3d->nclocks; i++) { in gr3d_power_up_legacy_domain()
335 if (WARN_ON(!gr3d->clocks[i].id)) in gr3d_power_up_legacy_domain()
338 if (!strcmp(gr3d->clocks[i].id, name)) { in gr3d_power_up_legacy_domain()
339 clk = gr3d->clocks[i].clk; in gr3d_power_up_legacy_domain()
344 if (WARN_ON(i == gr3d->nclocks)) in gr3d_power_up_legacy_domain()
345 return -EINVAL; in gr3d_power_up_legacy_domain()
372 * while GENPD not. Hence keep clock-enable balanced. in gr3d_power_up_legacy_domain()
393 err = of_count_phandle_with_args(dev->of_node, "power-domains", in gr3d_init_power()
394 "#power-domain-cells"); in gr3d_init_power()
396 if (err != -ENOENT) in gr3d_init_power()
400 * Older device-trees don't use GENPD. In this case we should in gr3d_init_power()
421 if (dev->pm_domain) in gr3d_init_power()
433 return -EINVAL; in gr3d_init_power()
439 return -EINVAL; in gr3d_init_power()
454 err = devm_clk_bulk_get_all(dev, &gr3d->clocks); in gr3d_get_clocks()
459 gr3d->nclocks = err; in gr3d_get_clocks()
461 if (gr3d->nclocks != gr3d->soc->num_clocks) { in gr3d_get_clocks()
462 dev_err(dev, "invalid number of clocks: %u\n", gr3d->nclocks); in gr3d_get_clocks()
463 return -ENOENT; in gr3d_get_clocks()
473 gr3d->resets[RST_MC].id = "mc"; in gr3d_get_resets()
474 gr3d->resets[RST_MC2].id = "mc2"; in gr3d_get_resets()
475 gr3d->resets[RST_GR3D].id = "3d"; in gr3d_get_resets()
476 gr3d->resets[RST_GR3D2].id = "3d2"; in gr3d_get_resets()
477 gr3d->nresets = gr3d->soc->num_resets; in gr3d_get_resets()
480 dev, gr3d->nresets, gr3d->resets); in gr3d_get_resets()
486 if (WARN_ON(!gr3d->resets[RST_GR3D].rstc) || in gr3d_get_resets()
487 WARN_ON(!gr3d->resets[RST_GR3D2].rstc && gr3d->nresets == 4)) in gr3d_get_resets()
488 return -ENOENT; in gr3d_get_resets()
500 gr3d = devm_kzalloc(&pdev->dev, sizeof(*gr3d), GFP_KERNEL); in gr3d_probe()
502 return -ENOMEM; in gr3d_probe()
506 gr3d->soc = of_device_get_match_data(&pdev->dev); in gr3d_probe()
508 syncpts = devm_kzalloc(&pdev->dev, sizeof(*syncpts), GFP_KERNEL); in gr3d_probe()
510 return -ENOMEM; in gr3d_probe()
512 err = gr3d_get_clocks(&pdev->dev, gr3d); in gr3d_probe()
516 err = gr3d_get_resets(&pdev->dev, gr3d); in gr3d_probe()
520 err = gr3d_init_power(&pdev->dev, gr3d); in gr3d_probe()
524 INIT_LIST_HEAD(&gr3d->client.base.list); in gr3d_probe()
525 gr3d->client.base.ops = &gr3d_client_ops; in gr3d_probe()
526 gr3d->client.base.dev = &pdev->dev; in gr3d_probe()
527 gr3d->client.base.class = HOST1X_CLASS_GR3D; in gr3d_probe()
528 gr3d->client.base.syncpts = syncpts; in gr3d_probe()
529 gr3d->client.base.num_syncpts = 1; in gr3d_probe()
531 INIT_LIST_HEAD(&gr3d->client.list); in gr3d_probe()
532 gr3d->client.version = gr3d->soc->version; in gr3d_probe()
533 gr3d->client.ops = &gr3d_ops; in gr3d_probe()
535 err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); in gr3d_probe()
539 err = host1x_client_register(&gr3d->client.base); in gr3d_probe()
541 dev_err(&pdev->dev, "failed to register host1x client: %d\n", in gr3d_probe()
548 set_bit(gr3d_addr_regs[i], gr3d->addr_regs); in gr3d_probe()
558 err = host1x_client_unregister(&gr3d->client.base); in gr3d_remove()
560 dev_err(&pdev->dev, "failed to unregister host1x client: %d\n", in gr3d_remove()
573 host1x_channel_stop(gr3d->channel); in gr3d_runtime_suspend()
575 err = reset_control_bulk_assert(gr3d->nresets, gr3d->resets); in gr3d_runtime_suspend()
584 * Older device-trees don't specify MC resets and power-gating can't in gr3d_runtime_suspend()
586 * for older DTBs. For newer DTBs, GENPD will perform the power-gating. in gr3d_runtime_suspend()
589 clk_bulk_disable_unprepare(gr3d->nclocks, gr3d->clocks); in gr3d_runtime_suspend()
590 reset_control_bulk_release(gr3d->nresets, gr3d->resets); in gr3d_runtime_suspend()
600 err = reset_control_bulk_acquire(gr3d->nresets, gr3d->resets); in gr3d_runtime_resume()
606 err = clk_bulk_prepare_enable(gr3d->nclocks, gr3d->clocks); in gr3d_runtime_resume()
612 err = reset_control_bulk_deassert(gr3d->nresets, gr3d->resets); in gr3d_runtime_resume()
621 clk_bulk_disable_unprepare(gr3d->nclocks, gr3d->clocks); in gr3d_runtime_resume()
623 reset_control_bulk_release(gr3d->nresets, gr3d->resets); in gr3d_runtime_resume()
636 .name = "tegra-gr3d",