Skip to contentSkip to conversation

clk: add always enabled clocks

PATCH Applied Antony Pavlov 2 participants 4 messages Dec 2, 2012 – Dec 3, 2012

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/2 clk: add always enabled clocks

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().

---
 drivers/clk/clk.c   |   10 ++++++++++
 include/linux/clk.h |    3 +++
 2 files changed, 13 insertions(+)
drivers/clk/clk.c +10 -0
index ea93ff8..2ff7586 100644
@@ -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;
 }
 
include/linux/clk.h +3 -0
index 00588bf..1030b50 100644
@@ -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);
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/2 commands: clk_dump: denote always enabled clocks

In reply to Antony Pavlov
---
 drivers/clk/clk.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/clk/clk.c +6 -2
index 2ff7586..cb94755 100644
@@ -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) {
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#3 lore raw
In reply to Antony Pavlov
Quoted 2 lines · Antony Pavlov

[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

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox