mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] clk: add always enabled clocks
@ 2012-12-02 20:42 Antony Pavlov
  2012-12-02 20:42 ` [PATCH 1/2] " Antony Pavlov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Antony Pavlov @ 2012-12-02 20:42 UTC (permalink / raw)
  To: barebox

[PATCH 1/2] clk: add always enabled clocks
[PATCH 2/2] commands: clk_dump: denote always enabled clocks

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] clk: add always enabled clocks
  2012-12-02 20:42 [PATCH 0/2] clk: add always enabled clocks Antony Pavlov
@ 2012-12-02 20:42 ` Antony Pavlov
  2012-12-02 20:42 ` [PATCH 2/2] commands: clk_dump: denote " Antony Pavlov
  2012-12-03  9:49 ` [PATCH 0/2] clk: add " Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Antony Pavlov @ 2012-12-02 20:42 UTC (permalink / raw)
  To: barebox

Current barebox clk framework allow disable any clock
and there is no means to prevent that.

But there are the clocks that can't be disabled
by software at all.

This patch allow registration of a clock immune to clk_disable().

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/clk/clk.c   |   10 ++++++++++
 include/linux/clk.h |    3 +++
 2 files changed, 13 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ea93ff8..2ff7586 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -46,6 +46,9 @@ int clk_enable(struct clk *clk)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
+	if (clk->flags & CLK_ALWAYS_ENABLED)
+		return 0;
+
 	if (!clk->enable_count) {
 		ret = clk_parent_enable(clk);
 		if (ret)
@@ -70,6 +73,9 @@ void clk_disable(struct clk *clk)
 	if (IS_ERR(clk))
 		return;
 
+	if (clk->flags & CLK_ALWAYS_ENABLED)
+		return;
+
 	if (!clk->enable_count)
 		return;
 
@@ -205,6 +211,10 @@ int clk_register(struct clk *clk)
 
 	list_add_tail(&clk->list, &clks);
 
+	if (clk->flags & CLK_ALWAYS_ENABLED) {
+		clk->enable_count = 1;
+	}
+
 	return 0;
 }
 
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 00588bf..1030b50 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -179,8 +179,11 @@ struct clk {
 	int num_parents;
 
 	struct clk **parents;
+	unsigned long flags;
 };
 
+#define CLK_ALWAYS_ENABLED	(1 << 0)
+
 struct clk *clk_fixed(const char *name, int rate);
 struct clk *clk_divider(const char *name, const char *parent,
 		void __iomem *reg, u8 shift, u8 width);
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] commands: clk_dump: denote always enabled clocks
  2012-12-02 20:42 [PATCH 0/2] clk: add always enabled clocks Antony Pavlov
  2012-12-02 20:42 ` [PATCH 1/2] " Antony Pavlov
@ 2012-12-02 20:42 ` Antony Pavlov
  2012-12-03  9:49 ` [PATCH 0/2] clk: add " Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Antony Pavlov @ 2012-12-02 20:42 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/clk/clk.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 2ff7586..cb94755 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -221,9 +221,13 @@ int clk_register(struct clk *clk)
 static void dump_one(struct clk *clk, int verbose, int indent)
 {
 	struct clk *c;
+	char *always = "";
 
-	printf("%*s%s (rate %ld, %sabled)\n", indent * 4, "", clk->name, clk_get_rate(clk),
-			clk->enable_count ? "en" : "dis");
+	if (clk->flags & CLK_ALWAYS_ENABLED)
+		always = "always ";
+
+	printf("%*s%s (rate %ld, %s%sabled)\n", indent * 4, "", clk->name, clk_get_rate(clk),
+			always, clk->enable_count ? "en" : "dis");
 	if (verbose) {
 
 		if (clk->num_parents > 1) {
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] clk: add always enabled clocks
  2012-12-02 20:42 [PATCH 0/2] clk: add always enabled clocks Antony Pavlov
  2012-12-02 20:42 ` [PATCH 1/2] " Antony Pavlov
  2012-12-02 20:42 ` [PATCH 2/2] commands: clk_dump: denote " Antony Pavlov
@ 2012-12-03  9:49 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-12-03  9:49 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Mon, Dec 03, 2012 at 12:42:23AM +0400, Antony Pavlov wrote:
> [PATCH 1/2] clk: add always enabled clocks
> [PATCH 2/2] commands: clk_dump: denote always enabled clocks

Nice. The clk_dump command looks a bit weird because it suggests that
all clocks are disabled. now I can turn them into always enabled clocks.

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-03  9:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-02 20:42 [PATCH 0/2] clk: add always enabled clocks Antony Pavlov
2012-12-02 20:42 ` [PATCH 1/2] " Antony Pavlov
2012-12-02 20:42 ` [PATCH 2/2] commands: clk_dump: denote " Antony Pavlov
2012-12-03  9:49 ` [PATCH 0/2] clk: add " Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox