aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>2019-05-25 14:42:53 -0400
committerStephen Boyd <sboyd@kernel.org>2019-06-06 14:31:03 -0400
commit4c34282fb7d7a1d47a4d901554b574ea6b256cd5 (patch)
treea128f2fe524687e0645927e65ba28dab85777d88
parenta188339ca5a396acc588e5851ed7e19f66b0ebd9 (diff)
clk: pwm: implement the .get_duty_cycle callback
Commit 9fba738a53dda2 ("clk: add duty cycle support") added support for getting and setting the duty cycle of a clock. This implements the get_duty_cycle callback for PWM based clocks so the duty cycle is shown in the debugfs output (/sys/kernel/debug/clk/clk_summary). Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
-rw-r--r--drivers/clk/clk-pwm.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/clk/clk-pwm.c b/drivers/clk/clk-pwm.c
index 02b472a1f9b0..c0cd6a0ff7f8 100644
--- a/drivers/clk/clk-pwm.c
+++ b/drivers/clk/clk-pwm.c
@@ -47,10 +47,24 @@ static unsigned long clk_pwm_recalc_rate(struct clk_hw *hw,
47 return clk_pwm->fixed_rate; 47 return clk_pwm->fixed_rate;
48} 48}
49 49
50static int clk_pwm_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)
51{
52 struct clk_pwm *clk_pwm = to_clk_pwm(hw);
53 struct pwm_state state;
54
55 pwm_get_state(clk_pwm->pwm, &state);
56
57 duty->num = state.duty_cycle;
58 duty->den = state.period;
59
60 return 0;
61}
62
50static const struct clk_ops clk_pwm_ops = { 63static const struct clk_ops clk_pwm_ops = {
51 .prepare = clk_pwm_prepare, 64 .prepare = clk_pwm_prepare,
52 .unprepare = clk_pwm_unprepare, 65 .unprepare = clk_pwm_unprepare,
53 .recalc_rate = clk_pwm_recalc_rate, 66 .recalc_rate = clk_pwm_recalc_rate,
67 .get_duty_cycle = clk_pwm_get_duty_cycle,
54}; 68};
55 69
56static int clk_pwm_probe(struct platform_device *pdev) 70static int clk_pwm_probe(struct platform_device *pdev)