diff options
-rw-r--r-- | driver/usb_mux/usb_mux.c | 24 | ||||
-rw-r--r-- | include/usb_mux.h | 1 |
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 |