Commit 95ffcb4c authored by Mikko Perttunen's avatar Mikko Perttunen Committed by Thierry Reding

drm/tegra: nvdec: Support multiple clocks

NVDEC on Tegra234 requires multiple clocks. Add support for that.
Signed-off-by: default avatarMikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent 97b93b7a
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (c) 2015-2021, NVIDIA Corporation. * Copyright (c) 2015-2022, NVIDIA Corporation.
*/ */
#include <linux/clk.h> #include <linux/clk.h>
...@@ -28,6 +28,7 @@ struct nvdec_config { ...@@ -28,6 +28,7 @@ struct nvdec_config {
const char *firmware; const char *firmware;
unsigned int version; unsigned int version;
bool supports_sid; bool supports_sid;
bool has_extra_clocks;
}; };
struct nvdec { struct nvdec {
...@@ -37,7 +38,8 @@ struct nvdec { ...@@ -37,7 +38,8 @@ struct nvdec {
struct tegra_drm_client client; struct tegra_drm_client client;
struct host1x_channel *channel; struct host1x_channel *channel;
struct device *dev; struct device *dev;
struct clk *clk; struct clk_bulk_data clks[3];
unsigned int num_clks;
/* Platform configuration */ /* Platform configuration */
const struct nvdec_config *config; const struct nvdec_config *config;
...@@ -258,7 +260,7 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev) ...@@ -258,7 +260,7 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev)
struct nvdec *nvdec = dev_get_drvdata(dev); struct nvdec *nvdec = dev_get_drvdata(dev);
int err; int err;
err = clk_prepare_enable(nvdec->clk); err = clk_bulk_prepare_enable(nvdec->num_clks, nvdec->clks);
if (err < 0) if (err < 0)
return err; return err;
...@@ -275,7 +277,7 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev) ...@@ -275,7 +277,7 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev)
return 0; return 0;
disable: disable:
clk_disable_unprepare(nvdec->clk); clk_bulk_disable_unprepare(nvdec->num_clks, nvdec->clks);
return err; return err;
} }
...@@ -285,7 +287,7 @@ static __maybe_unused int nvdec_runtime_suspend(struct device *dev) ...@@ -285,7 +287,7 @@ static __maybe_unused int nvdec_runtime_suspend(struct device *dev)
host1x_channel_stop(nvdec->channel); host1x_channel_stop(nvdec->channel);
clk_disable_unprepare(nvdec->clk); clk_bulk_disable_unprepare(nvdec->num_clks, nvdec->clks);
return 0; return 0;
} }
...@@ -383,13 +385,22 @@ static int nvdec_probe(struct platform_device *pdev) ...@@ -383,13 +385,22 @@ static int nvdec_probe(struct platform_device *pdev)
if (IS_ERR(nvdec->regs)) if (IS_ERR(nvdec->regs))
return PTR_ERR(nvdec->regs); return PTR_ERR(nvdec->regs);
nvdec->clk = devm_clk_get(dev, NULL); nvdec->clks[0].id = "nvdec";
if (IS_ERR(nvdec->clk)) { nvdec->num_clks = 1;
dev_err(&pdev->dev, "failed to get clock\n");
return PTR_ERR(nvdec->clk); if (nvdec->config->has_extra_clocks) {
nvdec->num_clks = 3;
nvdec->clks[1].id = "fuse";
nvdec->clks[2].id = "tsec_pka";
}
err = devm_clk_bulk_get(dev, nvdec->num_clks, nvdec->clks);
if (err) {
dev_err(&pdev->dev, "failed to get clock(s)\n");
return err;
} }
err = clk_set_rate(nvdec->clk, ULONG_MAX); err = clk_set_rate(nvdec->clks[0].clk, ULONG_MAX);
if (err < 0) { if (err < 0) {
dev_err(&pdev->dev, "failed to set clock rate\n"); dev_err(&pdev->dev, "failed to set clock rate\n");
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment