Skip to content

Commit bec1519

Browse files
RD Babieragregkh
authored andcommitted
usb: typec: tcpm: apply vbus before data bringup in tcpm_src_attach
This patch fixes Type-C compliance test TD 4.7.6 - Try.SNK DRP Connect SNKAS. tVbusON has a limit of 275ms when entering SRC_ATTACHED. Compliance testers can interpret the TryWait.Src to Attached.Src transition after Try.Snk as being in Attached.Src the entire time, so ~170ms is lost to the debounce timer. Setting the data role can be a costly operation in host mode, and when completed after 100ms can cause Type-C compliance test check TD 4.7.5.V.4 to fail. Turn VBUS on before tcpm_set_roles to meet timing requirement. Fixes: f0690a2 ("staging: typec: USB Type-C Port Manager (tcpm)") Cc: stable <[email protected]> Signed-off-by: RD Babiera <[email protected]> Reviewed-by: Badhri Jagan Sridharan <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7aed153 commit bec1519

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

drivers/usb/typec/tcpm/tcpm.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4410,17 +4410,6 @@ static int tcpm_src_attach(struct tcpm_port *port)
44104410

44114411
tcpm_enable_auto_vbus_discharge(port, true);
44124412

4413-
ret = tcpm_set_roles(port, true, TYPEC_STATE_USB,
4414-
TYPEC_SOURCE, tcpm_data_role_for_source(port));
4415-
if (ret < 0)
4416-
return ret;
4417-
4418-
if (port->pd_supported) {
4419-
ret = port->tcpc->set_pd_rx(port->tcpc, true);
4420-
if (ret < 0)
4421-
goto out_disable_mux;
4422-
}
4423-
44244413
/*
44254414
* USB Type-C specification, version 1.2,
44264415
* chapter 4.5.2.2.8.1 (Attached.SRC Requirements)
@@ -4430,13 +4419,24 @@ static int tcpm_src_attach(struct tcpm_port *port)
44304419
(polarity == TYPEC_POLARITY_CC2 && port->cc1 == TYPEC_CC_RA)) {
44314420
ret = tcpm_set_vconn(port, true);
44324421
if (ret < 0)
4433-
goto out_disable_pd;
4422+
return ret;
44344423
}
44354424

44364425
ret = tcpm_set_vbus(port, true);
44374426
if (ret < 0)
44384427
goto out_disable_vconn;
44394428

4429+
ret = tcpm_set_roles(port, true, TYPEC_STATE_USB, TYPEC_SOURCE,
4430+
tcpm_data_role_for_source(port));
4431+
if (ret < 0)
4432+
goto out_disable_vbus;
4433+
4434+
if (port->pd_supported) {
4435+
ret = port->tcpc->set_pd_rx(port->tcpc, true);
4436+
if (ret < 0)
4437+
goto out_disable_mux;
4438+
}
4439+
44404440
port->pd_capable = false;
44414441

44424442
port->partner = NULL;
@@ -4447,14 +4447,14 @@ static int tcpm_src_attach(struct tcpm_port *port)
44474447

44484448
return 0;
44494449

4450-
out_disable_vconn:
4451-
tcpm_set_vconn(port, false);
4452-
out_disable_pd:
4453-
if (port->pd_supported)
4454-
port->tcpc->set_pd_rx(port->tcpc, false);
44554450
out_disable_mux:
44564451
tcpm_mux_set(port, TYPEC_STATE_SAFE, USB_ROLE_NONE,
44574452
TYPEC_ORIENTATION_NONE);
4453+
out_disable_vbus:
4454+
tcpm_set_vbus(port, false);
4455+
out_disable_vconn:
4456+
tcpm_set_vconn(port, false);
4457+
44584458
return ret;
44594459
}
44604460

0 commit comments

Comments
 (0)