Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4797116ybv; Tue, 11 Feb 2020 03:41:22 -0800 (PST) X-Google-Smtp-Source: APXvYqw2KaB5rm5U/6wMSrffJSa6/t9UUE85ugMLubZ57CEmjzFE+CrLK1dPK3bZJkA9TJWBTOK6 X-Received: by 2002:a9d:4c06:: with SMTP id l6mr4987843otf.161.1581421282183; Tue, 11 Feb 2020 03:41:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581421282; cv=none; d=google.com; s=arc-20160816; b=uh+v+Ao0WanO79de2eLPp7kh7i6F0LGBD3I7feiuvQiZik4I+sl5tQ7VjCVwgcCjTR 3RjfjiaARVjvZc/d5CC4rj4T1PlL0jKM3OAszHKODkZHm7H+0xBBclw3/6JwDGRg4kGB zRU/MPbT1lgqCrJOYnoVhWCwXzGv72bUbKzQrHN1pg81cwZSibFOKLdSTZtdY6PX+KsC K4b8ndTvLdkImUjoQZCuk3jrrqSlNlMr90MWeYCHyQLFYAWVWWdvknWKRCB3wZcIz7EL bxOQ6HN89UgINKdcTzWKXAeWWNd8jiBmmH6hfqmHtnhfgW62aX5AzL5CnXy0sn/9Fl03 d8zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Ii60hdn/wdfHBcz++Zv/ks109klM/VIKtwdgXzoA9b4=; b=SA3ac7wHaO/1MdfwlQWoEth6X9gAluAGR2Pos2z1vgYq1yA52dw/A2HVu1R5LypNLQ r1N4XTogcYTQgcWOXok2vbf3fohi0jvokcX1oCBb3K8P5KsCcbnkDjDqopDo6t1tvS14 HlzpXrdocCpYog7VlqTV3S2V5q9Pk22kEWD4rtgdMXVNhbis1DbQKt5sTjRR9oR9S1tV oK/nULTpLwJO06GAGfYEv4FPZaGgf2AmIpN0v9/SUapkbdL+YkEu8Zmhnoi7pS/ckImZ fc4DZ8zCS8uda4OUI9zmoUstvfohn1AJwtqvAOJbgkv78M//AetyEuFuSJ5plkCJaJkl mSbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14si1822442oto.127.2020.02.11.03.41.10; Tue, 11 Feb 2020 03:41:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728442AbgBKKwM (ORCPT + 99 others); Tue, 11 Feb 2020 05:52:12 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:33860 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728312AbgBKKwM (ORCPT ); Tue, 11 Feb 2020 05:52:12 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id B9FDF294007 Subject: Re: [PATCH v2 3/4] platform/chrome: typec: Get PD_CONTROL cmd version To: Prashant Malani , linux-kernel@vger.kernel.org Cc: heikki.krogerus@intel.com, bleung@chromium.org, Guenter Roeck References: <20200207203752.209296-1-pmalani@chromium.org> <20200207203752.209296-4-pmalani@chromium.org> From: Enric Balletbo i Serra Message-ID: <01d3c407-d0e6-2495-30fe-68243050fe06@collabora.com> Date: Tue, 11 Feb 2020 11:52:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20200207203752.209296-4-pmalani@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > --- > > 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; >