Message ID | 20240228000512.746252-1-badhri@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-84255-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3040289dyb; Tue, 27 Feb 2024 16:05:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU5VWt3sd8UBu3WPTJ5XPx6J1Aswtl+ijCm4yLjCz9UCnI+YTPe3Kp/8y9OQlydSL5ndQqwTiYZWDnEYeqpE5WxrJ2z2w== X-Google-Smtp-Source: AGHT+IEx80ulZvYHO0aauejfV0Cc1Z4bTH1s6PHOFXk7ma85J/VmyRXHeXIltnASanGiZP7g5+UG X-Received: by 2002:a17:90a:398f:b0:29a:6d06:6253 with SMTP id z15-20020a17090a398f00b0029a6d066253mr8183901pjb.41.1709078744041; Tue, 27 Feb 2024 16:05:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709078744; cv=pass; d=google.com; s=arc-20160816; b=v9C/+AonUzODylPUQRwGdZebaVLoHvCvd4sA726CQxFSpEidlA8hoA3uqN4b13yv0C OlW5oPaNrKXoQ3YKT8ihIO3KawqGA661/9w9t6+d45Pfc8Rm94RED4snMt9VAGo13JSw /XkvohLAVlMuf97IQU1ItjbIVtChPaa4ycR9P8YcemE6cfoJ/NUSa126E2h5UJSXYPwa FWQ4mJoIbyk7WF5ZrolZo+jyS0jTyGJSNCn1gcU7xfSTNjiB3PRHZVg4Qb4kosJUz92e b9OxGcazANbYv9MG5lFrk80mUtl64O3twnhG2yM+r+ZSjvy2oFi4/oZHPqwxLYdVcYGn e+BQ== 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=3QynGLk1qlXS/b5BsO1d0j20dFGFaWGNAGl6bHTYfKo=; fh=e9W1bVyC5s83ZKNPDrdBTmDItGlYRWOsluGwhBVl5wM=; b=Ov9Mks9F4sqTKrniBPwk90b4HtS0aKOCXWo0CoOFJn527R53+x1wQ4I25uGtzMfAl0 ZRMwe2JiST2HfAvSVhIhYiYC46fCc7sTgQxz8kxPAEjC30K5aOnBPn88LwJuNvco0QEf yVGNhi/TzXNDc6P7Z/HALPGJGyNdZFEeiXIE3/eZ3v+iORDwMJRQRN7jCjzUwvZ5BApK qa+wwQb5sRNWVKcsAqFEG+2AOjR/bIJ526MeUUfBL3itpddBXnjRUU4T2JpLoMtaQx1m mhL9QDe7HZKsdTo7JUVqEMlGr5Ns95Aq1SuiudPvG9k9C/3b23lIsj4Nt5XfGuegilQl v/Ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ECLElM3H; 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-84255-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84255-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x11-20020a17090a970b00b0029a8498e2c8si231616pjo.8.2024.02.27.16.05.43 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 16:05:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84255-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ECLElM3H; 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-84255-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84255-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CC7D1288350 for <ouuuleilei@gmail.com>; Wed, 28 Feb 2024 00:05:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3DB51FB3; Wed, 28 Feb 2024 00:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ECLElM3H" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 A7CA6185E for <linux-kernel@vger.kernel.org>; Wed, 28 Feb 2024 00:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078717; cv=none; b=ntiG1DZzYTEQUeAKzCu4GVy0gHx8s6dWse0EGykn1BbuSw9IbTSB+mBbNFyUZ5ZGO4te9A8k0/gl8dzRnjulusrtfYQ44DmhgWc07U00NjIqZrp86FOOc7uwYiW0EvXrT57atd0ji5+J37rdc1s5Ht9RMO2WtBSXOc1+io6QjZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078717; c=relaxed/simple; bh=MNl2a9+9wniw0DL7pfu1Gvnvl1U5VZVdbJpueNcd744=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=BZo2UzuUhOI+iTfBfBi4noEFkb3oC6BfTqwhGp9phRu4jRlDhApOt/1fY4/aGOyLUSZ2zbGxwZOvxZY62NujM5BjmSO1bxr4Ttm8aKDQWhdJmJeWKu/PHKw+vzPNO25B6++EHqrvnBvKGBbOBJdovU1KXqPqaVXxBSjLQFCe8Z4= 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=ECLElM3H; arc=none smtp.client-ip=209.85.128.201 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-yw1-f201.google.com with SMTP id 00721157ae682-609239ad1bcso25000707b3.3 for <linux-kernel@vger.kernel.org>; Tue, 27 Feb 2024 16:05:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709078715; x=1709683515; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=3QynGLk1qlXS/b5BsO1d0j20dFGFaWGNAGl6bHTYfKo=; b=ECLElM3HQkvcm62xB5Xva3Vuz5+IoziuYtMtZzylSjPHH//vXeyiZ+Ks2wdGHWvlwX VK4hGLThu212pF9+EESz9NeZnh/uPAIRtu5jEzoJOazrkdwXkOJgqnhZaE0twESWbmNr BlmKfRMa/Wa3j6RXePNl4OGwueRZ6yM9prV7P+HxaqfODUNyx5I2a8DSq22Mi45531IO xpgFnOkKwuImqPUy5LO2mK/HB1/pGMAssdxYXsHdDYmk1HYb3MPbIFF93ofCeTf1BIqT OvGJdX4ENLK/e/2UYFcVXwEpIGthKWmuJ3BldxrB/AvcYUBZ5N8iL7nEE6wkmzf/Sa3J ISAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709078715; x=1709683515; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3QynGLk1qlXS/b5BsO1d0j20dFGFaWGNAGl6bHTYfKo=; b=IH6IckcLwJB58HVD1EzofgHbEcf6Uwy55806amazj9HXL0Ud+DjlQa1HY3r30JLfR8 diY39cJywgs3ZNGULF6KUO0BaZfAdeuFjuzdsJLB2a7Lykfk5Vb28dhSUoG8zFAf0R0Y BmRYaGxqIlWPCF1kR2fMNH0mdoTa0A2IdrV07LePLzmtf/KWBGbg4g2AOXOCVnLbRksR I6jcOgfx0JIb391HXSGpTTRL6AIMZL6C9yyMmUElqddZ+D3mNQRH8M3g6Ctfnie2W34B bQs4sFrOqK0ILxUjP6BN8wWKU6p1QUDEuJ2OuuydLVbo4KeJrZxzYzBilBSUwi5gtoEl up0w== X-Forwarded-Encrypted: i=1; AJvYcCWRuM0MPFdBjBPyQc16SxN6lzS5oKb8GfOY2box+69RTd2Tb0pfOwuthP7yqiARYjInmBwvG0xGHql1Ii7QGdpb42qPRHWOHrTypp0L X-Gm-Message-State: AOJu0YzjZMvDqYwEFa0DWi5zY/TTwaH/HY3qAFOQwPAQMCu0XlwwzzhW bE0uUEstdiKZ21DObpivjdr7RFmo7YrVkOKXW3n055KgZSa/DlY5BOYsi7j/Mz0BjpkoYVQOmp9 6jg== X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a0d:cb86:0:b0:609:2693:bb33 with SMTP id n128-20020a0dcb86000000b006092693bb33mr704963ywd.8.1709078714754; Tue, 27 Feb 2024 16:05:14 -0800 (PST) Date: Wed, 28 Feb 2024 00:05:12 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog Message-ID: <20240228000512.746252-1-badhri@google.com> Subject: [PATCH v2] usb: typec: tpcm: Fix PORT_RESET behavior for self powered devices From: Badhri Jagan Sridharan <badhri@google.com> 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 <badhri@google.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792098952884196405 X-GMAIL-MSGID: 1792098952884196405 |
Series |
[v2] usb: typec: tpcm: Fix PORT_RESET behavior for self powered devices
|
|
Commit Message
Badhri Jagan Sridharan
Feb. 28, 2024, 12:05 a.m. UTC
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@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
Changes since V1:
* Fix CC for linux stable
---
drivers/usb/typec/tcpm/tcpm.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
base-commit: a560a5672826fc1e057068bda93b3d4c98d037a2
Comments
On Wed, Feb 28, 2024 at 12:05:12AM +0000, Badhri Jagan Sridharan wrote: > 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 Tested-by: Mark Brown <broonie@kernel.org>
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;