diff options
author | Maarten ter Huurne <maarten@treewalker.org> | 2018-01-06 17:58:40 +0100 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2018-03-28 00:22:03 +0200 |
commit | df56b1712d57863e9686673bb13803dcd8a82f7a (patch) | |
tree | c0fc618f24474a7bfa1fc361985fb127560c1bb8 /drivers/pwm | |
parent | 1f6eefeb7cd45360397fb5d3f08ce9ec41e80b17 (diff) | |
download | op-kernel-dev-df56b1712d57863e9686673bb13803dcd8a82f7a.zip op-kernel-dev-df56b1712d57863e9686673bb13803dcd8a82f7a.tar.gz |
pwm: jz4740: Make disable operation compatible with TCU2 mode
On the JZ4750 and later SoCs, channel 1 and 2 operate in a different
way (TCU2 mode) as the other channels. If a TCU2 mode counter is
stopped before its PWM functionality is disabled, the output is not
guaranteed to return to the initial level.
Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/pwm-jz4740.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index a75ff36..2e41ba2 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -71,9 +71,15 @@ static void jz4740_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) { uint32_t ctrl = jz4740_timer_get_ctrl(pwm->hwpwm); + /* Disable PWM output. + * In TCU2 mode (channel 1/2 on JZ4750+), this must be done before the + * counter is stopped, while in TCU1 mode the order does not matter. + */ ctrl &= ~JZ_TIMER_CTRL_PWM_ENABLE; - jz4740_timer_disable(pwm->hwpwm); jz4740_timer_set_ctrl(pwm->hwpwm, ctrl); + + /* Stop counter */ + jz4740_timer_disable(pwm->hwpwm); } static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, |