Skip to content

Commit 5a330d8

Browse files
lumagidlethread
authored andcommitted
usb: typec: tcpci: report connection status for non-DRP devices
TCPM core calls start_toggling() unconditionally, but TCPCI simply returns -EOPNOTSUPP in such a case, ignoring the current 'connected' status. Make TCPCI driver check CC lines status and report current connected status. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
1 parent e290400 commit 5a330d8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/usb/typec/tcpm/tcpci.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ static int tcpci_apply_rc(struct tcpc_dev *tcpc, enum typec_cc_status cc,
178178
TCPC_ROLE_CTRL_CC_OPEN);
179179
}
180180

181+
static int tcpci_get_cc(struct tcpc_dev *tcpc,
182+
enum typec_cc_status *cc1, enum typec_cc_status *cc2);
181183
static int tcpci_start_toggling(struct tcpc_dev *tcpc,
182184
enum typec_port_type port_type,
183185
enum typec_cc_status cc)
@@ -186,8 +188,18 @@ static int tcpci_start_toggling(struct tcpc_dev *tcpc,
186188
struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
187189
unsigned int reg = TCPC_ROLE_CTRL_DRP;
188190

189-
if (port_type != TYPEC_PORT_DRP)
191+
if (port_type != TYPEC_PORT_DRP) {
192+
enum typec_cc_status cc1, cc2;
193+
194+
ret = tcpci_get_cc(tcpc, &cc1, &cc2);
195+
if (ret)
196+
return ret;
197+
198+
if (cc1 != TYPEC_CC_OPEN || cc2 != TYPEC_CC_OPEN)
199+
tcpm_cc_change(tcpci->port);
200+
190201
return -EOPNOTSUPP;
202+
}
191203

192204
/* Handle vendor drp toggling */
193205
if (tcpci->data->start_drp_toggling) {

0 commit comments

Comments
 (0)