]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
drm/msm/dsi: Implement RPM suspend/resume callbacks
authorArchit Taneja <architt@codeaurora.org>
Fri, 28 Jul 2017 10:47:04 +0000 (16:17 +0530)
committerRob Clark <robdclark@gmail.com>
Wed, 2 Aug 2017 11:53:46 +0000 (07:53 -0400)
The bus clocks are always enabled/disabled along with the power
domain, so move it to the runtime suspend/resume ops. This cleans
up the clock code a bit. Get rid of the clk_mutex mutex since it
isn't needed.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/dsi/dsi.c
drivers/gpu/drm/msm/dsi/dsi.h
drivers/gpu/drm/msm/dsi/dsi_host.c

index 311c1c1e7d6c05e735a78c86cdae376db73ff267..98742d7af6dcb21506434c31977941c5cfdea877 100644 (file)
@@ -161,12 +161,17 @@ static const struct of_device_id dt_match[] = {
        {}
 };
 
+static const struct dev_pm_ops dsi_pm_ops = {
+       SET_RUNTIME_PM_OPS(msm_dsi_runtime_suspend, msm_dsi_runtime_resume, NULL)
+};
+
 static struct platform_driver dsi_driver = {
        .probe = dsi_dev_probe,
        .remove = dsi_dev_remove,
        .driver = {
                .name = "msm_dsi",
                .of_match_table = dt_match,
+               .pm = &dsi_pm_ops,
        },
 };
 
index 9e6017387efb99bc7afb7ff1203fa8db3aff9655..2302046197a8afdebdca9eea6b751f25c68d7bcd 100644 (file)
@@ -179,6 +179,8 @@ void msm_dsi_host_destroy(struct mipi_dsi_host *host);
 int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
                                        struct drm_device *dev);
 int msm_dsi_host_init(struct msm_dsi *msm_dsi);
+int msm_dsi_runtime_suspend(struct device *dev);
+int msm_dsi_runtime_resume(struct device *dev);
 
 /* dsi phy */
 struct msm_dsi_phy;
index da0913a33ca07a290d3e7c6de507a81ecbf31320..dbb31a0144194662a85f20ae0b77117ce071b901 100644 (file)
@@ -135,7 +135,6 @@ struct msm_dsi_host {
        struct completion video_comp;
        struct mutex dev_mutex;
        struct mutex cmd_mutex;
-       struct mutex clk_mutex;
        spinlock_t intr_lock; /* Protect interrupt ctrl register */
 
        u32 err_work_state;
@@ -458,6 +457,34 @@ static void dsi_bus_clk_disable(struct msm_dsi_host *msm_host)
                clk_disable_unprepare(msm_host->bus_clks[i]);
 }
 
+int msm_dsi_runtime_suspend(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct msm_dsi *msm_dsi = platform_get_drvdata(pdev);
+       struct mipi_dsi_host *host = msm_dsi->host;
+       struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
+
+       if (!msm_host->cfg_hnd)
+               return 0;
+
+       dsi_bus_clk_disable(msm_host);
+
+       return 0;
+}
+
+int msm_dsi_runtime_resume(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct msm_dsi *msm_dsi = platform_get_drvdata(pdev);
+       struct mipi_dsi_host *host = msm_dsi->host;
+       struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
+
+       if (!msm_host->cfg_hnd)
+               return 0;
+
+       return dsi_bus_clk_enable(msm_host);
+}
+
 static int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host)
 {
        int ret;
@@ -599,35 +626,6 @@ static void dsi_link_clk_disable(struct msm_dsi_host *msm_host)
        }
 }
 
-static int dsi_clk_ctrl(struct msm_dsi_host *msm_host, bool enable)
-{
-       int ret = 0;
-
-       mutex_lock(&msm_host->clk_mutex);
-       if (enable) {
-               ret = dsi_bus_clk_enable(msm_host);
-               if (ret) {
-                       pr_err("%s: Can not enable bus clk, %d\n",
-                               __func__, ret);
-                       goto unlock_ret;
-               }
-               ret = dsi_link_clk_enable(msm_host);
-               if (ret) {
-                       pr_err("%s: Can not enable link clk, %d\n",
-                               __func__, ret);
-                       dsi_bus_clk_disable(msm_host);
-                       goto unlock_ret;
-               }
-       } else {
-               dsi_link_clk_disable(msm_host);
-               dsi_bus_clk_disable(msm_host);
-       }
-
-unlock_ret:
-       mutex_unlock(&msm_host->clk_mutex);
-       return ret;
-}
-
 static int dsi_calc_clk_rate(struct msm_dsi_host *msm_host)
 {
        struct drm_display_mode *mode = msm_host->mode;
@@ -1702,6 +1700,7 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
        }
 
        msm_host->pdev = pdev;
+       msm_dsi->host = &msm_host->base;
 
        ret = dsi_host_parse_dt(msm_host);
        if (ret) {
@@ -1758,7 +1757,6 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
        init_completion(&msm_host->video_comp);
        mutex_init(&msm_host->dev_mutex);
        mutex_init(&msm_host->cmd_mutex);
-       mutex_init(&msm_host->clk_mutex);
        spin_lock_init(&msm_host->intr_lock);
 
        /* setup workqueue */
@@ -1766,7 +1764,6 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
        INIT_WORK(&msm_host->err_work, dsi_err_worker);
        INIT_WORK(&msm_host->hpd_work, dsi_hpd_worker);
 
-       msm_dsi->host = &msm_host->base;
        msm_dsi->id = msm_host->id;
 
        DBG("Dsi Host %d initialized", msm_host->id);
@@ -1788,7 +1785,6 @@ void msm_dsi_host_destroy(struct mipi_dsi_host *host)
                msm_host->workqueue = NULL;
        }
 
-       mutex_destroy(&msm_host->clk_mutex);
        mutex_destroy(&msm_host->cmd_mutex);
        mutex_destroy(&msm_host->dev_mutex);
 
@@ -1889,7 +1885,7 @@ int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
         * mdp clock need to be enabled to receive dsi interrupt
         */
        pm_runtime_get_sync(&msm_host->pdev->dev);
-       dsi_clk_ctrl(msm_host, 1);
+       dsi_link_clk_enable(msm_host);
 
        /* TODO: vote for bus bandwidth */
 
@@ -1919,7 +1915,7 @@ void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
 
        /* TODO: unvote for bus bandwidth */
 
-       dsi_clk_ctrl(msm_host, 0);
+       dsi_link_clk_disable(msm_host);
        pm_runtime_put_autosuspend(&msm_host->pdev->dev);
 }
 
@@ -2169,8 +2165,11 @@ int msm_dsi_host_enable(struct mipi_dsi_host *host)
         * and only turned on before MDP START.
         * This part of code should be enabled once mdp driver support it.
         */
-       /* if (msm_panel->mode == MSM_DSI_CMD_MODE)
-               dsi_clk_ctrl(msm_host, 0); */
+       /* if (msm_panel->mode == MSM_DSI_CMD_MODE) {
+        *      dsi_link_clk_disable(msm_host);
+        *      pm_runtime_put_autosuspend(&msm_host->pdev->dev);
+        * }
+        */
 
        return 0;
 }
@@ -2227,9 +2226,10 @@ int msm_dsi_host_power_on(struct mipi_dsi_host *host,
        }
 
        pm_runtime_get_sync(&msm_host->pdev->dev);
-       ret = dsi_clk_ctrl(msm_host, 1);
+       ret = dsi_link_clk_enable(msm_host);
        if (ret) {
-               pr_err("%s: failed to enable clocks. ret=%d\n", __func__, ret);
+               pr_err("%s: failed to enable link clocks. ret=%d\n",
+                      __func__, ret);
                goto fail_disable_reg;
        }
 
@@ -2253,7 +2253,8 @@ int msm_dsi_host_power_on(struct mipi_dsi_host *host,
        return 0;
 
 fail_disable_clk:
-       dsi_clk_ctrl(msm_host, 0);
+       dsi_link_clk_disable(msm_host);
+       pm_runtime_put_autosuspend(&msm_host->pdev->dev);
 fail_disable_reg:
        dsi_host_regulator_disable(msm_host);
 unlock_ret:
@@ -2278,7 +2279,7 @@ int msm_dsi_host_power_off(struct mipi_dsi_host *host)
 
        pinctrl_pm_select_sleep_state(&msm_host->pdev->dev);
 
-       dsi_clk_ctrl(msm_host, 0);
+       dsi_link_clk_disable(msm_host);
        pm_runtime_put_autosuspend(&msm_host->pdev->dev);
 
        dsi_host_regulator_disable(msm_host);