linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Ying.Liu@freescale.com (Liu Ying)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] staging: drm/imx: ldb: correct the ldb di clock trees
Date: Tue, 20 Aug 2013 16:38:52 +0800	[thread overview]
Message-ID: <1376987932-5540-4-git-send-email-Ying.Liu@freescale.com> (raw)
In-Reply-To: <1376987932-5540-1-git-send-email-Ying.Liu@freescale.com>

In ldb split mode, the ldb_di[0/1]_ipu_div dividers should
be configured as clock dividers of 1/3.5, while in others
ldb modes of 1/7. This patch gets the di[0/1]_div_3_5,
di[0/1]_div_7 and di[0/1]_div_sel clocks and sets the
di[0/1]_div_3_5 or di[0/1]_div_7 clocks to be the parents of
di[0/1]_div_sel clocks according to the ldb mode. The real
dividers are the two fixed factors bewteen the ldb_di[0/1] and
the pll clocks, so it's unnecessary to set the frequency for
the ldb_di[0/1] clocks again after pll clock frequency is set.
This patch removes the redundant clock frequency setting code
as well.

Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
---
 drivers/staging/imx-drm/imx-ldb.c |   38 +++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c
index 8af7f3b..7c553b8 100644
--- a/drivers/staging/imx-drm/imx-ldb.c
+++ b/drivers/staging/imx-drm/imx-ldb.c
@@ -81,6 +81,9 @@ struct imx_ldb {
 	struct clk *clk[2]; /* our own clock */
 	struct clk *clk_sel[4]; /* parent of display clock */
 	struct clk *clk_pll[2]; /* upstream clock we can adjust */
+	struct clk *clk_div_3_5[2]; /* fixed factor of 1/3.5 */
+	struct clk *clk_div_7[2]; /* fixed factor of 1/7 */
+	struct clk *clk_div_sel[2]; /* 1/3.5 or 1/7 */
 	u32 ldb_ctrl;
 	const struct bus_mux *lvds_mux;
 };
@@ -150,6 +153,18 @@ static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
 {
 	int ret;
 
+	if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) {
+		ret = clk_set_parent(ldb->clk_div_sel[chno], ldb->clk_div_3_5[chno]);
+		if (ret)
+			dev_err(ldb->dev, "unable to set di%d_div_sel parent clock "
+				"to di%d_div_3_5\n", chno, chno);
+	} else {
+		ret = clk_set_parent(ldb->clk_div_sel[chno], ldb->clk_div_7[chno]);
+		if (ret)
+			dev_err(ldb->dev, "unable to set di%d_div_sel parent clock "
+				"to di%d_div_7\n", chno, chno);
+	}
+
 	dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
 			clk_get_rate(ldb->clk_pll[chno]), serial_clk);
 	clk_set_rate(ldb->clk_pll[chno], serial_clk);
@@ -157,14 +172,6 @@ static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
 	dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
 			clk_get_rate(ldb->clk_pll[chno]));
 
-	dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
-			clk_get_rate(ldb->clk[chno]),
-			(long int)di_clk);
-	clk_set_rate(ldb->clk[chno], di_clk);
-
-	dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
-			clk_get_rate(ldb->clk[chno]));
-
 	/* set display clock mux to LDB input clock */
 	ret = clk_set_parent(ldb->clk_sel[mux], ldb->clk[chno]);
 	if (ret) {
@@ -362,6 +369,21 @@ static int imx_ldb_get_clk(struct imx_ldb *ldb, int chno)
 	if (IS_ERR(ldb->clk_pll[chno]))
 		return PTR_ERR(ldb->clk_pll[chno]);
 
+	sprintf(clkname, "di%d_div_3_5", chno);
+	ldb->clk_div_3_5[chno] = devm_clk_get(ldb->dev, clkname);
+	if (IS_ERR(ldb->clk_div_3_5[chno]))
+		return PTR_ERR(ldb->clk_div_3_5[chno]);
+
+	sprintf(clkname, "di%d_div_7", chno);
+	ldb->clk_div_7[chno] = devm_clk_get(ldb->dev, clkname);
+	if (IS_ERR(ldb->clk_div_7[chno]))
+		return PTR_ERR(ldb->clk_div_7[chno]);
+
+	sprintf(clkname, "di%d_div_sel", chno);
+	ldb->clk_div_sel[chno] = devm_clk_get(ldb->dev, clkname);
+	if (IS_ERR(ldb->clk_div_sel[chno]))
+		return PTR_ERR(ldb->clk_div_sel[chno]);
+
 	return 0;
 }
 
-- 
1.7.9.5

  parent reply	other threads:[~2013-08-20  8:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20  8:38 [PATCH 0/3] refactor some ldb related clocks Liu Ying
2013-08-20  8:38 ` [PATCH 1/3] ARM: imx6q: " Liu Ying
2013-08-20 15:40   ` Fabio Estevam
2013-08-20 21:18     ` Mike Turquette
2013-08-21  1:40       ` Shawn Guo
2013-08-21  4:20     ` Liu Ying
2013-08-20  8:38 ` [PATCH 2/3] ARM: dts: imx6q/imx6dl: add necessary clocks for ldb node Liu Ying
2013-08-20  8:38 ` Liu Ying [this message]
2013-08-20  9:43 ` [PATCH 0/3] refactor some ldb related clocks Philipp Zabel
2013-08-20 10:08   ` Liu Ying
2013-08-21  1:59     ` Shawn Guo
2013-08-21  4:12       ` Liu Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376987932-5540-4-git-send-email-Ying.Liu@freescale.com \
    --to=ying.liu@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).