Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp354287ybm; Thu, 28 May 2020 04:40:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGiMM/FW6GZeeX8dbFnuLSqv1KvEiqMxP8d34DTndg1leSGs1Zuzn83wS0OefKVJSMn1w1 X-Received: by 2002:aa7:d487:: with SMTP id b7mr2636206edr.351.1590666012328; Thu, 28 May 2020 04:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590666012; cv=none; d=google.com; s=arc-20160816; b=XzwKlFU79ggbZ1TJo3ntdBlN78dy9WXywwvw2HAGXv38wu3ET7X4T+F/VXnfb0aR1Q J89jVzhrsIrh8XkKGiY/hkiGmwGTVB1db3ibp9Qr+5TdrLPsiirQ5CMeBtpI9Uah7EeJ rDbWDVYYjGYv/Lc/r62hcGnSPgNcuyI/Cbocb3WJd9B8CGXDCnhM4Rz3068FDSADCtgg KzSqosisGphuFJ6SkKGTWaEYhw8KcxpHJG+/nBZ8RlVDx+2+U++Rkm93GtwkTejAH7xr g554haVHc1S2Ae7D7iE1UCRX4G+ZiAi0k+hiU9p8aBnROxWl329ltP7AJ4eNyYG8WhTP +hSQ== 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=SPlSNhEoMy4GFhlZbMQB+IG1g/7jJz5UAQwhfKQZkc0=; b=t59YkciR+/lsgOWVbvXfEbmM9we5N+sHaRqngrCJoBZ43tjVKbjDz1CJwdvXG0Xst0 0iaybISYWOUD4Ct8Lx1ed5QfwNuFtS6ijtjhalUfRQ5FW6zxZ0j0YwbOEa7jzk9CBH4U +PErssVLOxovRpcwdz+FJMyo+vHDkvcW031yd7mw7dhy5nLq7dlC7t2vFPxoAnifZ6Ky vb86RY+TnFkm3wJGW5gcV7tKOkES1OI7n13KYJ5YvNtQPMQ5Vntogllje77lk4H/U7OM aU0/3b/2BA3VC/aFJ2IaN8vQB7aV0wIls2sBagKbESPc/58Z0UbfDGE5PeBFPz27nZ79 c7Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HhMcEpIh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id w20si3501066ejf.208.2020.05.28.04.39.49; Thu, 28 May 2020 04:40:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HhMcEpIh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2388451AbgE1Lgx (ORCPT + 99 others); Thu, 28 May 2020 07:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388326AbgE1Lgw (ORCPT ); Thu, 28 May 2020 07:36:52 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0BD8C05BD1E for ; Thu, 28 May 2020 04:36:52 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id f21so10362636pgg.12 for ; Thu, 28 May 2020 04:36:52 -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=SPlSNhEoMy4GFhlZbMQB+IG1g/7jJz5UAQwhfKQZkc0=; b=HhMcEpIht9SY74kN2eKZY+4AIad8N9YEflvLVjOmgNDuhnFtYjKbe81JGHw+6BulzK N3wFaZdKCJ3jzwxuM+pG1z2zWrRjWZl48HZIiaZgRJD3H+oiX2kYrlwu3C9os+bwag74 0WSwB1Q3wFUuzH+h9PhpX0pq6lcmxFj42icqI= 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=SPlSNhEoMy4GFhlZbMQB+IG1g/7jJz5UAQwhfKQZkc0=; b=AzFqQMkf/vO8Rhayel1sd6H4VYCcAs6mNMRr+hS23TA0fWpA+4LTOm/lE9MdBWoXaM tThkCNYk8Gq1ARbIkGqytugOFbtNgUd5Mg+BUvMZh8xCEilEq0pMiEqcrdCUn9pJldBX 2QreEU/1TTlJq2e6lfSlKteWpgr15MZsOg73LzN8pJ4TAq35OSc4gIYM5dC/uuMTx0Te TPsPA3AC8jhDYJ3ljhy6OiKE6xoyVwkfroN6c9DGocBBGFZhgOjUJapJFLkgy1X41waz btA0wAj7ZI4d+wsVUc2oTyTymLs8fj0pTtzCHj9+lF7Gl3u26Fcv7hJEMwOMq7n20cgO rLhQ== X-Gm-Message-State: AOAM531sCiluzxMibkDDPeABpe51UgmrZ+vbK8Z6k4S/Z/NNLJMS+5IX Q2UHxyT+RXr68qT/cgNJIYoIcSRR8FY= X-Received: by 2002:a63:6605:: with SMTP id a5mr2483594pgc.50.1590665812048; Thu, 28 May 2020 04:36:52 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id g7sm4519961pjs.48.2020.05.28.04.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2020 04:36:51 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Enric Balletbo i Serra , Fabien Lahoudere , Guenter Roeck , Gwendal Grignou , Lee Jones , Tzung-Bi Shih Subject: [PATCH 2/4] platform/chrome: typec: Register PD CTRL cmd v2 Date: Thu, 28 May 2020 04:36:05 -0700 Message-Id: <20200528113607.120841-3-pmalani@chromium.org> X-Mailer: git-send-email 2.27.0.rc0.183.gde8f92d652-goog In-Reply-To: <20200528113607.120841-1-pmalani@chromium.org> References: <20200528113607.120841-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 Recognize EC_CMD_USB_PD_CONTROL command version 2. This is necessary in order to process Type C mux information (like DP alt mode pin configuration), which is needed by the Type C Connector class API to configure the Type C muxes correctly While we are here, rename the struct member storing this version number from cmd_ver to pd_ctrl_ver, which more accurately reflects what is being stored. Also, slightly change the logic for calling cros_typec_set_port_params_*(). Now, v0 is called when pd_ctrl_ver is 0, and v1 is called otherwise. Signed-off-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 6e79f917314b..d69a88464cef 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -37,7 +37,7 @@ struct cros_typec_data { struct device *dev; struct cros_ec_device *ec; int num_ports; - unsigned int cmd_ver; + unsigned int pd_ctrl_ver; /* Array of ports, indexed by port number. */ struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS]; struct notifier_block nb; @@ -340,7 +340,7 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) req.mux = USB_PD_CTRL_MUX_NO_CHANGE; req.swap = USB_PD_CTRL_SWAP_NONE; - ret = cros_typec_ec_command(typec, typec->cmd_ver, + ret = cros_typec_ec_command(typec, typec->pd_ctrl_ver, EC_CMD_USB_PD_CONTROL, &req, sizeof(req), &resp, sizeof(resp)); if (ret < 0) @@ -351,7 +351,7 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) dev_dbg(typec->dev, "Polarity %d: 0x%hhx\n", port_num, resp.polarity); dev_dbg(typec->dev, "State %d: %s\n", port_num, resp.state); - if (typec->cmd_ver == 1) + if (typec->pd_ctrl_ver != 0) cros_typec_set_port_params_v1(typec, port_num, &resp); else cros_typec_set_port_params_v0(typec, port_num, @@ -374,13 +374,15 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec) if (ret < 0) return ret; - if (resp.version_mask & EC_VER_MASK(1)) - typec->cmd_ver = 1; + if (resp.version_mask & EC_VER_MASK(2)) + typec->pd_ctrl_ver = 2; + else if (resp.version_mask & EC_VER_MASK(1)) + typec->pd_ctrl_ver = 1; else - typec->cmd_ver = 0; + typec->pd_ctrl_ver = 0; dev_dbg(typec->dev, "PD Control has version mask 0x%hhx\n", - typec->cmd_ver); + typec->pd_ctrl_ver); return 0; } -- 2.27.0.rc0.183.gde8f92d652-goog