summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJameson Thies <jthies@google.com>2022-07-29 19:56:20 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-16 15:50:08 +0000
commite273823c19f2f902a67ccbdee51489119bb28669 (patch)
tree51ad7d2f81af29187996073b9cb0885492181688 /include
parent2e68f3ee03f51fb0a3f8c0cad6868b2f1fb34a5a (diff)
downloadchrome-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 'include')
-rw-r--r--include/config.h6
-rw-r--r--include/power_button.h7
-rw-r--r--include/usb_pd.h3
-rw-r--r--include/usb_pd_dpm.h1
-rw-r--r--include/usb_pd_timer.h16
5 files changed, 29 insertions, 4 deletions
diff --git a/include/config.h b/include/config.h
index b8a9c2fa69..e24b71c61f 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4975,6 +4975,12 @@
/* Index for temperature sensor used in PD messages. Defaults to 0. */
#define CONFIG_USB_PD_TEMP_SENSOR 0
+/*
+ * Time limit in ms for a USB PD power button press to be considered a short
+ * press
+ */
+#define CONFIG_USB_PD_SHORT_PRESS_MAX_MS 4000
+
/* Time limit in ms for a USB PD power button press to be considered valid. */
#define CONFIG_USB_PD_LONG_PRESS_MAX_MS 8000
diff --git a/include/power_button.h b/include/power_button.h
index a4264ab557..3c2eabf13e 100644
--- a/include/power_button.h
+++ b/include/power_button.h
@@ -69,4 +69,11 @@ int64_t get_time_dsw_pwrok(void);
*/
void board_pwrbtn_to_pch(int level);
+/**
+ * Simulates a power button press.
+ *
+ * @param duration Simulated power button press duration in ms.
+ */
+void power_button_simulate_press(int duration);
+
#endif /* __CROS_EC_POWER_BUTTON_H */
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 9a5c136d55..ab7f94b572 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -842,6 +842,9 @@ struct pd_cable {
/* Timeout for message receive in microseconds */
#define USB_PD_RX_TMOUT_US 1800
+/* Power button press length triggered by USB PD short button press */
+#define USB_PD_SHORT_BUTTON_PRESS_MS 500
+
/* --- Protocol layer functions --- */
enum pd_states {
diff --git a/include/usb_pd_dpm.h b/include/usb_pd_dpm.h
index 05459086fc..c874f41e80 100644
--- a/include/usb_pd_dpm.h
+++ b/include/usb_pd_dpm.h
@@ -173,6 +173,5 @@ enum dpm_msg_setup_status {
enum dpm_pd_button_state {
DPM_PD_BUTTON_IDLE,
DPM_PD_BUTTON_PRESSED,
- DPM_PD_BUTTON_RELEASED,
};
#endif /* __CROS_EC_USB_DPM_H */
diff --git a/include/usb_pd_timer.h b/include/usb_pd_timer.h
index ebcf6c6e7c..1f3fabc237 100644
--- a/include/usb_pd_timer.h
+++ b/include/usb_pd_timer.h
@@ -18,10 +18,16 @@
*/
enum pd_task_timer {
/*
- * Timer to wait for a button release alert after receiving a button
- * press alert.
+ * Timer to check if a USB PD power button press exceeds the long press
+ * time limit.
*/
- DPM_TIMER_PD_BUTTON_PRESS,
+ DPM_TIMER_PD_BUTTON_LONG_PRESS,
+
+ /*
+ * Timer to check if a USB PD power button press exceeds the short press
+ * time limit.
+ */
+ DPM_TIMER_PD_BUTTON_SHORT_PRESS,
/*
* In BIST_TX mode, this timer is used by a UUT to ensure that a
@@ -226,10 +232,14 @@ enum pd_task_timer {
};
enum pd_timer_range {
+ DPM_TIMER_RANGE,
PE_TIMER_RANGE,
PR_TIMER_RANGE,
TC_TIMER_RANGE,
};
+#define DPM_TIMER_START DPM_TIMER_PD_BUTTON_LONG_PRESS
+#define DPM_TIMER_END DPM_TIMER_PD_BUTTON_SHORT_PRESS
+
#define PE_TIMER_START PE_TIMER_BIST_CONT_MODE
#define PE_TIMER_END PE_TIMER_WAIT_AND_ADD_JITTER