All of lore.kernel.org
 help / color / mirror / Atom feed
* About disabling sun4i-pwm
@ 2018-02-14 17:17 Emil Lenngren
  0 siblings, 0 replies; only message in thread
From: Emil Lenngren @ 2018-02-14 17:17 UTC (permalink / raw)
  To: linux-pwm

Hi. I saw some discussions on disabling the PWM for sun4i and some
troubles about if it was being disabled during an active pulse, it
doesn't turn off the output but it stays active.

The original code is something like the following:
val = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG);
val &= ~BIT_CH(PWM_EN, pwm->hwpwm);
val &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm);
sun4i_pwm_writel(sun4i_pwm, val, PWM_CTRL_REG);

A suggested fix was to add a delay so it gets disabled during a low pulse.

But instead of the delay, I found it seems to be enough first writing
the ctrl reg with the PWM_EN bit disabled and then again writing the
ctrl reg with the PWM_CLK_GATING bit disabled, like this:

val = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG);
val &= ~BIT_CH(PWM_EN, pwm->hwpwm);
sun4i_pwm_writel(sun4i_pwm, val, PWM_CTRL_REG);
val &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm);
sun4i_pwm_writel(sun4i_pwm, val, PWM_CTRL_REG);

I have an Allwinner R8 chip, so not sure if that applies for the other
chips though. Anyone who has tested this more simpler fix?

/Emil

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-14 17:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14 17:17 About disabling sun4i-pwm Emil Lenngren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.