]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: CLKFW: Initial debugfs support for omap clock framework
authorHiroshi DOYU <Hiroshi.DOYU@nokia.com>
Thu, 17 Apr 2008 10:51:34 +0000 (13:51 +0300)
committerTony Lindgren <tony@atomide.com>
Mon, 21 Apr 2008 18:39:29 +0000 (11:39 -0700)
debugfs can provide the infrastructure to trace the dependencies of
clock tree hierarchy quite visibly. This patch enables to keep track
of clock tree hierarchy and expose their attributes under each clock
directry as below:

omap:~# tree -d -L 2 /debug/clock/omap_32k_fck/
/debug/clock/omap_32k_fck/
|-- gpt10_fck
|-- gpt11_fck
|-- gpt1_fck
|-- per_32k_alwon_fck
|   |-- gpio2_fck
|   |-- gpio3_fck
|   |-- gpio4_fck
|   |-- gpio5_fck
|   |-- gpio6_fck
|   `-- wdt3_fck
|-- ts_fck
`-- wkup_32k_fck
    |-- gpio1_fck
    `-- wdt2_fck

14 directories
omap:~# tree  /debug/clock/omap_32k_fck/gpt10_fck/
/debug/clock/omap_32k_fck/gpt10_fck/
|-- flags
|-- rate
`-- usecount

0 directories, 3 files

Although, compared with David Brownell's small patch, this may look
bit overkilling, I expect that this debugfs can deal with other PRCM
complexities at the same time. For example, powerdomain dependencies
can be expressed by using symbolic links of these clocks if
powerdomain supports dubgfs as well.

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/plat-omap/clock.c
include/asm-arm/arch-omap/clock.h

index 1bd878145e30a3a487f23a36c7ebdd046cc5dec5..2ae87bfda807c40347c61cd06ade51ae2962f2b4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  linux/arch/arm/plat-omap/clock.c
  *
- *  Copyright (C) 2004 - 2005 Nokia corporation
+ *  Copyright (C) 2004 - 2008 Nokia corporation
  *  Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
  *
  *  Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com>
@@ -21,6 +21,7 @@
 #include <linux/clk.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/debugfs.h>
 
 #include <asm/io.h>
 #include <asm/semaphore.h>
@@ -506,3 +507,94 @@ int __init omap_ck_init(void)
 }
 __initcall(omap_ck_init);
 #endif
+
+#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;
+       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 (IS_ERR(d))
+               return PTR_ERR(d);
+       c->dent = d;
+
+       d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount);
+       if (IS_ERR(d)) {
+               err = PTR_ERR(d);
+               goto err_out;
+       }
+       d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate);
+       if (IS_ERR(d)) {
+               err = PTR_ERR(d);
+               goto err_out;
+       }
+       d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags);
+       if (IS_ERR(d)) {
+               err = PTR_ERR(d);
+               goto err_out;
+       }
+       return 0;
+
+err_out:
+       d = c->dent;
+       list_for_each_entry(child, &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 (IS_ERR(d))
+               return PTR_ERR(d);
+       clk_debugfs_root = d;
+
+       list_for_each_entry(c, &clocks, node) {
+               err = clk_debugfs_register(c);
+               if (err)
+                       goto err_out;
+       }
+       return 0;
+err_out:
+       debugfs_remove(clk_debugfs_root); /* REVISIT: Cleanup correctly */
+       return err;
+}
+late_initcall(clk_debugfs_init);
+
+#endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
index cce55badff4e3ee7720979a8a5c86e388af87404..811af844cd72c53ad1c8a5e06c8c151d0ae18f23 100644 (file)
@@ -86,6 +86,9 @@ struct clk {
        __u8                    rate_offset;
        __u8                    src_offset;
 #endif
+#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
+       struct dentry           *dent;  /* For visible tree hierarchy */
+#endif
 };
 
 struct clk_functions {