From: Li Jun <jun.li-3arQi8VN3Tc@public.gmane.org>
To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
heikki.krogerus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org
Cc: yueyao-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
o_leveque-1tsiiZ//OF9QFI55V6+gNQ@public.gmane.org,
peter.chen-3arQi8VN3Tc@public.gmane.org,
aisheng.dong-3arQi8VN3Tc@public.gmane.org,
jun.li-3arQi8VN3Tc@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH resend 10/12] staging: typec: tcpci: update set_cc for different state
Date: Tue, 26 Sep 2017 12:05:21 +0800 [thread overview]
Message-ID: <1506398723-19359-11-git-send-email-jun.li@nxp.com> (raw)
In-Reply-To: <1506398723-19359-1-git-send-email-jun.li-3arQi8VN3Tc@public.gmane.org>
As we should keep the disconnected cc line to be open when attached,
so update the set_cc interface accordingly for it.
Signed-off-by: Li Jun <jun.li-3arQi8VN3Tc@public.gmane.org>
---
drivers/staging/typec/tcpci.c | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index cea67f9..c7c45da 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -57,10 +57,11 @@ static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val)
return regmap_raw_write(tcpci->regmap, reg, &val, sizeof(u16));
}
-static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
+static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc,
+ bool attached, enum typec_cc_polarity polarity)
{
struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
- unsigned int reg;
+ unsigned int reg = 0, reg_cc1 = 0, reg_cc2 = 0;
int ret;
switch (cc) {
@@ -69,26 +70,23 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
(TCPC_ROLE_CTRL_CC_RA << TCPC_ROLE_CTRL_CC2_SHIFT);
break;
case TYPEC_CC_RD:
- reg = (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT) |
- (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT);
+ reg_cc1 = TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT;
+ reg_cc2 = TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT;
break;
case TYPEC_CC_RP_DEF:
- reg = (TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC1_SHIFT) |
- (TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC2_SHIFT) |
- (TCPC_ROLE_CTRL_RP_VAL_DEF <<
- TCPC_ROLE_CTRL_RP_VAL_SHIFT);
+ reg_cc1 = TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC1_SHIFT;
+ reg_cc2 = TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC2_SHIFT;
+ reg = TCPC_ROLE_CTRL_RP_VAL_DEF << TCPC_ROLE_CTRL_RP_VAL_SHIFT;
break;
case TYPEC_CC_RP_1_5:
- reg = (TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC1_SHIFT) |
- (TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC2_SHIFT) |
- (TCPC_ROLE_CTRL_RP_VAL_1_5 <<
- TCPC_ROLE_CTRL_RP_VAL_SHIFT);
+ reg_cc1 = TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC1_SHIFT;
+ reg_cc2 = TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC2_SHIFT;
+ reg = TCPC_ROLE_CTRL_RP_VAL_1_5 << TCPC_ROLE_CTRL_RP_VAL_SHIFT;
break;
case TYPEC_CC_RP_3_0:
- reg = (TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC1_SHIFT) |
- (TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC2_SHIFT) |
- (TCPC_ROLE_CTRL_RP_VAL_3_0 <<
- TCPC_ROLE_CTRL_RP_VAL_SHIFT);
+ reg_cc1 = TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC1_SHIFT;
+ reg_cc2 = TCPC_ROLE_CTRL_CC_RP << TCPC_ROLE_CTRL_CC2_SHIFT;
+ reg = TCPC_ROLE_CTRL_RP_VAL_3_0 << TCPC_ROLE_CTRL_RP_VAL_SHIFT;
break;
case TYPEC_CC_OPEN:
default:
@@ -97,6 +95,13 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
break;
}
+ if (!attached)
+ reg |= reg_cc1 | reg_cc2;
+ else if (polarity == TYPEC_POLARITY_CC1)
+ reg |= reg_cc1;
+ else
+ reg |= reg_cc2;
+
ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
if (ret < 0)
return ret;
--
2.6.6
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-09-26 4:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-26 4:05 [PATCH resend 00/12] staging: typec: tcpci: move out of staging Li Jun
[not found] ` <1506398723-19359-1-git-send-email-jun.li-3arQi8VN3Tc@public.gmane.org>
2017-09-26 4:05 ` [PATCH resend 01/12] usb: typec: add API to get port type and preferred role Li Jun
2017-09-26 4:05 ` [PATCH resend 02/12] usb: typec: add basic typec properties Li Jun
[not found] ` <1506398723-19359-3-git-send-email-jun.li-3arQi8VN3Tc@public.gmane.org>
2017-10-05 20:44 ` Rob Herring
2017-10-09 11:21 ` Jun Li
[not found] ` <DB4PR04MB07683A52DD500A40C2B9047A89740-tLF+feb1Bz6HC8XOQgzeLs9NdZoXdze2vxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-10-09 13:12 ` Rob Herring
2017-09-26 4:05 ` [PATCH resend 03/12] staging: typec: tcpci: add documentation for tcpci Li Jun
2017-09-26 4:05 ` [PATCH resend 04/12] staging: typec: tcpci: support port config passed via dt Li Jun
2017-09-26 4:05 ` [PATCH resend 05/12] staging: typec: tcpci: register port before request irq Li Jun
2017-09-26 4:05 ` [PATCH resend 06/12] staging: typec: tcpci: enable vbus detection Li Jun
2017-09-26 4:05 ` [PATCH resend 07/12] typec: tcpm: add starting value for drp toggling Li Jun
2017-09-26 4:05 ` [PATCH resend 08/12] staging: typec: tcpci: correct " Li Jun
2017-09-26 4:05 ` [PATCH resend 09/12] usb: typec: tcpm: only drives the connected cc line when attached Li Jun
[not found] ` <1506398723-19359-10-git-send-email-jun.li-3arQi8VN3Tc@public.gmane.org>
2017-09-27 14:30 ` kbuild test robot
2017-09-26 4:05 ` Li Jun [this message]
2017-09-26 4:05 ` [PATCH resend 11/12] staging: typec: tcpci: Only touch target bit when enable vconn Li Jun
2017-09-26 4:05 ` [PATCH resend 12/12] staging: typec: tcpci: move tcpci driver out of staging Li Jun
2017-10-27 0:42 ` [PATCH resend 00/12] staging: typec: tcpci: move " Guenter Roeck
[not found] ` <96d37f9b-f04d-f923-ec09-b25fd62a90be-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2017-10-27 1:17 ` Jun Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1506398723-19359-11-git-send-email-jun.li@nxp.com \
--to=jun.li-3arqi8vn3tc@public.gmane.org \
--cc=aisheng.dong-3arQi8VN3Tc@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=heikki.krogerus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=o_leveque-1tsiiZ//OF9QFI55V6+gNQ@public.gmane.org \
--cc=peter.chen-3arQi8VN3Tc@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=yueyao-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).