linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: <linux-clk@vger.kernel.org>, <sboyd@kernel.org>,
	<mturquette@baylibre.com>
Cc: <tomi.valkeinen@ti.com>
Subject: [PATCH 2/4] clk: debug: add support for enable/disable/prep/un-prep from debugfs
Date: Tue, 1 Oct 2019 12:02:00 +0300	[thread overview]
Message-ID: <20191001090202.26346-3-t-kristo@ti.com> (raw)
In-Reply-To: <20191001090202.26346-1-t-kristo@ti.com>

The enable/prepare count variables can now be used to enable/disable/
prepare and un-prepare specific clocks. This is very useful for
debugging purposes, but can be considered dangerous. Thus, it is
protected by the same Kconfig option as the clk_rate modification
option.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 drivers/clk/clk.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b0e82193a63d..e0ceecf727c5 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3113,6 +3113,58 @@ static int clk_dbg_rate_set(void *data, u64 val)
 }
 
 DEFINE_SIMPLE_ATTRIBUTE(clk_dbg_option_rate, clk_dbg_rate_get, clk_dbg_rate_set, "%llu\n");
+
+static int clk_dbg_prepare_get(void *data, u64 *val)
+{
+	struct clk_core *core = data;
+
+	*val = core->prepare_count;
+
+	return 0;
+}
+
+static int clk_dbg_prepare_set(void *data, u64 val)
+{
+	struct clk_core *core = data;
+
+	if (val == 1)
+		return clk_core_prepare(core);
+
+	if (val == -1) {
+		clk_core_unprepare(core);
+		return 0;
+	}
+
+	pr_err("1: prepare, -1: unprepare\n");
+	return -EINVAL;
+}
+DEFINE_SIMPLE_ATTRIBUTE(clk_dbg_option_prepare, clk_dbg_prepare_get, clk_dbg_prepare_set, "%llu\n");
+
+static int clk_dbg_enable_get(void *data, u64 *val)
+{
+	struct clk_core *core = data;
+
+	*val = core->enable_count;
+
+	return 0;
+}
+
+static int clk_dbg_enable_set(void *data, u64 val)
+{
+	struct clk_core *core = data;
+
+	if (val == 1)
+		return clk_core_enable(core);
+
+	if (val == -1) {
+		clk_core_disable(core);
+		return 0;
+	}
+
+	pr_err("1: enable, -1: disable\n");
+	return -EINVAL;
+}
+DEFINE_SIMPLE_ATTRIBUTE(clk_dbg_option_enable, clk_dbg_enable_get, clk_dbg_enable_set, "%llu\n");
 #endif
 
 static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
@@ -3134,8 +3186,15 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 	debugfs_create_ulong("clk_accuracy", 0444, root, &core->accuracy);
 	debugfs_create_u32("clk_phase", 0444, root, &core->phase);
 	debugfs_create_file("clk_flags", 0444, root, core, &clk_flags_fops);
+#ifdef CONFIG_COMMON_CLK_DEBUGFS_WRITE_ACCESS
+	debugfs_create_file("clk_prepare_count", 0644,
+			    root, core, &clk_dbg_option_prepare);
+	debugfs_create_file("clk_enable_count", 0644,
+			    core->dentry, core, &clk_dbg_option_enable);
+#else
 	debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count);
 	debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
+#endif
 	debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
 	debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
 	debugfs_create_file("clk_duty_cycle", 0444, root, core,
-- 
2.17.1

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  parent reply	other threads:[~2019-10-01  9:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-01  9:01 [PATCH 0/4] clk: debugfs: add some simple debug functionality Tero Kristo
2019-10-01  9:01 ` [PATCH 1/4] clk: debug: add support for setting clk_rate from debugfs Tero Kristo
2019-10-01  9:02 ` Tero Kristo [this message]
2019-10-01  9:02 ` [PATCH 3/4] clk: ti: mux: add debugfs support for read/write of parent ID Tero Kristo
2019-10-01  9:02 ` [PATCH 4/4] clk: keystone: sci-clk: " Tero Kristo
2019-10-01  9:21 ` [PATCH 0/4] clk: debugfs: add some simple debug functionality Tomi Valkeinen
2020-01-06  3:13 ` Stephen Boyd

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=20191001090202.26346-3-t-kristo@ti.com \
    --to=t-kristo@ti.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=tomi.valkeinen@ti.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).