Skip to contentSkip to conversation

usb: typec: tcpm: move to SNK_UNATTACHED if sink removed for DRP

PATCH In review [email protected] 3 participants 3 messages Feb 19, 2020 – Feb 24, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: typec: tcpm: move to SNK_UNATTACHED if sink removed for DRP

From: Li Jun <[email protected]>

Per typec spec:
Figure 4-15 Connection State Diagram: DRP
Figure 4-16 Connection State Diagram: DRP with Accessory and Try.SRC
Support
Figure 4-17 Connection State Diagram: DRP with Accessory and Try.SNK
Support
DRP port should move to Unattached.SNK instead of Unattached.SRC if sink removed.

---
 drivers/usb/typec/tcpm/tcpm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +6 -2
index 78077c2..3174180 100644
@@ -3680,8 +3680,12 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1,
 	case SRC_SEND_CAPABILITIES:
 	case SRC_READY:
 		if (tcpm_port_is_disconnected(port) ||
-		    !tcpm_port_is_source(port))
-			tcpm_set_state(port, SRC_UNATTACHED, 0);
+		    !tcpm_port_is_source(port)) {
+			if (port->port_type == TYPEC_PORT_SRC)
+				tcpm_set_state(port, SRC_UNATTACHED, 0);
+			else
+				tcpm_set_state(port, SNK_UNATTACHED, 0);
+		}
 		break;
 	case SNK_UNATTACHED:
 		if (tcpm_port_is_sink(port))
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Thu, Feb 20, 2020 at 12:05:43AM +0800, [email protected] wrote:

From: Li Jun <[email protected]>

Per typec spec:
Figure 4-15 Connection State Diagram: DRP
Figure 4-16 Connection State Diagram: DRP with Accessory and Try.SRC
Support
Figure 4-17 Connection State Diagram: DRP with Accessory and Try.SNK
Support
DRP port should move to Unattached.SNK instead of Unattached.SRC if sink removed.

Quoted 1 line
Quoted 26 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +6 -2
index 78077c2..3174180 100644
@@ -3680,8 +3680,12 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1,
 	case SRC_SEND_CAPABILITIES:
 	case SRC_READY:
 		if (tcpm_port_is_disconnected(port) ||
-		    !tcpm_port_is_source(port))
-			tcpm_set_state(port, SRC_UNATTACHED, 0);
+		    !tcpm_port_is_source(port)) {
+			if (port->port_type == TYPEC_PORT_SRC)
+				tcpm_set_state(port, SRC_UNATTACHED, 0);
+			else
+				tcpm_set_state(port, SNK_UNATTACHED, 0);
+		}
 		break;
 	case SNK_UNATTACHED:
 		if (tcpm_port_is_sink(port))
Signature · 1 line
2.7.4
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 11 lines · On Thu, Feb 20, 2020 at 12:05:43AM +0800, [email protected] wrote:

From: Li Jun <[email protected]>

Per typec spec:
Figure 4-15 Connection State Diagram: DRP
Figure 4-16 Connection State Diagram: DRP with Accessory and Try.SRC
Support
Figure 4-17 Connection State Diagram: DRP with Accessory and Try.SNK
Support
DRP port should move to Unattached.SNK instead of Unattached.SRC if sink removed.

Quoted 1 line
Quoted 25 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +6 -2
index 78077c2..3174180 100644
@@ -3680,8 +3680,12 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1,
 	case SRC_SEND_CAPABILITIES:
 	case SRC_READY:
 		if (tcpm_port_is_disconnected(port) ||
-		    !tcpm_port_is_source(port))
-			tcpm_set_state(port, SRC_UNATTACHED, 0);
+		    !tcpm_port_is_source(port)) {
+			if (port->port_type == TYPEC_PORT_SRC)
+				tcpm_set_state(port, SRC_UNATTACHED, 0);
+			else
+				tcpm_set_state(port, SNK_UNATTACHED, 0);
+		}
 		break;
 	case SNK_UNATTACHED:
 		if (tcpm_port_is_sink(port))
Signature · 1 line
2.7.4

thanks,

Signature · 1 line
heikki