diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2022-11-22 15:07:31 +0200 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2022-11-22 18:19:39 -0800 |
commit | ac49a19280dfc229c4f2cd262787d27b91b944ea (patch) | |
tree | 165b1a2f58b0e420ced7e91f524de7e5ab2a1b69 /drivers/clk/clk-fractional-divider.c | |
parent | 7fffdb777371cbc20929cc648509765e1923937d (diff) |
clk: fractional-divider: Show numerator and denominator in debugfs
It's very useful to see what are the values of the fractional divider.
For that, add respective debugfs files.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221122130732.48537-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/clk-fractional-divider.c')
-rw-r--r-- | drivers/clk/clk-fractional-divider.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c index 5c6f1d0f8fb4..b6b52b79d671 100644 --- a/drivers/clk/clk-fractional-divider.c +++ b/drivers/clk/clk-fractional-divider.c @@ -39,6 +39,7 @@ */ #include <linux/clk-provider.h> +#include <linux/debugfs.h> #include <linux/io.h> #include <linux/math.h> #include <linux/module.h> @@ -193,10 +194,45 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate, return 0; } +#ifdef CONFIG_DEBUG_FS +static int clk_fd_numerator_get(void *hw, u64 *val) +{ + struct u32_fract fract; + + clk_fd_get_div(hw, &fract); + + *val = fract.numerator; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(clk_fd_numerator_fops, clk_fd_numerator_get, NULL, "%llu\n"); + +static int clk_fd_denominator_get(void *hw, u64 *val) +{ + struct u32_fract fract; + + clk_fd_get_div(hw, &fract); + + *val = fract.denominator; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(clk_fd_denominator_fops, clk_fd_denominator_get, NULL, "%llu\n"); + +static void clk_fd_debug_init(struct clk_hw *hw, struct dentry *dentry) +{ + debugfs_create_file("numerator", 0444, dentry, hw, &clk_fd_numerator_fops); + debugfs_create_file("denominator", 0444, dentry, hw, &clk_fd_denominator_fops); +} +#endif + const struct clk_ops clk_fractional_divider_ops = { .recalc_rate = clk_fd_recalc_rate, .round_rate = clk_fd_round_rate, .set_rate = clk_fd_set_rate, +#ifdef CONFIG_DEBUG_FS + .debug_init = clk_fd_debug_init, +#endif }; EXPORT_SYMBOL_GPL(clk_fractional_divider_ops); |