> -----Original Message-----
> From: shufan_lee(李��帆) [mailto:shufan_...@richtek.com]
> Sent: 2018年3月14日 16:59
> To: Jun Li <jun...@nxp.com>; robh...@kernel.org; mark.rutl...@arm.com;
> gre...@linuxfoundation.org; heikki.kroge...@linux.intel.com
> Cc: a.ha...@samsung.com; li...@roeck-us.net; yue...@google.com;
> o_leve...@orange.fr; linux-usb@vger.kernel.org; dl-linux-imx
> <linux-...@nxp.com>
> Subject: RE: [PATCH v3 10/12] staging: typec: tcpci: keep the not connecting
> cc line open
> 
> Hi Jun,
> 
> -----Original Message-----
> From: Li Jun [mailto:jun...@nxp.com]
> Sent: Tuesday, March 13, 2018 5:35 PM
> To: robh...@kernel.org; mark.rutl...@arm.com;
> gre...@linuxfoundation.org; heikki.kroge...@linux.intel.com
> Cc: a.ha...@samsung.com; jun...@nxp.com; li...@roeck-us.net;
> yue...@google.com; shufan_lee(李��帆); o_leve...@orange.fr;
> linux-usb@vger.kernel.org; linux-...@nxp.com
> 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...@nxp.com>
> ---
>  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.
> 

What's the RC.CCx value before setting RC.DRP in your case?
I suppose the RC.CCx should be updated accordingly by TCPC
(and its firmware), RT1711H still keep the starting value after
detected a 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.

The read out value has the correct RC.CCx in my HW, so another
question is: without my patch of this and below change, how does your chip
can work in this case before? RC.DRP == 1 and RC.CCx is Rp/Rp but actually
your typec chip is presenting Rd? (show me the RC value when set polarity
without my patch)

Jun Li
> 
> @@ -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!

Reply via email to