pwm: atmel: correct CDTY calculation
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>
Fri, 14 Mar 2014 14:19:09 +0000 (15:19 +0100)
committerThierry Reding <thierry.reding@gmail.com>
Tue, 18 Mar 2014 19:47:48 +0000 (20:47 +0100)
commit916030db4399f9237beef480fee6b11dd83cacd5
treef290ef1a4c72a5d6d0c0aea11b43062ddf80cfaf
parent8db9e29fe540c9640ea60f37ecf99d3a73bd12c5
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>
drivers/pwm/pwm-atmel.c