Commit 5e570373 authored by Jeffy Chen's avatar Jeffy Chen Committed by Sean Paul

drm/rockchip: vop: Enable pm domain before vop_initial

We're trying to access vop registers here, so need to make sure
the pm domain is on.

Normally it should be enabled by the bootloader, but there's no
guarantee of it. And if we wanna do unbind/bind, it would also
cause the device to hang.

And this patch also does these:
1/ move vop_initial to the end of vop_bind for eaiser error handling.
2/ correct the err_put_pm_runtime of vop_enable.
Signed-off-by: default avatarJeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1491481885-13775-8-git-send-email-jeffy.chen@rock-chips.com
parent 88582f56
...@@ -506,7 +506,7 @@ static int vop_enable(struct drm_crtc *crtc) ...@@ -506,7 +506,7 @@ static int vop_enable(struct drm_crtc *crtc)
ret = pm_runtime_get_sync(vop->dev); ret = pm_runtime_get_sync(vop->dev);
if (ret < 0) { if (ret < 0) {
dev_err(vop->dev, "failed to get pm runtime: %d\n", ret); dev_err(vop->dev, "failed to get pm runtime: %d\n", ret);
goto err_put_pm_runtime; return ret;
} }
ret = clk_enable(vop->hclk); ret = clk_enable(vop->hclk);
...@@ -1405,10 +1405,16 @@ static int vop_initial(struct vop *vop) ...@@ -1405,10 +1405,16 @@ static int vop_initial(struct vop *vop)
return PTR_ERR(vop->dclk); return PTR_ERR(vop->dclk);
} }
ret = pm_runtime_get_sync(vop->dev);
if (ret < 0) {
dev_err(vop->dev, "failed to get pm runtime: %d\n", ret);
return ret;
}
ret = clk_prepare(vop->dclk); ret = clk_prepare(vop->dclk);
if (ret < 0) { if (ret < 0) {
dev_err(vop->dev, "failed to prepare dclk\n"); dev_err(vop->dev, "failed to prepare dclk\n");
return ret; goto err_put_pm_runtime;
} }
/* Enable both the hclk and aclk to setup the vop */ /* Enable both the hclk and aclk to setup the vop */
...@@ -1468,6 +1474,8 @@ static int vop_initial(struct vop *vop) ...@@ -1468,6 +1474,8 @@ static int vop_initial(struct vop *vop)
vop->is_enabled = false; vop->is_enabled = false;
pm_runtime_put_sync(vop->dev);
return 0; return 0;
err_disable_aclk: err_disable_aclk:
...@@ -1476,6 +1484,8 @@ static int vop_initial(struct vop *vop) ...@@ -1476,6 +1484,8 @@ static int vop_initial(struct vop *vop)
clk_disable_unprepare(vop->hclk); clk_disable_unprepare(vop->hclk);
err_unprepare_dclk: err_unprepare_dclk:
clk_unprepare(vop->dclk); clk_unprepare(vop->dclk);
err_put_pm_runtime:
pm_runtime_put_sync(vop->dev);
return ret; return ret;
} }
...@@ -1576,12 +1586,6 @@ static int vop_bind(struct device *dev, struct device *master, void *data) ...@@ -1576,12 +1586,6 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
if (!vop->regsbak) if (!vop->regsbak)
return -ENOMEM; return -ENOMEM;
ret = vop_initial(vop);
if (ret < 0) {
dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret);
return ret;
}
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(dev, "cannot find irq for vop\n"); dev_err(dev, "cannot find irq for vop\n");
...@@ -1608,8 +1612,17 @@ static int vop_bind(struct device *dev, struct device *master, void *data) ...@@ -1608,8 +1612,17 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
ret = vop_initial(vop);
if (ret < 0) {
dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret);
goto err_disable_pm_runtime;
}
return 0; return 0;
err_disable_pm_runtime:
pm_runtime_disable(&pdev->dev);
vop_destroy_crtc(vop);
err_enable_irq: err_enable_irq:
enable_irq(vop->irq); /* To balance out the disable_irq above */ enable_irq(vop->irq); /* To balance out the disable_irq above */
return ret; return ret;
......
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