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 4/4] clk: keystone: sci-clk: add debugfs support for read/write of parent ID
Date: Tue, 1 Oct 2019 12:02:02 +0300	[thread overview]
Message-ID: <20191001090202.26346-5-t-kristo@ti.com> (raw)
In-Reply-To: <20191001090202.26346-1-t-kristo@ti.com>

Add parent_id node under debugfs for TI SCI clocks, that allow both
read/write operations. This can be used to read the current
parent ID, or force a change of current parent of a multi-parent clock.

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

diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c
index 7edf8c8432b6..39255b13bdc1 100644
--- a/drivers/clk/keystone/sci-clk.c
+++ b/drivers/clk/keystone/sci-clk.c
@@ -24,6 +24,7 @@
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include <linux/bsearch.h>
 #include <linux/list_sort.h>
+#include <linux/debugfs.h>
 
 #define SCI_CLK_SSC_ENABLE		BIT(0)
 #define SCI_CLK_ALLOW_FREQ_CHANGE	BIT(1)
@@ -254,6 +255,41 @@ static int sci_clk_set_parent(struct clk_hw *hw, u8 index)
 					      index + 1 + clk->clk_id);
 }
 
+#ifdef CONFIG_COMMON_CLK_DEBUGFS_WRITE_ACCESS
+static int dbg_pid_get(void *data, u64 *val)
+{
+	struct clk_hw *hw = data;
+
+	*val = sci_clk_get_parent(hw);
+
+	return 0;
+}
+
+static int dbg_pid_set(void *data, u64 val)
+{
+	struct clk_hw *hw = data;
+	struct clk_hw *parent = clk_hw_get_parent_by_index(hw, val);
+
+	if (!parent)
+		return -EINVAL;
+
+	clk_hw_reparent(hw, parent);
+
+	return sci_clk_set_parent(hw, val);
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(sci_parent_id_fops, dbg_pid_get, dbg_pid_set, "%llu\n");
+
+static void sci_clk_debug_init(struct clk_hw *hw, struct dentry *dentry)
+{
+	debugfs_create_file("parent_id", 0644, dentry, hw, &sci_parent_id_fops);
+}
+#else
+static void sci_clk_debug_init(struct clk_hw *hw, struct dentry *dentry)
+{
+}
+#endif
+
 static const struct clk_ops sci_clk_ops = {
 	.prepare = sci_clk_prepare,
 	.unprepare = sci_clk_unprepare,
@@ -263,6 +307,7 @@ static const struct clk_ops sci_clk_ops = {
 	.set_rate = sci_clk_set_rate,
 	.get_parent = sci_clk_get_parent,
 	.set_parent = sci_clk_set_parent,
+	.debug_init = sci_clk_debug_init,
 };
 
 /**
-- 
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 ` [PATCH 2/4] clk: debug: add support for enable/disable/prep/un-prep " Tero Kristo
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 ` Tero Kristo [this message]
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-5-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).