linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: Prashant Malani <pmalani@chromium.org>, linux-kernel@vger.kernel.org
Cc: heikki.krogerus@intel.com, bleung@chromium.org,
	Guenter Roeck <groeck@chromium.org>
Subject: Re: [PATCH v2 3/4] platform/chrome: typec: Get PD_CONTROL cmd version
Date: Tue, 11 Feb 2020 11:52:08 +0100	[thread overview]
Message-ID: <01d3c407-d0e6-2495-30fe-68243050fe06@collabora.com> (raw)
In-Reply-To: <20200207203752.209296-4-pmalani@chromium.org>

Hi Prashant,

On 7/2/20 21:37, Prashant Malani wrote:
> Query the EC to determine the version number of the PD_CONTROL
> command which is supported by the EC. Also store this value in the Type
> C data struct since it will be used to determine how to parse the
> response to queries for port information from the EC.
> 
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> ---
> 
> Changes in v2:
> - No changes.
> 
>  drivers/platform/chrome/cros_ec_typec.c | 34 ++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 8374ccfe784f3b..df01ce86c7146c 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -21,6 +21,7 @@ struct cros_typec_data {
>  	struct device *dev;
>  	struct cros_ec_device *ec;
>  	int num_ports;
> +	unsigned int cmd_ver;
>  	/* Array of ports, indexed by port number. */
>  	struct typec_port *ports[EC_USB_PD_MAX_PORTS];
>  };
> @@ -152,6 +153,31 @@ static int cros_typec_ec_command(struct cros_typec_data *typec,
>  	return ret;
>  }
>  
> +static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
> +{
> +	struct ec_params_get_cmd_versions_v1 req_v1;
> +	struct ec_response_get_cmd_versions resp;
> +	int ret;
> +
> +	/* We're interested in the PD control command version. */
> +	req_v1.cmd = EC_CMD_USB_PD_CONTROL;
> +	ret = cros_typec_ec_command(typec, 1, EC_CMD_GET_CMD_VERSIONS,
> +				    &req_v1, sizeof(req_v1), &resp,
> +				    sizeof(resp));
> +	if (ret < 0)
> +		return ret;
> +
> +	if (resp.version_mask & EC_VER_MASK(1))
> +		typec->cmd_ver = 1;
> +	else
> +		typec->cmd_ver = 0;
> +
> +	dev_dbg(typec->dev, "PD Control has version mask 0x%hhx\n",
> +		typec->cmd_ver);
> +
> +	return 0;
> +}
> +
>  #ifdef CONFIG_ACPI
>  static const struct acpi_device_id cros_typec_acpi_id[] = {
>  	{ "GOOG0014", 0 },
> @@ -182,6 +208,12 @@ static int cros_typec_probe(struct platform_device *pdev)
>  	typec->ec = dev_get_drvdata(pdev->dev.parent);
>  	platform_set_drvdata(pdev, typec);
>  
> +	ret = cros_typec_get_cmd_version(typec);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to get PD command version info\n");
> +		return ret;
> +	}
> +
>  	ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
>  				    &resp, sizeof(resp));
>  	if (ret < 0)
> @@ -196,7 +228,7 @@ static int cros_typec_probe(struct platform_device *pdev)
>  	}
>  
>  	ret = cros_typec_init_ports(typec);
> -	if (!ret)
> +	if (ret < 0)

Looks like this change should be in patch 2/4?

>  		return ret;
>  
>  	return 0;
> 

  reply	other threads:[~2020-02-11 10:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07 20:37 [PATCH v2 0/4] platform/chrome: Add Type C connector class driver Prashant Malani
2020-02-07 20:37 ` [PATCH v2 1/4] dt-bindings: Add cros-ec Type C port driver Prashant Malani
2020-02-11 10:28   ` Enric Balletbo i Serra
     [not found]     ` <CACeCKac-OjvCLZ4FefsGbH9JR_suB3nL5CVLa_N0o9qnSqi3-g@mail.gmail.com>
2020-02-11 19:01       ` Prashant Malani
2020-02-11 23:25   ` Rob Herring
2020-02-12 15:53     ` Heikki Krogerus
2020-02-07 20:37 ` [PATCH v2 2/4] platform/chrome: Add Type C connector class driver Prashant Malani
2020-02-11 11:26   ` Enric Balletbo i Serra
2020-02-12 16:53   ` Heikki Krogerus
2020-02-07 20:37 ` [PATCH v2 3/4] platform/chrome: typec: Get PD_CONTROL cmd version Prashant Malani
2020-02-11 10:52   ` Enric Balletbo i Serra [this message]
2020-02-07 20:37 ` [PATCH v2 4/4] platform/chrome: typec: Update port info from EC Prashant Malani

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=01d3c407-d0e6-2495-30fe-68243050fe06@collabora.com \
    --to=enric.balletbo@collabora.com \
    --cc=bleung@chromium.org \
    --cc=groeck@chromium.org \
    --cc=heikki.krogerus@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmalani@chromium.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).