Hi Amit,<div><br></div><div>We are trying to make this clock debug interface generic, so every platform can benefit from it. Maybe it is better to wait for a while until the common interface comes out.</div><div><br></div>
<div>Yong<br><br><div class="gmail_quote">On Tue, Nov 16, 2010 at 6:54 PM, <span dir="ltr"><<a href="mailto:amit.daniel@samsung.com">amit.daniel@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
From: Amit Daniel Kachhap <<a href="mailto:amit.daniel@samsung.com">amit.daniel@samsung.com</a>><br>
<br>
This patch adds support for clock information exposed to debug-fs<br>
interface.<br>
<br>
Signed-off-by: Amit Daniel Kachhap <<a href="mailto:amit.daniel@samsung.com">amit.daniel@samsung.com</a>><br>
---<br>
arch/arm/plat-samsung/clock.c | 92 ++++++++++++++++++++++++++++<br>
arch/arm/plat-samsung/include/plat/clock.h | 3 +<br>
2 files changed, 95 insertions(+), 0 deletions(-)<br>
<br>
diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c<br>
index e8d20b0..0ba209d 100644<br>
--- a/arch/arm/plat-samsung/clock.c<br>
+++ b/arch/arm/plat-samsung/clock.c<br>
@@ -39,6 +39,7 @@<br>
#include <linux/clk.h><br>
#include <linux/spinlock.h><br>
#include <linux/io.h><br>
+#include <linux/debugfs.h><br>
<br>
#include <mach/hardware.h><br>
#include <asm/irq.h><br>
@@ -447,3 +448,94 @@ int __init s3c24xx_register_baseclocks(unsigned long xtal)<br>
return 0;<br>
}<br>
<br>
+#if defined(CONFIG_DEBUG_FS)<br>
+/*<br>
+ * debugfs support to trace clock tree hierarchy and attributes<br>
+ */<br>
+static struct dentry *clk_debugfs_root;<br>
+<br>
+static int clk_debugfs_register_one(struct clk *c)<br>
+{<br>
+ int err;<br>
+ struct dentry *d, *child, *child_tmp;<br>
+ struct clk *pa = c->parent;<br>
+ char s[255];<br>
+ char *p = s;<br>
+<br>
+ p += sprintf(p, "%s", c->name);<br>
+#ifdef CONFIG_PLAT_SAMSUNG<br>
+ /*Append id field with name also*/<br>
+ if (c->id >= 0)<br>
+ p += sprintf(p, ":%d", c->id);<br>
+#endif<br>
+<br>
+ d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root);<br>
+ if (!d)<br>
+ return -ENOMEM;<br>
+<br>
+ c->dent = d;<br>
+<br>
+ d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usage);<br>
+ if (!d) {<br>
+ err = -ENOMEM;<br>
+ goto err_out;<br>
+ }<br>
+ d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate);<br>
+ if (!d) {<br>
+ err = -ENOMEM;<br>
+ goto err_out;<br>
+ }<br>
+ return 0;<br>
+<br>
+err_out:<br>
+ d = c->dent;<br>
+ list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child)<br>
+ debugfs_remove(child);<br>
+ debugfs_remove(c->dent);<br>
+ return err;<br>
+}<br>
+<br>
+static int clk_debugfs_register(struct clk *c)<br>
+{<br>
+ int err;<br>
+ struct clk *pa = c->parent;<br>
+<br>
+ if (pa && !pa->dent) {<br>
+ err = clk_debugfs_register(pa);<br>
+ if (err)<br>
+ return err;<br>
+ }<br>
+<br>
+ if (!c->dent) {<br>
+ err = clk_debugfs_register_one(c);<br>
+ if (err)<br>
+ return err;<br>
+ }<br>
+ return 0;<br>
+}<br>
+<br>
+static int __init clk_debugfs_init(void)<br>
+{<br>
+ struct clk *c;<br>
+ struct dentry *d;<br>
+ int err;<br>
+<br>
+ d = debugfs_create_dir("clock", NULL);<br>
+ if (!d)<br>
+ return -ENOMEM;<br>
+ clk_debugfs_root = d;<br>
+<br>
+ list_for_each_entry(c, &clocks, list) {<br>
+ err = clk_debugfs_register(c);<br>
+ if (err)<br>
+ goto err_out;<br>
+ }<br>
+ return 0;<br>
+err_out:<br>
+ debugfs_remove_recursive(clk_debugfs_root);<br>
+ return err;<br>
+}<br>
+late_initcall(clk_debugfs_init);<br>
+<br>
+#endif /* defined(CONFIG_DEBUG_FS) */<br>
+<br>
diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat-samsung/include/plat/clock.h<br>
index 0fbcd0e..f6180ab 100644<br>
--- a/arch/arm/plat-samsung/include/plat/clock.h<br>
+++ b/arch/arm/plat-samsung/include/plat/clock.h<br>
@@ -47,6 +47,9 @@ struct clk {<br>
<br>
struct clk_ops *ops;<br>
int (*enable)(struct clk *, int enable);<br>
+#if defined(CONFIG_DEBUG_FS)<br>
+ struct dentry *dent; /* For visible tree hierarchy */<br>
+#endif<br>
};<br>
<br>
/* other clocks which may be registered by board support */<br>
<font color="#888888">--<br>
1.6.0.6<br>
<br>
<br>
_______________________________________________<br>
linaro-dev mailing list<br>
<a href="mailto:linaro-dev@lists.linaro.org">linaro-dev@lists.linaro.org</a><br>
<a href="http://lists.linaro.org/mailman/listinfo/linaro-dev" target="_blank">http://lists.linaro.org/mailman/listinfo/linaro-dev</a><br>
</font></blockquote></div><br></div>