From patchwork Wed Sep 20 06:30:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wu X-Patchwork-Id: 142244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3917670vqi; Tue, 19 Sep 2023 23:33:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE60G3Bg3HsXxiWHMLdt1yxB1A4RX038hRehMU2JJv+VcB2xLwa0TusSPFLns0Wfa1MtKSu X-Received: by 2002:a05:6871:594:b0:1bf:440:a055 with SMTP id u20-20020a056871059400b001bf0440a055mr1972858oan.4.1695191583975; Tue, 19 Sep 2023 23:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695191583; cv=none; d=google.com; s=arc-20160816; b=o8+VbfCGStjB2Q4AB2Ms9eP3CzdiB78JkXO5/KQRgrA1OYx4O97hacJi9QbM8APCoe +0sbmEAuBTQNk+3qStPUnmjrrD8MdsYUHu4GRveoRJbFKXEr/1iJdrWimLTPjpLqOpKe pd13HVU/DoAemsLO0rmvRPHVBDneu2r+D5LOoOTO6762leDg2nLPl/CWMYchxgZ6gXdh Q0Uv7t7szniIvyjmiuxe6pbedbClqDezYBq4OIfCPyB+vod1vx+uINbfO6uNBB8yjBA8 pxiAdE3cAee7Gh4mRQvKPzjYizQpJu4WGg8cQSAwPXjXOR5GqA8w/k1vWZrAJWUitIw0 0XDA== 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=lZsnnr+ZJ9UUycaBTuHi/BUZXWWUC+yXvpL2VRsUUCo=; fh=9heofhu7MvbjDjs1Hguzot+SUMn0EWL0acDv2wGVjxY=; b=e5VsaZY/n5eP0UFH+Xx7Nkt7i2iVoL1k7kKf9lbvQuEKij5wCUoabOs2cnrZxISc6O v1Lz8/AdT7kuOvjfCSYQFz0qJRLe8coQdf+zQUREF12FW9az9fWni2y1TW2qC8/TC0Xr 5f7QAY9IuBw1bRgDI9+WSFldOG/GwgCVCbaJW1Gt2rNRJQ/AGKFv48Kp9bCgdJvKRfy4 tVBfvEmLdemdCmzpGn9svsWgQ6yqwNOEy9GxKTzarxV324RDhXmZbKZPRciOPkos6KHv 7mHh8Y/ng/RaPmpMvf1mypHHgCJc3I44Kan1E7lmsRINXTKwk5KORt83yAg86CtXmj1R 5cIA== 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 Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b7-20020a056a000cc700b0068fa9821905si728830pfv.335.2023.09.19.23.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 23:33:03 -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 96F4A8093414; Tue, 19 Sep 2023 23:30:49 -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 S233149AbjITGad (ORCPT + 26 others); Wed, 20 Sep 2023 02:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230447AbjITGab (ORCPT ); Wed, 20 Sep 2023 02:30:31 -0400 Received: from out28-77.mail.aliyun.com (out28-77.mail.aliyun.com [115.124.28.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 958CA9F; Tue, 19 Sep 2023 23:30:24 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.2589378|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.00268874-0.000101508-0.99721;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047208;MF=michael@allwinnertech.com;NM=1;PH=DS;RN=5;RT=5;SR=0;TI=SMTPD_---.Ujk16e._1695191419; Received: from SunxiBot.allwinnertech.com(mailfrom:michael@allwinnertech.com fp:SMTPD_---.Ujk16e._1695191419) by smtp.aliyun-inc.com; Wed, 20 Sep 2023 14:30:20 +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: [RESEND v2] usb:typec:tcpm:support double Rp to Vbus cable as sink Date: Wed, 20 Sep 2023 14:30:30 +0800 Message-Id: <20230920063030.66312-1-michael@allwinnertech.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 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 23:30:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777537210357034709 X-GMAIL-MSGID: 1777537210357034709 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 Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus --- v1 -> v2: Simplify expression and add a comment to the code. drivers/usb/typec/tcpm/tcpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)