Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6580fd17 authored by Paul Cercueil's avatar Paul Cercueil Committed by Thierry Reding
Browse files

pwm: jz4740: Force TCU2 channels to return to their init level



When the PWM mode of TCU2 channels is disabled, their corresponding pin
does not always return to its initial level. Force this by using a small
trick: we set duty > period, which is an invalid configuration for the
hardware, which then correctly resets the pin to the initial level.

Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 1ac99c58
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -72,7 +72,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.
	/*
	 * Set duty > period. This trick allows the TCU channels in TCU2 mode to
	 * properly return to their init level.
	 */
	jz4740_timer_set_duty(pwm->hwpwm, 0xffff);
	jz4740_timer_set_period(pwm->hwpwm, 0x0);

	/*
	 * 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.
	 */