Skip to contentSkip to conversation

staging: typec: tcpci: keep the not connecting cc line open

PATCH Superseded Jun Li 1 participant 1 message Mar 13, 2018

Subsystems (2)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Jun Li

author
#0 lore raw

PATCH v3 10/12 staging: typec: tcpci: keep the not connecting cc line open

While set polarity, we should keep the not connecting cc line to be open when attached.

---
 drivers/staging/typec/tcpci.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/staging/typec/tcpci.c +12 -1
index 9a230c6..6fdb179 100644
@@ -185,6 +185,7 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc,
 			      enum typec_cc_polarity polarity)
 {
 	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
+	unsigned int reg;
 	int ret;
 
 	ret = regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
@@ -193,7 +194,17 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc,
 	if (ret < 0)
 		return ret;
 
-	return 0;
+	/* Set the not connected cc line open */
+	ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, &reg);
+	if (ret < 0)
+		return ret;
+	if (polarity == TYPEC_POLARITY_CC2)
+		ret = TCPC_ROLE_CTRL_CC1_SHIFT;
+	else
+		ret = TCPC_ROLE_CTRL_CC2_SHIFT;
+	reg |= TCPC_ROLE_CTRL_CC_OPEN << ret;
+	reg &= ~TCPC_ROLE_CTRL_DRP;
+	return regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
 }
 
 static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)