>From 97c030ef053c7f7aa09cfed3e273f6b5600c471b Mon Sep 17 00:00:00 2001 From: Tero Kristo Date: Fri, 21 Sep 2018 10:53:20 +0300 Subject: [PATCH 2/4] sci-clk: debug: add reparenting support via debugfs Signed-off-by: Tero Kristo --- drivers/clk/keystone/sci-clk.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 7edf8c8432b6..7df582bb4ceb 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -24,6 +24,7 @@ #include #include #include +#include #define SCI_CLK_SSC_ENABLE BIT(0) #define SCI_CLK_ALLOW_FREQ_CHANGE BIT(1) @@ -254,6 +255,36 @@ static int sci_clk_set_parent(struct clk_hw *hw, u8 index) index + 1 + clk->clk_id); } +static int dbg_pid_get(void *data, u64 *val) +{ + struct clk_hw *hw = data; + + *val = sci_clk_get_parent(hw); + + return 0; +} + +static int dbg_pid_set(void *data, u64 val) +{ + struct clk_hw *hw = data; + struct clk_hw *parent = clk_hw_get_parent_by_index(hw, val); + + if (!parent) + return -EINVAL; + + clk_hw_reparent(hw, parent); + + return sci_clk_set_parent(hw, val); +} + +DEFINE_SIMPLE_ATTRIBUTE(sci_parent_id_fops, dbg_pid_get, dbg_pid_set, "%llu\n"); + +static void sci_clk_debug_init(struct clk_hw *hw, struct dentry *dentry) +{ + debugfs_create_file("parent_id", S_IRUGO | S_IWUSR, dentry, + hw, &sci_parent_id_fops); +} + static const struct clk_ops sci_clk_ops = { .prepare = sci_clk_prepare, .unprepare = sci_clk_unprepare, @@ -263,6 +294,7 @@ static const struct clk_ops sci_clk_ops = { .set_rate = sci_clk_set_rate, .get_parent = sci_clk_get_parent, .set_parent = sci_clk_set_parent, + .debug_init = sci_clk_debug_init, }; /** -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki