Thread (37 messages) 37 messages, 8 authors, 2018-05-01

RE: [PATCH v4 10/13] usb: typec: tcpm: set cc for drp toggling attach

From: Jun Li <hidden>
Date: 2018-03-31 03:37:21
Also in: linux-usb

Hi
-----Original Message-----
From: Mats Karrman [mailto:mats.dev.list@gmail.com]
Sent: 2018年3月30日 5:19
To: Jun Li <redacted>; robh+dt@kernel.org; gregkh@linuxfoundation.org;
heikki.krogerus@linux.intel.com; linux@roeck-us.net
Cc: a.hajda@samsung.com; shufan_lee@richtek.com; Peter Chen
[off-list ref]; devicetree@vger.kernel.org;
linux-usb@vger.kernel.org; dl-linux-imx [off-list ref];
devel@driverdev.osuosl.org
Subject: Re: [PATCH v4 10/13] usb: typec: tcpm: set cc for drp toggling attach

Hi Li,

On 03/28/2018 06:06 PM, Li Jun wrote:
quoted
In case of drp toggling, we may need set correct cc value for role
control after attach as it may never been set.

Signed-off-by: Li Jun <redacted>
---
 drivers/usb/typec/tcpm.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index
218c230..72d4232 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -2126,6 +2126,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
 	tcpm_set_attached_state(port, false);
 	port->try_src_count = 0;
 	port->try_snk_count = 0;
+	port->cc_req = 0;
I don't think it's OK to use "0" here. cc_req is an enum so why not use
"|TYPEC_CC_OPEN"?|
I will change to be TYPEC_CC_OPEN, also other place.

Li Jun
quoted
 }

 static void tcpm_detach(struct tcpm_port *port) @@ -2361,6 +2362,8 @@
static void run_state_machine(struct tcpm_port *port)
 		break;

 	case SRC_ATTACHED:
+		if (!port->cc_req)
        	if (port->cc_req == |TYPEC_CC_OPEN)|
quoted
+			tcpm_set_cc(port, tcpm_rp_cc(port));
 		ret = tcpm_src_attach(port);
 		tcpm_set_state(port, SRC_UNATTACHED,
 			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON); @@ -2531,6 +2534,8
@@
quoted
static void run_state_machine(struct tcpm_port *port)
 		tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE);
 		break;
 	case SNK_ATTACHED:
+		if (!port->cc_req)
Ditto.
quoted
+			tcpm_set_cc(port, TYPEC_CC_RD);
 		ret = tcpm_snk_attach(port);
 		if (ret < 0)
 			tcpm_set_state(port, SNK_UNATTACHED, 0);
// Mats
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help