summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-03-18 08:48:16 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-03-18 08:48:16 +0100
commit2987a000d400d6f6bd32ef98849d00931f7032c5 (patch)
tree0357eff8ef58f237c2ac5b53f87837a73dbd925d
parentec91b38f12bc2a10c54c434212f919a04fac6ef8 (diff)
parent5bf3e793ccef72e11a03ab3066a4893883249c5b (diff)
downloadbarebox-2987a000d400d6f6bd32ef98849d00931f7032c5.tar.gz
Merge branch 'for-next/clk'
-rw-r--r--drivers/clk/clk.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ea3304b..b27ad6d 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -84,12 +84,14 @@ void clk_disable(struct clk *clk)
if (!clk->enable_count)
return;
+ if (clk->enable_count == 1 && clk->flags & CLK_IS_CRITICAL) {
+ pr_warn("Disabling critical clock %s\n", clk->name);
+ return;
+ }
+
clk->enable_count--;
if (!clk->enable_count) {
- if (clk->flags & CLK_IS_CRITICAL)
- return;
-
if (clk->ops->disable)
clk->ops->disable(clk);
@@ -282,6 +284,9 @@ int clk_register(struct clk *clk)
list_add_tail(&clk->list, &clks);
+ if (clk->flags & CLK_IS_CRITICAL)
+ clk_enable(clk);
+
return 0;
}
@@ -627,12 +632,40 @@ int of_clk_init(struct device_node *root, const struct of_device_id *matches)
}
#endif
+static const char *clk_hw_stat(struct clk *clk)
+{
+ if (clk->ops->is_enabled) {
+ if (clk->ops->is_enabled(clk))
+ return "enabled";
+ else
+ return "disabled";
+ }
+
+ if (!clk->ops->enable)
+ return "always enabled";
+
+ return "unknown";
+}
+
static void dump_one(struct clk *clk, int verbose, int indent)
{
struct clk *c;
+ int enabled = clk_is_enabled(clk);
+ const char *hwstat, *stat;
+
+ hwstat = clk_hw_stat(clk);
+
+ if (enabled == 0)
+ stat = "disabled";
+ else
+ stat = "enabled";
+
+ printf("%*s%s (rate %lu, enable_count: %d, %s)\n", indent * 4, "",
+ clk->name,
+ clk_get_rate(clk),
+ clk->enable_count,
+ hwstat);
- printf("%*s%s (rate %lu, %sabled)\n", indent * 4, "", clk->name, clk_get_rate(clk),
- clk_is_enabled(clk) ? "en" : "dis");
if (verbose) {
if (clk->num_parents > 1) {