diff options
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 4 | ||||
-rw-r--r-- | common/usbc/usb_prl_sm.c | 31 | ||||
-rw-r--r-- | include/usb_prl_sm.h | 7 | ||||
-rw-r--r-- | test/fake_prl.c | 3 |
4 files changed, 33 insertions, 12 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 16a8dc48b7..3133a09864 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -2958,8 +2958,8 @@ static void pe_send_soft_reset_entry(int port) { print_current_state(port); - /* Reset Protocol Layer */ - prl_reset(port); + /* Reset Protocol Layer (softly) */ + prl_reset_soft(port); pe[port].sender_response_timer = TIMER_DISABLED; } diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index f9102ca80c..4fd0a79970 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -498,16 +498,6 @@ static void prl_init(int port) rch[port].flags = 0; #endif /* CONFIG_USB_PD_REV30 */ - /* - * Initialize to highest revision supported. If the port or cable - * partner doesn't support this revision, the Protocol Engine will - * lower this value to the revision supported by the partner. - */ - pdmsg[port].rev[TCPC_TX_SOP] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_PRIME] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_PRIME_PRIME] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME_PRIME] = PD_REVISION; pdmsg[port].flags = 0; prl_hr[port].flags = 0; @@ -599,8 +589,28 @@ void prl_send_ext_data_msg(int port, } #endif /* CONFIG_USB_PD_REV30 */ +static 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 + * lower this value to the revision supported by the partner. + */ + pdmsg[port].rev[TCPC_TX_SOP] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_PRIME_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME_PRIME] = PD_REVISION; +} + +void prl_reset_soft(int port) +{ + /* Do not change negotiated PD Revision Specification level */ + local_state[port] = SM_INIT; +} + void prl_reset(int port) { + prl_set_default_pd_revision(port); local_state[port] = SM_INIT; } @@ -610,6 +620,7 @@ 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); diff --git a/include/usb_prl_sm.h b/include/usb_prl_sm.h index ee357ccba2..6b35bd67e8 100644 --- a/include/usb_prl_sm.h +++ b/include/usb_prl_sm.h @@ -41,6 +41,13 @@ void prl_set_debug_level(enum debug_level level); void prl_reset(int port); /** + * Resets the Protocol Layer State Machine (softly) + * + * @param port USB-C port number + */ +void prl_reset_soft(int port); + +/** * Runs the Protocol Layer State Machine * * @param port USB-C port number diff --git a/test/fake_prl.c b/test/fake_prl.c index b4e2aaa11a..f174274318 100644 --- a/test/fake_prl.c +++ b/test/fake_prl.c @@ -33,6 +33,9 @@ int prl_is_running(int port) void prl_reset(int port) {} +void prl_reset_soft(int port) +{} + static enum pd_ctrl_msg_type last_ctrl_msg[CONFIG_USB_PD_PORT_MAX_COUNT]; void prl_send_ctrl_msg(int port, enum tcpm_transmit_type type, enum pd_ctrl_msg_type msg) |