diff options
author | Abe Levkoy <alevkoy@chromium.org> | 2021-02-04 12:17:20 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-09 17:17:23 +0000 |
commit | a589f3a0cb622dabc21a9695150a9e11b0e0f1c1 (patch) | |
tree | 0aaf43133270b31ace5848824951c01daeac6658 | |
parent | 235049a12b076633ded04712fcc1bce29ec1372a (diff) | |
download | chrome-ec-a589f3a0cb622dabc21a9695150a9e11b0e0f1c1.tar.gz |
TCPMv2: Reset stored PD revs at appropriate times
Stored PD revs for partners should only be reset upon Detach, Hard
Reset, or Error Recovery. Don't do it when the PE enters a Startup
state, e.g. after a Power Role Swap.
BUG=b:173725284,b:179198412
TEST=make buildall
TEST=PR Swap after SOP' Discover Identity with PD 2.0 cable; subsequent
SOP' messages still PD 2.0; subsequent Enter_USB message has
correct cable speed
BRANCH=none
Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: I2c12287c99154fba96e4f04a76ebc48273b0bb2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2676265
Reviewed-by: Diana Z <dzigterman@chromium.org>
Tested-by: Divya Sasidharan <divya.s.sasidharan@intel.corp-partner.google.com>
Tested-by: Ayushee Shah <ayushee.shah@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2684754
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 4 | ||||
-rw-r--r-- | common/usbc/usb_prl_sm.c | 16 | ||||
-rw-r--r-- | common/usbc/usb_tc_drp_acc_trysrc_sm.c | 18 | ||||
-rw-r--r-- | include/usb_prl_sm.h | 13 |
4 files changed, 46 insertions, 5 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 71ff487a69..cc17841da6 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -2167,7 +2167,7 @@ static void pe_src_startup_entry(int port) pe[port].caps_counter = 0; /* Reset the protocol layer */ - prl_reset(port); + prl_reset_soft(port); /* * Protocol layer reset clears the message IDs for all SOP types. @@ -2993,7 +2993,7 @@ static void pe_snk_startup_entry(int port) print_current_state(port); /* Reset the protocol layer */ - prl_reset(port); + prl_reset_soft(port); /* * Protocol layer reset clears the message IDs for all SOP types. diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index 5f1ca8e24c..0affa113b5 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -669,7 +669,8 @@ void prl_send_ext_data_msg(int port, } #endif /* CONFIG_USB_PD_EXTENDED_MESSAGES */ -static void prl_set_default_pd_revision(int port) { +void prl_set_default_pd_revision(int port) +{ /* * Initialize to highest revision supported. If the port or cable * partner doesn't support this revision, the Protocol Engine will @@ -706,7 +707,6 @@ void prl_run(int port, int evt, int en) case SM_PAUSED: if (!en) break; - prl_set_default_pd_revision(port); /* fall through */ case SM_INIT: prl_init(port); @@ -1285,6 +1285,18 @@ static void prl_hr_reset_layer_entry(const int port) tcpm_set_rx_enable(port, 0); /* + * PD r3.0 v2.0, ss6.2.1.1.5: + * After a physical or logical (USB Type-C Error Recovery) Attach, a + * Port discovers the common Specification Revision level between itself + * and its Port Partner and/or the Cable Plug(s), and uses this + * Specification Revision level until a Detach, Hard Reset or Error + * Recovery happens. + * + * This covers the Hard Reset case. + */ + prl_set_default_pd_revision(port); + + /* * Protocol Layer message transmission transitions to * PRL_Tx_Wait_For_Message_Request state. */ diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 1d6b9b995f..fab7757e9b 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -717,6 +717,8 @@ static void tc_detached(int port) tc_pd_connection(port, 0); tcpm_debug_accessory(port, 0); tc_set_modes_exit(port); + if (IS_ENABLED(CONFIG_USB_PRL_SM)) + prl_set_default_pd_revision(port); } static inline void pd_set_dual_role_and_event(int port, @@ -1455,6 +1457,22 @@ static void restart_tc_sm(int port, enum usb_tc_state start_state) charge_manager_update_dualrole(port, CAP_UNKNOWN); } + /* + * PD r3.0 v2.0, ss6.2.1.1.5: + * After a physical or logical (USB Type-C Error Recovery) Attach, a + * Port discovers the common Specification Revision level between itself + * and its Port Partner and/or the Cable Plug(s), and uses this + * Specification Revision level until a Detach, Hard Reset or Error + * Recovery happens. + * + * This covers the Error Recovery case, because TC_ERROR_RECOVERY + * reinitializes the TC state machine. This also covers the implicit + * case when PD is suspended and resumed or when the state machine is + * first initialized. + */ + if (IS_ENABLED(CONFIG_USB_PRL_SM)) + prl_set_default_pd_revision(port); + #ifdef CONFIG_USB_PE_SM tc_enable_pd(port, 0); tc[port].ps_reset_state = PS_STATE0; diff --git a/include/usb_prl_sm.h b/include/usb_prl_sm.h index 6a143f9acc..79b0b9c35c 100644 --- a/include/usb_prl_sm.h +++ b/include/usb_prl_sm.h @@ -45,13 +45,24 @@ void prl_set_debug_level(enum debug_level level); void prl_reset(int port); /** - * Resets the Protocol Layer State Machine (softly) + * Resets the Protocol Layer state machine but does not reset the stored PD + * revisions of the partners. * * @param port USB-C port number */ void prl_reset_soft(int port); /** + * resets the stored pd revisions for each sop type to their default value, the + * highest revision supported by this implementation. per pd r3.0 v2.0, + * ss6.2.1.1.5, this should only happen upon detach, hard reset, or error + * recovery. + * + * @param port USB-C port number + */ +void prl_set_default_pd_revision(int port); + +/** * Runs the Protocol Layer State Machine * * @param port USB-C port number |