@@ -3113,6 +3113,58 @@ static int clk_dbg_rate_set(void *data, u64 val)
}
DEFINE_SIMPLE_ATTRIBUTE(clk_dbg_option_rate, clk_dbg_rate_get, clk_dbg_rate_set, "%llu\n");
+
+static int clk_dbg_prepare_get(void *data, u64 *val)
+{
+ struct clk_core *core = data;
+
+ *val = core->prepare_count;
+
+ return 0;
+}
+
+static int clk_dbg_prepare_set(void *data, u64 val)
+{
+ struct clk_core *core = data;
+
+ if (val == 1)
+ return clk_core_prepare(core);
+
+ if (val == -1) {
+ clk_core_unprepare(core);
+ return 0;
+ }
+
+ pr_err("1: prepare, -1: unprepare\n");
+ return -EINVAL;
+}
+DEFINE_SIMPLE_ATTRIBUTE(clk_dbg_option_prepare, clk_dbg_prepare_get, clk_dbg_prepare_set, "%llu\n");
+
+static int clk_dbg_enable_get(void *data, u64 *val)
+{
+ struct clk_core *core = data;
+
+ *val = core->enable_count;
+
+ return 0;
+}
+
+static int clk_dbg_enable_set(void *data, u64 val)
+{
+ struct clk_core *core = data;
+
+ if (val == 1)
+ return clk_core_enable(core);
+
+ if (val == -1) {
+ clk_core_disable(core);
+ return 0;
+ }
+
+ pr_err("1: enable, -1: disable\n");
+ return -EINVAL;
+}
+DEFINE_SIMPLE_ATTRIBUTE(clk_dbg_option_enable, clk_dbg_enable_get, clk_dbg_enable_set, "%llu\n");
#endif
static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
@@ -3134,8 +3186,15 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
debugfs_create_ulong("clk_accuracy", 0444, root, &core->accuracy);
debugfs_create_u32("clk_phase", 0444, root, &core->phase);
debugfs_create_file("clk_flags", 0444, root, core, &clk_flags_fops);
+#ifdef CONFIG_COMMON_CLK_DEBUGFS_WRITE_ACCESS
+ debugfs_create_file("clk_prepare_count", 0644,
+ root, core, &clk_dbg_option_prepare);
+ debugfs_create_file("clk_enable_count", 0644,
+ core->dentry, core, &clk_dbg_option_enable);
+#else
debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count);
debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
+#endif
debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
debugfs_create_file("clk_duty_cycle", 0444, root, core,
The enable/prepare count variables can now be used to enable/disable/ prepare and un-prepare specific clocks. This is very useful for debugging purposes, but can be considered dangerous. Thus, it is protected by the same Kconfig option as the clk_rate modification option. Signed-off-by: Tero Kristo <t-kristo@ti.com> --- drivers/clk/clk.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)