MLK-18482: ISI: fix isi resume fail issue
authorGuoniu.Zhou <guoniu.zhou@nxp.com>
Tue, 12 Jun 2018 08:56:14 +0000 (16:56 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
Driver enable clock will fail in isi system power resume
callback because isi power domain is power off after system
power suspend so driver need to get device before disable
clock in system power suspend/resume callback and then put
device after disable clock.

Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
(cherry picked from commit 668fdea95ff9b4588f02a5c4285d56b90e05ccb4)

drivers/media/platform/imx8/mxc-isi-core.c

index 66ed18e..e78fbac 100644 (file)
@@ -198,9 +198,11 @@ static int mxc_isi_remove(struct platform_device *pdev)
        struct mxc_isi_dev *mxc_isi = platform_get_drvdata(pdev);
        struct device *dev = &pdev->dev;
 
+       pm_runtime_get_sync(&pdev->dev);
        mxc_isi_unregister_capture_subdev(mxc_isi);
 
        clk_disable_unprepare(mxc_isi->clk);
+       pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(dev);
 
        return 0;
@@ -211,6 +213,8 @@ static int mxc_isi_pm_suspend(struct device *dev)
 {
        struct mxc_isi_dev *mxc_isi = dev_get_drvdata(dev);
 
+       pm_runtime_get_sync(dev);
+
        if ((mxc_isi->flags & MXC_ISI_PM_SUSPENDED) ||
                (mxc_isi->flags & MXC_ISI_RUNTIME_SUSPEND))
                return 0;
@@ -218,6 +222,7 @@ static int mxc_isi_pm_suspend(struct device *dev)
        clk_disable_unprepare(mxc_isi->clk);
        mxc_isi->flags |= MXC_ISI_PM_SUSPENDED;
        mxc_isi->flags &= ~MXC_ISI_PM_POWERED;
+       pm_runtime_put_sync(dev);
 
        return 0;
 }
@@ -227,14 +232,21 @@ static int mxc_isi_pm_resume(struct device *dev)
        struct mxc_isi_dev *mxc_isi = dev_get_drvdata(dev);
        int ret;
 
+       pm_runtime_get_sync(dev);
        if (mxc_isi->flags & MXC_ISI_PM_POWERED)
                return 0;
 
+       ret = clk_prepare_enable(mxc_isi->clk);
+       if (ret) {
+               pr_info("== %s ret=%d\n", __func__, ret);
+               return -EAGAIN;
+       }
+
        mxc_isi->flags |= MXC_ISI_PM_POWERED;
        mxc_isi->flags &= ~MXC_ISI_PM_SUSPENDED;
+       pm_runtime_put_sync(dev);
 
-       ret = clk_prepare_enable(mxc_isi->clk);
-       return (ret) ? -EAGAIN : 0;
+       return 0;
 }
 #endif