drm/tegra: Wrap register init code in function

Put the actmon-related register initialization code in the function for
readability.

Bug 4183393

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Id68d128ae330105da0d3f76270fe38d57c12c740
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2931793
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Johnny Liu
2023-07-06 03:55:01 +00:00
committed by mobile promotions
parent 3264c9dfca
commit ff572997a3
4 changed files with 69 additions and 49 deletions

View File

@@ -521,22 +521,9 @@ cleanup:
return err;
}
static __maybe_unused int nvdec_runtime_resume(struct device *dev)
static void nvdec_actmon_reg_init(struct nvdec *nvdec)
{
struct nvdec *nvdec = dev_get_drvdata(dev);
int err;
err = clk_bulk_prepare_enable(nvdec->num_clks, nvdec->clks);
if (err < 0)
return err;
usleep_range(10, 20);
if (nvdec->config->has_riscv) {
err = nvdec_boot_riscv(nvdec);
if (err < 0)
goto disable;
nvdec_writel(nvdec,
NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_MASK,
NVDEC_FALCON_UCLASS_METHOD_OFFSET);
@@ -553,14 +540,6 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev)
NVDEC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
NVDEC_FALCON_UCLASS_METHOD_DATA);
} else {
err = nvdec_load_falcon_firmware(nvdec);
if (err < 0)
goto disable;
err = nvdec_boot_falcon(nvdec);
if (err < 0)
goto disable;
nvdec_writel(nvdec,
NVDEC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED |
NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
@@ -571,6 +550,34 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev)
NVDEC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
NVDEC_TFBIF_ACTMON_ACTIVE_BORPS);
}
}
static __maybe_unused int nvdec_runtime_resume(struct device *dev)
{
struct nvdec *nvdec = dev_get_drvdata(dev);
int err;
err = clk_bulk_prepare_enable(nvdec->num_clks, nvdec->clks);
if (err < 0)
return err;
usleep_range(10, 20);
if (nvdec->config->has_riscv) {
err = nvdec_boot_riscv(nvdec);
if (err < 0)
goto disable;
} else {
err = nvdec_load_falcon_firmware(nvdec);
if (err < 0)
goto disable;
err = nvdec_boot_falcon(nvdec);
if (err < 0)
goto disable;
}
nvdec_actmon_reg_init(nvdec);
host1x_actmon_enable(&nvdec->client.base);

View File

@@ -435,6 +435,18 @@ cleanup:
return err;
}
static void nvenc_actmon_reg_init(struct nvenc *nvenc)
{
nvenc_writel(nvenc,
NVENC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED |
NVENC_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
NVENC_TFBIF_ACTMON_ACTIVE_MASK_STARVED,
NVENC_TFBIF_ACTMON_ACTIVE_MASK);
nvenc_writel(nvenc,
NVENC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
NVENC_TFBIF_ACTMON_ACTIVE_BORPS);
}
static __maybe_unused int nvenc_runtime_resume(struct device *dev)
{
@@ -455,15 +467,7 @@ static __maybe_unused int nvenc_runtime_resume(struct device *dev)
if (err < 0)
goto disable;
nvenc_writel(nvenc,
NVENC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED |
NVENC_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
NVENC_TFBIF_ACTMON_ACTIVE_MASK_STARVED,
NVENC_TFBIF_ACTMON_ACTIVE_MASK);
nvenc_writel(nvenc,
NVENC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
NVENC_TFBIF_ACTMON_ACTIVE_BORPS);
nvenc_actmon_reg_init(nvenc);
host1x_actmon_enable(&nvenc->client.base);

View File

@@ -434,6 +434,18 @@ cleanup:
return err;
}
static void nvjpg_actmon_reg_init(struct nvjpg *nvjpg)
{
nvjpg_writel(nvjpg,
NVJPG_TFBIF_ACTMON_ACTIVE_MASK_STARVED |
NVJPG_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
NVJPG_TFBIF_ACTMON_ACTIVE_MASK_DELAYED,
NVJPG_TFBIF_ACTMON_ACTIVE_MASK);
nvjpg_writel(nvjpg,
NVJPG_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
NVJPG_TFBIF_ACTMON_ACTIVE_BORPS);
}
static __maybe_unused int nvjpg_runtime_resume(struct device *dev)
{
@@ -454,15 +466,7 @@ static __maybe_unused int nvjpg_runtime_resume(struct device *dev)
if (err < 0)
goto disable;
nvjpg_writel(nvjpg,
NVJPG_TFBIF_ACTMON_ACTIVE_MASK_STARVED |
NVJPG_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
NVJPG_TFBIF_ACTMON_ACTIVE_MASK_DELAYED,
NVJPG_TFBIF_ACTMON_ACTIVE_MASK);
nvjpg_writel(nvjpg,
NVJPG_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
NVJPG_TFBIF_ACTMON_ACTIVE_BORPS);
nvjpg_actmon_reg_init(nvjpg);
host1x_actmon_enable(&nvjpg->client.base);

View File

@@ -486,6 +486,19 @@ cleanup:
}
static void vic_actmon_reg_init(struct vic *vic)
{
vic_writel(vic,
VIC_TFBIF_ACTMON_ACTIVE_MASK_STARVED |
VIC_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
VIC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED,
NV_PVIC_TFBIF_ACTMON_ACTIVE_MASK);
vic_writel(vic,
VIC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
NV_PVIC_TFBIF_ACTMON_ACTIVE_BORPS);
}
static int __maybe_unused vic_runtime_resume(struct device *dev)
{
struct vic *vic = dev_get_drvdata(dev);
@@ -511,15 +524,7 @@ static int __maybe_unused vic_runtime_resume(struct device *dev)
if (err < 0)
goto assert;
vic_writel(vic,
VIC_TFBIF_ACTMON_ACTIVE_MASK_STARVED |
VIC_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
VIC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED,
NV_PVIC_TFBIF_ACTMON_ACTIVE_MASK);
vic_writel(vic,
VIC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
NV_PVIC_TFBIF_ACTMON_ACTIVE_BORPS);
vic_actmon_reg_init(vic);
host1x_actmon_enable(&vic->client.base);