Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2254456rbb; Tue, 27 Feb 2024 16:28:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVEVOmZG0H7sKhuawPE+2t7Xgu/ofud/jIeOOJOgDO9ID62Rbsr0jC7Eg6nXooxE3OiESwr3mE36T5oCwnwjb7N3zu/qnHsShJBWuaimw== X-Google-Smtp-Source: AGHT+IErAykUOsUUAB7gKvFmhFFp3FV6o5TBbwbfD2lmzxjtsariiJJ0OvI+RrZm2VGZa8lKfa2p X-Received: by 2002:a17:902:cf09:b0:1dc:8790:6809 with SMTP id i9-20020a170902cf0900b001dc87906809mr14307054plg.8.1709080129506; Tue, 27 Feb 2024 16:28:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709080129; cv=pass; d=google.com; s=arc-20160816; b=CzqW4eTaCrXqc218WMN52CeJ51ATKD5GWaJICKwkYmBEHr+9SknCd4etpmGCaN+7gR sj8g6HUfhQ0C85zqqv+SqeCvYujiRc23rZCRiZSWF/vhHBWB1m1IwxURpq0IPnJgV970 MOEP6g6PVCkEe9B1OszqW7utrRTa/kby7aWMKq7nfQd0N5Apyq43wgtgEz5bwvmjf3jt Jd+FMau6UOvyX21QP6X/RUXLk1mosqC0FMyuYuEztEGgLg85959CiZWNHMgeMAexbreJ KXVO6st3jFjNibfdwcSL0WgxJsDXt8RF2qAqqK6SR8E3w4kKDM/1+jDQLtfdbCAsJ9b5 ZAVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=/LdW7tPXFcFwIvF+jtRCAIo7Kke3BZ9m44DLtohg7Ec=; fh=hW9QHQzKlvAWpYSVsW5au1cYzU5yG11yIOGi+WzYRQc=; b=G7JyLxt6CNeTB18jYJ9GJ6sZwHFEzhOzxCZfUgNx89dzAxEPkGCsJs6uE5pu8+39Mj 878Gb+/v9Muh8FnIfdqP6O78/TiR0bW7umz5/rZ6xAvOxE8mwXAMYCXhPg9POGUJyQtN Cc9ohS2LapUqBkmSE5VVqw4SOJ60OO3HO+oP2YWC3zgd9hXBNiMNvALJmOcQnyIxkeoq VFE4L8iRSVKAD50InRbBcf3OmnOjCJuui1c56kDLBYtxFaBwDVeMhH08p/FGOf5Ax+3g qfT+ke/dNww1JIqpHGgWZDKBIoen2rRuwMBpirK2w2D8zab3FZ5tSHlCrh/pWN0jbnCk BiGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rBWiEFmc; arc=pass (i=1 spf=pass spfdomain=flex--badhri.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84241-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id jf13-20020a170903268d00b001db603f6482si2192508plb.415.2024.02.27.16.28.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 16:28:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rBWiEFmc; arc=pass (i=1 spf=pass spfdomain=flex--badhri.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84241-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3B346B284B5 for ; Tue, 27 Feb 2024 23:58:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E383155E48; Tue, 27 Feb 2024 23:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rBWiEFmc" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 912EC5674B for ; Tue, 27 Feb 2024 23:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078321; cv=none; b=Kz9pIlodstvTVEGCwg4+4/GRTIwQdiKL5xSpvgQaaknl6hpZL2zVrE7BLVG6TjMhlsq428HarAsMCJipSnHJL+xKWvQRXOCprVdpKuOoTwM7WMo2WM53PGjY+u21/Uh6LvHuhS8ngy2wX1PcewrCJrrK0vzp7qSKcu/4NQboy/E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078321; c=relaxed/simple; bh=2/lRzbav4ZEIZxCx4lcDj3Wd/X8auYnCnUQfBTX1XUM=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=RvXXnjRVKex+lajfAl2jA2FDKDoJ6WetSJr1ER7E00cXAcQt4dW0BWU6oQko4AFWSQ9nnK34vKKB11kJuGCPtjmi03T9H+nYlCr1D3ziOYmkb1wd81NRDexopDb51IJKR9pbAyeW1SCTOnBul0xXTNFw8F0GE1FAINIYdgWE7n0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--badhri.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rBWiEFmc; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--badhri.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dce775fa8adso9338925276.1 for ; Tue, 27 Feb 2024 15:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709078318; x=1709683118; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=/LdW7tPXFcFwIvF+jtRCAIo7Kke3BZ9m44DLtohg7Ec=; b=rBWiEFmcZqnDXPkn82+eQ5P9Zb2pGgmxxXOarVQMVv6GFdSfMNb8im2/RqG529TFWp sScu0GxpmpcqBUL14wytPzS/yywlC2lk/qlFJTUIcK3xb2YrOSkBV+68Np88wZeenloy eQYpIHe9e4Hx1C9dKZS76Yu41AqmTF0XJ9KIkBjFlYxKPQzlM03dRJm38DVo01Nr4lhB 5z4Us1QwcUkp8fW3nSx6s1d6o7XK3PJKpeo1pbCHWIFXwDYz4w5oOGDSjmakMQu4SQbT 1UCtCAODID72PnFNI07TY2LGdlJMNR4NVgRFZP9yNxlfDt/V4s7mP9gDpN0I75mKGVTR oKNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709078318; x=1709683118; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/LdW7tPXFcFwIvF+jtRCAIo7Kke3BZ9m44DLtohg7Ec=; b=ddfLL5QObDyjjQEMFCaJrwVu9HHq6SVhQfqADNLprHmtB3mxQEOjyt0Izu9vz4GRXh MWKKFMhCcAwqzD2PYqp726RfKjh4QlamYCIkg3aF+X+yz5UVBAvhaNIEIM0d+5mIu2so jl9FM5DY29tRDyE4g3ftGreNybTSf89bj+55a2HSN5uLBRn+1oPp+WP7gGr5mBjFW7xC Ona9n5S/kT0rcNiGkgkcaD2bjgZBpgSn1oca6LUVhgzmdrqQD1qkDxBqcBw85U12ZwoH ZO1ArrgwpqE9VdK564wChiLFe9ozG7m60oJSNl+9qHqSw+gg6x3GujGmdoj+TwyZX5e/ 8NVg== X-Forwarded-Encrypted: i=1; AJvYcCV5bUtcADTytRm19CiWJLVPadUxLNQNQW7Uyxq4Y1vfVCvGMg6sauI0wNIznZsdLIsks5E4lz9T2k9iOjie4JnQrBFEgKVe0rLTLqIZ X-Gm-Message-State: AOJu0YxZ0QGE1wXA4BMgJLL24zXK91E7byzhTjJpiv8RGcTiq6++MM7s 8kJqWsv8ff7oI6PsxRB32aO3lLXR5YbOzr7Yj53zB0zBk3ZOmvBK6fRlJyjD205YpzXSMaOKvxj pJA== X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a25:b341:0:b0:dcb:bc80:8333 with SMTP id k1-20020a25b341000000b00dcbbc808333mr294382ybg.13.1709078318262; Tue, 27 Feb 2024 15:58:38 -0800 (PST) Date: Tue, 27 Feb 2024 23:58:32 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog Message-ID: <20240227235832.744908-1-badhri@google.com> Subject: [PATCH v1] usb: typec: tpcm: Fix PORT_RESET behavior for self powered devices From: Badhri Jagan Sridharan To: gregkh@linuxfoundation.org, linux@roeck-us.net, heikki.krogerus@linux.intel.com Cc: kyletso@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, rdbabiera@google.com, amitsd@google.com, stable@vger.kernel.org, frank.wang@rock-chips.com, broonie@kernel.org, Badhri Jagan Sridharan , stable@kernel.org Content-Type: text/plain; charset="UTF-8" While commit 69f89168b310 ("usb: typec: tpcm: Fix issues with power being removed during reset") fixes the boot issues for bus powered devices such as LibreTech Renegade Elite/Firefly, it trades off the CC pins NOT being Hi-Zed during errory recovery (i.e PORT_RESET) for devices which are NOT bus powered(a.k.a self powered). This change Hi-Zs the CC pins only for self powered devices, thus preventing brown out for bus powered devices Adhering to spec is gaining more importance due to the Common charger initiative enforced by the European Union. Quoting from the spec: 4.5.2.2.2.1 ErrorRecovery State Requirements The port shall not drive VBUS or VCONN, and shall present a high-impedance to ground (above zOPEN) on its CC1 and CC2 pins. Hi-Zing the CC pins is the inteded behavior for PORT_RESET. CC pins are set to default state after tErrorRecovery in PORT_RESET_WAIT_OFF. 4.5.2.2.2.2 Exiting From ErrorRecovery State A Sink shall transition to Unattached.SNK after tErrorRecovery. A Source shall transition to Unattached.SRC after tErrorRecovery. Fixes: 69f89168b310 ("usb: typec: tpcm: Fix issues with power being removed during reset") Cc: stable@kernel.org Cc: Mark Brown Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index c9a78f55ca48..bbe1381232eb 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -5593,8 +5593,11 @@ static void run_state_machine(struct tcpm_port *port) break; case PORT_RESET: tcpm_reset_port(port); - tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ? - TYPEC_CC_RD : tcpm_rp_cc(port)); + if (port->self_powered) + tcpm_set_cc(port, TYPEC_CC_OPEN); + else + tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ? + TYPEC_CC_RD : tcpm_rp_cc(port)); tcpm_set_state(port, PORT_RESET_WAIT_OFF, PD_T_ERROR_RECOVERY); break; base-commit: a560a5672826fc1e057068bda93b3d4c98d037a2 -- 2.44.0.rc1.240.g4c46232300-goog