From: Guenter Roeck <linux@roeck-us.net>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Michael Wu <michael@allwinnertech.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb:typec:tcpm:support double Rp to Vbus cable as sink
Date: Mon, 18 Sep 2023 07:22:41 -0700 [thread overview]
Message-ID: <c52acbd0-e8e3-83e7-d87b-939b47aa39c1@roeck-us.net> (raw)
In-Reply-To: <ZQgm/Lb4iZtWrWbs@kuha.fi.intel.com>
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 <michael@allwinnertech.com>
>> ---
>> 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,
>
next prev parent reply other threads:[~2023-09-18 15:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 0:31 [PATCH] usb:typec:tcpm:support double Rp to Vbus cable as sink Michael Wu
2023-09-18 10:31 ` Heikki Krogerus
2023-09-18 14:22 ` Guenter Roeck [this message]
2023-09-20 10:45 ` Michael Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c52acbd0-e8e3-83e7-d87b-939b47aa39c1@roeck-us.net \
--to=linux@roeck-us.net \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=michael@allwinnertech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).