Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp706876ybv; Wed, 5 Feb 2020 13:02:56 -0800 (PST) X-Google-Smtp-Source: APXvYqx4gpWo5PLKXNqOLN/+HrSBl6bYHJcgyWm1vr+mDEqc0ku8E9SV5bRoP+T/JXZx7/OBgTDl X-Received: by 2002:aca:b7c5:: with SMTP id h188mr4487407oif.100.1580936576410; Wed, 05 Feb 2020 13:02:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580936576; cv=none; d=google.com; s=arc-20160816; b=OISTNw+kAV1ZaudGEv6UHDEFTTFb9a+eZV4pOjy/Q+48/QrGJNxAA+yyTNuih11wkO TAliWkDgonSZ36goJDhcn9g6qB+9GeA3arVHeLHulmjMc+H7D2EViOeM16O2X8i4evD8 a7DTMEe+qoiEYh5ELnp+0lZUnGJtxNix68oTqcXDo4VQc7wiVNuDkNMzpYaklrTGOCa0 ZueL+0PChvp/lHvjDrxVjEgpaI0ZnCypPl5sYXnA/MBLmFfs3EY5nUAEYasB/2IIPsFk XuOFt28rMwN5+55fnmXSyRYfb082RGI6EQ4d1BKxduuocHHBqkLwCJhedkdGCoassrDo Jqog== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SQ0GAnvyRYeOH9Mitx5dzN1/E/DrwnX3jWdRMovUOco=; b=ED4AC4QCy0wdFRMXhwIzlas2poP1magDYba1Dk4xamIoUPIeIH06byPOLeaQRzoxg9 DKjAACa3Z4NxBBAjyL3zQADMNmvPoc/ymGIqkrvWAM+B9CZvweheDKzczWHFF/oQ7jJG Sm+j3WgcMqsyWziTcr7x1Sxh+ebEBC488rE1kJ3z+7HqUh+h5wOiZPSzn3xdhnmYDQDh ysaPsPjqYovEYv33tFLzjR199RwMs+WaYtXmrOjT7xszTVXnW0Nrr0OQVMUZQtNueGKL ewOKipd75KJF86Y2VKCphelq+8yxCbrACz2XN3B4ECOJ39Ib9SNkuaqP7QCTKySvnfyk wU8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HMwCz2GC; 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 i124si774524oif.214.2020.02.05.13.02.44; Wed, 05 Feb 2020 13:02:56 -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; dkim=pass header.i=@chromium.org header.s=google header.b=HMwCz2GC; 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 S1727234AbgBEVBo (ORCPT + 99 others); Wed, 5 Feb 2020 16:01:44 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37665 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgBEVBo (ORCPT ); Wed, 5 Feb 2020 16:01:44 -0500 Received: by mail-pg1-f194.google.com with SMTP id z12so1560545pgl.4 for ; Wed, 05 Feb 2020 13:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SQ0GAnvyRYeOH9Mitx5dzN1/E/DrwnX3jWdRMovUOco=; b=HMwCz2GCC0Jfy1f9ihH08auHez7uQ6tn0r4XPFzFK3hhUou76MmRNGoLjNQRRVdk/S uYpaaknKmil8nDrofl03+3tk5nnJleooK8Rxas6cR/X8m8EY+KCPzL9xW5nZ9ZdkO1bY Qa1hRmoQ7kQpoK/4l3AnWMvxZsoXa0iXT+FQU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SQ0GAnvyRYeOH9Mitx5dzN1/E/DrwnX3jWdRMovUOco=; b=tGE3+EXQNAi5FsSPMq/FnG3D8nAZbQNX4rHiIU1BAM1qu4j712xc291erQ3kgKOeCk QGM7cXW7EUaVPl0mQUqR/wrYGQES4AahlKMb2H33FtsD9Cm7SgTrX/f6ivDzQu3YAzbv /ez25r23/WXlZlLo6R7CkmPlMRaDSe3Sd82dosLeOtbpEgZGtV/xo6kvL+FiB70M+PUs r0dV87fDkB8lWFhi2m1bovh8KujIJYLW0Zuq7znFCmpsDXOVBmO8QutZ3+JjpsURyBzR 1EkYjbBvBZCusX1Eylzk30qcOJEqgGw3yzfDXRYt7nIygz5CnuC6FVJu3y8BLVIaF1My S9jA== X-Gm-Message-State: APjAAAWcpCS9yDZ8qze3N31lhy3mV1ItSRbxeervm3o238YhLT8cPNdz 860GWF03tfy38LNQM+16lKOOOoHJ8SQ= X-Received: by 2002:a63:26c4:: with SMTP id m187mr38940067pgm.410.1580936502800; Wed, 05 Feb 2020 13:01:42 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:172e:4646:c089:ce59]) by smtp.gmail.com with ESMTPSA id f8sm648797pjg.28.2020.02.05.13.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2020 13:01:42 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: heikki.krogerus@intel.com, enric.balletbo@collabora.com, bleung@chromium.org, Prashant Malani , Guenter Roeck Subject: [PATCH 2/3] platform/chrome: typec: Get PD_CONTROL cmd version Date: Wed, 5 Feb 2020 12:59:52 -0800 Message-Id: <20200205205954.84503-3-pmalani@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200205205954.84503-1-pmalani@chromium.org> References: <20200205205954.84503-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 fe5659171c2a85..b8edcfaa8a5297 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]; }; @@ -173,6 +174,31 @@ static int cros_typec_get_num_ports(struct cros_typec_data *typec) return 0; } +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 }, @@ -206,8 +232,14 @@ static int cros_typec_probe(struct platform_device *pdev) if (ret < 0) return ret; + 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_init_ports(typec); - if (!ret) + if (ret < 0) return ret; return 0; -- 2.25.0.341.g760bfbb309-goog