All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: linux-clk@vger.kernel.org
Cc: Marek Vasut <marek.vasut+renesas@gmail.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Alexey Firago <alexey_firago@mentor.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-renesas-soc@vger.kernel.org
Subject: [PATCH V3 4/8] clk: vc5: Configure the output buffer input mux on prepare
Date: Sun,  9 Jul 2017 15:28:10 +0200	[thread overview]
Message-ID: <20170709132814.2339-4-marek.vasut+renesas@gmail.com> (raw)
In-Reply-To: <20170709132814.2339-1-marek.vasut+renesas@gmail.com>

The output buffer input mux can be configured in either of three
states -- disabled, input from FOD, input from previous output.
Once the .prepare() callback of the output buffer is called, the
output buffer input mux must be set to either input from FOD or
input from previous output, it cannot be set to Disabled anymore
or the output won't work.

Default to the input from FOD if the output buffer input mux was
Disabled and the .prepare() was called on it.

Note that we do not set the output buffer input mux back to Disabled
in the .unprepare() callback as there is no obvious benefit of doing
so. We disable the entire output buffer in the .unprepare() callback
already.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
on Salvator-XS with the display LVDS output.
---
V2: None
V3: None
---
 drivers/clk/clk-versaclock5.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index 248689d89632..7bdfd34e8280 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -507,6 +507,25 @@ static int vc5_clk_out_prepare(struct clk_hw *hw)
 {
 	struct vc5_hw_data *hwdata = container_of(hw, struct vc5_hw_data, hw);
 	struct vc5_driver_data *vc5 = hwdata->vc5;
+	const u8 mask = VC5_OUT_DIV_CONTROL_SELB_NORM |
+			VC5_OUT_DIV_CONTROL_SEL_EXT |
+			VC5_OUT_DIV_CONTROL_EN_FOD;
+	unsigned int src;
+	int ret;
+
+	/*
+	 * If the input mux is disabled, enable it first and
+	 * select source from matching FOD.
+	 */
+	regmap_read(vc5->regmap, VC5_OUT_DIV_CONTROL(hwdata->num), &src);
+	if ((src & mask) == 0) {
+		src = VC5_OUT_DIV_CONTROL_RESET | VC5_OUT_DIV_CONTROL_EN_FOD;
+		ret = regmap_update_bits(vc5->regmap,
+					 VC5_OUT_DIV_CONTROL(hwdata->num),
+					 mask | VC5_OUT_DIV_CONTROL_RESET, src);
+		if (ret)
+			return ret;
+	}
 
 	/* Enable the clock buffer */
 	regmap_update_bits(vc5->regmap, VC5_CLK_OUTPUT_CFG(hwdata->num, 1),
-- 
2.11.0

  parent reply	other threads:[~2017-07-09 13:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-09 13:28 [PATCH V3 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
2017-07-09 13:28 ` [PATCH V3 2/8] clk: vc5: Fix trivial typo Marek Vasut
2017-07-12 23:10   ` Stephen Boyd
2017-07-09 13:28 ` [PATCH V3 3/8] clk: vc5: Do not warn about disabled output buffer input muxes Marek Vasut
2017-07-12 23:10   ` Stephen Boyd
2017-07-09 13:28 ` Marek Vasut [this message]
2017-07-12 23:10   ` [PATCH V3 4/8] clk: vc5: Configure the output buffer input mux on prepare Stephen Boyd
2017-07-09 13:28 ` [PATCH V3 5/8] clk: vc5: Split clock input mux and predivider Marek Vasut
2017-07-12 23:10   ` Stephen Boyd
2017-07-09 13:28 ` [PATCH V3 6/8] clk: vc5: Add support for the input frequency doubler Marek Vasut
2017-07-12 23:10   ` Stephen Boyd
     [not found] ` <20170709132814.2339-1-marek.vasut+renesas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-07-09 13:28   ` [PATCH V3 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901 Marek Vasut
2017-07-09 13:28     ` Marek Vasut
2017-07-12 23:10     ` Stephen Boyd
2017-07-09 13:28 ` [PATCH V3 8/8] clk: vc5: Add support " Marek Vasut
2017-07-12 23:10   ` Stephen Boyd
2017-07-12 23:10 ` [PATCH V3 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Stephen Boyd

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=20170709132814.2339-4-marek.vasut+renesas@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=alexey_firago@mentor.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.