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">&lt;<a href="mailto:amit.daniel@samsung.com">amit.daniel@samsung.com</a>&gt;</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 &lt;<a href="mailto:amit.daniel@samsung.com">amit.daniel@samsung.com</a>&gt;<br>
<br>
This patch adds support for clock information exposed to debug-fs<br>
interface.<br>
<br>
Signed-off-by: Amit Daniel Kachhap &lt;<a href="mailto:amit.daniel@samsung.com">amit.daniel@samsung.com</a>&gt;<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 &lt;linux/clk.h&gt;<br>
 #include &lt;linux/spinlock.h&gt;<br>
 #include &lt;linux/io.h&gt;<br>
+#include &lt;linux/debugfs.h&gt;<br>
<br>
 #include &lt;mach/hardware.h&gt;<br>
 #include &lt;asm/irq.h&gt;<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-&gt;parent;<br>
+       char s[255];<br>
+       char *p = s;<br>
+<br>
+       p += sprintf(p, &quot;%s&quot;, c-&gt;name);<br>
+#ifdef CONFIG_PLAT_SAMSUNG<br>
+       /*Append id field with name also*/<br>
+       if (c-&gt;id &gt;= 0)<br>
+               p += sprintf(p, &quot;:%d&quot;, c-&gt;id);<br>
+#endif<br>
+<br>
+       d = debugfs_create_dir(s, pa ? pa-&gt;dent : clk_debugfs_root);<br>
+       if (!d)<br>
+               return -ENOMEM;<br>
+<br>
+       c-&gt;dent = d;<br>
+<br>
+       d = debugfs_create_u8(&quot;usecount&quot;, S_IRUGO, c-&gt;dent, (u8 *)&amp;c-&gt;usage);<br>
+       if (!d) {<br>
+               err = -ENOMEM;<br>
+               goto err_out;<br>
+       }<br>
+       d = debugfs_create_u32(&quot;rate&quot;, S_IRUGO, c-&gt;dent, (u32 *)&amp;c-&gt;rate);<br>
+       if (!d) {<br>
+               err = -ENOMEM;<br>
+               goto err_out;<br>
+       }<br>
+       return 0;<br>
+<br>
+err_out:<br>
+       d = c-&gt;dent;<br>
+       list_for_each_entry_safe(child, child_tmp, &amp;d-&gt;d_subdirs, d_u.d_child)<br>
+               debugfs_remove(child);<br>
+       debugfs_remove(c-&gt;dent);<br>
+       return err;<br>
+}<br>
+<br>
+static int clk_debugfs_register(struct clk *c)<br>
+{<br>
+       int err;<br>
+       struct clk *pa = c-&gt;parent;<br>
+<br>
+       if (pa &amp;&amp; !pa-&gt;dent) {<br>
+               err = clk_debugfs_register(pa);<br>
+               if (err)<br>
+                       return err;<br>
+       }<br>
+<br>
+       if (!c-&gt;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(&quot;clock&quot;, NULL);<br>
+       if (!d)<br>
+               return -ENOMEM;<br>
+       clk_debugfs_root = d;<br>
+<br>
+       list_for_each_entry(c, &amp;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>