Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1243092rdb; Wed, 20 Sep 2023 04:01:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJCZKzQYmXIsfj3Pu/y4Fxu0tm3IweRXeyCHgrOH20p4QMJlIoyRMnR4Px88G8iP54Uiyb X-Received: by 2002:a05:6a00:1a90:b0:68e:3b0b:8192 with SMTP id e16-20020a056a001a9000b0068e3b0b8192mr2227327pfv.21.1695207705298; Wed, 20 Sep 2023 04:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695207705; cv=none; d=google.com; s=arc-20160816; b=s31Kym+q40GnhGftrQYw3gc9zKGsIBih3ZTrfSjYrAg4UDDAuigIzMAclDL0MUx3Od 7E3MEgUw/lV2IPT4E6EkQWTOO4gggu2vh0Z+TkvgZ1p7HN4oQxhu2Ljrv/+OqR4+qh8+ /uCcMAPFnt2zIrb0GttDqzISSs1MZXpQEMTbvTxitzgHUYY7qMNH7FxfbLcEASLZHGKt R0+CyhINp9QVRdXZs4e/MUQTMooTo1pboKrzm/kXywlTXu9hyXzoFbE02K289g7wncbL swqEDSynwZks6UuhIe2x3MC2FOX374QfxqIppParBHyw06a6tlcx+0kLqIrPUomg/Hfx NDRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=6dfyThOHotqOQmFKQdCvZ8q1Qzd+Pyb+Ybl+LTU434w=; fh=sh7LW/G9+2LOLyo12TEKlcSOTrof6xUoN6nJmKuyB6w=; b=JVDCOVWXxdR8rJlHExVC6wWW0qj7q1R36QT9bX/jG+O5mx7yJ6ClDKgWCrscOrCg9e baUCxspBQmhorxW9bvlspohxOLufZs/wNbnCRzu0gtlLRemThc4IlOdAniujwkc/5+Mf cLvk3zj5jBMzAXO6OY+n5hMYUBEdt9FMf2nj8ERy2zYJjwhyexUc8dVL1dBdK41C2Etg 3dmpdsS/e8CdhHEdUPXwU5Fa/mLlpsd8JBrdM+Vnd1dtArY7u8UhqwvQdzL8LYWPpDtI 9qkjMVR2gXHaUyVVS4PEvWoDE8NLyO7+iLUZy7PePVwt22G6JFnpb6PPVTpfxgC19hvv Lc7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id a11-20020a65640b000000b00577f7c8db80si11300313pgv.372.2023.09.20.04.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 04:01:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 6497980AD09D; Wed, 20 Sep 2023 03:46:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234500AbjITKqj (ORCPT + 99 others); Wed, 20 Sep 2023 06:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233999AbjITKqL (ORCPT ); Wed, 20 Sep 2023 06:46:11 -0400 Received: from out28-73.mail.aliyun.com (out28-73.mail.aliyun.com [115.124.28.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 048DECF8; Wed, 20 Sep 2023 03:45:51 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07524619|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.0665893-0.00179403-0.931617;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047212;MF=michael@allwinnertech.com;NM=1;PH=DS;RN=5;RT=5;SR=0;TI=SMTPD_---.UjzWuGe_1695206747; Received: from 192.168.220.129(mailfrom:michael@allwinnertech.com fp:SMTPD_---.UjzWuGe_1695206747) by smtp.aliyun-inc.com; Wed, 20 Sep 2023 18:45:49 +0800 Message-ID: <56e26444-f289-d017-6225-24658e81ab84@allwinnertech.com> Date: Wed, 20 Sep 2023 18:45:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] usb:typec:tcpm:support double Rp to Vbus cable as sink Content-Language: en-US To: Guenter Roeck , Heikki Krogerus Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230914003154.27977-1-michael@allwinnertech.com> From: Michael Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Wed, 20 Sep 2023 03:46:58 -0700 (PDT) On 2023/9/18 22:22, Guenter Roeck wrote: > On 9/18/23 03:31, Heikki Krogerus wrote: >> On Thu, Sep 14, 2023 at 08:31:54AM +0800, Michael Wu wrote: >>> 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 | 3 ++- >>>   1 file changed, 2 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/usb/typec/tcpm/tcpm.c >>> b/drivers/usb/typec/tcpm/tcpm.c >>> index d962f67c95ae6..beb7143128667 100644 >>> --- a/drivers/usb/typec/tcpm/tcpm.c >>> +++ b/drivers/usb/typec/tcpm/tcpm.c >>> @@ -519,7 +519,8 @@ static const char * const pd_rev[] = { >>>   #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)->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) >> >> This look OK to me, but I would still like to wait for comments from >> Guenter - just in case. >> > > Look at the conditions. Reordered, we end up with >     (tcpm_cc_is_sink((port)->cc1) && !tcpm_cc_is_sink((port)->cc2)) || >     (tcpm_cc_is_sink((port)->cc1) && tcpm_cc_is_sink((port)->cc2)) > which simplifies to >     tcpm_cc_is_sink((port)->cc1) > making the complete expression >     tcpm_cc_is_sink((port)->cc1) || >     (tcpm_cc_is_sink((port)->cc2) && !tcpm_cc_is_sink((port)->cc1)) > which simplifies further to >     tcpm_cc_is_sink((port)->cc1) || tcpm_cc_is_sink((port)->cc2) > > The simplified expression doesn't conflict with other detections, so I am > ok with it. It might be worthwhile adding a comment to the code, though, > explaining the reason > Guenter > >> thanks, >> Dear Guenter, I have modified it according to your opinion, and resend it as patch v2[1]. Please review. [1] https://lore.kernel.org/all/20230920063030.66312-1-michael@allwinnertech.com/ -- Regards, Michael Wu