MLK-17047-2: drm/imx: Fix suspend/resume for nwl_dsi-imx
authorRobert Chiras <robert.chiras@nxp.com>
Fri, 8 Dec 2017 14:21:33 +0000 (16:21 +0200)
committerNitin Garg <nitin.garg@nxp.com>
Tue, 20 Mar 2018 19:51:04 +0000 (14:51 -0500)
This patch addresses two issues:
1. Always request/release bus_freq, not just on suspend/resume routines
2. Check if the driver is running when doing a suspend, so that we won't
enable it by mistake on resume.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
drivers/gpu/drm/imx/nwl_dsi-imx.c

index 87a6338..1ab22b3 100644 (file)
@@ -93,6 +93,7 @@ struct imx_mipi_dsi {
        u32                             sync_pol;
        u32                             power_on_delay;
        bool                            enabled;
+       bool                            suspended;
 };
 
 struct clk_config {
@@ -508,6 +509,8 @@ static void imx_nwl_dsi_enable(struct imx_mipi_dsi *dsi)
                usleep_range(min_sleep, max_sleep);
        }
 
+       request_bus_freq(BUS_FREQ_HIGH);
+
        imx_nwl_dsi_set_clocks(dsi, true);
 
        ret = devtype->poweron(dsi);
@@ -535,6 +538,8 @@ static void imx_nwl_dsi_disable(struct imx_mipi_dsi *dsi)
 
        imx_nwl_dsi_set_clocks(dsi, false);
 
+       release_bus_freq(BUS_FREQ_HIGH);
+
        dsi->enabled = false;
 }
 
@@ -959,12 +964,14 @@ static int imx_nwl_dsi_remove(struct platform_device *pdev)
 static int imx_nwl_suspend(struct device *dev)
 {
        struct imx_mipi_dsi *dsi = dev_get_drvdata(dev);
-       bool enabled = dsi->enabled;
 
-       if (enabled && dsi->next_bridge)
+       if (!dsi->enabled)
+               return 0;
+
+       if (dsi->next_bridge)
                drm_bridge_disable(dsi->next_bridge);
        imx_nwl_dsi_disable(dsi);
-       release_bus_freq(BUS_FREQ_HIGH);
+       dsi->suspended = true;
 
        return 0;
 }
@@ -972,12 +979,14 @@ static int imx_nwl_suspend(struct device *dev)
 static int imx_nwl_resume(struct device *dev)
 {
        struct imx_mipi_dsi *dsi = dev_get_drvdata(dev);
-       bool enabled = dsi->enabled;
 
-       request_bus_freq(BUS_FREQ_HIGH);
+       if (!dsi->suspended)
+               return 0;
+
        imx_nwl_dsi_enable(dsi);
-       if (!enabled && dsi->next_bridge)
+       if (dsi->next_bridge)
                drm_bridge_enable(dsi->next_bridge);
+       dsi->suspended = false;
 
        return 0;
 }