pwm: jz4740: Make PWM start with the active part
authorPaul Cercueil <paul@crapouillou.net>
Wed, 27 May 2020 11:52:24 +0000 (13:52 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Tue, 2 Jun 2020 12:24:26 +0000 (14:24 +0200)
commita020f22a4ff555386f136eb951e16e4cff709e01
tree725d04bb2259db4742e4eaca31654a656424ea4e
parent9017dc4fbd59c09463019ce494cfe36d654495a8
pwm: jz4740: Make PWM start with the active part

The PWM in Ingenic SoCs starts in inactive state until the internal
timer reaches the duty value, then becomes active until the timer
reaches the period value. In theory, we should then use (period - duty)
as the real duty value, as a high duty value would otherwise result in
the PWM pin being inactive most of the time.

This is the reason why the duty value was inverted in the driver until
now, but it still had the problem that it would not start with the
active part.

To address this remaining issue, the common trick is to invert the
duty, and invert the polarity when the PWM is enabled.

Since the duty was already inverted, and we invert it again, we now
program the hardware for the requested duty, and simply invert the
polarity when the PWM is enabled.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-jz4740.c