diff options
author | Philip Chen <philipchen@google.com> | 2018-11-15 15:35:06 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-11-20 22:35:08 +0000 |
commit | 80f0e301768cf7e53cc98a5fcd6dc593dfecd597 (patch) | |
tree | 15ca01f2322b6f3ec68db6200c5ae8dc3c881937 | |
parent | b3049f1774998110e96db862364f185ffc148382 (diff) | |
download | chrome-ec-80f0e301768cf7e53cc98a5fcd6dc593dfecd597.tar.gz |
scarlet: Consider power state transition when throttling PD
When battery level changes or board suspend/resume, we call a hook
function, board_pd_voltage(), to check the chipset power status and
battery level. If the device is in S3 or S5 and the battery SOC > 90%,
we limit PD voltage to 5V.
However, during S0->S3 transition, there is a delay of 40+ milliseconds
between hook_notify(HOOK_CHIPSET_SUSPEND) and the chipset power status
really turning into S3.
Assuming the battery SOC = 95% and the device is in S0,
here is what can happen:
(1) Scarlet wants to suspend (S0->S3).
(2) board_pd_voltage() is called and checked chipset power status.
(3) Scarlet decides to not limit PD voltage because it finds the
power status is still S0S3.
(4) Scarlet finally enters S3, but PD voltage doesn't get limited,
even though all conditions meet.
So we should go ahead to limit PD voltage when the battery SOC > 90%
and the power state is S0S3.
BUG=b:78792296
BRANCH=scarlet
TEST=Put a dru in S0 with full battery power:
(1) Do S0->S5->S0, see PD voltage do 9V->5V->9V.
(2) Do S0->S3->S0, see PD voltage go 9V->5V->9V.
Change-Id: I1c2b823a3ac6dd7d6938ef7a76cf26931a50dea0
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/1338601
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Trybot-Ready: Philip Chen <philipchen@chromium.org>
-rw-r--r-- | board/scarlet/battery.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/board/scarlet/battery.c b/board/scarlet/battery.c index 294909eded..c36978636a 100644 --- a/board/scarlet/battery.c +++ b/board/scarlet/battery.c @@ -308,8 +308,9 @@ static void board_pd_voltage(void) int bat_level; bat_level = charge_get_percent(); - pd_limit_en = chipset_in_state(CHIPSET_STATE_ANY_OFF | - CHIPSET_STATE_ANY_SUSPEND) && bat_level > BAT_LEVEL_PD_LIMIT; + pd_limit_en = chipset_in_or_transitioning_to_state( + CHIPSET_STATE_ANY_OFF | CHIPSET_STATE_ANY_SUSPEND) && + bat_level > BAT_LEVEL_PD_LIMIT; pd_limit_5v(pd_limit_en); } |