From patchwork Fri Nov 6 18:40:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 11887735 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2B806A2 for ; Fri, 6 Nov 2020 18:41:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85A3020702 for ; Fri, 6 Nov 2020 18:41:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="aGylUOm+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727771AbgKFSl3 (ORCPT ); Fri, 6 Nov 2020 13:41:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727800AbgKFSl2 (ORCPT ); Fri, 6 Nov 2020 13:41:28 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1D23C0613CF for ; Fri, 6 Nov 2020 10:41:28 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id c20so2147402pfr.8 for ; Fri, 06 Nov 2020 10:41:28 -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=va4fdIrdP2IdsG/GMrr9ULupTAJYmD75mo7OfHaDQgk=; b=aGylUOm+hDDwVgunzYVsiy0jrr2dsOjYijGrNN+OfsqVEVG3hj3ksqVufLCmjdquzo GblZkxZ1khPUiBiSNEyMcTi2yB0jFKFa9xJwXAuBsIqnBPhtB8/y8iEhsV9LT5IbbP6K oXOmkhh5C5yRyS9EpMu6hfI69Ll/AfhADXn+s= 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=va4fdIrdP2IdsG/GMrr9ULupTAJYmD75mo7OfHaDQgk=; b=ZN66YsmR7jzkmCgbr1uuS9q4knmAKkdJgxsu8zcR9dHscUcZQ0C47OnIByVq8mXx04 GE6N53TKpqp89YrGcbrz9oHhBYXiOsoa2SOpVOuu7OAzKE2TJZISbSVhmcDgDt/B15qB 0638Tqb1B1GfVoa29cksfCj9mCJltoXHdA2Uj3A6i5jyhxRKFgYrNHNMR9IJCkk0OK3g xsW0M5dmcIpp7lc2A/QITIWdOc9lJrwJ9Haai2kuIOvKgllFarJnylSe1cPFCV3bK0zu 6uHyfkxt4XoULYEg4dAii7gOM9cJw9j9pJVZ8nGTGrEQsXwiDg6ZvTWLiFZwDxjuXxg4 i4jw== X-Gm-Message-State: AOAM531Ve/b1IlTa/XwiBqqp/uaLnFeiDetPf2Dh6G9Tvmj+erY0OKOw v8bajt+/1qrnG2FjECxkgvEy3g== X-Google-Smtp-Source: ABdhPJyJtu/SBfDLacYRDH/63/REAhLo8Kftv5yFqIQ6ReAz1Vn7xkdyNIyR76XeRNjL6lIs4eGa9A== X-Received: by 2002:aa7:934a:0:b029:18a:aaea:ff4 with SMTP id 10-20020aa7934a0000b029018aaaea0ff4mr3319762pfn.56.1604688088280; Fri, 06 Nov 2020 10:41:28 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:a28c:fdff:fef0:49dd]) by smtp.gmail.com with ESMTPSA id b6sm3246143pjq.42.2020.11.06.10.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 10:41:27 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org Cc: Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH v2 1/6] platform/chrome: cros_ec_typec: Make disc_done flag partner-only Date: Fri, 6 Nov 2020 10:40:59 -0800 Message-Id: <20201106184104.939284-2-pmalani@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog In-Reply-To: <20201106184104.939284-1-pmalani@chromium.org> References: <20201106184104.939284-1-pmalani@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Change the disc_done flag, which indicates whether PD discovery is complete, to sop_disc_done instead, since we will process SOP and SOP' discovery data separately. Signed-off-by: Prashant Malani Reviewed-by: Heikki Krogerus --- Changes in v2: - No changes. drivers/platform/chrome/cros_ec_typec.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index ce031a10eb1b..801c3d2c1fbd 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -57,8 +57,8 @@ struct cros_typec_port { /* Port alt modes. */ struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX]; - /* Flag indicating that PD discovery data parsing is completed. */ - bool disc_done; + /* Flag indicating that PD partner discovery data parsing is completed. */ + bool sop_disc_done; struct ec_response_typec_discovery *sop_disc; struct list_head partner_mode_list; }; @@ -210,7 +210,7 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec, typec_unregister_partner(port->partner); port->partner = NULL; memset(&port->p_identity, 0, sizeof(port->p_identity)); - port->disc_done = false; + port->sop_disc_done = false; } static void cros_unregister_ports(struct cros_typec_data *typec) @@ -727,18 +727,13 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num return; } - if (typec->ports[port_num]->disc_done) - return; - /* Handle any events appropriately. */ - if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE) { + 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); - if (ret < 0) { + if (ret < 0) dev_err(typec->dev, "Couldn't parse SOP Disc data, port: %d\n", port_num); - return; - } - - typec->ports[port_num]->disc_done = true; + else + typec->ports[port_num]->sop_disc_done = true; } } From patchwork Fri Nov 6 18:41:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 11887737 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 168076A2 for ; Fri, 6 Nov 2020 18:41:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E124D206D5 for ; Fri, 6 Nov 2020 18:41:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="YdIg0K5x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728010AbgKFSlk (ORCPT ); Fri, 6 Nov 2020 13:41:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727944AbgKFSlk (ORCPT ); Fri, 6 Nov 2020 13:41:40 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0604DC0613CF for ; Fri, 6 Nov 2020 10:41:40 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id a18so1969702pfl.3 for ; Fri, 06 Nov 2020 10:41:40 -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=Wq6Preoru3IfCh2dMMdaJylKOwWTSm5/Yosw2jaNCWA=; b=YdIg0K5xvHn3rYHxnyjF69EcZrXG4YQrIsW23NhkkkMfCwd0dny7SQGaI77hv42ag8 bzvC/KKaGXE0IEQVDyOToDt4AonfC6VQjNadnisCaSQaC7PaJsqzZvqiMtJajvLGiIt1 II7lzEea/elUf4VaNyXnYIwOlFOvffa1dNLB0= 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=Wq6Preoru3IfCh2dMMdaJylKOwWTSm5/Yosw2jaNCWA=; b=Qa95K3erca9NlOmiVq/eWulAM+60WPmjgnRpbU9PK5jzspF7xFksEBlvUE2NiveOy1 IHZXidBB2P4X0UCxV5duVFPi3m3HfD5prtoKXXMBRZPlPHZ8xGpgVBzbgkvZ8DfXGQBz EgZfxo+PQbImzNdcaMiDXo+AMUhsVGQuSqgynkh33bmKV7/tW4aCXE5iOcFp+9I1T/VX nO6tfnkAZC3CMIVxD/DFvAUvae9KKF6mu0deEz4tQ4nCSRSppb2hTj0IXOtvls3uHxXM ccpS9mfeowutgFAnlgr21w3PObIEzbO3U4wuZL7afhzsao6h6y58vohmm0++01R8N7fI bmlw== X-Gm-Message-State: AOAM531nFFbEVaVhGnI4FciljI0KpwhndXeGHu8yrCaPrdCedhGjwQoa tR+PRNBGCLZW4t1Gev2bk09NXw== X-Google-Smtp-Source: ABdhPJw7Kza5aXwcBCrWlM3szUeapkz0JJMR6hSxnH5Ki/BT0FdWNCIGlPzCXAGvpTw1xbyiy0ZCSg== X-Received: by 2002:a17:90a:e20f:: with SMTP id a15mr954488pjz.12.1604688099572; Fri, 06 Nov 2020 10:41:39 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:a28c:fdff:fef0:49dd]) by smtp.gmail.com with ESMTPSA id b6sm3246143pjq.42.2020.11.06.10.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 10:41:39 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org Cc: Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH v2 2/6] platform/chrome: cros_ec_typec: Factor out PD identity parsing Date: Fri, 6 Nov 2020 10:41:01 -0800 Message-Id: <20201106184104.939284-3-pmalani@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog In-Reply-To: <20201106184104.939284-1-pmalani@chromium.org> References: <20201106184104.939284-1-pmalani@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Factor out the PD identity parsing code into a separate function. This way it can be re-used for Cable PD identity parsing in future patches. No functional changes are introduced by this patch. Signed-off-by: Prashant Malani Reviewed-by: Heikki Krogerus --- Changes in v2: - No changes. drivers/platform/chrome/cros_ec_typec.c | 35 ++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 801c3d2c1fbd..f6d3c37c2c27 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -657,6 +657,28 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_ return ret; } +/* + * Parse the PD identity data from the EC PD discovery responses and copy that to the supplied + * PD identity struct. + */ +static void cros_typec_parse_pd_identity(struct usb_pd_identity *id, + struct ec_response_typec_discovery *disc) +{ + int i; + + /* First, update the PD identity VDOs for the partner. */ + if (disc->identity_count > 0) + id->id_header = disc->discovery_vdo[0]; + if (disc->identity_count > 1) + id->cert_stat = disc->discovery_vdo[1]; + if (disc->identity_count > 2) + id->product = disc->discovery_vdo[2]; + + /* Copy the remaining identity VDOs till a maximum of 6. */ + for (i = 3; i < disc->identity_count && i < VDO_MAX_OBJECTS; i++) + id->vdo[i - 3] = disc->discovery_vdo[i]; +} + static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num) { struct cros_typec_port *port = typec->ports[port_num]; @@ -666,7 +688,6 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu .partner_type = TYPEC_PARTNER_SOP, }; int ret = 0; - int i; if (!port->partner) { dev_err(typec->dev, @@ -684,17 +705,7 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu goto disc_exit; } - /* First, update the PD identity VDOs for the partner. */ - if (sop_disc->identity_count > 0) - port->p_identity.id_header = sop_disc->discovery_vdo[0]; - if (sop_disc->identity_count > 1) - port->p_identity.cert_stat = sop_disc->discovery_vdo[1]; - if (sop_disc->identity_count > 2) - port->p_identity.product = sop_disc->discovery_vdo[2]; - - /* Copy the remaining identity VDOs till a maximum of 6. */ - for (i = 3; i < sop_disc->identity_count && i < VDO_MAX_OBJECTS; i++) - port->p_identity.vdo[i - 3] = sop_disc->discovery_vdo[i]; + cros_typec_parse_pd_identity(&port->p_identity, sop_disc); ret = typec_partner_set_identity(port->partner); if (ret < 0) { From patchwork Fri Nov 6 18:41:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 11887741 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3AE136A2 for ; Fri, 6 Nov 2020 18:41:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1169620702 for ; Fri, 6 Nov 2020 18:41:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nQa6i0RJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728031AbgKFSl6 (ORCPT ); Fri, 6 Nov 2020 13:41:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728018AbgKFSl6 (ORCPT ); Fri, 6 Nov 2020 13:41:58 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2317CC0613CF for ; Fri, 6 Nov 2020 10:41:58 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id y7so2139485pfq.11 for ; Fri, 06 Nov 2020 10:41:58 -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=XeYdtp0accnvA282EGyKNiLUJ2oXayxLKluUy6e2Lcw=; b=nQa6i0RJCQB07WIpfmxyQT/17YrFmbUVIoptN9h7XwkTEPBoaE8/L+4Cg3aZ1STUf/ saL6DU/0jXXGXqlekniKYJaJh0D4xakhzAUCsevAofzhIs1f9nbLEVE6Fl4pu2CdiSqI Z/wNkzG5gNRM5ap5jN9hN28mLQDEwucJFGb68= 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=XeYdtp0accnvA282EGyKNiLUJ2oXayxLKluUy6e2Lcw=; b=ck1AXvrD/lMsNevc0GUU9BFZt5PI12azLWOg0wxgYPC75YQDbWHwDpcyE74VnhYkLt yvcrkREtknqKRIqYTflf1W+eF2c3clnD9+Rm59D9nbW8hT1zJAzvqwWqO7Zg/Sl2W/cn 58Z+NVZcNtrOZGOj+Ajf6VHGojT0xa6HdpN8Ur/7SHvB8R4QveJyR+4WH98SaizBSsvw NheNANAEahBeD5jALJvries83d6tCBm8llHmlEFgw21VWDLUNbTC2VQwJQ6kFNR5wj5F EttjLYiC3/3XaTFpj6naF03kpja4rL20QnwavwxsLL0txyxulKbOQiX6K57p5wuASWfn ding== X-Gm-Message-State: AOAM531Bh3hjQr8mT7BdfNftjdv9kzguQ81zXb9mDqUScwJl1RPQ3WrK qle+Jm0/g9bGDp8bbjWcF1+C7Q== X-Google-Smtp-Source: ABdhPJyEYplM6gN85L78WJ0voo+lWqX77lX5OJRSbzensgU5sFXRNOfpZXpMd77wTX2/0ROhBmtEEQ== X-Received: by 2002:a17:90a:11:: with SMTP id 17mr991022pja.66.1604688117767; Fri, 06 Nov 2020 10:41:57 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:a28c:fdff:fef0:49dd]) by smtp.gmail.com with ESMTPSA id b6sm3246143pjq.42.2020.11.06.10.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 10:41:57 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org Cc: Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH v2 3/6] platform/chrome: cros_ec_typec: Rename discovery struct Date: Fri, 6 Nov 2020 10:41:04 -0800 Message-Id: <20201106184104.939284-4-pmalani@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog In-Reply-To: <20201106184104.939284-1-pmalani@chromium.org> References: <20201106184104.939284-1-pmalani@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Rename the sop_disc data struct which is used to store PD discovery data to the more generic name of disc_data. It can then be re-used to store and process cable discovery data. Signed-off-by: Prashant Malani Reviewed-by: Heikki Krogerus --- Changes in v2: - No changes. drivers/platform/chrome/cros_ec_typec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index f6d3c37c2c27..3c8ff07c8803 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -59,7 +59,7 @@ struct cros_typec_port { /* Flag indicating that PD partner discovery data parsing is completed. */ bool sop_disc_done; - struct ec_response_typec_discovery *sop_disc; + struct ec_response_typec_discovery *disc_data; struct list_head partner_mode_list; }; @@ -323,8 +323,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) cros_typec_register_port_altmodes(typec, port_num); - cros_port->sop_disc = devm_kzalloc(dev, EC_PROTO2_MAX_RESPONSE_SIZE, GFP_KERNEL); - if (!cros_port->sop_disc) { + cros_port->disc_data = devm_kzalloc(dev, EC_PROTO2_MAX_RESPONSE_SIZE, GFP_KERNEL); + if (!cros_port->disc_data) { ret = -ENOMEM; goto unregister_ports; } @@ -617,7 +617,7 @@ static int cros_typec_get_mux_info(struct cros_typec_data *typec, int port_num, static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_num) { struct cros_typec_port *port = typec->ports[port_num]; - struct ec_response_typec_discovery *sop_disc = port->sop_disc; + struct ec_response_typec_discovery *sop_disc = port->disc_data; struct cros_typec_altmode_node *node; struct typec_altmode_desc desc; struct typec_altmode *amode; @@ -682,7 +682,7 @@ static void cros_typec_parse_pd_identity(struct usb_pd_identity *id, static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num) { struct cros_typec_port *port = typec->ports[port_num]; - struct ec_response_typec_discovery *sop_disc = port->sop_disc; + struct ec_response_typec_discovery *sop_disc = port->disc_data; struct ec_params_typec_discovery req = { .port = port_num, .partner_type = TYPEC_PARTNER_SOP, From patchwork Fri Nov 6 18:41:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 11887743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D495F6A2 for ; Fri, 6 Nov 2020 18:42:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB2C72067B for ; Fri, 6 Nov 2020 18:42:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="GlnjqT95" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728075AbgKFSmH (ORCPT ); Fri, 6 Nov 2020 13:42:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728011AbgKFSmG (ORCPT ); Fri, 6 Nov 2020 13:42:06 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9273BC0613CF for ; Fri, 6 Nov 2020 10:42:06 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id y7so2139821pfq.11 for ; Fri, 06 Nov 2020 10:42:06 -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=5EZhbJ3C4t4hJhEZ2rcWc8jkgRA7J6G3Sqacz6pQbKk=; b=GlnjqT95BiH0kFLKse/Vi8e+S3vcjYAnz9KX0JpJpySOh67IwOseV+Ee8ZU2XLQZsE 5mF9bZmcyk5cH4R2BN0c0CXiFTDVGKFiIZ+a1LD03Gp/fdfMup/q+opDAYE9JCJ2JT27 /dOIN6XqkRUvFtprXquwMF3znkVU9GAWblpys= 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=5EZhbJ3C4t4hJhEZ2rcWc8jkgRA7J6G3Sqacz6pQbKk=; b=Dh/woOHgcRSQ76Z9Dxs6KNQVd4sHVzjaEbH+GQ5Q4cGckAy9EnpN6S38tQggEDjEuE 0dKtFMeOwxRToUeUjMTQ+PC9DjNUX27Ghpeb8tjk9I2gcHWj1aJCH1OunlhVTXiA/xSi apKinYSO84udDaYWD3zVZwANs/znaDhC8Z1v1F6ZHUsYAE9lOEu4BU6N3gJIl0gY95oD EcScOmueX8tJmbAmoKJ/KFpLuKDWuku7IIUvKTUO0lwjxFuUQE25EVHL+sXvSs1fny39 6jnYDH9iSVlrQ4mqm3b8s9X/R4xaLHI0NpW0t6Sf9vm72V2mYqVAtgGnV0YwFgkQGmU9 fQpA== X-Gm-Message-State: AOAM530mtPHoY3hHEzIszUsiiCj032N+JuQg1sFb5WWB2T0DZDkkB6ex TUH+1UtFpzkte30NdyzDcOiUbQ== X-Google-Smtp-Source: ABdhPJwyQYX3JnXiI25GTyzm7Y/RJX8OESCJxRkojyHaPRLibqNRGgS2pwlW/TATwH+zDB5DYPbcpg== X-Received: by 2002:a63:e54a:: with SMTP id z10mr2615528pgj.297.1604688126190; Fri, 06 Nov 2020 10:42:06 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:a28c:fdff:fef0:49dd]) by smtp.gmail.com with ESMTPSA id b6sm3246143pjq.42.2020.11.06.10.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 10:42:05 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org Cc: Prashant Malani , Heikki Krogerus , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH v2 4/6] platform/chrome: cros_ec_typec: Register cable Date: Fri, 6 Nov 2020 10:41:06 -0800 Message-Id: <20201106184104.939284-5-pmalani@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog In-Reply-To: <20201106184104.939284-1-pmalani@chromium.org> References: <20201106184104.939284-1-pmalani@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When the Chrome Embedded Controller notifies the driver that SOP' discovery is complete, retrieve the PD discovery data and register a cable object with the Type C connector class framework. Cc: Heikki Krogerus Signed-off-by: Prashant Malani Reviewed-by: Heikki Krogerus --- Changes in v2: - No changes. drivers/platform/chrome/cros_ec_typec.c | 67 +++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 3c8ff07c8803..5e7f0b4ebbec 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -44,8 +44,11 @@ struct cros_typec_port { /* Initial capabilities for the port. */ struct typec_capability caps; struct typec_partner *partner; + struct typec_cable *cable; /* Port partner PD identity info. */ struct usb_pd_identity p_identity; + /* Port cable PD identity info. */ + struct usb_pd_identity c_identity; struct typec_switch *ori_sw; struct typec_mux *mux; struct usb_role_switch *role_sw; @@ -59,6 +62,7 @@ struct cros_typec_port { /* Flag indicating that PD partner discovery data parsing is completed. */ bool sop_disc_done; + bool sop_prime_disc_done; struct ec_response_typec_discovery *disc_data; struct list_head partner_mode_list; }; @@ -213,6 +217,17 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec, port->sop_disc_done = false; } +static void cros_typec_remove_cable(struct cros_typec_data *typec, + int port_num) +{ + struct cros_typec_port *port = typec->ports[port_num]; + + typec_unregister_cable(port->cable); + port->cable = NULL; + memset(&port->c_identity, 0, sizeof(port->c_identity)); + port->sop_prime_disc_done = false; +} + static void cros_unregister_ports(struct cros_typec_data *typec) { int i; @@ -224,6 +239,9 @@ static void cros_unregister_ports(struct cros_typec_data *typec) if (typec->ports[i]->partner) cros_typec_remove_partner(typec, i); + if (typec->ports[i]->cable) + cros_typec_remove_cable(typec, i); + usb_role_switch_put(typec->ports[i]->role_sw); typec_switch_put(typec->ports[i]->ori_sw); typec_mux_put(typec->ports[i]->mux); @@ -600,6 +618,9 @@ static void cros_typec_set_port_params_v1(struct cros_typec_data *typec, if (!typec->ports[port_num]->partner) return; cros_typec_remove_partner(typec, port_num); + + if (typec->ports[port_num]->cable) + cros_typec_remove_cable(typec, port_num); } } @@ -679,6 +700,43 @@ static void cros_typec_parse_pd_identity(struct usb_pd_identity *id, id->vdo[i - 3] = disc->discovery_vdo[i]; } +static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int port_num) +{ + struct cros_typec_port *port = typec->ports[port_num]; + struct ec_response_typec_discovery *disc = port->disc_data; + struct typec_cable_desc desc = {}; + struct ec_params_typec_discovery req = { + .port = port_num, + .partner_type = TYPEC_PARTNER_SOP_PRIME, + }; + int ret = 0; + + memset(disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE); + ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req), + disc, EC_PROTO2_MAX_RESPONSE_SIZE); + if (ret < 0) { + dev_err(typec->dev, "Failed to get SOP' discovery data for port: %d\n", port_num); + goto sop_prime_disc_exit; + } + + /* Parse the PD identity data, even if only 0s were returned. */ + cros_typec_parse_pd_identity(&port->c_identity, disc); + + if (disc->identity_count != 0) + desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE; + + desc.identity = &port->c_identity; + + port->cable = typec_register_cable(port->port, &desc); + if (IS_ERR(port->cable)) { + ret = PTR_ERR(port->cable); + port->cable = NULL; + } + +sop_prime_disc_exit: + return ret; +} + static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num) { struct cros_typec_port *port = typec->ports[port_num]; @@ -746,6 +804,15 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num else typec->ports[port_num]->sop_disc_done = true; } + + if (resp.events & PD_STATUS_EVENT_SOP_PRIME_DISC_DONE && + !typec->ports[port_num]->sop_prime_disc_done) { + ret = cros_typec_handle_sop_prime_disc(typec, port_num); + if (ret < 0) + dev_err(typec->dev, "Couldn't parse SOP' Disc data, port: %d\n", port_num); + else + typec->ports[port_num]->sop_prime_disc_done = true; + } } static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) From patchwork Fri Nov 6 18:41:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 11887745 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D31616A2 for ; Fri, 6 Nov 2020 18:42:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFF392067B for ; Fri, 6 Nov 2020 18:42:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Ms0ZORNW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727994AbgKFSmS (ORCPT ); Fri, 6 Nov 2020 13:42:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbgKFSmR (ORCPT ); Fri, 6 Nov 2020 13:42:17 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8792C0613CF for ; Fri, 6 Nov 2020 10:42:17 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id z3so2157817pfz.6 for ; Fri, 06 Nov 2020 10:42:17 -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=DPZFud9+2AdS3xX2fJ3kB9txFUGh/iGWRXP+Nhtqe4E=; b=Ms0ZORNWLognrlgAgG2IcsJuwRwKUXVZAbKDQRnRMNeMnNUpUlg8e4k7hi/p49wIHk pBYdJmYaljTng7N4Lq812ZHZ0/G1XM27dEMv2Fv+l33lLfLCTaDe1+6Cx/za2xvSj/DG uyGWhDC5yqjJ9kFYZViOtik+IjntEHI+Sh0Ag= 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=DPZFud9+2AdS3xX2fJ3kB9txFUGh/iGWRXP+Nhtqe4E=; b=FwPWsOKfB4/E9jgKaS/6lYsllEWAf7ncsMA1F6+5oIXXD4hKWvefdeYR3SNlanqV2L v5RMlakgHZWLw7UIp8zbUI0xGW+fyuF0HihxZsOPkUzlvA1MlpzqeNgKyY3rs7vvl3gL gp6jDDoqTYT9OZt85evlX4b2h1xCF9d5ugges7BLX1RIa7Eu9ItaD1zTS5wPviHKJi9t U0vtmimJDLXfQIJxSuMTZdjwPBL8+5TfHoE+88YdmDAz6eR8v/4dt4ps1co/LERrBu4g 5RKmxIKWB1nUh/aIJ7+zIWT/5HIPn1ccDJKfEzyZtQOO97kPyjDQbjXCr2gqpZpfQHee Y4Kg== X-Gm-Message-State: AOAM530WXw0ixcyZ8xJnGLvIGiPNlOWCgr8t59q8GpOZGx9kb32ikiPN WkHgGi61x56YxICRYUTS8e97ig== X-Google-Smtp-Source: ABdhPJxfJ4xolEPygoxqHZkReo4KRySZlr82c/DktCivdHuHhSaP6qlZp0vUI+hE/geAq1USEYaw5Q== X-Received: by 2002:a17:90b:316:: with SMTP id ay22mr1005715pjb.8.1604688137310; Fri, 06 Nov 2020 10:42:17 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:a28c:fdff:fef0:49dd]) by smtp.gmail.com with ESMTPSA id b6sm3246143pjq.42.2020.11.06.10.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 10:42:16 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org Cc: Prashant Malani , Heikki Krogerus Subject: [PATCH v2 5/6] usb: pd: Add captive Type C cable type Date: Fri, 6 Nov 2020 10:41:08 -0800 Message-Id: <20201106184104.939284-6-pmalani@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog In-Reply-To: <20201106184104.939284-1-pmalani@chromium.org> References: <20201106184104.939284-1-pmalani@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The USB Power Delivery Specification R3.0 adds a captive cable type to the "USB Type-C plug to USB Type-C/Captive" field (Bits 19-18, Passive/Active Cable VDO, Table 6-38 & 6-39). Add the corresponding definition to the Cable VDO header. Also add a helper macro to get the Type C cable connector type, when provided the cable VDO. Cc: Heikki Krogerus Signed-off-by: Prashant Malani Reviewed-by: Benson Leung Reviewed-by: Heikki Krogerus --- Changes in v2: - No changes. include/linux/usb/pd_vdo.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/usb/pd_vdo.h b/include/linux/usb/pd_vdo.h index 68bdc4e2f5a9..8c5cb5830754 100644 --- a/include/linux/usb/pd_vdo.h +++ b/include/linux/usb/pd_vdo.h @@ -177,7 +177,7 @@ * <31:28> :: Cable HW version * <27:24> :: Cable FW version * <23:20> :: Reserved, Shall be set to zero - * <19:18> :: type-C to Type-A/B/C (00b == A, 01 == B, 10 == C) + * <19:18> :: type-C to Type-A/B/C/Captive (00b == A, 01 == B, 10 == C, 11 == Captive) * <17> :: Type-C to Plug/Receptacle (0b == plug, 1b == receptacle) * <16:13> :: cable latency (0001 == <10ns(~1m length)) * <12:11> :: cable termination type (11b == both ends active VCONN req) @@ -193,6 +193,7 @@ #define CABLE_ATYPE 0 #define CABLE_BTYPE 1 #define CABLE_CTYPE 2 +#define CABLE_CAPTIVE 3 #define CABLE_PLUG 0 #define CABLE_RECEPTACLE 1 #define CABLE_CURR_1A5 0 @@ -208,6 +209,7 @@ | (tx1d) << 10 | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7 \ | ((cur) & 0x3) << 5 | (vps) << 4 | (sopp) << 3 \ | ((usbss) & 0x7)) +#define VDO_TYPEC_CABLE_TYPE(vdo) (((vdo) >> 18) & 0x3) /* * AMA VDO From patchwork Fri Nov 6 18:41:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 11887747 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F654697 for ; Fri, 6 Nov 2020 18:42:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2863620735 for ; Fri, 6 Nov 2020 18:42:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="fPU257iA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728096AbgKFSme (ORCPT ); Fri, 6 Nov 2020 13:42:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727944AbgKFSmd (ORCPT ); Fri, 6 Nov 2020 13:42:33 -0500 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 2F33FC0613CF for ; Fri, 6 Nov 2020 10:42:32 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id 62so1586992pgg.12 for ; Fri, 06 Nov 2020 10:42:32 -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=ZIbxuFcWEsm1IZwnLCYdZyYRjU3KKvSYVK6rSgB6bkQ=; b=fPU257iApiVM5ZmKvNaVne8y3hNHUFNH1RDNQnXpKJ2MqUGURLqgAl4hIQl3NYfojQ rwhz+zEByqiwYfV++HLmDLP5DqcIWPhnx+TL5RKRnYaby3uNqhe1OYW0vPCn5EIm1zNc 18jcCOC3Fx1mwy84rHdkrp6MMc6jPxy7UGXPc= 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=ZIbxuFcWEsm1IZwnLCYdZyYRjU3KKvSYVK6rSgB6bkQ=; b=pMiXUp2qBVmrs1hT+YrfmSGtwdtjXnFGfsGYSDWC4oCl8OFQHuulGiEDIiqLhLTfH3 Vj3kpcdxZdDF+X7Pplxhn4Dgj/DF9By0MTCiYvCcjZIHH1WlfDISYyZXop2Te+J5FYVa i2eNjcS0cyH5NHEpGlXs9a4QHWR8AGGYtVoUstAx//hp3icqq6nDlVhHqmI79xYbo92F DfXA3vfO2IQ9b9JO/PgPANKEYCOvZSXuMVWmkm20WcC611bvGEvwZ5EnBUYn61CljTVo xO5xlvVVd368RFOdIyldgdyxSz6/pyqHRUUpAxTNhbOxOmayJVkgBnurMKGbbAW6F7GW fAaA== X-Gm-Message-State: AOAM5317TgpLB4Q0+jA3xuTHjHbfkkiyzZHZiRvj8MpyFEI5f5Kl+Wdh sj4xedeTtMUreGnbhD2Ys629nA== X-Google-Smtp-Source: ABdhPJzevWVC1by/7jK4Y0IL195o8gPGu04HuvVtT+MV9LoFz3MHh1HFuSl7U3CpItiCa+7GU5pQDA== X-Received: by 2002:a65:679a:: with SMTP id e26mr2914937pgr.374.1604688151778; Fri, 06 Nov 2020 10:42:31 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:a28c:fdff:fef0:49dd]) by smtp.gmail.com with ESMTPSA id b6sm3246143pjq.42.2020.11.06.10.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 10:42:31 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org Cc: Prashant Malani , Heikki Krogerus , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH v2 6/6] platform/chrome: cros_ec_typec: Store cable plug type Date: Fri, 6 Nov 2020 10:41:10 -0800 Message-Id: <20201106184104.939284-7-pmalani@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog In-Reply-To: <20201106184104.939284-1-pmalani@chromium.org> References: <20201106184104.939284-1-pmalani@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use the PD VDO Type C cable plug type macro to retrieve and store the cable plug type in the cable descriptor. Cc: Heikki Krogerus Cc: Greg Kroah-Hartman Signed-off-by: Prashant Malani Reviewed-by: Heikki Krogerus --- Changes in v2: - Changed local variable from uint32_to u32. drivers/platform/chrome/cros_ec_typec.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 5e7f0b4ebbec..cf609aa10567 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -709,6 +709,7 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p .port = port_num, .partner_type = TYPEC_PARTNER_SOP_PRIME, }; + u32 cable_plug_type; int ret = 0; memset(disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE); @@ -722,8 +723,26 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p /* Parse the PD identity data, even if only 0s were returned. */ cros_typec_parse_pd_identity(&port->c_identity, disc); - if (disc->identity_count != 0) + if (disc->identity_count != 0) { + cable_plug_type = VDO_TYPEC_CABLE_TYPE(port->c_identity.vdo[0]); + switch (cable_plug_type) { + case CABLE_ATYPE: + desc.type = USB_PLUG_TYPE_A; + break; + case CABLE_BTYPE: + desc.type = USB_PLUG_TYPE_B; + break; + case CABLE_CTYPE: + desc.type = USB_PLUG_TYPE_C; + break; + case CABLE_CAPTIVE: + desc.type = USB_PLUG_CAPTIVE; + break; + default: + desc.type = USB_PLUG_NONE; + } desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE; + } desc.identity = &port->c_identity;