Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3651913ybh; Tue, 17 Mar 2020 04:10:23 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuCt8mAyYxjtBVS0UQkuTpkA/V7xX45sOyv0g55w7CMnC4mvl7r7I6oFKEIscNhTO3LTw8V X-Received: by 2002:aca:2801:: with SMTP id 1mr3052521oix.168.1584443422859; Tue, 17 Mar 2020 04:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584443422; cv=none; d=google.com; s=arc-20160816; b=ULwynlBvHbg9xYkwdCDzGKCZGBVxGsECsJFNomUGC1CqquV37dcaecDMTnZT1aeH18 mXwdDXmMB4TYk6siDb6qmdSLA/hNb+ktNuluv0Vw0geIpx3dppLvy6384siJGeq5cgO0 osPQNbB9NQTwrKHqpLnWHbtKrytZGT7NRVzrMVSOpbY1kx4/bw1Jd3PtN/OT8EGbt0DW S65ZHOKzzBymJk7AEG/UgcI4kpXw+V76lHrL7y6ufGlcyiqAZ/JrbDawfeyq7KkoVbzg IPLADv8RhShnLmWv7m0v5mHMlpRUMebeQ6K2OpgSg2FPLPh400c/LtNcc58TBkLZtjxJ NgZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=6YBBlmiXartpwvR3hISvMI3/oVlWxdYlbnGan/EBRjw=; b=KnGOUCEjPt4NkoP7d4sUQZpDoFnwewKZsIWRK2s/6irtIJueKysYXVI3FFCbFexukC 9FyVClBwJWagjhqi5OTjH4BD0bQpNTi11HMFdquAJEFDFmqQVr5n74TYxsdWICMvcdGN 1b7bqwGjCsF9nNCHoRpKwP5RKS5nZUUuxruGLvEet6nbREV6siiN56z/yHHaia9edMFW zIZsjgaSBpk28ZaiTiISBcJ2Mq8B4wX3zRbsNY17zokveLqKeg1jrOyPNHfh+yNFM9VJ AakHtDdj0vUPQTt9GOLdTOkI1R5JAfmI41YtRAgiF+AxPBrHHv4w+W7dujj4z1HfEZL+ 93JA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d185si1491892oif.234.2020.03.17.04.10.11; Tue, 17 Mar 2020 04:10:22 -0700 (PDT) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728546AbgCQLJz (ORCPT + 99 others); Tue, 17 Mar 2020 07:09:55 -0400 Received: from mga05.intel.com ([192.55.52.43]:55398 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728995AbgCQLJw (ORCPT ); Tue, 17 Mar 2020 07:09:52 -0400 IronPort-SDR: upN4Lle8p1HOnoqErtBg1gA/yI16yPnmw9SpYIGQI8dtS9jL0KclTBefYkABBFWl26Ou28JMeu ikB3QwrVjnCA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 04:09:52 -0700 IronPort-SDR: DcubFaa8G9/CwOKUQ6thFIpoZ8Jo8KEl50diC5OSde67LgFhejYj16g5WhC20KhC/iW6SocgkM ZH7vkdC3zl5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,564,1574150400"; d="scan'208";a="355330981" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 17 Mar 2020 04:09:49 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 17 Mar 2020 13:09:49 +0200 Date: Tue, 17 Mar 2020 13:09:49 +0200 From: Heikki Krogerus To: Prashant Malani Cc: linux-kernel@vger.kernel.org, Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: Re: [PATCH v5 3/4] platform/chrome: typec: Get PD_CONTROL cmd version Message-ID: <20200317110949.GB3015886@kuha.fi.intel.com> References: <20200316090021.52148-1-pmalani@chromium.org> <20200316090021.52148-4-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200316090021.52148-4-pmalani@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 > --- > > 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