]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
ARM: SAMSUNG: Add support for clock debugging through debug-fs interface
authorAmit Daniel Kachhap <amit.daniel@samsung.com>
Wed, 12 Jan 2011 04:40:04 +0000 (13:40 +0900)
committerKukjin Kim <kgene.kim@samsung.com>
Wed, 12 Jan 2011 04:40:04 +0000 (13:40 +0900)
This patch adds support for clock information exposed to debug-fs interface.

Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
[kgene.kim@samsung.com: removed useless empty lines]
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
arch/arm/plat-samsung/clock.c
arch/arm/plat-samsung/include/plat/clock.h

index e8d20b0bc50e11ee43d78f230b811409def1cb87..772892826ffc88c59e8b2641a665a7f5169e6446 100644 (file)
@@ -39,6 +39,9 @@
 #include <linux/clk.h>
 #include <linux/spinlock.h>
 #include <linux/io.h>
+#if defined(CONFIG_DEBUG_FS)
+#include <linux/debugfs.h>
+#endif
 
 #include <mach/hardware.h>
 #include <asm/irq.h>
@@ -447,3 +450,92 @@ int __init s3c24xx_register_baseclocks(unsigned long xtal)
        return 0;
 }
 
+#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
+/* debugfs support to trace clock tree hierarchy and attributes */
+
+static struct dentry *clk_debugfs_root;
+
+static int clk_debugfs_register_one(struct clk *c)
+{
+       int err;
+       struct dentry *d, *child, *child_tmp;
+       struct clk *pa = c->parent;
+       char s[255];
+       char *p = s;
+
+       p += sprintf(p, "%s", c->name);
+
+       if (c->id >= 0)
+               sprintf(p, ":%d", c->id);
+
+       d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root);
+       if (!d)
+               return -ENOMEM;
+
+       c->dent = d;
+
+       d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usage);
+       if (!d) {
+               err = -ENOMEM;
+               goto err_out;
+       }
+
+       d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate);
+       if (!d) {
+               err = -ENOMEM;
+               goto err_out;
+       }
+       return 0;
+
+err_out:
+       d = c->dent;
+       list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child)
+               debugfs_remove(child);
+       debugfs_remove(c->dent);
+       return err;
+}
+
+static int clk_debugfs_register(struct clk *c)
+{
+       int err;
+       struct clk *pa = c->parent;
+
+       if (pa && !pa->dent) {
+               err = clk_debugfs_register(pa);
+               if (err)
+                       return err;
+       }
+
+       if (!c->dent) {
+               err = clk_debugfs_register_one(c);
+               if (err)
+                       return err;
+       }
+       return 0;
+}
+
+static int __init clk_debugfs_init(void)
+{
+       struct clk *c;
+       struct dentry *d;
+       int err;
+
+       d = debugfs_create_dir("clock", NULL);
+       if (!d)
+               return -ENOMEM;
+       clk_debugfs_root = d;
+
+       list_for_each_entry(c, &clocks, list) {
+               err = clk_debugfs_register(c);
+               if (err)
+                       goto err_out;
+       }
+       return 0;
+
+err_out:
+       debugfs_remove_recursive(clk_debugfs_root);
+       return err;
+}
+late_initcall(clk_debugfs_init);
+
+#endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
index 0fbcd0effd8e436fb0ac0351c46a835ec1ee7506..9a82b8874918d5c3fb16247d92a3cdd84623a4ad 100644 (file)
@@ -47,6 +47,9 @@ struct clk {
 
        struct clk_ops          *ops;
        int                 (*enable)(struct clk *, int enable);
+#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
+       struct dentry           *dent;  /* For visible tree hierarchy */
+#endif
 };
 
 /* other clocks which may be registered by board support */