linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <gabriel.fernandez@st.com>
To: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Srinivas Kandagatla <srinivas.kandagatla@gmail.com>,
	Patrice Chotard <patrice.chotard@st.com>,
	Russell King <linux@armlinux.org.uk>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Olivier Bideau <olivier.bideau@st.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Pankaj Dev <pankaj.dev@st.com>,
	Dinh Nguyen <dinguyen@opensource.altera.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Thierry Reding <treding@nvidia.com>
Cc: <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <kernel@stlinux.com>,
	<linux-clk@vger.kernel.org>, Lee Jones <lee.jones@linaro.org>,
	Peter Griffin <peter.griffin@linaro.org>,
	<arnaud.pouliquen@st.com>, <benjamin.gaignard@st.com>,
	<vincent.abriou@st.com>, <gabriel.fernandez@st.com>,
	Gabriel Fernandez <gabriel.fernandez@linaro.org>
Subject: [PATCH v3 06/14] drivers: clk: st: Handle clk synchronous mode for video clocks
Date: Mon, 29 Aug 2016 14:26:58 +0200	[thread overview]
Message-ID: <1472473626-15398-7-git-send-email-gabriel.fernandez@st.com> (raw)
In-Reply-To: <1472473626-15398-1-git-send-email-gabriel.fernandez@st.com>

From: Gabriel Fernandez <gabriel.fernandez@st.com>

This patch configures the semi-synchronous mode of the video clocks
of clkgenD2.

Signed-off-by: Olivier Bideau <olivier.bideau@st.com>
Signed-off-by: Gabriel Fernandez <gabriel.fernandez@st.com>
Acked-by: Peter Griffin <peter.griffin@linaro.org>
---
 .../devicetree/bindings/clock/st/st,flexgen.txt    |  2 ++
 drivers/clk/st/clk-flexgen.c                       | 37 ++++++++++++++++++++--
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/st/st,flexgen.txt b/Documentation/devicetree/bindings/clock/st/st,flexgen.txt
index d68f6a5f..7ff77fc 100644
--- a/Documentation/devicetree/bindings/clock/st/st,flexgen.txt
+++ b/Documentation/devicetree/bindings/clock/st/st,flexgen.txt
@@ -62,6 +62,8 @@ Required properties:
   "st,flexgen"
   "st,flexgen-audio", "st,flexgen" (enable clock propagation on parent for
   audio use case)
+  "st,flexgen-video", "st,flexgen" (enable clock propagation on parent
+					and activate synchronous mode)
 
 - #clock-cells : from common clock binding; shall be set to 1 (multiple clock
   outputs).
diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c
index 7ed05f0..a485f3b 100644
--- a/drivers/clk/st/clk-flexgen.c
+++ b/drivers/clk/st/clk-flexgen.c
@@ -17,6 +17,7 @@
 
 struct clkgen_data {
 	unsigned long flags;
+	bool mode;
 };
 
 struct flexgen {
@@ -32,9 +33,14 @@ struct flexgen {
 	struct clk_gate fgate;
 	/* Final divisor */
 	struct clk_divider fdiv;
+	/* Asynchronous mode control */
+	struct clk_gate sync;
+	/* hw control flags */
+	bool control_mode;
 };
 
 #define to_flexgen(_hw) container_of(_hw, struct flexgen, hw)
+#define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw)
 
 static int flexgen_enable(struct clk_hw *hw)
 {
@@ -143,12 +149,21 @@ static int flexgen_set_rate(struct clk_hw *hw, unsigned long rate,
 	struct flexgen *flexgen = to_flexgen(hw);
 	struct clk_hw *pdiv_hw = &flexgen->pdiv.hw;
 	struct clk_hw *fdiv_hw = &flexgen->fdiv.hw;
+	struct clk_hw *sync_hw = &flexgen->sync.hw;
+	struct clk_gate *config = to_clk_gate(sync_hw);
 	unsigned long div = 0;
 	int ret = 0;
+	u32 reg;
 
 	__clk_hw_set_clk(pdiv_hw, hw);
 	__clk_hw_set_clk(fdiv_hw, hw);
 
+	if (flexgen->control_mode) {
+		reg = readl(config->reg);
+		reg &= ~BIT(config->bit_idx);
+		writel(reg, config->reg);
+	}
+
 	div = clk_best_div(parent_rate, rate);
 
 	/*
@@ -182,7 +197,7 @@ static const struct clk_ops flexgen_ops = {
 static struct clk *clk_register_flexgen(const char *name,
 				const char **parent_names, u8 num_parents,
 				void __iomem *reg, spinlock_t *lock, u32 idx,
-				unsigned long flexgen_flags) {
+				unsigned long flexgen_flags, bool mode) {
 	struct flexgen *fgxbar;
 	struct clk *clk;
 	struct clk_init_data init;
@@ -231,6 +246,13 @@ static struct clk *clk_register_flexgen(const char *name,
 	fgxbar->fdiv.reg = fdiv_reg;
 	fgxbar->fdiv.width = 6;
 
+	/* Final divider sync config */
+	fgxbar->sync.lock = lock;
+	fgxbar->sync.reg = fdiv_reg;
+	fgxbar->sync.bit_idx = 7;
+
+	fgxbar->control_mode = mode;
+
 	fgxbar->hw.init = &init;
 
 	clk = clk_register(NULL, &fgxbar->hw);
@@ -267,11 +289,20 @@ static const struct clkgen_data clkgen_audio = {
 	.flags = CLK_SET_RATE_PARENT,
 };
 
+static const struct clkgen_data clkgen_video = {
+	.flags = CLK_SET_RATE_PARENT,
+	.mode = 1,
+};
+
 static const struct of_device_id flexgen_of_match[] = {
 	{
 		.compatible = "st,flexgen-audio",
 		.data = &clkgen_audio,
 	},
+	{
+		.compatible = "st,flexgen-video",
+		.data = &clkgen_video,
+	},
 	{}
 };
 
@@ -287,6 +318,7 @@ static void __init st_of_flexgen_setup(struct device_node *np)
 	struct clkgen_data *data = NULL;
 	unsigned long flex_flags = 0;
 	int ret;
+	bool clk_mode = 0;
 
 	pnode = of_get_parent(np);
 	if (!pnode)
@@ -304,6 +336,7 @@ static void __init st_of_flexgen_setup(struct device_node *np)
 	if (match) {
 		data = (struct clkgen_data *)match->data;
 		flex_flags = data->flags;
+		clk_mode = data->mode;
 	}
 
 	clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
@@ -347,7 +380,7 @@ static void __init st_of_flexgen_setup(struct device_node *np)
 			continue;
 
 		clk = clk_register_flexgen(clk_name, parents, num_parents,
-					   reg, rlock, i, flex_flags);
+					   reg, rlock, i, flex_flags, clk_mode);
 
 		if (IS_ERR(clk))
 			goto err;
-- 
1.9.1

  parent reply	other threads:[~2016-08-29 12:30 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-29 12:26 [PATCH v3 00/14] Clock improvement for video playback gabriel.fernandez
2016-08-29 12:26 ` [PATCH v3 01/14] drivers: clk: st: Remove stih415-416 clock support gabriel.fernandez
2016-09-16 23:02   ` Stephen Boyd
2016-08-29 12:26 ` [PATCH v3 02/14] drivers: clk: st: Simplify clock binding of STiH4xx platforms gabriel.fernandez
2016-09-16 23:02   ` Stephen Boyd
2016-08-29 12:26 ` [PATCH v3 03/14] ARM: DT: STiH4xx: " gabriel.fernandez
2016-09-15  7:44   ` Patrice Chotard
2016-08-29 12:26 ` [PATCH v3 04/14] drivers: clk: st: Add fs660c32 synthesizer algorithm gabriel.fernandez
2016-09-16 23:03   ` Stephen Boyd
2016-08-29 12:26 ` [PATCH v3 05/14] drivers: clk: st: Add clock propagation for audio clocks gabriel.fernandez
2016-09-16 23:03   ` Stephen Boyd
2016-08-29 12:26 ` gabriel.fernandez [this message]
2016-08-29 12:26 ` [PATCH v3 07/14] ARM: DT: STiH407: Enable " gabriel.fernandez
2016-09-15  7:46   ` Patrice Chotard
2016-08-29 12:27 ` [PATCH v3 08/14] ARM: DT: STiH410: " gabriel.fernandez
2016-09-15  7:47   ` Patrice Chotard
2016-08-29 12:27 ` [PATCH v3 09/14] ARM: DT: STiH418: " gabriel.fernandez
2016-09-15  7:47   ` Patrice Chotard
2016-08-29 12:27 ` [PATCH v3 10/14] ARM: DT: STiH407: Enable synchronous clock mode for video clocks gabriel.fernandez
2016-09-15  7:47   ` Patrice Chotard
2016-08-29 12:27 ` [PATCH v3 11/14] ARM: DT: STiH410: " gabriel.fernandez
2016-09-15  7:47   ` Patrice Chotard
2016-08-29 12:27 ` [PATCH v3 12/14] ARM: DT: STiH418: " gabriel.fernandez
2016-09-15  7:47   ` Patrice Chotard
2016-08-29 12:27 ` [PATCH v3 13/14] ARM: DT: STi: STiH407: clock configuration to address 720p and 1080p gabriel.fernandez
2016-09-15  7:47   ` Patrice Chotard
2016-08-29 12:27 ` [PATCH v3 14/14] ARM: DT: STi: STiH410: " gabriel.fernandez
2016-09-15  7:48   ` Patrice Chotard
2016-09-05 13:20 ` [PATCH v3 00/14] Clock improvement for video playback Patrice Chotard
2016-09-14 18:36 ` Stephen Boyd
2016-09-15  6:57   ` Patrice Chotard
2016-09-15 11:42     ` Patrice Chotard
2016-09-15  7:47   ` Gabriel Fernandez

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=1472473626-15398-7-git-send-email-gabriel.fernandez@st.com \
    --to=gabriel.fernandez@st.com \
    --cc=a.hajda@samsung.com \
    --cc=arnaud.pouliquen@st.com \
    --cc=arnd@arndb.de \
    --cc=benjamin.gaignard@st.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dinguyen@opensource.altera.com \
    --cc=gabriel.fernandez@linaro.org \
    --cc=galak@codeaurora.org \
    --cc=geert+renesas@glider.be \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kernel@stlinux.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=olivier.bideau@st.com \
    --cc=pankaj.dev@st.com \
    --cc=patrice.chotard@st.com \
    --cc=peter.griffin@linaro.org \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=srinivas.kandagatla@gmail.com \
    --cc=treding@nvidia.com \
    --cc=vincent.abriou@st.com \
    /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).