Re: pwm-sun4i: PWM backlight is not turned off on shutdown

From: Pascal Roeleven
Date: Wed Sep 02 2020 - 15:52:16 EST


Thank you for adding me. Emil (also added now) and I spent a while on trying to figure out how to solve this. The Allwinner PWM controller has some quirks.

Unfortunately I never got around to perform some more tests and fix it indefinitely. It's still on my todo list..

On 9/2/20 12:54 PM, Daniel Thompson wrote:
There's some rather odd logic in sun4i_pwm_apply() that results in the
PWM being disabled twice... once when it applies the initial config
and again after waiting for a duty_cycle.

That's true. To properly turn off the controller you have to turn the controller off first and keep the gate on for at least two full clock cycles. Then the gate must be turned off. Otherwise it might get stuck. That's probably what is trying to be done here.

On 2020-09-02 21:05, Andrey Lebedev wrote:
Indeed, this fixes the issue for me. The display goes dark reliably on
writing 4 to "/sys/.../bl_power" as well as when system is halted. I did
not notice any negative side effects so far.

Problems start to arise when combining bl_power and brightness setting in a particular order or at the same time (with for example a backlight driver which sets both bl_power and brightness). I can't recall exactly what caused problems and when, but one thing I was sure of is that timing was of the essence. Once I added some delays here and there it started to work.

If this patch works for you then that's great, but unfortunately it isn't a complete solution.

Regards,
Pascal