|
@@ -455,3 +455,86 @@ static int clock_rate_show(void *data, u64 *val)
|
|
}
|
|
}
|
|
DEFINE_SIMPLE_ATTRIBUTE(clock_rate_fops, clock_rate_show, NULL, "%llu\n");
|
|
DEFINE_SIMPLE_ATTRIBUTE(clock_rate_fops, clock_rate_show, NULL, "%llu\n");
|
|
|
|
|
|
|
|
+static int clk_debugfs_register_one(struct clk *c)
|
|
|
|
+{
|
|
|
|
+ int err;
|
|
|
|
+ struct dentry *d;
|
|
|
|
+ struct clk *pa = c->parent;
|
|
|
|
+ char s[255];
|
|
|
|
+ char *p = s;
|
|
|
|
+
|
|
|
|
+ p += sprintf(p, "%s", c->devname);
|
|
|
|
+
|
|
|
|
+ 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_file("rate", S_IRUGO, c->dent, c, &clock_rate_fops);
|
|
|
|
+ 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 = -ENOMEM;
|
|
|
|
+
|
|
|
|
+ d = debugfs_create_dir("clock", NULL);
|
|
|
|
+ if (!d)
|
|
|
|
+ return -ENOMEM;
|
|
|
|
+ clk_debugfs_root = d;
|
|
|
|
+
|
|
|
|
+ d = debugfs_create_file("clock_tree", S_IRUGO, clk_debugfs_root, NULL,
|
|
|
|
+ &clock_tree_fops);
|
|
|
|
+ if (!d)
|
|
|
|
+ goto err_out;
|
|
|
|
+
|
|
|
|
+ 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) */
|