linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: qcom: List rates in debugfs for rcg
@ 2018-12-18 17:08 Jeffrey Hugo
  0 siblings, 0 replies; only message in thread
From: Jeffrey Hugo @ 2018-12-18 17:08 UTC (permalink / raw)
  To: mturquette, sboyd, andy.gross, david.brown
  Cc: bjorn.andersson, linux-clk, linux-arm-msm, linux-kernel, Jeffrey Hugo

RCGs typically have multiple frequencies they can support based on client
requests.  It can be very helpful to have a list of what are the supported
frequencies when attempting to bringup or debug a new device.  Add a clock
specific "list_rates" debugfs file which dumps the supported rates of a
selected rcg in a convenient format.

Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
---
 drivers/clk/qcom/clk-rcg2.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
index 6e3bd19..e4b1d35 100644
--- a/drivers/clk/qcom/clk-rcg2.c
+++ b/drivers/clk/qcom/clk-rcg2.c
@@ -13,6 +13,8 @@
 #include <linux/regmap.h>
 #include <linux/math64.h>
 #include <linux/slab.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 
 #include <asm/div64.h>
 
@@ -347,6 +349,36 @@ static int clk_rcg2_set_floor_rate_and_parent(struct clk_hw *hw,
 	return __clk_rcg2_set_rate(hw, rate, FLOOR);
 }
 
+static int rcg2_list_rates_show(struct seq_file *m, void *unused)
+{
+	struct clk_rcg2 *rcg = m->private;
+	const struct freq_tbl *f;
+
+	if (rcg->freq_tbl)
+		for (f = rcg->freq_tbl; f->freq; f++)
+			seq_printf(m, "%lu\n", f->freq);
+
+	return 0;
+}
+
+static int rcg2_list_rates_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, rcg2_list_rates_show, inode->i_private);
+}
+
+static const struct file_operations rcg2_list_rates_fops = {
+	.open		= rcg2_list_rates_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+
+static void clk_rcg2_debug_init(struct clk_hw *hw, struct dentry *dentry)
+{
+	debugfs_create_file("list_rates", 0444, dentry, to_clk_rcg2(hw),
+			    &rcg2_list_rates_fops);
+}
+
 const struct clk_ops clk_rcg2_ops = {
 	.is_enabled = clk_rcg2_is_enabled,
 	.get_parent = clk_rcg2_get_parent,
@@ -355,6 +387,7 @@ static int clk_rcg2_set_floor_rate_and_parent(struct clk_hw *hw,
 	.determine_rate = clk_rcg2_determine_rate,
 	.set_rate = clk_rcg2_set_rate,
 	.set_rate_and_parent = clk_rcg2_set_rate_and_parent,
+	.debug_init = clk_rcg2_debug_init,
 };
 EXPORT_SYMBOL_GPL(clk_rcg2_ops);
 
-- 
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-18 17:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-18 17:08 [PATCH] clk: qcom: List rates in debugfs for rcg Jeffrey Hugo

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