Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2966629ybh; Mon, 16 Mar 2020 13:09:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtokIUbafiWS+RZexgCb3cMh02oFPo+l07GpxaXiUSa2GRGX24DEi6qg7Pil2dHntaoRPEf X-Received: by 2002:a9d:4c05:: with SMTP id l5mr796446otf.371.1584389346681; Mon, 16 Mar 2020 13:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584389346; cv=none; d=google.com; s=arc-20160816; b=cSkyl5Q+OYvy5wDALnCOvaNZiaZIncmZGAKPvNxzpuDkvPJXCAzz0LYbJmVMNtY/Ed Gf1Uf1cW0rpjo0XRDomNMX1PV2aF1uGxbFCaU+vj7F9CR52KNlPmmXVJUMiwzjnvAfZF 3E+9S2AQglIigcT4daEzYSfNWa9BcyDVOPHgdA160DVt/65bK1BStJ1y01TjNGmPpLyp ugXFqmpxWqiCiH9e8nxqlW4DSCMErGdW8Y8j4t3Kw9hnq4Zinr7TnF1+bZe4ZdslmrqJ h/tFw/nivfS95UlboUUW6w430RckPFTo+McCChOpX1xzs0BmfP4M4w4+5ZLXRJqYdgoZ j7xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Y7O+y+5PEoVenZhGHq9mu4e8GpUF5OMLN8jJyvkkAuA=; b=xdtbs05CpgpcAC4WgbuEq6KaGoTJblX4BPp040WLRbKqsqByb0a0U03y4aFUuLlfEN K10C+EJjd79W0KcYLu49IqY7f5JCORtUmJhB7ESqVPzk1wKYuLFv9cITFaq7szi8ku5G SR9Q05G6x5Ba2049h3bXD/YdkqM0eUi4lGl/jyGG0G4g4TPWg3gcWEPnKsnUcbWYdn47 uTd8kidYnxXSOIG2zGgMFavUWxRt4pUFurGAFwkaCuZMYdX3syNIzJceWbLjcPd7SXWN SPxcwhHroFuXyIyBldbBlOcKXThRZ0fmTTHFrT3zsI+38GztRGahV5s6HGDzBZNSurVQ NaYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GLK3ib9J; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j125si505933oia.150.2020.03.16.13.08.53; Mon, 16 Mar 2020 13:09:06 -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; dkim=pass header.i=@chromium.org header.s=google header.b=GLK3ib9J; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732504AbgCPUI0 (ORCPT + 99 others); Mon, 16 Mar 2020 16:08:26 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:41787 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732436AbgCPUI0 (ORCPT ); Mon, 16 Mar 2020 16:08:26 -0400 Received: by mail-qk1-f193.google.com with SMTP id s11so17239128qks.8 for ; Mon, 16 Mar 2020 13:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Y7O+y+5PEoVenZhGHq9mu4e8GpUF5OMLN8jJyvkkAuA=; b=GLK3ib9JqbFf9iF8NGea8Z02yjbUhv86Qnz2UVCwo6GJzRWxTihfsWCUTHZiIDKBe3 iwbbt7GKMKqQVqrPm3UqZlhhj/gpOHWNXYIU9l7EwsPYpkzTVKLEISUcpQ/Kc0T14rTK ba9kRoWtffQWv9ZAOZiZYjZ3/7WOSquGBDkwA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Y7O+y+5PEoVenZhGHq9mu4e8GpUF5OMLN8jJyvkkAuA=; b=IpS0270uUGYygQ25qcCe8hpuOTkZApx3wujthrao0hCl8KQZgUzF5I1fS4OyZ9MKhJ 0ZOoo290pNg1bW7zQgBBq8WWm6w1gkpuLLiydcipqFhh1fERg33703310dODZQqD+U/k BjufjxNNf0LKyUi4wTzp5fO2cyr0UN2EtEAHXxtBJYMXGbFRrszzA7/Pg6mGiuS9+d2I z0qweajOZL6L9mVk9nlf2lWQTnGgXXkhSHDB5uYZhJo/UUEhB7lv0yxhSgsm29MmYFpU gtKhoEMCGoKbnABSWSv64kJ/pUR78IOa0T3TJhvPKiPT2sKhssDbgj5AU0016XZy0Lxf 2BIQ== X-Gm-Message-State: ANhLgQ2kbMfTSGOaNXITfTmtSAt8AdEKQvt6SsG+9sd7BDIO8desYjfd Qdz0+H/ydKAuoYyAs6k3uuckFIiOyuDh0OGNtLRqBoUV X-Received: by 2002:a05:620a:a5b:: with SMTP id j27mr1394597qka.179.1584389303039; Mon, 16 Mar 2020 13:08:23 -0700 (PDT) MIME-Version: 1.0 References: <20200316090021.52148-1-pmalani@chromium.org> <20200316090021.52148-4-pmalani@chromium.org> In-Reply-To: <20200316090021.52148-4-pmalani@chromium.org> From: Prashant Malani Date: Mon, 16 Mar 2020 13:08:11 -0700 Message-ID: Subject: Re: [PATCH v5 3/4] platform/chrome: typec: Get PD_CONTROL cmd version To: Linux Kernel Mailing List Cc: Benson Leung , Enric Balletbo i Serra , Guenter Roeck , Heikki Krogerus Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org My apologies, missed adding Heikki. On Mon, Mar 16, 2020 at 2:01 AM 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 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 >