[PATCH 3/4] clk: debug: add support for enabling / preparing clocks manually
From: Tero Kristo
Date: Mon Oct 01 2018 - 08:53:47 EST
Add support for enabling / disabling clocks manually from debugfs.
Setting 1 to prepare/enable counts calls corresponding enable routine
once, incrementing the usecounts by 1. Setting the same files as -1
does the unprepare / disable call similarly. Reading both files
returns the current usecount, as is done without this patch.
Signed-off-by: Tero Kristo <t-kristo@xxxxxx>
---
drivers/clk/clk.c | 54 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 3429680691bd..b40b3cae0c6b 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3107,6 +3107,56 @@ 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);
+ } else if (val == -1) {
+ clk_core_unprepare(core);
+ return 0;
+ } else {
+ 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);
+ } else if (val == -1) {
+ clk_core_disable(core);
+ return 0;
+ } else {
+ 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");
+
static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
{
struct dentry *root;
@@ -3121,8 +3171,8 @@ 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);
- debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count);
- debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
+ debugfs_create_file("clk_prepare_count", 0666, root, core, &clk_dbg_option_prepare);
+ debugfs_create_file("clk_enable_count", 0666, root, core, &clk_dbg_option_enable);
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,
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
--------------E535A013B30481111D3FF646
Content-Type: text/x-patch;
name="0004-dss1_alwon_fck_3430es2-test-hacks.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="0004-dss1_alwon_fck_3430es2-test-hacks.patch"