Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2381795ybh; Mon, 16 Mar 2020 02:03:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt1h0QSvz1QcLjFPtdLknWJLZRv8ML6VyJmeEtfp3PCY4J7maeT55ghneBg8C+mQ+8/Z0kQ X-Received: by 2002:a9d:5e9:: with SMTP id 96mr21752038otd.307.1584349405855; Mon, 16 Mar 2020 02:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584349405; cv=none; d=google.com; s=arc-20160816; b=iGS2alvZjagafigMljEzfvLBNavi/2QU3ayQLoxJaMKgCb0xdJzkDC+8DdoE6rRZu2 aPudwdxJSJoJIkeXNgJPTkwgcGMKqx6dIyG4AgGSf1L4ULQjoCt6A9KB1FS9ROEaYFpq C5X1Weqqi4ZwMbIEXBu2YM5z/Uc/FIAKgXH6fTr2IZf6A7WskKoYf97TFTzvT93GZ1XJ dXmv/fvj3EbZ30wKc27BqZaj75kjFmYKWQX1GvUMSNmBFFEg0EH+CciVyIv32dyq89W0 1Ukth6xOUh9c0O8Z3dPwajs32vQZWNv0cdUvjSWf5xjGj/sV+dF9Og8DTYmhC51Fg/rr uDtQ== 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=mPt7LHQC0VkAtA+GFeRvZAx3rFXp2/l5EXFJ5H0G1qQ=; b=N+zWD4/tvEXqrfN/wqCtRiDEdyCiTHmU1rJrLVW2vQoptamuXqzAWnBd6XLv5wsd9s fF2Fcu/91j472i4nbsergdtSflCIAoPz5sD/FGTWJN86Td+RW+qoC1d6pRfLTccU8f9L xRP2ZDRybhMtLN4YthznEI3zZPyJw9SKtN/JUG+JPy49UHYmudzHldEC/Q8pNSmYa5LC v98za68kL252LY2NbhgBf1t/2byDzrlrhxbdQaWmSBX9NfroTmA3z0mY2d5hkhAguS/P F4rH2mlltKRLqQjbKRKE8e/u8ZyIHuXBNOUtUEapMNVHpcKBOkkNbd+ZIrC6mOw2LpOe kmig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hklC2Dw0; 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 131si3510826oid.75.2020.03.16.02.03.11; Mon, 16 Mar 2020 02:03:25 -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=hklC2Dw0; 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 S1730396AbgCPJBY (ORCPT + 99 others); Mon, 16 Mar 2020 05:01:24 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:39209 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730242AbgCPJBX (ORCPT ); Mon, 16 Mar 2020 05:01:23 -0400 Received: by mail-pj1-f67.google.com with SMTP id d8so8277083pje.4 for ; Mon, 16 Mar 2020 02:01:21 -0700 (PDT) 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=mPt7LHQC0VkAtA+GFeRvZAx3rFXp2/l5EXFJ5H0G1qQ=; b=hklC2Dw0fPeR9wjYyhFbhgcF0Vupbnd23oPU6+U1we0/gbQM7bqlqGXI9BRC7xfSQj 4nuFS9Ng373XdHFQc16A2eYqzW1b/YCZn9M9bP5r1mPlqRWdC0cueciOsul3ULFQm7OU iXokaSebMQBtnW0bd4q+eGXsIULjLVHhHsohU= 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=mPt7LHQC0VkAtA+GFeRvZAx3rFXp2/l5EXFJ5H0G1qQ=; b=ldMmDycNDzxO2Rjyd1GmjjQznXpnyiUrG0jMMjQ6+oX19LkQF4czv3hO7txvTA4jj4 ClxNUHkaDgaLD3l3EhIfX6Z39sm3ltOch2FLHJDR9C4ygAjJLJ44ZZBpuxmF1N58/seG bbMzqZham5OVIc4f1ofX8BhHVoavTEJOP4M+tNptPj9Ek3w5lG0hqFlR+rZcsbgjFt4i l5VDPOFfdu9zUcA2ushQ1FD+WThElV3WFWhnWlYSU3OaghU2HR/EzTHVuIWim/VcdIh8 2c5wMXZz/TZn0qNIfm1UlG0Ciw1MbrU9byLYoPb2EBEODNZlber5dcP5PAkRTAMZlrvA ioRw== X-Gm-Message-State: ANhLgQ2fGJ8bgpqWKwNXTzQ/7GfzAQpivbQ9TMNZ0uWpRYnp5qw3ej0n uQmYrWxr7PXJ4T2ypzBR8DQAkyeB8EM= X-Received: by 2002:a17:902:9a08:: with SMTP id v8mr25875764plp.192.1584349280705; Mon, 16 Mar 2020 02:01:20 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id d3sm65040080pfn.113.2020.03.16.02.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 02:01:20 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH v5 3/4] platform/chrome: typec: Get PD_CONTROL cmd version Date: Mon, 16 Mar 2020 02:00:19 -0700 Message-Id: <20200316090021.52148-4-pmalani@chromium.org> X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-goog In-Reply-To: <20200316090021.52148-1-pmalani@chromium.org> References: <20200316090021.52148-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 --- 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