mbox series

[v2,0/5] pwm: pxa: Fixes for enable/disable transitions

Message ID 20221003015546.202308-1-doug@schmorgal.com
Headers show
Series pwm: pxa: Fixes for enable/disable transitions | expand

Message

Doug Brown Oct. 3, 2022, 1:55 a.m. UTC
I ran into a couple of problems while getting this driver working on the
PXA168. It wouldn't always activate properly when I turned it on, and it
wouldn't always deactivate properly when I turned it off. These patches
fix issues with the clock enable/disable transitions.

With these patches applied, the driver works flawlessly with my use
cases on the PXA168. I don't have any other PXAxxx devices to test with.

Changes since v1:

- Remove pxa_pwm_enable and pxa_pwm_disable.
- Reorganize pxa_pwm_apply based on Uwe's suggestions.
- Enable this driver with ARCH_MMP for the PXA168.
- Add delay after clock is disabled (and inhibit brief on/off blips).

After applying the first round of suggested fixes, I discovered (while
using it as a PWM backlight) that I was once again being affected by the
"too quick" on->off->on transitions, which resulted in silent failure.
Hopefully this isn't too crazy, but I fixed it by adding a delay to
allow the last period to finish after the clock is requested to be
disabled. When you turn the clock off, it stays latched on until the
period finishes (because PWMCR_SD is not set). If you try to turn it
back on during this time, the request is ignored and it shuts off
anyway. Waiting a full period before attempting to start the clock again
avoids the problem.

I also inhibited register setup if PWM is already disabled and staying
disabled in an attempt to avoid unnecessary brief on/off "blips".

Doug Brown (5):
  pwm: pxa: Remove pxa_pwm_enable/disable
  pwm: pxa: Set duty cycle to 0 when disabling PWM
  pwm: pxa: Remove clk enable/disable from pxa_pwm_config
  pwm: pxa: Wait for final PWM period to finish
  pwm: pxa: Enable for MMP platform

 drivers/pwm/Kconfig   |  2 +-
 drivers/pwm/pwm-pxa.c | 64 ++++++++++++++++++++++---------------------
 2 files changed, 34 insertions(+), 32 deletions(-)