* [v6,13/15] staging: typec: tcpci: keep the disconnected cc line open
@ 2018-05-28 2:52 Jun Li
0 siblings, 0 replies; 2+ messages in thread
From: Jun Li @ 2018-05-28 2:52 UTC (permalink / raw)
To: robh+dt, gregkh, heikki.krogerus, linux
Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
jun.li, linux-usb, devicetree, linux-imx
While set polarity, we should keep the disconnected cc line to be
open.
Signed-off-by: Li Jun <jun.li@nxp.com>
---
drivers/staging/typec/tcpci.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 4d3b0ae..11c2d37 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -185,15 +185,25 @@ 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,
- (polarity == TYPEC_POLARITY_CC2) ?
- TCPC_TCPC_CTRL_ORIENTATION : 0);
+ /* Keep the disconnect cc line open */
+ ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, ®);
if (ret < 0)
return ret;
- return 0;
+ if (polarity == TYPEC_POLARITY_CC2)
+ reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT;
+ else
+ reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT;
+ ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
+ if (ret < 0)
+ return ret;
+
+ return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
+ (polarity == TYPEC_POLARITY_CC2) ?
+ TCPC_TCPC_CTRL_ORIENTATION : 0);
}
static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [v6,13/15] staging: typec: tcpci: keep the disconnected cc line open
@ 2018-06-11 13:14 Heikki Krogerus
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2018-06-11 13:14 UTC (permalink / raw)
To: Li Jun
Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx
On Mon, May 28, 2018 at 10:52:45AM +0800, Li Jun wrote:
> While set polarity, we should keep the disconnected cc line to be
> open.
>
> Signed-off-by: Li Jun <jun.li@nxp.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/staging/typec/tcpci.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 4d3b0ae..11c2d37 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -185,15 +185,25 @@ 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,
> - (polarity == TYPEC_POLARITY_CC2) ?
> - TCPC_TCPC_CTRL_ORIENTATION : 0);
> + /* Keep the disconnect cc line open */
> + ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, ®);
> if (ret < 0)
> return ret;
>
> - return 0;
> + if (polarity == TYPEC_POLARITY_CC2)
> + reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT;
> + else
> + reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT;
> + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
> + if (ret < 0)
> + return ret;
> +
> + return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
> + (polarity == TYPEC_POLARITY_CC2) ?
> + TCPC_TCPC_CTRL_ORIENTATION : 0);
> }
>
> static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)
Thanks,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-11 13:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-28 2:52 [v6,13/15] staging: typec: tcpci: keep the disconnected cc line open Jun Li
-- strict thread matches above, loose matches on Subject: below --
2018-06-11 13:14 Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).