MLK-16013-29 usb: typec: tcpm: Don't reset message id after soft reset
authorLi Jun <jun.li@nxp.com>
Wed, 9 Jan 2019 06:58:35 +0000 (12:28 +0530)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
If the power source sent soft reset and the other end accepted, we should
not reset the message id as it was already updated by pd_transmit when
handling the soft reset.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
drivers/usb/typec/tcpm.c

index bd4bd2c..3632b25 100644 (file)
@@ -1793,12 +1793,18 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
                        tcpm_set_state(port, SNK_TRANSITION_SINK, 0);
                        break;
                case SOFT_RESET_SEND:
-                       port->message_id = 0;
                        port->rx_msgid = -1;
-                       if (port->pwr_role == TYPEC_SOURCE)
+                       /*
+                        * After reset data sent, the msg id is updated
+                        * by pd_transmit(0+1), now the other end gives
+                        * an accept so we can go on with msg id 1.
+                        */
+                       if (port->pwr_role == TYPEC_SOURCE) {
                                next_state = SRC_SEND_CAPABILITIES;
-                       else
+                       } else {
+                               port->message_id = 0;
                                next_state = SNK_WAIT_CAPABILITIES;
+                       }
                        tcpm_set_state(port, next_state, 0);
                        break;
                case DR_SWAP_SEND: