From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Kyle Tso <kyletso@google.com>
Cc: linux@roeck-us.net, gregkh@linuxfoundation.org,
robh+dt@kernel.org, badhri@google.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 3/3] usb: typec: tcpm: Introduce snk_vdo_v1 for SVDM version 1.0
Date: Mon, 31 May 2021 12:05:27 +0300 [thread overview]
Message-ID: <YLSm13rYy0GPfapW@kuha.fi.intel.com> (raw)
In-Reply-To: <20210527084419.4164369-4-kyletso@google.com>
On Thu, May 27, 2021 at 04:44:19PM +0800, Kyle Tso wrote:
> The ID Header VDO and Product VDOs defined in USB PD Spec rev 2.0 and
> rev 3.1 are quite different. Add an additional array snk_vdo_v1 and
> send it as the response to the port partner if it only supports SVDM
> version 1.0.
>
> Signed-off-by: Kyle Tso <kyletso@google.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tcpm/tcpm.c | 40 +++++++++++++++++++++++++----------
> 1 file changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index a1bf0dc5babf..07d2bed0a63b 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -401,6 +401,8 @@ struct tcpm_port {
> unsigned int nr_src_pdo;
> u32 snk_pdo[PDO_MAX_OBJECTS];
> unsigned int nr_snk_pdo;
> + u32 snk_vdo_v1[VDO_MAX_OBJECTS];
> + unsigned int nr_snk_vdo_v1;
> u32 snk_vdo[VDO_MAX_OBJECTS];
> unsigned int nr_snk_vdo;
>
> @@ -1561,18 +1563,18 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev,
> */
> if ((port->data_role == TYPEC_DEVICE || svdm_version >= SVDM_VER_2_0) &&
> port->nr_snk_vdo) {
> - /*
> - * Product Type DFP and Connector Type are not defined in SVDM
> - * version 1.0 and shall be set to zero.
> - */
> - if (svdm_version < SVDM_VER_2_0)
> - response[1] = port->snk_vdo[0] & ~IDH_DFP_MASK
> - & ~IDH_CONN_MASK;
> - else
> + if (svdm_version < SVDM_VER_2_0) {
> + response[1] = port->snk_vdo_v1[0];
> + for (i = 1; i < port->nr_snk_vdo_v1; i++)
> + response[i + 1] = port->snk_vdo_v1[i];
> + rlen = port->nr_snk_vdo_v1 + 1;
> +
> + } else {
> response[1] = port->snk_vdo[0];
> - for (i = 1; i < port->nr_snk_vdo; i++)
> - response[i + 1] = port->snk_vdo[i];
> - rlen = port->nr_snk_vdo + 1;
> + for (i = 1; i < port->nr_snk_vdo; i++)
> + response[i + 1] = port->snk_vdo[i];
> + rlen = port->nr_snk_vdo + 1;
> + }
> }
> break;
> case CMD_DISCOVER_SVID:
> @@ -5953,6 +5955,22 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> return ret;
> }
>
> + /* If sink-vdos is found, sink-vdos-v1 is expected for backward compatibility. */
> + if (port->nr_snk_vdo) {
> + ret = fwnode_property_count_u32(fwnode, "sink-vdos-v1");
> + if (ret < 0)
> + return ret;
> + else if (ret == 0)
> + return -ENODATA;
> +
> + port->nr_snk_vdo_v1 = min(ret, VDO_MAX_OBJECTS);
> + ret = fwnode_property_read_u32_array(fwnode, "sink-vdos-v1",
> + port->snk_vdo_v1,
> + port->nr_snk_vdo_v1);
> + if (ret < 0)
> + return ret;
> + }
> +
> return 0;
> }
>
> --
> 2.31.1.818.g46aad6cb9e-goog
--
heikki
prev parent reply other threads:[~2021-05-31 9:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 8:44 [PATCH 0/3] Add the support of SVDM Version 2.0 VDOs Kyle Tso
2021-05-27 8:44 ` [PATCH 1/3] usb: typec: tcpm: Correct the responses in SVDM Version 2.0 DFP Kyle Tso
2021-05-31 8:49 ` Heikki Krogerus
2021-05-27 8:44 ` [PATCH 2/3] dt-bindings: connector: Add PD rev 2.0 VDO definition Kyle Tso
2021-05-27 8:44 ` [PATCH 3/3] usb: typec: tcpm: Introduce snk_vdo_v1 for SVDM version 1.0 Kyle Tso
2021-05-31 9:05 ` Heikki Krogerus [this message]
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=YLSm13rYy0GPfapW@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=badhri@google.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kyletso@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--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).