From: Guenter Roeck <linux@roeck-us.net>
To: Badhri Jagan Sridharan <badhri@google.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Kyle Tso <kyletso@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v1 4/4] usb: typec: tcpci: Implement callback for apply_rc
Date: Mon, 17 May 2021 07:38:28 -0700 [thread overview]
Message-ID: <20210517143828.GC3434992@roeck-us.net> (raw)
In-Reply-To: <20210515052613.3261340-4-badhri@google.com>
On Fri, May 14, 2021 at 10:26:13PM -0700, Badhri Jagan Sridharan wrote:
> APPLY RC is defined as ROLE_CONTROL.CC1 != ROLE_CONTROL.CC2 and
> POWER_CONTROL.AutodischargeDisconnect is 0. When ROLE_CONTROL.CC1 ==
> ROLE_CONTROL.CC2, set the other CC to OPEN.
>
> Fixes: f321a02caebd ("usb: typec: tcpm: Implement enabling Auto Discharge disconnect support")
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/usb/typec/tcpm/tcpci.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index 25b480752266..34b5095cc84f 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -115,6 +115,32 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
> return 0;
> }
>
> +int tcpci_apply_rc(struct tcpc_dev *tcpc, enum typec_cc_status cc, enum typec_cc_polarity polarity)
> +{
> + struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
> + unsigned int reg;
> + int ret;
> +
> + ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, ®);
> + if (ret < 0)
> + return ret;
> +
> + /*
> + * APPLY_RC state is when ROLE_CONTROL.CC1 != ROLE_CONTROL.CC2 and vbus autodischarge on
> + * disconnect is disabled. Bail out when ROLE_CONTROL.CC1 != ROLE_CONTROL.CC2.
> + */
> + if (((reg & (TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT)) >>
> + TCPC_ROLE_CTRL_CC2_SHIFT) !=
> + ((reg & (TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT)) >>
> + TCPC_ROLE_CTRL_CC1_SHIFT))
> + return 0;
> +
> + return regmap_update_bits(tcpci->regmap, TCPC_ROLE_CTRL, polarity == TYPEC_POLARITY_CC1 ?
> + TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT :
> + TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT,
> + TCPC_ROLE_CTRL_CC_OPEN);
> +}
> +
> static int tcpci_start_toggling(struct tcpc_dev *tcpc,
> enum typec_port_type port_type,
> enum typec_cc_status cc)
> @@ -728,6 +754,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
> tcpci->tcpc.get_vbus = tcpci_get_vbus;
> tcpci->tcpc.set_vbus = tcpci_set_vbus;
> tcpci->tcpc.set_cc = tcpci_set_cc;
> + tcpci->tcpc.apply_rc = tcpci_apply_rc;
> tcpci->tcpc.get_cc = tcpci_get_cc;
> tcpci->tcpc.set_polarity = tcpci_set_polarity;
> tcpci->tcpc.set_vconn = tcpci_set_vconn;
> --
> 2.31.1.751.gd2f1c929bd-goog
>
next prev parent reply other threads:[~2021-05-17 16:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-15 5:26 [PATCH v1 1/4] usb: typec: tcpm: Fix up PR_SWAP when vsafe0v is signalled Badhri Jagan Sridharan
2021-05-15 5:26 ` [PATCH v1 2/4] usb: typec: tcpm: Refactor logic to enable/disable auto vbus dicharge Badhri Jagan Sridharan
2021-05-17 14:33 ` Guenter Roeck
2021-05-15 5:26 ` [PATCH v1 3/4] usb: typec: tcpm: Move TCPC to APPLY_RC state during PR_SWAP Badhri Jagan Sridharan
2021-05-17 14:37 ` Guenter Roeck
2021-05-15 5:26 ` [PATCH v1 4/4] usb: typec: tcpci: Implement callback for apply_rc Badhri Jagan Sridharan
2021-05-17 14:38 ` Guenter Roeck [this message]
2021-05-17 1:30 ` [PATCH v1 1/4] usb: typec: tcpm: Fix up PR_SWAP when vsafe0v is signalled Peter Chen
2021-05-17 14:32 ` Guenter Roeck
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=20210517143828.GC3434992@roeck-us.net \
--to=linux@roeck-us.net \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=kyletso@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.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).