Lines Matching +full:tegra20 +full:- +full:gr3d

1 // SPDX-License-Identifier: GPL-2.0-only
24 #include "gr3d.h"
40 struct gr3d { struct
53 static inline struct gr3d *to_gr3d(struct tegra_drm_client *client) in to_gr3d() argument
55 return container_of(client, struct gr3d, client); in to_gr3d()
61 struct drm_device *dev = dev_get_drvdata(client->host); in gr3d_init()
63 struct gr3d *gr3d = to_gr3d(drm); in gr3d_init() local
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 err = tegra_drm_register_client(dev->dev_private, drm); in gr3d_init()
85 dev_err(client->dev, "failed to register client: %d\n", err); in gr3d_init()
94 host1x_syncpt_put(client->syncpts[0]); in gr3d_init()
96 host1x_channel_put(gr3d->channel); in gr3d_init()
103 struct drm_device *dev = dev_get_drvdata(client->host); in gr3d_exit()
104 struct gr3d *gr3d = to_gr3d(drm); in gr3d_exit() local
107 err = tegra_drm_unregister_client(dev->dev_private, drm); in gr3d_exit()
111 pm_runtime_dont_use_autosuspend(client->dev); in gr3d_exit()
112 pm_runtime_force_suspend(client->dev); in gr3d_exit()
115 host1x_syncpt_put(client->syncpts[0]); in gr3d_exit()
116 host1x_channel_put(gr3d->channel); in gr3d_exit()
118 gr3d->channel = NULL; in gr3d_exit()
131 struct gr3d *gr3d = to_gr3d(client); in gr3d_open_channel() local
133 context->channel = host1x_channel_get(gr3d->channel); in gr3d_open_channel()
134 if (!context->channel) in gr3d_open_channel()
135 return -ENOMEM; in gr3d_open_channel()
142 host1x_channel_put(context->channel); in gr3d_close_channel()
147 struct gr3d *gr3d = dev_get_drvdata(dev); in gr3d_is_addr_reg() local
160 if (test_bit(offset, gr3d->addr_regs)) in gr3d_is_addr_reg()
195 { .compatible = "nvidia,tegra114-gr3d", .data = &tegra114_gr3d_soc },
196 { .compatible = "nvidia,tegra30-gr3d", .data = &tegra30_gr3d_soc },
197 { .compatible = "nvidia,tegra20-gr3d", .data = &tegra20_gr3d_soc },
310 struct gr3d *gr3d = dev_get_drvdata(dev); in gr3d_power_up_legacy_domain() local
317 * Tegra20 device-tree doesn't specify 3d clock name and there is only in gr3d_power_up_legacy_domain()
318 * one clock for Tegra20. Tegra30+ device-trees always specified names in gr3d_power_up_legacy_domain()
321 if (gr3d->nclocks == 1) { in gr3d_power_up_legacy_domain()
325 clk = gr3d->clocks[0].clk; in gr3d_power_up_legacy_domain()
327 for (i = 0; i < gr3d->nclocks; i++) { in gr3d_power_up_legacy_domain()
328 if (WARN_ON(!gr3d->clocks[i].id)) in gr3d_power_up_legacy_domain()
331 if (!strcmp(gr3d->clocks[i].id, name)) { in gr3d_power_up_legacy_domain()
332 clk = gr3d->clocks[i].clk; in gr3d_power_up_legacy_domain()
337 if (WARN_ON(i == gr3d->nclocks)) in gr3d_power_up_legacy_domain()
338 return -EINVAL; in gr3d_power_up_legacy_domain()
365 * while GENPD not. Hence keep clock-enable balanced. in gr3d_power_up_legacy_domain()
377 static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) in gr3d_init_power() argument
386 err = of_count_phandle_with_args(dev->of_node, "power-domains", in gr3d_init_power()
387 "#power-domain-cells"); in gr3d_init_power()
389 if (err != -ENOENT) in gr3d_init_power()
393 * Older device-trees don't use GENPD. In this case we should in gr3d_init_power()
412 * on Tegra20 and two domains on Tegra30+. in gr3d_init_power()
414 if (dev->pm_domain) in gr3d_init_power()
426 return -EINVAL; in gr3d_init_power()
432 return -EINVAL; in gr3d_init_power()
443 static int gr3d_get_clocks(struct device *dev, struct gr3d *gr3d) in gr3d_get_clocks() argument
447 err = devm_clk_bulk_get_all(dev, &gr3d->clocks); in gr3d_get_clocks()
452 gr3d->nclocks = err; in gr3d_get_clocks()
454 if (gr3d->nclocks != gr3d->soc->num_clocks) { in gr3d_get_clocks()
455 dev_err(dev, "invalid number of clocks: %u\n", gr3d->nclocks); in gr3d_get_clocks()
456 return -ENOENT; in gr3d_get_clocks()
462 static int gr3d_get_resets(struct device *dev, struct gr3d *gr3d) in gr3d_get_resets() argument
466 gr3d->resets[RST_MC].id = "mc"; in gr3d_get_resets()
467 gr3d->resets[RST_MC2].id = "mc2"; in gr3d_get_resets()
468 gr3d->resets[RST_GR3D].id = "3d"; in gr3d_get_resets()
469 gr3d->resets[RST_GR3D2].id = "3d2"; in gr3d_get_resets()
470 gr3d->nresets = gr3d->soc->num_resets; in gr3d_get_resets()
473 dev, gr3d->nresets, gr3d->resets); in gr3d_get_resets()
479 if (WARN_ON(!gr3d->resets[RST_GR3D].rstc) || in gr3d_get_resets()
480 WARN_ON(!gr3d->resets[RST_GR3D2].rstc && gr3d->nresets == 4)) in gr3d_get_resets()
481 return -ENOENT; in gr3d_get_resets()
489 struct gr3d *gr3d; in gr3d_probe() local
493 gr3d = devm_kzalloc(&pdev->dev, sizeof(*gr3d), GFP_KERNEL); in gr3d_probe()
494 if (!gr3d) in gr3d_probe()
495 return -ENOMEM; in gr3d_probe()
497 platform_set_drvdata(pdev, gr3d); in gr3d_probe()
499 gr3d->soc = of_device_get_match_data(&pdev->dev); in gr3d_probe()
501 syncpts = devm_kzalloc(&pdev->dev, sizeof(*syncpts), GFP_KERNEL); in gr3d_probe()
503 return -ENOMEM; in gr3d_probe()
505 err = gr3d_get_clocks(&pdev->dev, gr3d); in gr3d_probe()
509 err = gr3d_get_resets(&pdev->dev, gr3d); in gr3d_probe()
513 err = gr3d_init_power(&pdev->dev, gr3d); in gr3d_probe()
517 INIT_LIST_HEAD(&gr3d->client.base.list); in gr3d_probe()
518 gr3d->client.base.ops = &gr3d_client_ops; in gr3d_probe()
519 gr3d->client.base.dev = &pdev->dev; in gr3d_probe()
520 gr3d->client.base.class = HOST1X_CLASS_GR3D; in gr3d_probe()
521 gr3d->client.base.syncpts = syncpts; in gr3d_probe()
522 gr3d->client.base.num_syncpts = 1; in gr3d_probe()
524 INIT_LIST_HEAD(&gr3d->client.list); in gr3d_probe()
525 gr3d->client.version = gr3d->soc->version; in gr3d_probe()
526 gr3d->client.ops = &gr3d_ops; in gr3d_probe()
528 err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); in gr3d_probe()
532 err = host1x_client_register(&gr3d->client.base); in gr3d_probe()
534 dev_err(&pdev->dev, "failed to register host1x client: %d\n", in gr3d_probe()
541 set_bit(gr3d_addr_regs[i], gr3d->addr_regs); in gr3d_probe()
548 struct gr3d *gr3d = platform_get_drvdata(pdev); in gr3d_remove() local
550 pm_runtime_disable(&pdev->dev); in gr3d_remove()
551 host1x_client_unregister(&gr3d->client.base); in gr3d_remove()
556 struct gr3d *gr3d = dev_get_drvdata(dev); in gr3d_runtime_suspend() local
559 host1x_channel_stop(gr3d->channel); in gr3d_runtime_suspend()
561 err = reset_control_bulk_assert(gr3d->nresets, gr3d->resets); in gr3d_runtime_suspend()
570 * Older device-trees don't specify MC resets and power-gating can't in gr3d_runtime_suspend()
572 * for older DTBs. For newer DTBs, GENPD will perform the power-gating. in gr3d_runtime_suspend()
575 clk_bulk_disable_unprepare(gr3d->nclocks, gr3d->clocks); in gr3d_runtime_suspend()
576 reset_control_bulk_release(gr3d->nresets, gr3d->resets); in gr3d_runtime_suspend()
583 struct gr3d *gr3d = dev_get_drvdata(dev); in gr3d_runtime_resume() local
586 err = reset_control_bulk_acquire(gr3d->nresets, gr3d->resets); in gr3d_runtime_resume()
592 err = clk_bulk_prepare_enable(gr3d->nclocks, gr3d->clocks); in gr3d_runtime_resume()
598 err = reset_control_bulk_deassert(gr3d->nresets, gr3d->resets); in gr3d_runtime_resume()
611 clk_bulk_disable_unprepare(gr3d->nclocks, gr3d->clocks); in gr3d_runtime_resume()
613 reset_control_bulk_release(gr3d->nresets, gr3d->resets); in gr3d_runtime_resume()
626 .name = "tegra-gr3d",