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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jun,

-----Original Message-----
From: Li Jun [mailto:jun.li@xxxxxxx]
Sent: Tuesday, March 13, 2018 5:35 PM
To: robh+dt@xxxxxxxxxx; mark.rutland@xxxxxxx; gregkh@xxxxxxxxxxxxxxxxxxx; heikki.krogerus@xxxxxxxxxxxxxxx
Cc: a.hajda@xxxxxxxxxxx; jun.li@xxxxxxx; linux@xxxxxxxxxxxx; yueyao@xxxxxxxxxx; shufan_lee(李書帆); o_leveque@xxxxxxxxx; linux-usb@xxxxxxxxxxxxxxx; linux-imx@xxxxxxx
Subject: [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.

Signed-off-by: Li Jun <jun.li@xxxxxxx>
---
 drivers/staging/typec/tcpci.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c index 9a230c6..6fdb179 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -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)
--
2.7.4

  I applied all of your patches and tested with RT1711H.
  I met a case as following:
  1. The state machine starts toggling with RC.CCx = Rp/Rp
  2. Connect to adapter with an A2C cable
  3. open/open is received after setting RC.DRP to 0. Because RC.CCx is Rp/Rp while setting RC.DRP to 0 and the connected A2C cable is a cable with Rp.

  According to TCPCI's specification, Figure 4-20. DRP Initialization and Connection Detection, we need to set RC.CCx before setting RC.DRP to 0.

  ConnectionDetermine CC & VCONN
    - Set RC.CC1 & RC.CC2 per decision
    - Set RC.DRP=0
    - Set TCPC_CONTROl.PlugOrientation
    - Set PC.AutoDischargeDisconnect=1 & PC.EnableVconn

  If I understand correctly, we'll need to do the following step before setting DRP to 0.

@@ -1900,6 +1901,8 @@ static int tcpm_src_attach(struct tcpm_port *port)
        if (port->attached)
                return 0;

+       tcpm_set_cc(port, tcpm_rp_cc(port));
+
        ret = tcpm_set_polarity(port, polarity);
        if (ret < 0)
                return ret;
@@ -2014,6 +2017,8 @@ static int tcpm_snk_attach(struct tcpm_port *port)
        if (port->attached)
                return 0;

+       tcpm_set_cc(port, TYPEC_CC_RD);
+
        ret = tcpm_set_polarity(port, port->cc2 != TYPEC_CC_OPEN ?
                                TYPEC_POLARITY_CC2 : TYPEC_POLARITY_CC1);
        if (ret < 0)

************* Email Confidentiality Notice ********************

The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!
?頨{.n?????%??橆??w?{.n???{殺???緡w*jg炳????▏?拷G??98夸:+v??鋟喓???茶庫全??ㄑ搬?????



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux