diff options
author | Abe Levkoy <alevkoy@chromium.org> | 2022-08-18 16:45:49 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-19 22:45:01 +0000 |
commit | 817cb7376ec309218a2498714edac87a5c004498 (patch) | |
tree | 3ec39b73649228f59718fe8e70fafeddc16cacb3 /common/usbc/usb_prl_sm.c | |
parent | 773dc7f6b04873874befec1c54f7fe95ce4eddb7 (diff) | |
download | chrome-ec-817cb7376ec309218a2498714edac87a5c004498.tar.gz |
TCPMv2: Expose function to reset message IDs
Expose prl_reset_msg_ids as a function and use it in the PRL where
appropriate.
BUG=b:243071481
TEST=make buildall
BRANCH=none
Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: I18d41d1e2cebf1c4c77470f7b301af23f8d73844
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3840663
Reviewed-by: Diana Z <dzigterman@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'common/usbc/usb_prl_sm.c')
-rw-r--r-- | common/usbc/usb_prl_sm.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index 925e61c430..03afd86d2e 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -573,10 +573,8 @@ static void prl_init(int port) prl_hr[port].flags = 0; - for (i = 0; i < NUM_SOP_STAR_TYPES; i++) { - prl_rx[port].msg_id[i] = -1; - prl_tx[port].msg_id_counter[i] = 0; - } + for (i = 0; i < NUM_SOP_STAR_TYPES; i++) + prl_reset_msg_ids(port, i); pd_timer_disable_range(port, PR_TIMER_RANGE); @@ -777,6 +775,12 @@ enum pd_rev_type prl_get_rev(int port, enum tcpci_msg_type type) return pdmsg[port].rev[type]; } +void prl_reset_msg_ids(int port, enum tcpci_msg_type type) +{ + prl_tx[port].msg_id_counter[type] = 0; + prl_rx[port].msg_id[type] = -1; +} + static void prl_copy_msg_to_buffer(int port) { /* @@ -1018,16 +1022,14 @@ static void prl_tx_layer_reset_for_transmit_entry(const int port) * From section 6.3.13 Soft Reset Message in the USB PD 3.0 * v2.0 spec, Soft_Reset Message Shall be targeted at a * specific entity depending on the type of SOP* Packet used. - */ - prl_tx[port].msg_id_counter[pdmsg[port].xmit_type] = 0; - - /* + * + * * From section 6.11.2.3.2, the MessageID should be cleared * from the PRL_Rx_Layer_Reset_for_Receive state. However, we * don't implement a full state machine for PRL RX states so * clear the MessageID here. */ - prl_rx[port].msg_id[pdmsg[port].xmit_type] = -1; + prl_reset_msg_ids(port, pdmsg[port].xmit_type); } } @@ -1312,8 +1314,7 @@ static void prl_hr_reset_layer_entry(const int port) /* Hard reset resets messageIDCounters for all TX types */ for (i = 0; i < NUM_SOP_STAR_TYPES; i++) { - prl_rx[port].msg_id[i] = -1; - prl_tx[port].msg_id_counter[i] = 0; + prl_reset_msg_ids(port, i); } /* Disable RX */ @@ -2194,10 +2195,8 @@ static void prl_rx_wait_for_phy_message(const int port, int evt) /* Handle incoming soft reset as special case */ if (cnt == 0 && type == PD_CTRL_SOFT_RESET) { - /* Clear MessageIdCounter */ - prl_tx[port].msg_id_counter[prl_rx[port].sop] = 0; - /* Clear stored MessageID value */ - prl_rx[port].msg_id[prl_rx[port].sop] = -1; + /* Clear MessageIdCounter and stored MessageID value. */ + prl_reset_msg_ids(port, prl_rx[port].sop); /* Soft Reset occurred */ set_state_prl_tx(port, PRL_TX_PHY_LAYER_RESET); |