Skip to content

Commit

Permalink
gpu: host1x: Support module reset
Browse files Browse the repository at this point in the history
Newer versions of Tegra come with early boot software that aggressively
puts various modules in reset. Add support to the host1x driver to take
the module out of reset on probe, and assert reset on removal.

Signed-off-by: Thierry Reding <treding@nvidia.com>
  • Loading branch information
Thierry Reding committed Apr 5, 2017
1 parent 7e7d432 commit b386c6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion drivers/gpu/host1x/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ static int host1x_probe(struct platform_device *pdev)
return err;
}

host->rst = devm_reset_control_get(&pdev->dev, "host1x");
if (IS_ERR(host->rst)) {
err = PTR_ERR(host->clk);
dev_err(&pdev->dev, "failed to get reset: %d\n", err);
return err;
}

if (iommu_present(&platform_bus_type)) {
struct iommu_domain_geometry *geometry;
unsigned long order;
Expand Down Expand Up @@ -203,10 +210,16 @@ static int host1x_probe(struct platform_device *pdev)
goto fail_detach_device;
}

err = reset_control_deassert(host->rst);
if (err < 0) {
dev_err(&pdev->dev, "failed to deassert reset: %d\n", err);
goto fail_unprepare_disable;
}

err = host1x_syncpt_init(host);
if (err) {
dev_err(&pdev->dev, "failed to initialize syncpts\n");
goto fail_unprepare_disable;
goto fail_reset_assert;
}

err = host1x_intr_init(host, syncpt_irq);
Expand All @@ -227,6 +240,8 @@ static int host1x_probe(struct platform_device *pdev)
host1x_intr_deinit(host);
fail_deinit_syncpt:
host1x_syncpt_deinit(host);
fail_reset_assert:
reset_control_assert(host->rst);
fail_unprepare_disable:
clk_disable_unprepare(host->clk);
fail_detach_device:
Expand All @@ -248,6 +263,7 @@ static int host1x_remove(struct platform_device *pdev)
host1x_unregister(host);
host1x_intr_deinit(host);
host1x_syncpt_deinit(host);
reset_control_assert(host->rst);
clk_disable_unprepare(host->clk);

if (host->domain) {
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/host1x/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/iommu.h>
#include <linux/iova.h>
#include <linux/platform_device.h>
#include <linux/reset.h>

#include "cdma.h"
#include "channel.h"
Expand Down Expand Up @@ -109,6 +110,7 @@ struct host1x {
struct host1x_syncpt_base *bases;
struct device *dev;
struct clk *clk;
struct reset_control *rst;

struct iommu_domain *domain;
struct iova_domain iova;
Expand Down

0 comments on commit b386c6b

Please sign in to comment.