pwm: pca9685: Switch to atomic API
authorClemens Gruber <clemens.gruber@pqgruber.com>
Thu, 15 Apr 2021 12:14:48 +0000 (14:14 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Fri, 23 Apr 2021 16:44:55 +0000 (18:44 +0200)
commit9af1fba33b5751d71c0e6727a875b9fd7d8a99de
tree0696057e620fb2715c380d3cafc169723bdaccbf
parent64d7d074acd52e1bdff621f2cb86c0aae9bcef80
pwm: pca9685: Switch to atomic API

The switch to the atomic API goes hand in hand with a few fixes to
previously experienced issues:
- The duty cycle is no longer lost after disable/enable (previously the
  OFF registers were cleared in disable and the user was required to
  call config to restore the duty cycle settings)
- If one sets a period resulting in the same prescale register value,
  the sleep and write to the register is now skipped
- Previously, only the full ON bit was toggled in GPIO mode (and full
  OFF cleared if set to high), which could result in both full OFF and
  full ON not being set and on=0, off=0, which is not allowed according
  to the datasheet
- The OFF registers were reset to 0 in probe, which could lead to the
  forbidden on=0, off=0. Fixed by resetting to POR default (full OFF)

Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-pca9685.c