[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200317110949.GB3015886@kuha.fi.intel.com>
Date: Tue, 17 Mar 2020 13:09:49 +0200
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: Prashant Malani <pmalani@...omium.org>
Cc: linux-kernel@...r.kernel.org, Benson Leung <bleung@...omium.org>,
Enric Balletbo i Serra <enric.balletbo@...labora.com>,
Guenter Roeck <groeck@...omium.org>
Subject: Re: [PATCH v5 3/4] platform/chrome: typec: Get PD_CONTROL cmd version
On Mon, Mar 16, 2020 at 02:00:19AM -0700, 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@...omium.org>
In case there is v6, please consider merging this into patch 4/4. I
don't think this needs separate patch. Otherwise, FWIW:
Reviewed-by: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
> ---
>
> Changes in v5:
> - No changes.
>
> Changes in v4:
> - No changes
>
> Changes in v3:
> - Moved if statement check in the end of probe() from this patch to a
> previous patch.
>
> Changes in v2:
> - No changes.
>
> drivers/platform/chrome/cros_ec_typec.c | 32 +++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 02e6d5cbbbf7a..9f692eb78b322 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];
> /* Initial capabilities for each port. */
> @@ -171,6 +172,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 },
> @@ -202,6 +228,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)
> --
> 2.25.1.481.gfbce0eb801-goog
thanks,
--
heikki
Powered by blists - more mailing lists