BACKPORT: usb: typec: tcpm: Do not disconnect link for self powered devices

During HARD_RESET the data link is disconnected.
For self powered device, the spec is advising against doing that.

From USB_PD_R3_0
7.1.5 Response to Hard Resets
Device operation during and after a Hard Reset is defined as follows:
Self-powered devices Should Not disconnect from USB during a Hard Reset
(see Section 9.1.2).
Bus powered devices will disconnect from USB during a Hard Reset due to the
loss of their power source.

Tackle this by letting TCPM know whether the device is self or bus powered.

This overcomes unnecessary port disconnections from hard reset.
Also, speeds up the enumeration time when connected to Type-A ports.

Bug: 112376366
Bug: 112296845
Change-Id: I833f89d34cbdba32c43ba43e7d8394385d419bc3
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
This commit is contained in:
Badhri Jagan Sridharan
2018-10-01 14:32:51 -07:00
parent 11ccfec2ed
commit 2b4e0221d4
2 changed files with 9 additions and 2 deletions

View File

@@ -299,6 +299,9 @@ struct tcpm_port {
/* Deadline in jiffies to exit src_try_wait state */
unsigned long max_wait;
/* port belongs to a self powered device */
bool self_powered;
#ifdef CONFIG_DEBUG_FS
struct dentry *dentry;
struct mutex logbuffer_lock; /* log buffer access lock */
@@ -2765,7 +2768,8 @@ static void run_state_machine(struct tcpm_port *port)
case SRC_HARD_RESET_VBUS_OFF:
tcpm_set_vconn(port, false);
tcpm_set_vbus(port, false);
tcpm_set_roles(port, false, TYPEC_SOURCE, TYPEC_HOST);
tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE,
TYPEC_HOST);
tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER);
break;
case SRC_HARD_RESET_VBUS_ON:
@@ -2778,7 +2782,8 @@ static void run_state_machine(struct tcpm_port *port)
case SNK_HARD_RESET_SINK_OFF:
tcpm_set_vconn(port, false);
tcpm_set_charge(port, false);
tcpm_set_roles(port, false, TYPEC_SINK, TYPEC_DEVICE);
tcpm_set_roles(port, port->self_powered, TYPEC_SINK,
TYPEC_DEVICE);
/*
* VBUS may or may not toggle, depending on the adapter.
* If it doesn't toggle, transition to SNK_HARD_RESET_SINK_ON
@@ -3868,6 +3873,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
port->typec_caps.vconn_set = tcpm_vconn_set;
port->typec_caps.try_role = tcpm_try_role;
port->typec_caps.port_type_set = tcpm_port_type_set;
port->self_powered = tcpc->config->self_powered;
port->partner_desc.identity = &port->partner_ident;
port->port_type = tcpc->config->type;

View File

@@ -93,6 +93,7 @@ struct tcpc_config {
enum typec_port_type type;
enum typec_role default_role;
bool try_role_hw; /* try.{src,snk} implemented in hardware */
bool self_powered; /* port belongs to a self powered device */
const struct typec_altmode_desc *alt_modes;
};