Re: [PATCH 1/1] pwm: pca9685: fix gpio-only operation.

From: Sven Van Asbroeck
Date: Mon Apr 10 2017 - 12:08:24 EST


Thanks for the feedback Mika, I really appreciate it.

> How about implementing a real runtime PM in the driver? Then when the
> device is idle regardless of whether it is GPIO or PWM, the SLEEP bit is
> set and cleared accordingly.

The current code will keep driving pwms/leds even when these are
currently not exported in sysfs. Until the last export disappears.
That behaviour feels counter-intuitive to me.

Example:
1. export pwm1 and pwm2
echo 1 > export
echo 2 > export
2. configure/enable pwm1 and pwm2
3. enjoy the blinkenlights on your board
4. unexport pwm1
echo 1 > unexport
both pwms are still driven !
5. unexport pwm2
echo 2 > unexport
both pwms shut down !
6. export pwm1
echo 1 > export
both pwms come back on !

Do we want to get rid of this behaviour? I see two intuitive alternatives:

a) keep SLEEP off all the time, so LEDs are still driven even when no
pwms/gpios are exported.

Pro: simple, predictable
Con: not power efficient

b) when a pwm/gpio is unexported, turn off the LED. when all pwms/gpios
are unexported, set the SLEEP bit.

Pro: power efficient
Con: output turns off when gpio/pwm is unexported, this may surprise users

Sven