Skip to contentSkip to conversation

usb: typec: tcpm: Handle vbus shutoff when in source mode

PATCH In review Badhri Jagan Sridharan 3 participants 3 messages Feb 1, 2021 – Feb 2, 2021

Subsystems (3)
lore
Share & tools
lore

Badhri Jagan Sridharan

author maintainer
#0 lore raw

PATCH 1/1 usb: typec: tcpm: Handle vbus shutoff when in source mode

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.

---
 drivers/usb/typec/tcpm/tcpm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +11 -0
index 0afd8ef692e8..ff0732c12b8a 100644
@@ -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.
Signature · 1 line
2.30.0.365.g02bc693789-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Badhri Jagan Sridharan

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.

Quoted 27 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +11 -0
index 0afd8ef692e8..ff0732c12b8a 100644
@@ -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.
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Badhri Jagan Sridharan
Quoted 6 lines · Badhri Jagan Sridharan

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.

Quoted 28 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +11 -0
index 0afd8ef692e8..ff0732c12b8a 100644
@@ -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.
Signature · 1 line
2.30.0.365.g02bc693789-goog

thanks,

Signature · 1 line
heikki