summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-08-12 15:23:38 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-16 17:04:11 +0000
commit376dec8631c123f9c6b7b8df48fad41d5bee82aa (patch)
treefd866119d4498ddda6f9674f18bff8ddead59901
parentc92ea88aea820166207cd30300bd301166316267 (diff)
downloadchrome-ec-376dec8631c123f9c6b7b8df48fad41d5bee82aa.tar.gz
USB MUX: Introduce flag to clear mux state in G3
Some muxes may need to be re-set after they've power cycled, and many muxes are tied to the S5 power rails. Introduce a flag which can be used to indicate a mux needs to re-run init and is no longer in LPM after the G3 state has been hit. BRANCH=None BUG=b:195045790 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I8bd4184dbea629edf106dbee32f811620ebda0dd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3093086 Reviewed-by: Rob Barnes <robbarnes@google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--driver/usb_mux/usb_mux.c24
-rw-r--r--include/usb_mux.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index cf2e660a4f..e49a5a76d5 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -375,6 +375,30 @@ static void mux_chipset_reset(void)
}
DECLARE_HOOK(HOOK_CHIPSET_RESET, mux_chipset_reset, HOOK_PRIO_DEFAULT);
+/*
+ * For muxes which have powered off in G3, clear any cached INIT and LPM flags
+ * since the chip will need reset.
+ */
+static void usb_mux_reset_in_g3(void)
+{
+ int port;
+ const struct usb_mux *mux_ptr;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ mux_ptr = &usb_muxes[port];
+
+ while (mux_ptr) {
+ if (mux_ptr->flags & USB_MUX_FLAG_RESETS_IN_G3) {
+ atomic_clear_bits(&flags[port],
+ USB_MUX_FLAG_INIT |
+ USB_MUX_FLAG_IN_LPM);
+ }
+ mux_ptr = mux_ptr->next_mux;
+ }
+ }
+}
+DECLARE_HOOK(HOOK_CHIPSET_HARD_OFF, usb_mux_reset_in_g3, HOOK_PRIO_DEFAULT);
+
#ifdef CONFIG_CMD_TYPEC
static int command_typec(int argc, char **argv)
{
diff --git a/include/usb_mux.h b/include/usb_mux.h
index 548ee8940b..f2cd37acdb 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -17,6 +17,7 @@
/* Flags used for usb_mux.flags */
#define USB_MUX_FLAG_NOT_TCPC BIT(0) /* TCPC/MUX device used only as MUX */
#define USB_MUX_FLAG_SET_WITHOUT_FLIP BIT(1) /* SET should not flip */
+#define USB_MUX_FLAG_RESETS_IN_G3 BIT(2) /* Mux chip will reset in G3 */
/*
* USB-C mux state