aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm/pwm-twl.c
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2016-03-29 14:55:45 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-09-05 01:13:47 -0400
commit45c0ce847a99ca053d432ea98e4ff55d88357d7e (patch)
tree326a9da74853c23a24f940beb6b79d045e4c6174 /drivers/pwm/pwm-twl.c
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
pwm: twl: Reliably disable TWL6030 PWMs
The current TWL6030 code for the TWL PWM driver does not reliably disable the PWM output, as tested with LEDs. The previous commit to that driver introduced that regression. However, it does make sense to disable the PWM clock after resetting the PWM, but for some obscure reason, doing it all at once simply doesn't work. The TWL6030 datasheet mentions that PWMs have to be disabled in two distinct steps. However, clearing the clock enable bit in a second step (after issuing a reset first) does not work. The only approach that works is the one that was in place before the previous commit to the driver. It consists in enabling the PWM clock after issuing a reset. This is what TI kernel trees and production code seem to be using. However, adding an extra step to disable the PWM clock seems to work reliably, despite looking quite odd. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-twl.c')
-rw-r--r--drivers/pwm/pwm-twl.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
index 04f76725d591..7a993b056638 100644
--- a/drivers/pwm/pwm-twl.c
+++ b/drivers/pwm/pwm-twl.c
@@ -269,6 +269,22 @@ static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
269 goto out; 269 goto out;
270 } 270 }
271 271
272 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN);
273
274 ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_TOGGLE3_REG);
275 if (ret < 0) {
276 dev_err(chip->dev, "%s: Failed to disable PWM\n", pwm->label);
277 goto out;
278 }
279
280 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN);
281
282 ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_TOGGLE3_REG);
283 if (ret < 0) {
284 dev_err(chip->dev, "%s: Failed to disable PWM\n", pwm->label);
285 goto out;
286 }
287
272 twl->twl6030_toggle3 = val; 288 twl->twl6030_toggle3 = val;
273out: 289out:
274 mutex_unlock(&twl->mutex); 290 mutex_unlock(&twl->mutex);