diff options
author | li feng <li1.feng@intel.com> | 2021-04-28 21:21:58 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-01 03:07:49 +0000 |
commit | 7499e5b0472f142cb3cec7af8d35903ed96f74a5 (patch) | |
tree | d1b3548028846027214ecac2f5a8d8a2cd0531e6 | |
parent | 01ef01d06be623269cf286c580d39e1f0e3a78d4 (diff) | |
download | chrome-ec-7499e5b0472f142cb3cec7af8d35903ed96f74a5.tar.gz |
retimer: check power for firmware upgrade
Before retimer firmware update, check power, if battery is not present,
or battery level is low (<5%), not allow PD suspend/performing
retimer firmware update process.
BUG=b:185320314
BRANCH=none
TEST=On Voxel DVT, AC only, no battery, boot up system and confirm
NDA PD port is not suspended, and retimer firmware update is not performed.
DA port has correct device functions.
TEST=On Voxel DVT, battery is low (< 5%), boot up system and
confirmed NDA PD ports is not suspended, and retimer firmware update is not
performed; DA port has correct device functions.
TEST=On Voxel DVT, when battery level >=5%, confirmed NDA PD port can be
suspended and retimer is scanned. DA port has correct device functions; device
tested are DP dongle, TBT dock and USB4 device.
Signed-off-by: li feng <li1.feng@intel.com>
Change-Id: I1c5b2bc54b2f6307503f82112f28bbc8d6b0591a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2858283
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | common/usbc/usb_retimer_fw_update.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/common/usbc/usb_retimer_fw_update.c b/common/usbc/usb_retimer_fw_update.c index 5d420ad991..2634081e2e 100644 --- a/common/usbc/usb_retimer_fw_update.c +++ b/common/usbc/usb_retimer_fw_update.c @@ -3,7 +3,6 @@ * found in the LICENSE file. */ -#include "atomic.h" #include <stdbool.h> #include <stdint.h> #include "compile_time_macros.h" @@ -52,8 +51,8 @@ /* Track current port AP requested to update retimer firmware */ static int cur_port; static int last_op; /* Operation received from AP via ACPI_WRITE */ -/* MUX value returned to ACPI_READ */ -static int last_mux_result = USB_RETIMER_FW_UPDATE_INVALID_MUX; +/* Operation result returned to ACPI_READ */ +static int last_result; int usb_retimer_fw_update_get_result(void) { @@ -61,6 +60,11 @@ int usb_retimer_fw_update_get_result(void) switch (last_op) { case USB_RETIMER_FW_UPDATE_SUSPEND_PD: + if (last_result == USB_RETIMER_FW_UPDATE_ERR) { + result = last_result; + break; + } + /* fall through */ case USB_RETIMER_FW_UPDATE_RESUME_PD: result = pd_is_port_enabled(cur_port); break; @@ -72,7 +76,7 @@ int usb_retimer_fw_update_get_result(void) case USB_RETIMER_FW_UPDATE_SET_SAFE: case USB_RETIMER_FW_UPDATE_SET_TBT: case USB_RETIMER_FW_UPDATE_DISCONNECT: - result = last_mux_result; + result = last_result; break; default: break; @@ -91,6 +95,16 @@ void usb_retimer_fw_update_process_op_cb(int port) { switch (last_op) { case USB_RETIMER_FW_UPDATE_SUSPEND_PD: + last_result = 0; + /* + * Do not perform retimer firmware update process + * if battery is not present, or battery level is low. + */ + if (!pd_firmware_upgrade_check_power_readiness(port)) { + last_result = USB_RETIMER_FW_UPDATE_ERR; + break; + } + /* * If the port has entered low power mode, the PD task * is paused and will not complete processing of @@ -104,26 +118,26 @@ void usb_retimer_fw_update_process_op_cb(int port) pd_set_suspend(port, RESUME); break; case USB_RETIMER_FW_UPDATE_GET_MUX: - last_mux_result = usb_mux_get(port); + last_result = usb_mux_get(port); break; case USB_RETIMER_FW_UPDATE_SET_USB: usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT, pd_get_polarity(port)); - last_mux_result = usb_mux_get(port); + last_result = usb_mux_get(port); break; case USB_RETIMER_FW_UPDATE_SET_SAFE: usb_mux_set_safe_mode(port); - last_mux_result = usb_mux_get(port); + last_result = usb_mux_get(port); break; case USB_RETIMER_FW_UPDATE_SET_TBT: usb_mux_set(port, USB_PD_MUX_TBT_COMPAT_ENABLED, USB_SWITCH_CONNECT, pd_get_polarity(port)); - last_mux_result = usb_mux_get(port); + last_result = usb_mux_get(port); break; case USB_RETIMER_FW_UPDATE_DISCONNECT: usb_mux_set(port, USB_PD_MUX_NONE, USB_SWITCH_DISCONNECT, pd_get_polarity(port)); - last_mux_result = usb_mux_get(port); + last_result = usb_mux_get(port); break; default: break; @@ -145,7 +159,7 @@ void usb_retimer_fw_update_process_op(int port, int op) break; /* Operations can't be processed in ISR, defer to later */ case USB_RETIMER_FW_UPDATE_GET_MUX: - last_mux_result = USB_RETIMER_FW_UPDATE_INVALID_MUX; + last_result = USB_RETIMER_FW_UPDATE_INVALID_MUX; tc_usb_firmware_fw_update_run(port); break; case USB_RETIMER_FW_UPDATE_SUSPEND_PD: @@ -158,9 +172,9 @@ void usb_retimer_fw_update_process_op(int port, int op) case USB_RETIMER_FW_UPDATE_SET_TBT: case USB_RETIMER_FW_UPDATE_DISCONNECT: if (pd_is_port_enabled(port)) { - last_mux_result = USB_RETIMER_FW_UPDATE_ERR; + last_result = USB_RETIMER_FW_UPDATE_ERR; } else { - last_mux_result = USB_RETIMER_FW_UPDATE_INVALID_MUX; + last_result = USB_RETIMER_FW_UPDATE_INVALID_MUX; tc_usb_firmware_fw_update_limited_run(port); } break; |