Skip to content

Commit

Permalink
drm/nouveau/platform: make VDD regulator optional
Browse files Browse the repository at this point in the history
GP10B's power is managed by generic PM domains, so it does not require a
VDD regulator. Add this option into the chip function structure.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Alexandre Courbot authored and Ben Skeggs committed Apr 6, 2017
1 parent 51751f7 commit e6e1817
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
4 changes: 4 additions & 0 deletions drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ struct nvkm_device_tegra_func {
* Whether the chip requires a reference clock
*/
bool require_ref_clk;
/*
* Whether the chip requires the VDD regulator
*/
bool require_vdd;
};

int nvkm_device_tegra_new(const struct nvkm_device_tegra_func *,
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/nouveau/nouveau_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ static int nouveau_platform_remove(struct platform_device *pdev)
#if IS_ENABLED(CONFIG_OF)
static const struct nvkm_device_tegra_func gk20a_platform_data = {
.iommu_bit = 34,
.require_vdd = true,
};

static const struct nvkm_device_tegra_func gm20b_platform_data = {
.iommu_bit = 34,
.require_vdd = true,
.require_ref_clk = true,
};

Expand Down
31 changes: 22 additions & 9 deletions drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ nvkm_device_tegra_power_up(struct nvkm_device_tegra *tdev)
{
int ret;

ret = regulator_enable(tdev->vdd);
if (ret)
goto err_power;
if (tdev->vdd) {
ret = regulator_enable(tdev->vdd);
if (ret)
goto err_power;
}

ret = clk_prepare_enable(tdev->clk);
if (ret)
Expand Down Expand Up @@ -67,14 +69,17 @@ nvkm_device_tegra_power_up(struct nvkm_device_tegra *tdev)
err_clk_ref:
clk_disable_unprepare(tdev->clk);
err_clk:
regulator_disable(tdev->vdd);
if (tdev->vdd)
regulator_disable(tdev->vdd);
err_power:
return ret;
}

static int
nvkm_device_tegra_power_down(struct nvkm_device_tegra *tdev)
{
int ret;

reset_control_assert(tdev->rst);
udelay(10);

Expand All @@ -84,7 +89,13 @@ nvkm_device_tegra_power_down(struct nvkm_device_tegra *tdev)
clk_disable_unprepare(tdev->clk);
udelay(10);

return regulator_disable(tdev->vdd);
if (tdev->vdd) {
ret = regulator_disable(tdev->vdd);
if (ret)
return ret;
}

return 0;
}

static void
Expand Down Expand Up @@ -264,10 +275,12 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func,
tdev->func = func;
tdev->pdev = pdev;

tdev->vdd = devm_regulator_get(&pdev->dev, "vdd");
if (IS_ERR(tdev->vdd)) {
ret = PTR_ERR(tdev->vdd);
goto free;
if (func->require_vdd) {
tdev->vdd = devm_regulator_get(&pdev->dev, "vdd");
if (IS_ERR(tdev->vdd)) {
ret = PTR_ERR(tdev->vdd);
goto free;
}
}

tdev->rst = devm_reset_control_get(&pdev->dev, "gpu");
Expand Down

0 comments on commit e6e1817

Please sign in to comment.