chip/stm32/pwm: Prevent sleeping while PWM output is active

STM32F0 cannot keep PWM output active when chip is in deep sleep.

The only other board that uses both CONFIG_LOW_POWER_IDLE
and CONFIG_PWM on stm32 is jerry, and this logic should also apply
to it.

Also, switch using_pwm from array to bitmask to simplify handling.

BRANCH=none
BUG=b:36173380
TEST=On AP, tell it to autosuspend hammer:
     echo auto > /sys/bus/usb/devices/1-2/power/control
     Then see, using idlestats, that hammer does to deep sleep.
     In hammer console: pwm 0 50, see that PWM output is stable,
     idlestats shows EC does not sleep.
     In hammer console: pwm 0 -1, idlestats shows EC sleeps again.

Change-Id: Ic74c1905364fe4335239da95a99193d0e3e979f7
Reviewed-on: https://chromium-review.googlesource.com/541115
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Nicolas Boichat
2017-06-20 09:07:52 +08:00
committed by chrome-bot
parent d68b1ca803
commit e3336f4c8d
2 changed files with 21 additions and 8 deletions

View File

@@ -388,6 +388,7 @@ enum {
SLEEP_MASK_I2C_SLAVE = (1 << 7), /* I2C slave communication ongoing */
SLEEP_MASK_FAN = (1 << 8), /* Fan control loop ongoing */
SLEEP_MASK_USB_DEVICE = (1 << 9), /* Generic USB device in use */
SLEEP_MASK_PWM = (1 << 10), /* PWM output is enabled */
SLEEP_MASK_FORCE_NO_DSLEEP = (1 << 15), /* Force disable. */