Skip to content

Commit 3af50c2

Browse files
Junlisuzhougregkh
authored andcommitted
staging: typec: tcpci: keep the disconnected cc line open
While set polarity, we should keep the disconnected cc line to be open. Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8e04b37 commit 3af50c2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

drivers/staging/typec/tcpci.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,25 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc,
185185
enum typec_cc_polarity polarity)
186186
{
187187
struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
188+
unsigned int reg;
188189
int ret;
189190

190-
ret = regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
191-
(polarity == TYPEC_POLARITY_CC2) ?
192-
TCPC_TCPC_CTRL_ORIENTATION : 0);
191+
/* Keep the disconnect cc line open */
192+
ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, &reg);
193193
if (ret < 0)
194194
return ret;
195195

196-
return 0;
196+
if (polarity == TYPEC_POLARITY_CC2)
197+
reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT;
198+
else
199+
reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT;
200+
ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
201+
if (ret < 0)
202+
return ret;
203+
204+
return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
205+
(polarity == TYPEC_POLARITY_CC2) ?
206+
TCPC_TCPC_CTRL_ORIENTATION : 0);
197207
}
198208

199209
static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)

0 commit comments

Comments
 (0)