Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp514027rdb; Tue, 19 Sep 2023 02:11:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETn0M+IV5I4ItLxKXesl3ArXvZ81notAUs4ednVdOsNyUYukH9rcT5RHS4lkwJo+jojWVc X-Received: by 2002:a05:6a20:6a20:b0:132:cd2d:16fd with SMTP id p32-20020a056a206a2000b00132cd2d16fdmr12221483pzk.38.1695114671704; Tue, 19 Sep 2023 02:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695114671; cv=none; d=google.com; s=arc-20160816; b=qJkQQ8UhL8Qz3v39ck8QxBFryEO1RIC83c5tfQNCd0nCNR15gc7FOg8VY4Ng4VLGZY 4ULyg9QMcGH36sXefvfWi5SXqBtJy+g+XIf3xHLcB0CwAckZhj1bUWP/R9XlH7FihhHy 7FtqGBl6As32O6CwePWtAaafDIHsD5osJSdb8fiYg1da6hw2fQa1Vi9EZWBiY3p8YoMd gqEWu0zMEdJ2h8N+elvfV0cLyzhGX8InXH9rL15MU8+L8uf7UMI40HT2UwF76B57RM1t pL14Hb6V+HaY2yuAndeYUC47+c8mlk/gUje5wigKbP63Z9dv2b3ajX+PYXRYUou29GnC /mWA== 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 :message-id:date:subject:cc:to:from; bh=GdRa3Ayt0poZXpC9iWcNHwhOprbm/byGSUar/JbTmIM=; fh=9heofhu7MvbjDjs1Hguzot+SUMn0EWL0acDv2wGVjxY=; b=Mf+rSlDYoI1O/U3AlBSw/SH6xfaWZaH0M6Sc7ji4KreES6lrCRlkL6B4en3SyMiDQz UlrGg9HUx2CC+J8+ma0813dvBq9xTJ37dejTJpN6QliAqzHwEwOYbE394BT4nIEsRqHO 0FSeaD5QU1dcQ25cyfsZEmrqDyVD2Uc/Tm37qkflCkmnkRwngOmn9arCMQ0NEgIGTSz/ tuCSQWo1Fbp3XaBinM/7wW/AaaeHgRGlMnCaACaRyHau95DN1cJUVDl2Sw207rONUiWx M02Yju2EbtjBuu1sYO0vPp5ICGBYFZQwd7TccmpViH/Tf/yQIjvgIkPoimJeF2DTELMi V/Qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id by4-20020a056a00400400b0068e42950c86si9427757pfb.44.2023.09.19.02.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 02:11:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B831F807600D; Tue, 19 Sep 2023 02:06:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbjISJGe (ORCPT + 99 others); Tue, 19 Sep 2023 05:06:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjISJGc (ORCPT ); Tue, 19 Sep 2023 05:06:32 -0400 Received: from out28-218.mail.aliyun.com (out28-218.mail.aliyun.com [115.124.28.218]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CCCFDA; Tue, 19 Sep 2023 02:06:26 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.2303904|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.00369381-0.000118264-0.996188;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047192;MF=michael@allwinnertech.com;NM=1;PH=DS;RN=5;RT=5;SR=0;TI=SMTPD_---.UixELv._1695114383; Received: from SunxiBot.allwinnertech.com(mailfrom:michael@allwinnertech.com fp:SMTPD_---.UixELv._1695114383) by smtp.aliyun-inc.com; Tue, 19 Sep 2023 17:06:24 +0800 From: Michael Wu To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] usb:typec:tcpm:support double Rp to Vbus cable as sink Date: Tue, 19 Sep 2023 17:06:32 +0800 Message-Id: <20230919090632.42517-1-michael@allwinnertech.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 02:06:32 -0700 (PDT) The USB Type-C Cable and Connector Specification defines the wire connections for the USB Type-C to USB 2.0 Standard-A cable assembly (Release 2.2, Chapter 3.5.2). The Notes says that Pin A5 (CC) of the USB Type-C plug shall be connected to Vbus through a resister Rp. However, there is a large amount of such double Rp connected to Vbus non-standard cables which produced by UGREEN circulating on the market, and it can affects the normal operations of the state machine easily, especially to CC1 and CC2 be pulled up at the same time. In fact, we can regard those cables as sink to avoid abnormal state. Message as follow: [ 58.900212] VBUS on [ 59.265433] CC1: 0 -> 3, CC2: 0 -> 3 [state TOGGLING, polarity 0, connected] [ 62.623308] CC1: 3 -> 0, CC2: 3 -> 0 [state TOGGLING, polarity 0, disconnected] [ 62.625006] VBUS off [ 62.625012] VBUS VSAFE0V Signed-off-by: Michael Wu --- drivers/usb/typec/tcpm/tcpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index d962f67c95ae6..6e843c511b856 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -517,9 +517,9 @@ static const char * const pd_rev[] = { ((cc) == TYPEC_CC_RP_DEF || (cc) == TYPEC_CC_RP_1_5 || \ (cc) == TYPEC_CC_RP_3_0) +/* As long as cc is pulled up, we can consider it as sink. */ #define tcpm_port_is_sink(port) \ - ((tcpm_cc_is_sink((port)->cc1) && !tcpm_cc_is_sink((port)->cc2)) || \ - (tcpm_cc_is_sink((port)->cc2) && !tcpm_cc_is_sink((port)->cc1))) + (tcpm_cc_is_sink((port)->cc1) || tcpm_cc_is_sink((port)->cc2)) #define tcpm_cc_is_source(cc) ((cc) == TYPEC_CC_RD) #define tcpm_cc_is_audio(cc) ((cc) == TYPEC_CC_RA) -- 2.29.0