linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: jamie@jamieiles.com (Jamie Iles)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/11] clk: Add simple gated clock
Date: Thu, 25 Aug 2011 14:17:36 +0100	[thread overview]
Message-ID: <20110825131736.GE2838@pulham.picochip.com> (raw)
In-Reply-To: <1314191759-16941-4-git-send-email-broonie@opensource.wolfsonmicro.com>

Hi Mark, Jeremy,

On Wed, Aug 24, 2011 at 02:15:52PM +0100, Mark Brown wrote:
> From: Jeremy Kerr <jeremy.kerr@canonical.com>
> 
> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

I've just ported my (currently out-of-tree) platform to use the common 
struct clk and it all works nicely (if I add a naive implementation of 
clk_set_parent()).

Our platform has gateable clocks where bits in the control register are 
set to disable the clocks rather than enable them.  I've used the patch 
below to add support for that.

Jamie

8<----

Subject: [PATCH] clk: allow gateable clocks to work with both polarities

Some devices (picoxcell in particular) have gateable clocks where the
control register is a set-to-disable register.  Create a new set of
clock ops that can use struct clk_gate with this register configuration.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 drivers/clk/clk-gate.c |   45 +++++++++++++++++++++++++++++++++++++--------
 include/linux/clk.h    |    3 ++-
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c
index 833e0da..30926e9 100644
--- a/drivers/clk/clk-gate.c
+++ b/drivers/clk/clk-gate.c
@@ -10,7 +10,7 @@ static unsigned long clk_gate_get_rate(struct clk_hw *clk)
 	return clk_get_rate(clk_get_parent(clk->clk));
 }
 
-static int clk_gate_enable(struct clk_hw *clk)
+static void clk_gate_set_bit(struct clk_hw *clk)
 {
 	struct clk_gate *gate = to_clk_gate(clk);
 	u32 reg;
@@ -18,11 +18,9 @@ static int clk_gate_enable(struct clk_hw *clk)
 	reg = __raw_readl(gate->reg);
 	reg |= 1 << gate->bit_idx;
 	__raw_writel(reg, gate->reg);
-
-	return 0;
 }
 
-static void clk_gate_disable(struct clk_hw *clk)
+static void clk_gate_clear_bit(struct clk_hw *clk)
 {
 	struct clk_gate *gate = to_clk_gate(clk);
 	u32 reg;
@@ -32,10 +30,41 @@ static void clk_gate_disable(struct clk_hw *clk)
 	__raw_writel(reg, gate->reg);
 }
 
-struct clk_hw_ops clk_gate_ops = {
+static int clk_gate_enable_set(struct clk_hw *clk)
+{
+	clk_gate_set_bit(clk);
+
+	return 0;
+}
+
+static void clk_gate_disable_clear(struct clk_hw *clk)
+{
+	clk_gate_clear_bit(clk);
+}
+
+struct clk_hw_ops clk_gate_set_enable_ops = {
+	.recalc_rate = clk_gate_get_rate,
+	.enable = clk_gate_enable_set,
+	.disable = clk_gate_disable_clear,
+};
+EXPORT_SYMBOL_GPL(clk_gate_set_enable_ops);
+
+static int clk_gate_enable_clear(struct clk_hw *clk)
+{
+	clk_gate_clear_bit(clk);
+
+	return 0;
+}
+
+static void clk_gate_disable_set(struct clk_hw *clk)
+{
+	clk_gate_set_bit(clk);
+}
+
+struct clk_hw_ops clk_gate_set_disable_ops = {
 	.recalc_rate = clk_gate_get_rate,
-	.enable = clk_gate_enable,
-	.disable = clk_gate_disable,
+	.enable = clk_gate_enable_clear,
+	.disable = clk_gate_disable_set,
 };
-EXPORT_SYMBOL_GPL(clk_gate_ops);
+EXPORT_SYMBOL_GPL(clk_gate_set_disable_ops);
 
diff --git a/include/linux/clk.h b/include/linux/clk.h
index cb1879b..d30314a 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -132,7 +132,8 @@ struct clk_gate {
 	u8		bit_idx;
 };
 
-extern struct clk_hw_ops clk_gate_ops;
+extern struct clk_hw_ops clk_gate_set_enable_ops;
+extern struct clk_hw_ops clk_gate_set_disable_ops;
 
 #endif /* CONFIG_GENERIC_CLK_GATE */
 
-- 
1.7.4.1

  reply	other threads:[~2011-08-25 13:17 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-24 13:13 [PATCH 0/11] generic struct clk patches Mark Brown
2011-08-24 13:15 ` [PATCH 01/11] clk: Add a generic clock infrastructure Mark Brown
2011-08-24 13:15   ` [PATCH 02/11] clk: Implement clk_set_rate Mark Brown
2011-08-26  8:53     ` Sascha Hauer
2011-08-26  8:55       ` Mark Brown
2011-08-26  8:58         ` Sascha Hauer
2011-08-26  9:01           ` Mark Brown
2011-08-26 23:45     ` Turquette, Mike
2011-09-13 19:03     ` Stephen Boyd
2011-08-24 13:15   ` [PATCH 03/11] clk: Add fixed-rate clock Mark Brown
2011-08-24 13:15   ` [PATCH 04/11] clk: Add simple gated clock Mark Brown
2011-08-25 13:17     ` Jamie Iles [this message]
2011-09-13 19:03     ` Stephen Boyd
2011-08-24 13:15   ` [PATCH 05/11] clk: Prototype and document clk_register() Mark Brown
2011-09-13 19:03     ` Stephen Boyd
2011-08-24 13:15   ` [PATCH 06/11] clk: Provide a dummy clk_unregister() Mark Brown
2011-08-25 11:12     ` Jamie Iles
2011-08-24 13:15   ` [PATCH 07/11] clk: Constify struct clk_hw_ops Mark Brown
2011-08-24 13:15   ` [PATCH 08/11] clk: Avoid clock name collisions Mark Brown
2011-09-13 19:03     ` Stephen Boyd
2011-08-24 13:15   ` [PATCH 09/11] clk: Add Kconfig option to build all generic clk drivers Mark Brown
2011-08-24 13:15   ` [PATCH 10/11] clk: Add initial WM831x clock driver Mark Brown
2011-08-24 13:15   ` [PATCH 11/11] x86: Enable generic clk API on x86 Mark Brown
2011-09-13 19:03   ` [PATCH 01/11] clk: Add a generic clock infrastructure Stephen Boyd
     [not found]   ` <1314191759-16941-1-git-send-email-broonie@opensource.wolfsonmicro.com >
2011-09-14  2:22     ` Saravana Kannan
2011-09-14  9:41       ` Mark Brown

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=20110825131736.GE2838@pulham.picochip.com \
    --to=jamie@jamieiles.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).