usb: typec: tcpm: Handle vbus shutoff when in source mode
authorBadhri Jagan Sridharan <badhri@google.com>
Mon, 1 Feb 2021 10:02:12 +0000 (02:02 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 2 Feb 2021 15:14:28 +0000 (16:14 +0100)
While in source mode, vbus could be shutoff by protections
circuits. TCPM does not move back to toggling state to
re-initiate connection. Fix this by moving to SRC_UNATTACHED
state when vbus shuts off while in source mode.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Link: https://lore.kernel.org/r/20210201100212.49863-1-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/tcpm/tcpm.c

index 0afd8ef..ff0732c 100644 (file)
@@ -4897,6 +4897,17 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port)
                /* Do nothing, waiting for sink detection */
                break;
 
+       case SRC_STARTUP:
+       case SRC_SEND_CAPABILITIES:
+       case SRC_SEND_CAPABILITIES_TIMEOUT:
+       case SRC_NEGOTIATE_CAPABILITIES:
+       case SRC_TRANSITION_SUPPLY:
+       case SRC_READY:
+       case SRC_WAIT_NEW_CAPABILITIES:
+               /* Force to unattached state to re-initiate connection */
+               tcpm_set_state(port, SRC_UNATTACHED, 0);
+               break;
+
        case PORT_RESET:
                /*
                 * State set back to default mode once the timer completes.