From patchwork Thu May 27 08:44:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Tso X-Patchwork-Id: 449007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F0E9C4707F for ; Thu, 27 May 2021 08:44:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BB6A61028 for ; Thu, 27 May 2021 08:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235589AbhE0Iq2 (ORCPT ); Thu, 27 May 2021 04:46:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235580AbhE0IqX (ORCPT ); Thu, 27 May 2021 04:46:23 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36B60C06138A for ; Thu, 27 May 2021 01:44:51 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id e8-20020a05620a2088b02903a5edeec4d6so2901405qka.11 for ; Thu, 27 May 2021 01:44:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=NBDr+PfWkI5thsojxPz9Zu9rvFYhCniTcdDmiakb3Dw=; b=ux0r69a6ttQbODXqEMUgeZ85sKH1ZMbFb/gSjFmkCETjERqvim+5xdHvC8KDl8bGg7 6dmqmEkyTDBcYXsOsvPxZHGI2fSjqkBTZ4u5dl2aBvF/W8fIRty0vdOueSqxkJ/xakHq AnbJhUT0h0EJ45YvA6om3t+dSDJ6lFKQuNHFTGJR5X7yw13cQADzUqNAxduHsm6CXWuY a9eOSDyGWYCzVBN+/WcCMbRQSlRW5oZu1kBPQ6nWeMpm9kBrxzKxULdGx7QRv5EqgUQI txOTtwrEfMnfXFD+kNjO0LPakpfmBLFUbAEGldIzmvNisC3Ln7RBqTsmXNuP3rSbheO8 FzDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=NBDr+PfWkI5thsojxPz9Zu9rvFYhCniTcdDmiakb3Dw=; b=mIm6OTzm+w6m0wHZ+1sxjE80rN3GR2zI2ltQPiG6ZO1ioV6dh3zCpUyvEAEy84DcIk 0rd/2RRqJPdq0GqNW3Zxh6ohxIPm3JgjfnL372Wh6eTWoO0Yjw12b3QtRWqUAX3WAUQU aef4wRIiSw5CaxpetZ8N6OzmMhhoRlZiv0ZDoZD+le7kdCpGLxdIKAZ0z5/9tXdL8xgz kU/mlugiZ4kYVR0CisFSjNsnOYWavrdkovk4RAO3qpvIPV93dowwZhgFjEUc77ReQ9RD xZi0nuwVTzVv7ENuF+5FifcjYSjEmSzlBOFzuE8/AvIgZPSz7xaYJMqkaK+xvJwIGXv/ AMOA== X-Gm-Message-State: AOAM531pZtxImOHjznHdFsqctvaPgQEqwIVQcalhUdEGJkiJsW4l5Lln 2st4nRDjBxF2bHmVmI1pz1+PE0iHM06F X-Google-Smtp-Source: ABdhPJy6fnlPAVOcK75o5E5a/M2Mr+tkHtuP8kxViBO7TwlYcGtSRFK8RoyP5a3gCSyXFOAMTvdxfaGom61d X-Received: from kyletso.ntc.corp.google.com ([2401:fa00:fc:202:c563:7257:f641:cbcd]) (user=kyletso job=sendgmr) by 2002:ad4:478d:: with SMTP id z13mr2168630qvy.39.1622105090294; Thu, 27 May 2021 01:44:50 -0700 (PDT) Date: Thu, 27 May 2021 16:44:17 +0800 In-Reply-To: <20210527084419.4164369-1-kyletso@google.com> Message-Id: <20210527084419.4164369-2-kyletso@google.com> Mime-Version: 1.0 References: <20210527084419.4164369-1-kyletso@google.com> X-Mailer: git-send-email 2.31.1.818.g46aad6cb9e-goog Subject: [PATCH 1/3] usb: typec: tcpm: Correct the responses in SVDM Version 2.0 DFP From: Kyle Tso To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, robh+dt@kernel.org Cc: badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Kyle Tso Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org In USB PD Spec Rev 3.1 Ver 1.0, section "6.12.5 Applicability of Structured VDM Commands", DFP is allowed and recommended to respond to Discovery Identity with ACK. And in section "6.4.4.2.5.1 Commands other than Attention", NAK should be returned only when receiving Messages with invalid fields, Messages in wrong situation, or unrecognize Messages. Still keep the original design for SVDM Version 1.0 for backward compatibilities. Fixes: 193a68011fdc ("staging: typec: tcpm: Respond to Discover Identity commands") Signed-off-by: Kyle Tso Acked-by: Heikki Krogerus --- drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 9ce8c9af4da5..a1bf0dc5babf 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -1547,19 +1547,25 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, if (PD_VDO_VID(p[0]) != USB_SID_PD) break; - if (PD_VDO_SVDM_VER(p[0]) < svdm_version) + if (PD_VDO_SVDM_VER(p[0]) < svdm_version) { typec_partner_set_svdm_version(port->partner, PD_VDO_SVDM_VER(p[0])); + svdm_version = PD_VDO_SVDM_VER(p[0]); + } tcpm_ams_start(port, DISCOVER_IDENTITY); - /* 6.4.4.3.1: Only respond as UFP (device) */ - if (port->data_role == TYPEC_DEVICE && + /* + * PD2.0 Spec 6.10.3: respond with NAK as DFP (data host) + * PD3.1 Spec 6.4.4.2.5.1: respond with NAK if "invalid field" or + * "wrong configuation" or "Unrecognized" + */ + if ((port->data_role == TYPEC_DEVICE || svdm_version >= SVDM_VER_2_0) && port->nr_snk_vdo) { /* * Product Type DFP and Connector Type are not defined in SVDM * version 1.0 and shall be set to zero. */ - if (typec_get_negotiated_svdm_version(typec) < SVDM_VER_2_0) + if (svdm_version < SVDM_VER_2_0) response[1] = port->snk_vdo[0] & ~IDH_DFP_MASK & ~IDH_CONN_MASK; else From patchwork Thu May 27 08:44:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Tso X-Patchwork-Id: 449685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2949AC4708B for ; Thu, 27 May 2021 08:45:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06ACB613CA for ; Thu, 27 May 2021 08:45:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235580AbhE0Iqb (ORCPT ); Thu, 27 May 2021 04:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235582AbhE0Iqa (ORCPT ); Thu, 27 May 2021 04:46:30 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEFD3C061761 for ; Thu, 27 May 2021 01:44:57 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id a16-20020a63e8500000b029021ab84617c0so2518932pgk.14 for ; Thu, 27 May 2021 01:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=hWuYlcm+G88I6W6ZPGMYy1rv3ZPflGwOGWbdhraiZfw=; b=BeEXzIMLWyyubqRMQSd15E1pcWUNkuTOPtLuKiYOTQgFdA0zfnGbboJL/8cmsIgi00 19iffh0eS7gxKW4Nj3bu2L9aDkNTm6Y4+WGsYm9TYdXNBOcRGctBHLwCBvXFnz8kLLJW +J5V1oXppObeg+6CA4hfE5EulOxRaJEUt5faGVttw8cWT9a0AVPpMVu3pIuOZxN8OBNS 3m++sFhZG1mofeTyrQ9OQAr1+75ZBvMK0TrkV4cS/Gz/nqty/cQ0Od6R5emnfhdws3Q3 hnX3UT2z5WYw/0fl0uOpOvV/V7+/hML4xgr7Ofm1nJiie+vI3nMopwoq4kyxkrt5S8iL KCiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=hWuYlcm+G88I6W6ZPGMYy1rv3ZPflGwOGWbdhraiZfw=; b=bOAHN9iAuiG1Hnoj6gY+RtNmr324IgHuBwzT+bOGKe9jCKGVhS9C85Xx9pT2Dk1DhD KL2KxFD4wdz+8n6/bBEyBCq2/i3qf3Kj1JiF2JDUMr+fVOgSroQk8YLAXzJnps/Mfd9D SU5faiUiQDZpC/gaEuoN9ET5rB5Ptm329ISJeF3fwebkHBNGUPMvjOq4gbDDvCCEEeY/ aATuuJ46Y0NI5KzKHz1ioNbMoO02hbLwT75kWdmSz2gVVGGt1pXmSnoHG6GutXz42BIe yTK0DkRfpDj/SgHrQ7ccLJkHs6XyxZPRDRD0apo7Eyk/Qdh8Lf1bcoULBMMJqNXUpr/9 zGUg== X-Gm-Message-State: AOAM530ZO5CSaNhFMbhQoMPbtkgv4Iuw8roaRtGH+mXBOp1ms5Tg/AgY OB37QJK+VUbRQf91Ys3oKRgPXZhZjvBy X-Google-Smtp-Source: ABdhPJwWqd2c/SeCjB5kXo6UfnqbusgfeLv1co24ChSKQXJwh1dyMBtRueGKRsvEOW5usgRPbx/hAB9DXaiu X-Received: from kyletso.ntc.corp.google.com ([2401:fa00:fc:202:c563:7257:f641:cbcd]) (user=kyletso job=sendgmr) by 2002:aa7:8c0b:0:b029:2e7:d663:f3e6 with SMTP id c11-20020aa78c0b0000b02902e7d663f3e6mr2667962pfd.79.1622105094041; Thu, 27 May 2021 01:44:54 -0700 (PDT) Date: Thu, 27 May 2021 16:44:18 +0800 In-Reply-To: <20210527084419.4164369-1-kyletso@google.com> Message-Id: <20210527084419.4164369-3-kyletso@google.com> Mime-Version: 1.0 References: <20210527084419.4164369-1-kyletso@google.com> X-Mailer: git-send-email 2.31.1.818.g46aad6cb9e-goog Subject: [PATCH 2/3] dt-bindings: connector: Add PD rev 2.0 VDO definition From: Kyle Tso To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, robh+dt@kernel.org Cc: badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Kyle Tso Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add the VDO definition for USB PD rev 2.0 in the bindings and define a new property snk-vdos-v1 containing legacy VDOs as the responses to the port partner which only supports PD rev 2.0. Signed-off-by: Kyle Tso --- .../bindings/connector/usb-connector.yaml | 15 ++++ include/dt-bindings/usb/pd.h | 69 ++++++++++++++++++- 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml index 32509b98142e..92b49bc37939 100644 --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml @@ -149,6 +149,17 @@ properties: maxItems: 6 $ref: /schemas/types.yaml#/definitions/uint32-array + sink-vdos-v1: + description: An array of u32 with each entry, a Vendor Defined Message Object (VDO), + providing additional information corresponding to the product, the detailed bit + definitions and the order of each VDO can be found in + "USB Power Delivery Specification Revision 2.0, Version 1.3" chapter 6.4.4.3.1 Discover + Identity. User can specify the VDO array via VDO_IDH/_CERT/_PRODUCT/_CABLE/_AMA defined in + dt-bindings/usb/pd.h. + minItems: 3 + maxItems: 6 + $ref: /schemas/types.yaml#/definitions/uint32-array + op-sink-microwatt: description: Sink required operating power in microwatt, if source can't offer the power, Capability Mismatch is set. Required for power sink and @@ -207,6 +218,10 @@ properties: SNK_READY for non-pd link. type: boolean +dependencies: + sink-vdos-v1: [ 'sink-vdos' ] + sink-vdos: [ 'sink-vdos-v1' ] + required: - compatible diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h index fef3ef65967f..9e47f9673405 100644 --- a/include/dt-bindings/usb/pd.h +++ b/include/dt-bindings/usb/pd.h @@ -106,6 +106,10 @@ * <20:16> :: Reserved, Shall be set to zero * <15:0> :: USB-IF assigned VID for this cable vendor */ + +/* PD Rev2.0 definition */ +#define IDH_PTYPE_UNDEF 0 + /* SOP Product Type (UFP) */ #define IDH_PTYPE_NOT_UFP 0 #define IDH_PTYPE_HUB 1 @@ -228,7 +232,25 @@ | ((pnum) & 0x1f)) /* - * Passive Cable VDO + * Cable VDO (for both Passive and Active Cable VDO in PD Rev2.0) + * --------- + * <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/Captive (00b == A, 01 == B, 10 == C, 11 == Captive) + * <17> :: Reserved, Shall be set to zero + * <16:13> :: cable latency (0001 == <10ns(~1m length)) + * <12:11> :: cable termination type (11b == both ends active VCONN req) + * <10> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable) + * <9> :: SSTX2 Directionality support + * <8> :: SSRX1 Directionality support + * <7> :: SSRX2 Directionality support + * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A) + * <4> :: Vbus through cable (0b == no, 1b == yes) + * <3> :: SOP" controller present? (0b == no, 1b == yes) + * <2:0> :: USB SS Signaling support + * + * Passive Cable VDO (PD Rev3.0+) * --------- * <31:28> :: Cable HW version * <27:24> :: Cable FW version @@ -244,7 +266,7 @@ * <4:3> :: Reserved, Shall be set to zero * <2:0> :: USB highest speed * - * Active Cable VDO 1 + * Active Cable VDO 1 (PD Rev3.0+) * --------- * <31:28> :: Cable HW version * <27:24> :: Cable FW version @@ -266,7 +288,9 @@ #define CABLE_VDO_VER1_0 0 #define CABLE_VDO_VER1_3 3 -/* Connector Type */ +/* Connector Type (_ATYPE and _BTYPE are for PD Rev2.0 only) */ +#define CABLE_ATYPE 0 +#define CABLE_BTYPE 1 #define CABLE_CTYPE 2 #define CABLE_CAPTIVE 3 @@ -303,12 +327,22 @@ #define CABLE_CURR_3A 1 #define CABLE_CURR_5A 2 +/* USB SuperSpeed Signaling Support (PD Rev2.0) */ +#define CABLE_USBSS_U2_ONLY 0 +#define CABLE_USBSS_U31_GEN1 1 +#define CABLE_USBSS_U31_GEN2 2 + /* USB Highest Speed */ #define CABLE_USB2_ONLY 0 #define CABLE_USB32_GEN1 1 #define CABLE_USB32_4_GEN2 2 #define CABLE_USB4_GEN3 3 +#define VDO_CABLE(hw, fw, cbl, lat, term, tx1d, tx2d, rx1d, rx2d, cur, vps, sopp, usbss) \ + (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 | ((cbl) & 0x3) << 18 \ + | ((lat) & 0x7) << 13 | ((term) & 0x3) << 11 | (tx1d) << 10 \ + | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7 | ((cur) & 0x3) << 5 \ + | (vps) << 4 | (sopp) << 3 | ((usbss) & 0x7)) #define VDO_PCABLE(hw, fw, ver, conn, lat, term, vbm, cur, spd) \ (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \ | ((conn) & 0x3) << 18 | ((lat) & 0xf) << 13 | ((term) & 0x3) << 11 \ @@ -373,6 +407,35 @@ | ((hops) & 0x3) << 6 | (u2) << 5 | (u32) << 4 | (lane) << 3 \ | (iso) << 2 | (gen)) +/* + * AMA VDO (PD Rev2.0) + * --------- + * <31:28> :: Cable HW version + * <27:24> :: Cable FW version + * <23:12> :: Reserved, Shall be set to zero + * <11> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable) + * <10> :: SSTX2 Directionality support + * <9> :: SSRX1 Directionality support + * <8> :: SSRX2 Directionality support + * <7:5> :: Vconn power + * <4> :: Vconn power required + * <3> :: Vbus power required + * <2:0> :: USB SS Signaling support + */ +#define VDO_AMA(hw, fw, tx1d, tx2d, rx1d, rx2d, vcpwr, vcr, vbr, usbss) \ + (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 \ + | (tx1d) << 11 | (tx2d) << 10 | (rx1d) << 9 | (rx2d) << 8 \ + | ((vcpwr) & 0x7) << 5 | (vcr) << 4 | (vbr) << 3 \ + | ((usbss) & 0x7)) + +#define PD_VDO_AMA_VCONN_REQ(vdo) (((vdo) >> 4) & 1) +#define PD_VDO_AMA_VBUS_REQ(vdo) (((vdo) >> 3) & 1) + +#define AMA_USBSS_U2_ONLY 0 +#define AMA_USBSS_U31_GEN1 1 +#define AMA_USBSS_U31_GEN2 2 +#define AMA_USBSS_BBONLY 3 + /* * VPD VDO * --------- From patchwork Thu May 27 08:44:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Tso X-Patchwork-Id: 449006 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56B05C4707F for ; Thu, 27 May 2021 08:45:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DBB4613CA for ; Thu, 27 May 2021 08:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235475AbhE0Iqc (ORCPT ); Thu, 27 May 2021 04:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235587AbhE0Iqb (ORCPT ); Thu, 27 May 2021 04:46:31 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80E0CC061763 for ; Thu, 27 May 2021 01:44:58 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id f14-20020a170902684eb02900fda7a7235cso1971350pln.14 for ; Thu, 27 May 2021 01:44:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=NqV+UHFoHvqcq/R8sYfWHsT1BHUr10auoTbMwxVa1MY=; b=bFU7d2YlIPh4DrUCoLhoyuXTbXmpERmsK2e9/0I3kHPO/okifmGXJZ6amu3Y2scpCY 0dFja/iCvMzIFt7FG7fQyRqdwD44bBHYu3DYic/TOu4PE+NHoJmMt9kHHFSZ0fr5rgRd EXCr+xQ6cknD/Rzl9DDst6IXrG0Eg6PX+sVgg4ma2ygqvOIAlekI3kgFsLaNZhAhGd1D dEQO/vz1hiMmvRVPtIVrTg37qgHqckiwkH9CWD/iZwtkukyIEd7tTUwyWnIdMrevNYPO OgvrOKliaLjrwVTAz/khH/yjnaDxnSDcpdrE4Wwjf31Bc1XS1n/HgqljxStzmGMKvRr2 /hFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=NqV+UHFoHvqcq/R8sYfWHsT1BHUr10auoTbMwxVa1MY=; b=MKt3n1rGHNxZO0zhWOqvrKn7J35XVcSAsiok82JvqGAZ3goF4VESYTLzHBlsIytOOM SgL2QhIxHzFwx9oTR5pI5uLV0yrO+ld8oxU6jB64z3sepxbSPP55tcCt6Ofrj02iCKng baXK/AW0vW3cU9FAIuI7bzZhTVykbIFjyhc5+aeQeq1HIyLVcECBY7CJuQkNrOPJW0VW yj8DtLe0iAKYRbXneZ3FBjnHDhv0uprOSJx1vqCLuejxr6iw3qYJ1wfIcacINPIEbQpm EzpSUL+hFfJJ3DH8MT4KcTb5i9MOfSRp+DhkCJGiJO1hEaYEu6HmKQkD5h+8AM8D1DGd Ok5g== X-Gm-Message-State: AOAM530WpVirZE0GJANWXruNoiRx6IeRBSsYBmRqnqx0zX9Z+VpVKzHo PghRa+NgQeRnplikNXDWTs8S8FzMB58R X-Google-Smtp-Source: ABdhPJwxZJ6gmdrZ26fdJ3KzSUJDVghx72sFTMFQY+TWdVvQW5dNHefeQdnQqkFqyXVZ7PhBsDpr/owQtgZ2 X-Received: from kyletso.ntc.corp.google.com ([2401:fa00:fc:202:c563:7257:f641:cbcd]) (user=kyletso job=sendgmr) by 2002:a62:1d52:0:b029:2dd:ee:1439 with SMTP id d79-20020a621d520000b02902dd00ee1439mr2646720pfd.57.1622105097999; Thu, 27 May 2021 01:44:57 -0700 (PDT) Date: Thu, 27 May 2021 16:44:19 +0800 In-Reply-To: <20210527084419.4164369-1-kyletso@google.com> Message-Id: <20210527084419.4164369-4-kyletso@google.com> Mime-Version: 1.0 References: <20210527084419.4164369-1-kyletso@google.com> X-Mailer: git-send-email 2.31.1.818.g46aad6cb9e-goog Subject: [PATCH 3/3] usb: typec: tcpm: Introduce snk_vdo_v1 for SVDM version 1.0 From: Kyle Tso To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, robh+dt@kernel.org Cc: badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Kyle Tso Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The ID Header VDO and Product VDOs defined in USB PD Spec rev 2.0 and rev 3.1 are quite different. Add an additional array snk_vdo_v1 and send it as the response to the port partner if it only supports SVDM version 1.0. Signed-off-by: Kyle Tso Acked-by: Heikki Krogerus --- drivers/usb/typec/tcpm/tcpm.c | 40 +++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index a1bf0dc5babf..07d2bed0a63b 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -401,6 +401,8 @@ struct tcpm_port { unsigned int nr_src_pdo; u32 snk_pdo[PDO_MAX_OBJECTS]; unsigned int nr_snk_pdo; + u32 snk_vdo_v1[VDO_MAX_OBJECTS]; + unsigned int nr_snk_vdo_v1; u32 snk_vdo[VDO_MAX_OBJECTS]; unsigned int nr_snk_vdo; @@ -1561,18 +1563,18 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, */ if ((port->data_role == TYPEC_DEVICE || svdm_version >= SVDM_VER_2_0) && port->nr_snk_vdo) { - /* - * Product Type DFP and Connector Type are not defined in SVDM - * version 1.0 and shall be set to zero. - */ - if (svdm_version < SVDM_VER_2_0) - response[1] = port->snk_vdo[0] & ~IDH_DFP_MASK - & ~IDH_CONN_MASK; - else + if (svdm_version < SVDM_VER_2_0) { + response[1] = port->snk_vdo_v1[0]; + for (i = 1; i < port->nr_snk_vdo_v1; i++) + response[i + 1] = port->snk_vdo_v1[i]; + rlen = port->nr_snk_vdo_v1 + 1; + + } else { response[1] = port->snk_vdo[0]; - for (i = 1; i < port->nr_snk_vdo; i++) - response[i + 1] = port->snk_vdo[i]; - rlen = port->nr_snk_vdo + 1; + for (i = 1; i < port->nr_snk_vdo; i++) + response[i + 1] = port->snk_vdo[i]; + rlen = port->nr_snk_vdo + 1; + } } break; case CMD_DISCOVER_SVID: @@ -5953,6 +5955,22 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, return ret; } + /* If sink-vdos is found, sink-vdos-v1 is expected for backward compatibility. */ + if (port->nr_snk_vdo) { + ret = fwnode_property_count_u32(fwnode, "sink-vdos-v1"); + if (ret < 0) + return ret; + else if (ret == 0) + return -ENODATA; + + port->nr_snk_vdo_v1 = min(ret, VDO_MAX_OBJECTS); + ret = fwnode_property_read_u32_array(fwnode, "sink-vdos-v1", + port->snk_vdo_v1, + port->nr_snk_vdo_v1); + if (ret < 0) + return ret; + } + return 0; }