From: Tony Lindgren <tony@atomide.com>
To: linux-arm-kernel@lists.arm.linux.org.uk
Cc: linux-omap@vger.kernel.org, Hiroshi DOYU <Hiroshi.DOYU@nokia.com>,
Tony Lindgren <tony@atomide.com>
Subject: [PATCH 15/21] ARM: OMAP: CLKFW: Initial debugfs support for omap clock framework
Date: Fri, 6 Jun 2008 18:30:47 -0700 [thread overview]
Message-ID: <1212802253-17797-16-git-send-email-tony@atomide.com> (raw)
In-Reply-To: <1212802253-17797-15-git-send-email-tony@atomide.com>
From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
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>
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 2db5580..c2e741d 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -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>
@@ -22,6 +22,7 @@
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/cpufreq.h>
+#include <linux/debugfs.h>
#include <asm/io.h>
@@ -33,41 +34,6 @@ static DEFINE_SPINLOCK(clockfw_lock);
static struct clk_functions *arch_clock;
-#ifdef CONFIG_PM_DEBUG
-
-static void print_parents(struct clk *clk)
-{
- struct clk *p;
- int printed = 0;
-
- list_for_each_entry(p, &clocks, node) {
- if (p->parent == clk && p->usecount) {
- if (!clk->usecount && !printed) {
- printk("MISMATCH: %s\n", clk->name);
- printed = 1;
- }
- printk("\t%-15s\n", p->name);
- }
- }
-}
-
-void clk_print_usecounts(void)
-{
- unsigned long flags;
- struct clk *p;
-
- spin_lock_irqsave(&clockfw_lock, flags);
- list_for_each_entry(p, &clocks, node) {
- if (p->usecount)
- printk("%-15s: %d\n", p->name, p->usecount);
- print_parents(p);
-
- }
- spin_unlock_irqrestore(&clockfw_lock, flags);
-}
-
-#endif
-
/*-------------------------------------------------------------------------
* Standard clock functions defined in include/linux/clk.h
*-------------------------------------------------------------------------*/
@@ -446,3 +412,93 @@ int __init clk_init(struct clk_functions * custom_clocks)
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;
+ 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) */
diff --git a/include/asm-arm/arch-omap/clock.h b/include/asm-arm/arch-omap/clock.h
index 12a5e4d..8490fbb 100644
--- a/include/asm-arm/arch-omap/clock.h
+++ b/include/asm-arm/arch-omap/clock.h
@@ -71,6 +71,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 cpufreq_frequency_table;
next prev parent reply other threads:[~2008-06-07 1:31 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <omap-upstream-20080607182613-0-21>
2008-06-07 1:30 ` [PATCH 00/21] Omap upstream patches for post 2.6.26 Tony Lindgren
2008-06-07 1:30 ` [PATCH 01/21] ARM: OMAP: DMTimer: Use posted mode Tony Lindgren
2008-06-07 1:30 ` [PATCH 02/21] ARM: OMAP: DMTimer: Optimize by adding load and start Tony Lindgren
2008-06-07 1:30 ` [PATCH 03/21] ARM: OMAP: Add OMAP3430 base defines Tony Lindgren
2008-06-07 1:30 ` [PATCH 04/21] ARM: OMAP: DMA: Make channels dynamic for multi-boot Tony Lindgren
2008-06-07 1:30 ` [PATCH 05/21] ARM: OMAP: DMA: Remove __REG access Tony Lindgren
2008-06-07 1:30 ` [PATCH 06/21] ARM: OMAP: DMA: Clean-up code Tony Lindgren
2008-06-07 1:30 ` [PATCH 07/21] ARM: OMAP: SRAM: Move sram-fn.S from plat-omap to mach-omap1 Tony Lindgren
2008-06-07 1:30 ` [PATCH 08/21] ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S Tony Lindgren
2008-06-07 1:30 ` [PATCH 09/21] ARM: OMAP: SRAM: Split sram24xx.S into sram242x.S and sram243x.S Tony Lindgren
2008-06-07 1:30 ` [PATCH 10/21] ARM: OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Tony Lindgren
2008-06-07 1:30 ` [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 code Tony Lindgren
2008-06-07 1:30 ` [PATCH 12/21] ARM: OMAP: McBSP: Add support for mcbsp on mach-omap1 Tony Lindgren
2008-06-07 1:30 ` [PATCH 13/21] ARM: OMAP: McBSP: Add support for mcbsp on mach-omap2 Tony Lindgren
2008-06-07 1:30 ` [PATCH 14/21] ARM: OMAP: Clean up interrupt lines to fix warnings for multi-omap Tony Lindgren
2008-06-07 1:30 ` Tony Lindgren [this message]
2008-06-07 1:30 ` [PATCH 16/21] ARM: OMAP: Change omap_cf.c and omap_nor.c to use omap_readw/writew instead of __REG Tony Lindgren
[not found] ` <1212802253-17797-17-git-send-email-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2008-06-07 1:30 ` [PATCH 17/21] ARM: OMAP: USB: Change omap USB code to use omap_read/write " Tony Lindgren
2008-06-07 1:30 ` [PATCH 18/21] ARM: OMAP: Remove __REG access for multi-omap Tony Lindgren
2008-06-07 1:30 ` [PATCH 19/21] ARM: OMAP: Introduce omap_globals and prcm access functions " Tony Lindgren
2008-06-07 1:30 ` [PATCH 20/21] ARM: OMAP: Turn CM and PRM access into functions Tony Lindgren
2008-06-07 1:30 ` [PATCH 21/21] ARM: OMAP: Add OMAP chip type structure; clean up mach-omap2/id.c Tony Lindgren
2008-06-14 9:22 ` Russell King - ARM Linux
2008-06-17 15:43 ` Paul Walmsley
2008-06-14 9:17 ` [PATCH 20/21] ARM: OMAP: Turn CM and PRM access into functions Russell King - ARM Linux
2008-06-14 9:09 ` [PATCH 19/21] ARM: OMAP: Introduce omap_globals and prcm access functions for multi-omap Russell King - ARM Linux
2008-06-17 7:46 ` Tony Lindgren
2008-06-22 14:08 ` Russell King - ARM Linux
2008-06-14 9:06 ` [PATCH 18/21] ARM: OMAP: Remove __REG access " Russell King - ARM Linux
2008-06-14 8:17 ` [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 code Russell King - ARM Linux
2008-06-17 8:41 ` Tony Lindgren
2008-06-23 9:39 ` Tony Lindgren
2008-06-23 10:34 ` [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting intoomap1 " shekhar, chandra
2008-06-14 8:19 ` [PATCH 10/21] ARM: OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Russell King - ARM Linux
2008-06-23 9:02 ` Tony Lindgren
2008-06-14 8:05 ` [PATCH 08/21] ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S Russell King - ARM Linux
2008-06-17 7:36 ` Tony Lindgren
2008-06-22 14:06 ` Russell King - ARM Linux
2008-06-17 7:34 ` [PATCH 07/21] ARM: OMAP: SRAM: Move sram-fn.S from plat-omap to mach-omap1 Tony Lindgren
2008-06-22 14:06 ` Russell King - ARM Linux
2008-06-14 8:13 ` [PATCH 06/21] ARM: OMAP: DMA: Clean-up code Russell King - ARM Linux
2008-06-17 7:27 ` Tony Lindgren
2008-06-22 14:06 ` Russell King - ARM Linux
2008-06-14 8:04 ` [PATCH 05/21] ARM: OMAP: DMA: Remove __REG access Russell King - ARM Linux
2008-06-17 7:22 ` Tony Lindgren
2008-06-22 14:05 ` Russell King - ARM Linux
2008-06-14 8:03 ` [PATCH 04/21] ARM: OMAP: DMA: Make channels dynamic for multi-boot Russell King - ARM Linux
2008-06-14 8:01 ` [PATCH 03/21] ARM: OMAP: Add OMAP3430 base defines Russell King - ARM Linux
2008-06-17 7:19 ` Tony Lindgren
2008-06-14 8:20 ` [PATCH 02/21] ARM: OMAP: DMTimer: Optimize by adding load and start Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1212802253-17797-16-git-send-email-tony@atomide.com \
--to=tony@atomide.com \
--cc=Hiroshi.DOYU@nokia.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-omap@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox