diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2022-05-09 22:13:41 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-11 21:18:25 +0000 |
commit | e7eab0d5b6a56119454dd4e0c577a5387f0404f8 (patch) | |
tree | 95c66fef2fd1d23d9b23cdad22376970ce798408 | |
parent | 1ad60ff66e3399d2efd1d8a7c48a082a77c44621 (diff) | |
download | chrome-ec-e7eab0d5b6a56119454dd4e0c577a5387f0404f8.tar.gz |
PCHG: Don't wake up device if lid is closed
Currently, a PCHG device wakes up the system even with the lid is
closed. Since the lid is closed, the system would re-suspend after 30
seconds but this is a little wasting power.
This patch makes the PCHG subsystem prevent device an attach or detach
event from resuming the system if the lid is closed.
BUG=b:192098599
BRANCH=None
TEST=Suspend CoachZ by closing the lid. Verify device doesn't resume by
attacing or removing a stylus.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I11b6fbf30270174048de215a27905524a04a40bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3636448
Reviewed-by: Parth Malkan <parthmalkan@google.com>
-rw-r--r-- | common/peripheral_charger.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/common/peripheral_charger.c b/common/peripheral_charger.c index dedd254df7..024379fe58 100644 --- a/common/peripheral_charger.c +++ b/common/peripheral_charger.c @@ -8,6 +8,7 @@ #include "common.h" #include "hooks.h" #include "host_command.h" +#include "lid_switch.h" #include "mkbp_event.h" #include "peripheral_charger.h" #include "queue.h" @@ -498,9 +499,13 @@ static int pchg_run(struct pchg *ctx) if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) return 0; - if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) - return (ctx->event == PCHG_EVENT_DEVICE_DETECTED) - || (ctx->event == PCHG_EVENT_DEVICE_LOST); + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) { + if (IS_ENABLED(CONFIG_LID_SWITCH) && !lid_is_open()) + /* Don't wake up if the lid is closed. */ + return 0; + return (ctx->event == PCHG_EVENT_DEVICE_DETECTED || + ctx->event == PCHG_EVENT_DEVICE_LOST); + } if (ctx->event == PCHG_EVENT_CHARGE_UPDATE) return ctx->battery_percent != previous_battery; |