devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] pwm: jz4740: Make disable operation compatible with TCU2 mode
@ 2018-01-06 16:58 Paul Cercueil
       [not found] ` <20180106165843.3461-1-paul-icTtO2rgO2OTuSrc4Mpeew@public.gmane.org>
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Paul Cercueil @ 2018-01-06 16:58 UTC (permalink / raw)
  To: Thierry Reding, Rob Herring, Mark Rutland
  Cc: linux-pwm, devicetree, linux-kernel, Maarten ter Huurne

From: Maarten ter Huurne <maarten@treewalker.org>

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>
---
 drivers/pwm/pwm-jz4740.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index a75ff3622450..2e41ba213f39 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,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-27 22:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-06 16:58 [PATCH 1/4] pwm: jz4740: Make disable operation compatible with TCU2 mode Paul Cercueil
     [not found] ` <20180106165843.3461-1-paul-icTtO2rgO2OTuSrc4Mpeew@public.gmane.org>
2018-01-06 16:58   ` [PATCH 2/4] pwm: pwm-jz4740: Implement set_polarity Paul Cercueil
2018-03-17 20:46     ` Paul Cercueil
2018-01-06 16:58 ` [PATCH 3/4] pwm: jz4740: Add support for devicetree Paul Cercueil
     [not found]   ` <20180106165843.3461-3-paul-icTtO2rgO2OTuSrc4Mpeew@public.gmane.org>
2018-01-19 19:44     ` Rob Herring
2018-01-06 16:58 ` [PATCH 4/4] pwm: jz4740: Enable for all Ingenic SoCs Paul Cercueil
2018-03-27 22:25 ` [PATCH 1/4] pwm: jz4740: Make disable operation compatible with TCU2 mode Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).