Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp779162lql; Mon, 11 Mar 2024 18:28:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGfIiWb1sSkXm0F5FYq9oNzUpKVcP0Ekq6j+9xIMijnNbrI0Tp/FU349d836lZ4rKcfG6ogHR+n9W1pa48AAgmUaXBfRbOKjjXjXVDZw== X-Google-Smtp-Source: AGHT+IFjc7kaCPJlFY4hq0DBnUGxkBNwHJGlfkcD3fAH2NqwqLgxS9yTSbHBxRrhfmQMvIJdMMTo X-Received: by 2002:a05:620a:204e:b0:788:5e46:e02 with SMTP id d14-20020a05620a204e00b007885e460e02mr9458106qka.50.1710206928697; Mon, 11 Mar 2024 18:28:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710206928; cv=pass; d=google.com; s=arc-20160816; b=jDtL/6y9X5MVkkNp9c402sjZlqn1MuE0hUb49P3W/x1u1KzUPWu1dMpR0Nethul4uD 9fAl3iXqUYSmrNe5Arbr3Hr+FDhqGxTVZiRqDmM9o+HEC1FfYyEI+710QVKKUMxXUWPd tQkv/6SYjnDiCV/lxNSzJIDEjoUV6tDoxoc6LGwco5AMLshPBszUKp/0LMMHP5gtxtY/ kK3U18CT3UyIKBN1khNzMM+hHaVycSK9yK2BdKkPpvGyld9gIzIH5zODycfS3fY9Hal6 inRkWEoYE64qbJo38ah2mPoBsHpvQC3UU3qkud8y3wMO5BWek6EiGBebMpDwVcoBON9t txFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=4G0VYgujwQ3tNOq4qlx7LzxGXZd+MyERDiV5edC9vi0=; fh=5uG2meqrVprO4EQZO3rzvcDKpuswEfJNBRvX4dAe5rk=; b=FpMq/+bAZdzO5prrKGVd520Z1T8LhCzsC0VOtZA3qDPx6rbBE8FH5l1T2bpvGX+3hP AIy3+JWMvBLyvyzE1yacuMP+S7NBF9VzBitS6a/0jwP6oToUqYUEkWNgc0dn0JRLiwlP 6Uh+bviiixZt0Pvlin5vRCAalW5yhvJ0GZH7ZljDbGW+WP4TtM9Qpw0u5uBf9xQW10xO sy7EaBkswx//VeID/gIBZoVmUFmC19yVwFM11KPj6R91ZN1KdURyIXtCajOWHfBaWLAJ e6DMNeUrocJm7IJ/L+lkiS/47/nYaux4UbmK5mHYv+tpBRNZkSU+6ueGdV+6NkVcxmxJ dSww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=allwinnertech.com); spf=pass (google.com: domain of linux-kernel+bounces-99723-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99723-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p17-20020a05620a057100b00788322c3c1csi6369037qkp.604.2024.03.11.18.28.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 18:28:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99723-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=allwinnertech.com); spf=pass (google.com: domain of linux-kernel+bounces-99723-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99723-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6C7381C210E7 for ; Tue, 12 Mar 2024 01:28:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB4701C17; Tue, 12 Mar 2024 01:28:38 +0000 (UTC) Received: from out28-123.mail.aliyun.com (out28-123.mail.aliyun.com [115.124.28.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 221B77E6; Tue, 12 Mar 2024 01:28:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.123 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710206918; cv=none; b=XMehRS8yvr2AVlalUTIuKnWTFG+5ZaYThz8omDKJU/fFcIHAbvzNFOs4BnZYfpYMtUrYwPbpwZEEJX8/biO+lGN1Ji/MBhqP/6Zfxv2w4lhZ3+XzdG379Gi4bWnBKdBqydrVFRJxZ3BNcSHfGzLU485+TnZltvymm6PLZeJSqpU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710206918; c=relaxed/simple; bh=ZOW09UAyi19w6YXLQJO4RsJctfi8bD03FHleAH9bN6s=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=O6ri9oRs015VOv+YORCzGPI296sWMshycJUgXtvq0kLv7MNTxt7G79qkkTs27ae1i9etRivBGNblWhVp/jAopjIwK/d1WpMKKEjxJumbg7NGPRGYz1BAdqKE5yiyLh6xHlr8QsmE9qMISC/F/K37DB9JFR3vgjEFPcAq7cnTaCw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=allwinnertech.com; spf=pass smtp.mailfrom=allwinnertech.com; arc=none smtp.client-ip=115.124.28.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=allwinnertech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=allwinnertech.com X-Alimail-AntiSpam:AC=CONTINUE;BC=0.257409|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0556319-0.00218893-0.942179;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047188;MF=michael@allwinnertech.com;NM=1;PH=DS;RN=10;RT=10;SR=0;TI=SMTPD_---.WkSydQt_1710205966; Received: from SunxiBot.allwinnertech.com(mailfrom:michael@allwinnertech.com fp:SMTPD_---.WkSydQt_1710205966) by smtp.aliyun-inc.com; Tue, 12 Mar 2024 09:12:47 +0800 From: Michael Wu To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, linux@roeck-us.net, badhri@google.com, kyletso@google.com, frank.wang@rock-chips.com, rdbabiera@google.com, xu.yang_2@nxp.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: typec: tcpm: support sink port for debounce Date: Tue, 12 Mar 2024 09:13:00 +0800 Message-Id: <20240312011300.75081-1-michael@allwinnertech.com> X-Mailer: git-send-email 2.29.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When both CC1 and CC2 pins are simultaneously pulled up, it often leads to the double Rp to Vbus cable being stuck in the SNK_ATTACH_WAIT state. And the state machine fails to transition to the SNK_ATTACHED state. Therefore, it is recommended to focus on transitioning the sink port to the SNK_DEBOUNCED state instead. By doing so, the desired outcome can be achieved more effectively. [ 134.525750] VBUS on [ 134.713240] CC1: 0 -> 3, CC2: 0 -> 3 [state TOGGLING, polarity 0, connected] [ 134.713249] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS] Signed-off-by: Michael Wu --- drivers/usb/typec/tcpm/tcpm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 0965972310275..9228dbd78bf2b 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -4197,6 +4197,8 @@ static void run_state_machine(struct tcpm_port *port) else if (tcpm_port_is_disconnected(port)) tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE); + else if (tcpm_port_is_sink(port)) + tcpm_set_state(port, SNK_DEBOUNCED, 0); break; case SNK_DEBOUNCED: if (tcpm_port_is_disconnected(port)) -- 2.29.0