pwm: pwm-samsung: Trigger manual update when disabling PWM
authorMårten Lindahl <marten.lindahl@axis.com>
Thu, 9 Sep 2021 10:10:42 +0000 (12:10 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Fri, 5 Nov 2021 10:51:42 +0000 (11:51 +0100)
commit5d82e661398e06fa32dc7e11909df5dc34c808d2
treea9995cf33f13c694af8eb70ec57482f82729ed3f
parent6facd84083485dff109f1f78cbf6a1d760efc939
pwm: pwm-samsung: Trigger manual update when disabling PWM

When duty-cycle is at full level (100%), the TCNTn and TCMPn registers
needs to be flushed in order to disable the signal. The PWM manual does
not say anything about this, but states that only clearing the TCON
auto-reload bit should be needed, and this seems to be true when the PWM
duty-cycle is not at full level. This can be observed on an Axis
ARTPEC-8, by running:

  echo <period> > pwm/period
  echo <period> > pwm/duty_cycle
  echo 1 > pwm/enable
  echo 0 > pwm/enable

Since the TCNTn and TCMPn registers are activated when enabling the PWM
(setting TCON auto-reload bit), and are not touched when disabling the
PWM, the double buffered auto-reload function seems to be still active.
Lowering duty-cycle, and restoring it again in between the enabling and
disabling, makes the disable work since it triggers a reload of the
TCNTn and TCMPn registers.

Fix this by securing a reload of the TCNTn and TCMPn registers when
disabling the PWM and having a full duty-cycle.

Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-samsung.c