mirror of https://gitee.com/openkylin/linux.git
pwm: atmel: correct CDTY calculation
From the datasheet, the actual duty cycle is: (period - (1 / clk) * CDTY) / period This actually correct the polarity of the PWM and solves the issue that pwm-leds exhibits: when setting a duty cycle of 0 and then disabling a channel, the level was wrong (1 when the polarity was normal and 0 when the polarity was inversed). Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
parent
8db9e29fe5
commit
916030db43
|
@ -133,7 +133,7 @@ static int atmel_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
prd = div;
|
prd = div;
|
||||||
div *= duty_ns;
|
div *= duty_ns;
|
||||||
do_div(div, period_ns);
|
do_div(div, period_ns);
|
||||||
dty = div;
|
dty = prd - div;
|
||||||
|
|
||||||
ret = clk_enable(atmel_pwm->clk);
|
ret = clk_enable(atmel_pwm->clk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
Loading…
Reference in New Issue