From 17b68807bd789e4efccda7f06d2268e845527f9e Mon Sep 17 00:00:00 2001
From: Liu Ying <victor.liu@nxp.com>
Date: Fri, 13 Oct 2017 12:30:46 +0800
Subject: [PATCH] MLK-16581-3 drm/imx: ldb: Get bypass & pixel clock rates
 before setting their rates

Due to i.MX8 clock issue, we need to get bypass and pixel clock rates
before setting their rates when system resumes back from PM sleep mode,
otherwise, we'll fail to set the clock rates.  So, this is a workaround
and it can be removed when the clock issue is properly fixed.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
---
 drivers/gpu/drm/imx/imx-ldb.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index 3f7b4741a1e20d..389d87f6f130ae 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -251,6 +251,15 @@ static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
 	int ret;
 
 	if (ldb->is_imx8) {
+		/*
+		 * To workaround setting clock rate failure issue
+		 * when the system resumes back from PM sleep mode,
+		 * we need to get the clock rates before setting
+		 * their rates, otherwise, setting the clock rates
+		 * will fail.
+		 */
+		clk_get_rate(ldb->clk_bypass);
+		clk_get_rate(ldb->clk_pixel);
 		clk_set_rate(ldb->clk_bypass, di_clk);
 		clk_set_rate(ldb->clk_pixel, di_clk);
 		return;
-- 
GitLab