mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
clk: pwm: implement the .get_duty_cycle callback
Commit 9fba738a53
("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>
This commit is contained in:
parent
a188339ca5
commit
4c34282fb7
1 changed files with 14 additions and 0 deletions
|
@ -47,10 +47,24 @@ static unsigned long clk_pwm_recalc_rate(struct clk_hw *hw,
|
|||
return clk_pwm->fixed_rate;
|
||||
}
|
||||
|
||||
static int clk_pwm_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)
|
||||
{
|
||||
struct clk_pwm *clk_pwm = to_clk_pwm(hw);
|
||||
struct pwm_state state;
|
||||
|
||||
pwm_get_state(clk_pwm->pwm, &state);
|
||||
|
||||
duty->num = state.duty_cycle;
|
||||
duty->den = state.period;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct clk_ops clk_pwm_ops = {
|
||||
.prepare = clk_pwm_prepare,
|
||||
.unprepare = clk_pwm_unprepare,
|
||||
.recalc_rate = clk_pwm_recalc_rate,
|
||||
.get_duty_cycle = clk_pwm_get_duty_cycle,
|
||||
};
|
||||
|
||||
static int clk_pwm_probe(struct platform_device *pdev)
|
||||
|
|
Loading…
Reference in a new issue