diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2021-04-30 09:07:10 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-10 21:19:16 +0000 |
commit | ddf11157cd952a6df79aefc06c456eea426b6f10 (patch) | |
tree | 14b4455b7c044d19611f145685419d7f96cfea42 | |
parent | 1dc0c0446eca2caf95765081c3add878ac7be532 (diff) | |
download | chrome-ec-ddf11157cd952a6df79aefc06c456eea426b6f10.tar.gz |
PCHG: Enable device event on suspend complete
Currently, PCHG can send a device event any time. When a signal is
sent to the host while it's attempting to suspend, suspend is delayed
by 10 seconds.
A solution is to make Powerd disable a corresponding PCHG event (i.e.
EC_DEVICE_EVENT_WLC) when it's notifying an upcoming suspend to other
processes.
This patch makes PCHG re-enable EC_DEVICE_EVENT_WLC after suspend is
complete.
BUG=b:182973695, b:173235954
BRANCH=trogdor
TEST=Verify CoachZ suspends without a delay.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I10d7fcf234a7e0e05ce5d77b8e930a0cf0748331
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2863564
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | common/device_event.c | 5 | ||||
-rw-r--r-- | common/peripheral_charger.c | 9 | ||||
-rw-r--r-- | include/device_event.h | 7 |
3 files changed, 21 insertions, 0 deletions
diff --git a/common/device_event.c b/common/device_event.c index 0e86b00f32..f7944ae930 100644 --- a/common/device_event.c +++ b/common/device_event.c @@ -78,6 +78,11 @@ static void device_set_enabled_events(uint32_t mask) device_enabled_events = mask; } +void device_enable_event(enum ec_device_event event) +{ + atomic_or(&device_enabled_events, EC_DEVICE_EVENT_MASK(event)); +} + /*****************************************************************************/ /* Console commands */ diff --git a/common/peripheral_charger.c b/common/peripheral_charger.c index 73bd5e32b8..0b467afc6e 100644 --- a/common/peripheral_charger.c +++ b/common/peripheral_charger.c @@ -449,6 +449,15 @@ void pchg_irq(enum gpio_signal signal) } } + +static void pchg_suspend_complete(void) +{ + CPRINTS("%s", __func__); + device_enable_event(EC_DEVICE_EVENT_WLC); +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND_COMPLETE, pchg_suspend_complete, + HOOK_PRIO_DEFAULT); + static void pchg_startup(void) { struct pchg *ctx; diff --git a/include/device_event.h b/include/device_event.h index debec00d52..7a6403e51d 100644 --- a/include/device_event.h +++ b/include/device_event.h @@ -43,4 +43,11 @@ static inline void device_set_single_event(int event) device_set_events(EC_DEVICE_EVENT_MASK(event)); } +/** + * Enable device event. + * + * @param event Event to enable (EC_DEVICE_EVENT_*) + */ +void device_enable_event(enum ec_device_event event); + #endif /* __CROS_EC_DEVICE_EVENT_H */ |