Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1569729pxb; Thu, 28 Jan 2021 22:18:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2tiW5qD4o9CDkbb/5aiRlPuR3zCxAHJiIzwnvu6h5ToGIRq8WqpWKJ0WN5/6JSF6dNsUg X-Received: by 2002:a17:906:b41:: with SMTP id v1mr3038004ejg.277.1611901098921; Thu, 28 Jan 2021 22:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611901098; cv=none; d=google.com; s=arc-20160816; b=xhJurKVkCA48KzXMNeczXa3dzcU4S7GxfDHP3+cjLKEHo30yrx5V6oTOwsoCa4ZRNZ 1UAvrIp0iASTQ5VTGguhBZzVuz5EsaSMVLUs7UJwEdNVc4BZmH1iwm7GZV0yqyW1f3KH iByZQgwILGmaCfZB4iqeYhyrVI6ByByguHHKefts5f8EEBbeaH8B+qiICXmODPQcEWGB I2JR8HnesZx7wXOLIjE73GQok+Kj7oK2altUtEDYOv9p20gBAY/K79OUcdxsIiuUmwa9 cwgp5LueAteIVDAVY+vw+dWMRoh/n6YZwWqm3ckLhxMhg7rXOFfJ1Y8xTf+HiCVsVg6f 6v1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5a9vXvilUsJkEIHHvcNcA0AGVYZkJf6YL+90eMCO+bY=; b=DCkP4K4pqAnOyVYtwmxrLIJlDNMpFVe7wzQ5f1GgsRaeX+nREyFEJPu9gzBNxVIUpy xDcSiDvLX6q++7cYu9WJw9N+RbJ2A/CiMB2M4CiaiztRb+KipeJh1OfijUn3IeYLzROQ 2abFaxwJVv27KgzgOyegUfECQiBS2c8CqS/i2DJCjFLFxIulmFyX6cTdEbx0Ai0Kk3XC Upn194kN9lZRyzXtmgCdMnGEmlnUBJFlO81SG8JYcTZTT64Gq3ANZH/eoEsNN3qtcwML CYXx3dKnRQ32SrwnyljmFwI6GyHBxxQr1VxERol6GtiuURTU5m2Z4NUfazDCF73QvG0h wc7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=T3Hpc4dc; 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 r29si4704016edx.223.2021.01.28.22.17.54; Thu, 28 Jan 2021 22:18:18 -0800 (PST) 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=T3Hpc4dc; 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 S232118AbhA2GQG (ORCPT + 99 others); Fri, 29 Jan 2021 01:16:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232031AbhA2GPk (ORCPT ); Fri, 29 Jan 2021 01:15:40 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C72CBC06178C for ; Thu, 28 Jan 2021 22:14:23 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id g15so5796335pjd.2 for ; Thu, 28 Jan 2021 22:14:23 -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=5a9vXvilUsJkEIHHvcNcA0AGVYZkJf6YL+90eMCO+bY=; b=T3Hpc4dc1N4vqSVRq5p3mq01HEp6AqFztlf6BwQas3cg7xfpyZccRlAOQ9XaqfUAGT ipsxJmNDkpIYMFLCLk3u4TnJ07YeUB35spN+f9FHqY+hva9oLebpXo8xoubfMR9ijxgE 3yC/KAkW/H2ilEoC5DxRWPpXwK8iHo5gJFsLU= 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=5a9vXvilUsJkEIHHvcNcA0AGVYZkJf6YL+90eMCO+bY=; b=WxFw8ntWy9ilJw52sjcyMZg4UxVPtg2MexaW5HIO/YGkehYWYwjLLXVpTtjBNahY6G RWBFe5jK61AZ7F2RQltAYkNQYbnvnsGWzAnU0P1e6hyJ1P5uDE60qKOZchfyDVl0DZ9e LAsGp/Nh3e6vDY9Y7wb1utMYSm5OHpI5RyG0ovNXN8MzxRqoL8wjevE7f0A5ZdH/V3s1 bWjB996jvufSAt59llSrWz6KyGqkrEIQxqKCQUXcEBU5XTDp3W1AhBTefyjbr1sbu2Sc 7LGqdyz+Kn2OpKhT7ctltfaqTRept06FWYnuTVvnWPQArGsIj40vfJkT6Hl0AVD+wLYN A6fw== X-Gm-Message-State: AOAM533vYkgF0DjrtDJXBTKx1SRBga8o6/uK/W7/Ltl54iVzAadriV4U LDebrerCmhxW1QhBygKxR4Vh6w== X-Received: by 2002:a17:90b:4b86:: with SMTP id lr6mr3002156pjb.107.1611900863438; Thu, 28 Jan 2021 22:14:23 -0800 (PST) Received: from bleung.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:fc72]) by smtp.gmail.com with ESMTPSA id 17sm7551013pfv.13.2021.01.28.22.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 22:14:22 -0800 (PST) From: Benson Leung To: heikki.krogerus@linux.intel.com, enric.balletbo@collabora.com, pmalani@chromium.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: groeck@chromium.org, bleung@google.com, bleung@chromium.org Subject: [PATCH 5/6] platform/chrome: cros_ec_typec: Set Partner PD revision from status Date: Thu, 28 Jan 2021 22:14:05 -0800 Message-Id: <20210129061406.2680146-6-bleung@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210129061406.2680146-1-bleung@chromium.org> References: <20210129061406.2680146-1-bleung@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Status provides sop_revision. Process it, and set it using the new setter in the typec class. Signed-off-by: Benson Leung --- drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 30600e9454e1..6bc6fafd54a4 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -824,7 +824,7 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p return ret; } -static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num) +static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num, u16 pd_revision) { struct cros_typec_port *port = typec->ports[port_num]; struct ec_response_typec_discovery *sop_disc = port->disc_data; @@ -842,6 +842,12 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu goto disc_exit; } + ret = typec_partner_set_pd_revision(port->partner, pd_revision); + if (ret < 0) { + dev_err(typec->dev, "Failed to update partner PD revision, port: %d\n", port_num); + goto disc_exit; + } + memset(sop_disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE); ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req), sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE); @@ -885,7 +891,11 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num /* Handle any events appropriately. */ if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE && !typec->ports[port_num]->sop_disc_done) { - ret = cros_typec_handle_sop_disc(typec, port_num); + u16 sop_revision; + + /* Convert BCD to the format preferred by the TypeC framework */ + sop_revision = (le16_to_cpu(resp.sop_revision) & 0xff00) >> 4; + ret = cros_typec_handle_sop_disc(typec, port_num, sop_revision); if (ret < 0) dev_err(typec->dev, "Couldn't parse SOP Disc data, port: %d\n", port_num); else -- 2.30.0.365.g02bc693789-goog