|
@@ -977,3 +977,128 @@ static int __init clk_disable_unused(void)
|
|
|
late_initcall(clk_disable_unused);
|
|
|
late_initcall(omap_clk_enable_autoidle_all);
|
|
|
#endif
|
|
|
+
|
|
|
+#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
|
|
|
+/*
|
|
|
+ * debugfs support to trace clock tree hierarchy and attributes
|
|
|
+ */
|
|
|
+
|
|
|
+#include <linux/debugfs.h>
|
|
|
+#include <linux/seq_file.h>
|
|
|
+
|
|
|
+static struct dentry *clk_debugfs_root;
|
|
|
+
|
|
|
+static int clk_dbg_show_summary(struct seq_file *s, void *unused)
|
|
|
+{
|
|
|
+ struct clk *c;
|
|
|
+ struct clk *pa;
|
|
|
+
|
|
|
+ mutex_lock(&clocks_mutex);
|
|
|
+ seq_printf(s, "%-30s %-30s %-10s %s\n",
|
|
|
+ "clock-name", "parent-name", "rate", "use-count");
|
|
|
+
|
|
|
+ list_for_each_entry(c, &clocks, node) {
|
|
|
+ pa = c->parent;
|
|
|
+ seq_printf(s, "%-30s %-30s %-10lu %d\n",
|
|
|
+ c->name, pa ? pa->name : "none", c->rate,
|
|
|
+ c->usecount);
|
|
|
+ }
|
|
|
+ mutex_unlock(&clocks_mutex);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int clk_dbg_open(struct inode *inode, struct file *file)
|
|
|
+{
|
|
|
+ return single_open(file, clk_dbg_show_summary, inode->i_private);
|
|
|
+}
|
|
|
+
|
|
|
+static const struct file_operations debug_clock_fops = {
|
|
|
+ .open = clk_dbg_open,
|
|
|
+ .read = seq_read,
|
|
|
+ .llseek = seq_lseek,
|
|
|
+ .release = single_release,
|
|
|
+};
|
|
|
+
|
|
|
+static int clk_debugfs_register_one(struct clk *c)
|
|
|
+{
|
|
|
+ int err;
|
|
|
+ struct dentry *d;
|
|
|
+ struct clk *pa = c->parent;
|
|
|
+
|
|
|
+ d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root);
|
|
|
+ if (!d)
|
|
|
+ return -ENOMEM;
|
|
|
+ c->dent = d;
|
|
|
+
|
|
|
+ d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags);
|
|
|
+ if (!d) {
|
|
|
+ err = -ENOMEM;
|
|
|
+ goto err_out;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+
|
|
|
+err_out:
|
|
|
+ debugfs_remove_recursive(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, node) {
|
|
|
+ err = clk_debugfs_register(c);
|
|
|
+ if (err)
|
|
|
+ goto err_out;
|
|
|
+ }
|
|
|
+
|
|
|
+ d = debugfs_create_file("summary", S_IRUGO,
|
|
|
+ d, NULL, &debug_clock_fops);
|
|
|
+ if (!d)
|
|
|
+ return -ENOMEM;
|
|
|
+
|
|
|
+ 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) */
|