Skip to content

Commit 10fa811

Browse files
bebarinorkhuangtao
authored andcommitted
UPSTREAM: clk: pwm: Use pwm_get_args() where appropriate
The PWM framework has clarified the concept of reference PWM config (the platform dependent config retrieved from the DT or the PWM lookup table) and real PWM state. Use pwm_get_args() when the PWM user wants to retrieve this reference config and not the current state. This is part of the rework allowing the PWM framework to support hardware readout and expose real PWM state even when the PWM has just been requested (before the user calls pwm_config/enable/disable()). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com> (cherry picked from commit dd0b38b7ca0d8c8aadcf8a17d7c90d36ab8ab6e4) Change-Id: I54c4b3853359b5fa41f8f949b504f82c6f069034 Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
1 parent 6724059 commit 10fa811

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

drivers/clk/clk-pwm.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static int clk_pwm_probe(struct platform_device *pdev)
5959
struct clk_init_data init;
6060
struct clk_pwm *clk_pwm;
6161
struct pwm_device *pwm;
62+
struct pwm_args pargs;
6263
const char *clk_name;
6364
struct clk *clk;
6465
int ret;
@@ -71,22 +72,28 @@ static int clk_pwm_probe(struct platform_device *pdev)
7172
if (IS_ERR(pwm))
7273
return PTR_ERR(pwm);
7374

74-
if (!pwm->period) {
75+
pwm_get_args(pwm, &pargs);
76+
if (!pargs.period) {
7577
dev_err(&pdev->dev, "invalid PWM period\n");
7678
return -EINVAL;
7779
}
7880

7981
if (of_property_read_u32(node, "clock-frequency", &clk_pwm->fixed_rate))
80-
clk_pwm->fixed_rate = NSEC_PER_SEC / pwm->period;
82+
clk_pwm->fixed_rate = NSEC_PER_SEC / pargs.period;
8183

82-
if (pwm->period != NSEC_PER_SEC / clk_pwm->fixed_rate &&
83-
pwm->period != DIV_ROUND_UP(NSEC_PER_SEC, clk_pwm->fixed_rate)) {
84+
if (pargs.period != NSEC_PER_SEC / clk_pwm->fixed_rate &&
85+
pargs.period != DIV_ROUND_UP(NSEC_PER_SEC, clk_pwm->fixed_rate)) {
8486
dev_err(&pdev->dev,
8587
"clock-frequency does not match PWM period\n");
8688
return -EINVAL;
8789
}
8890

89-
ret = pwm_config(pwm, (pwm->period + 1) >> 1, pwm->period);
91+
/*
92+
* FIXME: pwm_apply_args() should be removed when switching to the
93+
* atomic PWM API.
94+
*/
95+
pwm_apply_args(pwm);
96+
ret = pwm_config(pwm, (pargs.period + 1) >> 1, pargs.period);
9097
if (ret < 0)
9198
return ret;
9299

0 commit comments

Comments
 (0)