summaryrefslogtreecommitdiff
path: root/driver/usb_mux/usb_mux.c
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2020-07-22 12:14:02 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-24 22:16:23 +0000
commit9ce7944afcba6930af667a1479fd8bf7d4d7648d (patch)
tree1e07c8f88917e5d0350e54c5b5f529adf0303839 /driver/usb_mux/usb_mux.c
parent8298b19bb8e5708e879615de9cc28e86b954593f (diff)
downloadchrome-ec-9ce7944afcba6930af667a1479fd8bf7d4d7648d.tar.gz
usb_mux: Retain mux's power state on read
Following functions need to read the mux's current mode: 1. "usb_pd_control" host command and 2. "typec" console command For reading the current mode, mux needs to exit the low power mode. This commit ensures that the mux's power state is retained before and after the read by saving the status of low power mode and re-entering the low power mode depending on the status. BUG=b:161367077 BRANCH=None TEST=The retimer is held in low power mode when no device attached. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: If63f7da816d58f7ff0a0a1d695e7e4fad2d14c07 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2314105 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'driver/usb_mux/usb_mux.c')
-rw-r--r--driver/usb_mux/usb_mux.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index ebf5db4e3b..c4af3b2ed9 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -231,17 +231,28 @@ void usb_mux_set(int port, mux_state_t mux_mode,
mux_state_t usb_mux_get(int port)
{
mux_state_t mux_state;
+ bool is_low_power_mode;
+ int rv;
if (port >= board_get_usb_pd_port_count()) {
return USB_PD_MUX_NONE;
}
+ /* Store the status of LPM flag (low power mode) */
+ is_low_power_mode = flags[port] & USB_MUX_FLAG_IN_LPM;
+
exit_low_power_mode(port);
- if (configure_mux(port, USB_MUX_GET_MODE, &mux_state))
- return USB_PD_MUX_NONE;
+ rv = configure_mux(port, USB_MUX_GET_MODE, &mux_state);
+
+ /*
+ * If the LPM flag was set prior to reading the mux state, re-enter the
+ * low power mode.
+ */
+ if (is_low_power_mode)
+ enter_low_power_mode(port);
- return mux_state;
+ return rv ? USB_PD_MUX_NONE : mux_state;
}
void usb_mux_flip(int port)