Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5351815pxb; Wed, 26 Jan 2022 10:00:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoWabK5W76rEcwW4YfzSI1yy9OoExpxMaUW7P8xJtBtBKVsB46s4qhX8ly+OpNae8Ck4/3 X-Received: by 2002:a63:4345:: with SMTP id q66mr66612pga.358.1643220046371; Wed, 26 Jan 2022 10:00:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643220046; cv=none; d=google.com; s=arc-20160816; b=llZout0pEO4P/131j0OS+0OfRo0x/FLNoennJj10O7wQwQVbX7fgia7rCtxOjN5HBX 543yJEtELoEUUq96JG506LWuQ6Jr3SZpLOrLuIYICtRoBRYWm1GjmUo25zJ+dqBS0eyZ D+PdcZIHUfIO0VaD25pitxNz8YG1ibVmJ1xNvWvBSUqBoQ2vGKh7x3TJR365xHlsW3cR ThfelrlUaahgsdEYSyzO9zuF5BXcnMeIshDfknL+cNDPwt5xiCEGutxEIJH99xav8FdW yIqVpnh9UNgoNy9naVcbTwVBq59WinD9MsFV6p8plsTRl2FAYLZts2qROubk5sK1PPAq oJ0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=HkfPmpCPhI4ODIe5DoaH45p7aAixzF8Mvfn5ikpABY8=; b=Qz8bVUjatZw97wsSNL9tnlKQehlLrUucTWYRncj5nLSDNH2K5QCZqlrVko7FRZB1c1 dckpZ1TM8kPtoJ4UoQ39CAHKT23961Wp17ZUzCiHvc0AeSrIXKv70b1vmsqcXYCG2WIq tvQRasINDE0TLkNEQTMPPYsTHJGshGXOrVyvxR1BTXvwSts4vVcH8PJvBrRhF2MfFQwB uOtdleFm07mhgH6JV0bHSYvo1gczBnvMzra1bppoI8exWcDQhGnMdzfx0KaSbOYgwlV0 0+fBIzoNozihUWboLwc2HtITP2ayh0ocR0SKggZdNTpQitSLSc3dosZJ2fu6Ef7tmYAQ CY8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PcqY+kCD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id np7si1904974pjb.1.2022.01.26.10.00.32; Wed, 26 Jan 2022 10:00:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PcqY+kCD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237506AbiAZEGx (ORCPT + 99 others); Tue, 25 Jan 2022 23:06:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237499AbiAZEGu (ORCPT ); Tue, 25 Jan 2022 23:06:50 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7180BC061747 for ; Tue, 25 Jan 2022 20:06:50 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id c76-20020a25c04f000000b00613e2c514e2so41784724ybf.21 for ; Tue, 25 Jan 2022 20:06:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=HkfPmpCPhI4ODIe5DoaH45p7aAixzF8Mvfn5ikpABY8=; b=PcqY+kCDb8UqpK1dbw2lWC2guuzF7QDxlHNXlojxEspoAt0IsvZMUY/4+w4Zmk2i7H POj4/X0fq5WzuXP6mk+hQtEf0PUQa2Yf8EKH0vx+XfAv6bl9dKa30vWtUxA//FgLKQEQ tImo3owgB2h2Tj16PS+IuY35CKVIox2JQKQdtfrVFZPbOdxiLB9o2mlDv58G32ktakfZ dJpgZcSxYPczZyqbguctBdp2G43VJbXeduU9q1rloZxYfNpf9OU7iayZUta38sbS1eHY S3/YGLFmbW/to6LyAKj15/7wbl8jWonI+XP5ZbfPGb7scPT8ySAGRhw4Yx1Wi+EhmVWS vP6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=HkfPmpCPhI4ODIe5DoaH45p7aAixzF8Mvfn5ikpABY8=; b=mZVNqg3aqg2YOZUN9LkucjB4BoCm87tgn2TXMhJIbrbr3SjaFR9Vpw/Wkn5ZNVhQGG 5OIsi3l8Ls+0spTvngbY6PjR9v5hwhO5OraKY2Cm/2LHAmLzhwk0Bf3iNT4K76ZNNjcI hZgfRJgPdlPlWiYLisEo5L/BYhayLFvGGPHu0GSPsIy5Q4uIKhjeNAF0LJv0oDBJnjUl LDoRq58/+fytTFADstOZWWo8t0Qi3Sr+jLN3Ery6LIuKusRPvWyxAKfUVM0H33+jqu1r pfQSgwWCZKU9gWQ6WTSEFMD158+qMVMn6VGuOuer9zEw1XBN+rkY9hhQIL7PuxMVMQC0 ptuA== X-Gm-Message-State: AOAM531pqkk1Ed2aFWzexs0yaLQ6HI3ft7ZGnPVUzUxi86nGt/aAxjF3 qHIuJq1aIevhwXbsb8m69OQ0rQeQjKY= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f4a7:8e16:f301:160]) (user=badhri job=sendgmr) by 2002:a25:b94b:: with SMTP id s11mr34233129ybm.439.1643170009692; Tue, 25 Jan 2022 20:06:49 -0800 (PST) Date: Tue, 25 Jan 2022 20:06:45 -0800 Message-Id: <20220126040645.3187200-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH v3 2/2] usb: typec: tcpm: Do not disconnect when receiving VSAFE0V From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , stable@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With some chargers, vbus might momentarily raise above VSAFE5V and fall back to 0V causing VSAFE0V to be triggered. This will report a VBUS off event causing TCPM to transition to SNK_UNATTACHED state where it should be waiting in either SNK_ATTACH_WAIT or SNK_DEBOUNCED state. This patch makes TCPM avoid VSAFE0V events while in SNK_ATTACH_WAIT or SNK_DEBOUNCED state. Stub from the spec: "4.5.2.2.4.2 Exiting from AttachWait.SNK State A Sink shall transition to Unattached.SNK when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. A DRP shall transition to Unattached.SRC when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce." [23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] [23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [23.300579] VBUS off [23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] [23.301014] VBUS VSAFE0V [23.301111] Start toggling Fixes: f0690a25a140b8 ("staging: typec: USB Type-C Port Manager (tcpm)") Cc: stable@vger.kernel.org Signed-off-by: Badhri Jagan Sridharan Acked-by: Heikki Krogerus Reviewed-by: Guenter Roeck --- Changes since v1: - Fix typos stated by Guenter Roeck. Changes since v2: - Add reviewed-by/acked-by tags --- drivers/usb/typec/tcpm/tcpm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 3bf79f52bd34..0e0985355a14 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -5264,6 +5264,10 @@ static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port) case PR_SWAP_SNK_SRC_SOURCE_ON: /* Do nothing, vsafe0v is expected during transition */ break; + case SNK_ATTACH_WAIT: + case SNK_DEBOUNCED: + /* Do nothing, still waiting for VSAFE5V to connect */ + break; default: if (port->pwr_role == TYPEC_SINK && port->auto_vbus_discharge_enabled) tcpm_set_state(port, SNK_UNATTACHED, 0); -- 2.35.0.rc0.227.g00780c9af4-goog