linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Kyle Tso <kyletso@google.com>
Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
	hdegoede@redhat.com, robh+dt@kernel.org, badhri@google.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v6 4/7] usb: typec: ucsi: Determine common SVDM Version
Date: Thu, 11 Feb 2021 20:18:48 -0800	[thread overview]
Message-ID: <20210212041848.GD103223@roeck-us.net> (raw)
In-Reply-To: <20210205033415.3320439-5-kyletso@google.com>

On Fri, Feb 05, 2021 at 11:34:12AM +0800, Kyle Tso wrote:
> This patch implements the following requirement in the Spec.
> 
> PD Spec Revision 3.0 Version 2.0 + ECNs 2020-12-10
>   6.4.4.2.3 Structured VDM Version
>   "The Structured VDM Version field of the Discover Identity Command
>   sent and received during VDM discovery Shall be used to determine the
>   lowest common Structured VDM Version supported by the Port Partners or
>   Cable Plug and Shall continue to operate using this Specification
>   Revision until they are Detached."
> 
> Signed-off-by: Kyle Tso <kyletso@google.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
> Changes since v5:
> - follow the changes of "usb: typec: Manage SVDM version"
> - remove the "reset to default". Now the default SVDM version will be
>   set when calling to typec_register_partner
> 
>  drivers/usb/typec/ucsi/displayport.c | 32 +++++++++++++++++++++++++---
>  drivers/usb/typec/ucsi/ucsi.c        |  1 +
>  2 files changed, 30 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/ucsi/displayport.c b/drivers/usb/typec/ucsi/displayport.c
> index 1d387bddefb9..73cd5bf35047 100644
> --- a/drivers/usb/typec/ucsi/displayport.c
> +++ b/drivers/usb/typec/ucsi/displayport.c
> @@ -49,6 +49,7 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
>  {
>  	struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);
>  	struct ucsi *ucsi = dp->con->ucsi;
> +	int svdm_version;
>  	u64 command;
>  	u8 cur = 0;
>  	int ret;
> @@ -83,7 +84,13 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
>  	 * mode, and letting the alt mode driver continue.
>  	 */
>  
> -	dp->header = VDO(USB_TYPEC_DP_SID, 1, SVDM_VER_1_0, CMD_ENTER_MODE);
> +	svdm_version = typec_altmode_get_svdm_version(alt);
> +	if (svdm_version < 0) {
> +		ret = svdm_version;
> +		goto err_unlock;
> +	}
> +
> +	dp->header = VDO(USB_TYPEC_DP_SID, 1, svdm_version, CMD_ENTER_MODE);
>  	dp->header |= VDO_OPOS(USB_TYPEC_DP_MODE);
>  	dp->header |= VDO_CMDT(CMDT_RSP_ACK);
>  
> @@ -101,6 +108,7 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
>  static int ucsi_displayport_exit(struct typec_altmode *alt)
>  {
>  	struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);
> +	int svdm_version;
>  	u64 command;
>  	int ret = 0;
>  
> @@ -120,7 +128,13 @@ static int ucsi_displayport_exit(struct typec_altmode *alt)
>  	if (ret < 0)
>  		goto out_unlock;
>  
> -	dp->header = VDO(USB_TYPEC_DP_SID, 1, SVDM_VER_1_0, CMD_EXIT_MODE);
> +	svdm_version = typec_altmode_get_svdm_version(alt);
> +	if (svdm_version < 0) {
> +		ret = svdm_version;
> +		goto out_unlock;
> +	}
> +
> +	dp->header = VDO(USB_TYPEC_DP_SID, 1, svdm_version, CMD_EXIT_MODE);
>  	dp->header |= VDO_OPOS(USB_TYPEC_DP_MODE);
>  	dp->header |= VDO_CMDT(CMDT_RSP_ACK);
>  
> @@ -186,6 +200,7 @@ static int ucsi_displayport_vdm(struct typec_altmode *alt,
>  	struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);
>  	int cmd_type = PD_VDO_CMDT(header);
>  	int cmd = PD_VDO_CMD(header);
> +	int svdm_version;
>  
>  	mutex_lock(&dp->con->lock);
>  
> @@ -198,9 +213,20 @@ static int ucsi_displayport_vdm(struct typec_altmode *alt,
>  		return -EOPNOTSUPP;
>  	}
>  
> +	svdm_version = typec_altmode_get_svdm_version(alt);
> +	if (svdm_version < 0) {
> +		mutex_unlock(&dp->con->lock);
> +		return svdm_version;
> +	}
> +
>  	switch (cmd_type) {
>  	case CMDT_INIT:
> -		dp->header = VDO(USB_TYPEC_DP_SID, 1, SVDM_VER_1_0, cmd);
> +		if (PD_VDO_SVDM_VER(header) < svdm_version) {
> +			typec_partner_set_svdm_version(dp->con->partner, PD_VDO_SVDM_VER(header));
> +			svdm_version = PD_VDO_SVDM_VER(header);
> +		}
> +
> +		dp->header = VDO(USB_TYPEC_DP_SID, 1, svdm_version, cmd);
>  		dp->header |= VDO_OPOS(USB_TYPEC_DP_MODE);
>  
>  		switch (cmd) {
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index ca3f4194ad90..244270755ae6 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1052,6 +1052,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
>  
>  	cap->revision = ucsi->cap.typec_version;
>  	cap->pd_revision = ucsi->cap.pd_version;
> +	cap->svdm_version = SVDM_VER_2_0;
>  	cap->prefer_role = TYPEC_NO_PREFERRED_ROLE;
>  
>  	if (con->cap.op_mode & UCSI_CONCAP_OPMODE_AUDIO_ACCESSORY)
> -- 
> 2.30.0.365.g02bc693789-goog
> 

  reply	other threads:[~2021-02-12  4:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05  3:34 [PATCH v6 0/7] common SVDM version and VDO from dt Kyle Tso
2021-02-05  3:34 ` [PATCHi v6 1/7] usb: typec: Manage SVDM version Kyle Tso
2021-02-12  4:09   ` Guenter Roeck
2021-02-05  3:34 ` [PATCH v6 2/7] usb: pd: Make SVDM Version configurable in VDM header Kyle Tso
2021-02-12  4:09   ` Guenter Roeck
2021-02-05  3:34 ` [PATCH v6 3/7] usb: typec: tcpm: Determine common SVDM Version Kyle Tso
2021-02-12  4:17   ` Guenter Roeck
2021-02-12  7:10     ` Kyle Tso
2021-02-12  7:24       ` Kyle Tso
2021-02-12 15:18         ` Guenter Roeck
2021-02-12 15:20   ` Guenter Roeck
2021-02-05  3:34 ` [PATCH v6 4/7] usb: typec: ucsi: " Kyle Tso
2021-02-12  4:18   ` Guenter Roeck [this message]
2021-02-05  3:34 ` [PATCH v6 5/7] usb: typec: displayport: Fill the negotiated SVDM Version in the header Kyle Tso
2021-02-12  4:19   ` Guenter Roeck
2021-02-05  3:34 ` [PATCH v6 6/7] dt-bindings: connector: Add SVDM VDO properties Kyle Tso
2021-02-05 21:29   ` Rob Herring
2021-02-06  0:29     ` Kyle Tso
2021-02-12  4:21   ` Guenter Roeck
2021-02-12  7:28     ` Kyle Tso
2021-02-05  3:34 ` [PATCH v6 7/7] usb: typec: tcpm: Get Sink VDO from fwnode Kyle Tso
2021-02-12  4:21   ` Guenter Roeck
2021-02-05 11:42 ` [PATCH v6 0/7] common SVDM version and VDO from dt Heikki Krogerus
2021-02-05 12:20   ` 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=20210212041848.GD103223@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=badhri@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kyletso@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=robh+dt@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).