diff options
author | Jameson Thies <jthies@google.com> | 2022-07-29 19:56:20 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-16 15:50:08 +0000 |
commit | e273823c19f2f902a67ccbdee51489119bb28669 (patch) | |
tree | 51ad7d2f81af29187996073b9cb0885492181688 /common/power_button.c | |
parent | 2e68f3ee03f51fb0a3f8c0cad6868b2f1fb34a5a (diff) | |
download | chrome-ec-e273823c19f2f902a67ccbdee51489119bb28669.tar.gz |
TCMPV2: Add USB PD power button support in S0/S0ix/S3 states
Currently a USB PD power button can only be used wake a device which is
shutdown. To account for devices which use a USB PD power button and
cannot enable a HID interface, this CL adds USB PD power button support
to Suspend and On power states. When a device is either suspended or on,
a short USB PD power button press will simulate a 500ms power button
press and a long USB PD power button press will shutdown the device.
BUG=b:236022894
TEST=make try_build_boards, make runhosttests and zmake test
test-drivers. Also working interactively with a dock that supports
sending alerts on button presses.
BRANCH=None
Signed-off-by: Jameson Thies <jthies@google.com>
Change-Id: I3a8adaa01dbf07a03b0e1451d3a5af5d5f39c442
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3794615
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'common/power_button.c')
-rw-r--r-- | common/power_button.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/common/power_button.c b/common/power_button.c index 9fd4cbdb36..aec4571cd7 100644 --- a/common/power_button.c +++ b/common/power_button.c @@ -200,6 +200,22 @@ void power_button_interrupt(enum gpio_signal signal) power_button.debounce_us); } +void power_button_simulate_press(int duration) +{ + ccprintf("Simulating %d ms %s press.\n", duration, power_button.name); + simulate_power_pressed = 1; + power_button_is_stable = 0; + hook_call_deferred(&power_button_change_deferred_data, 0); + + if (duration > 0) + msleep(duration); + + ccprintf("Simulating %s release.\n", power_button.name); + simulate_power_pressed = 0; + power_button_is_stable = 0; + hook_call_deferred(&power_button_change_deferred_data, 0); +} + /*****************************************************************************/ /* Console commands */ @@ -214,19 +230,7 @@ static int command_powerbtn(int argc, char **argv) return EC_ERROR_PARAM1; } - ccprintf("Simulating %d ms %s press.\n", ms, power_button.name); - simulate_power_pressed = 1; - power_button_is_stable = 0; - hook_call_deferred(&power_button_change_deferred_data, 0); - - if (ms > 0) - msleep(ms); - - ccprintf("Simulating %s release.\n", power_button.name); - simulate_power_pressed = 0; - power_button_is_stable = 0; - hook_call_deferred(&power_button_change_deferred_data, 0); - + power_button_simulate_press(ms); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(powerbtn, command_powerbtn, "[msec]", |