Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2244553rbb; Tue, 27 Feb 2024 16:05:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUk1rdIhKcwqacc3YG1xmU1xDKeAT99hPh5L/al17+fVGnbgNWVKtbyRAtQQz7VLasyJswxEGpy2V+Ak3qNUji1hANsornb9eXVOmpwHA== X-Google-Smtp-Source: AGHT+IE9pHFKBdfq4BoAS+M2ympEyRfwMYqEGCvAR2GLVqt59wF73Vh+0oKTy2+G/EzqHL0UzjVg X-Received: by 2002:a17:906:abcb:b0:a43:f4c3:7c6d with SMTP id kq11-20020a170906abcb00b00a43f4c37c6dmr273385ejb.16.1709078727453; Tue, 27 Feb 2024 16:05:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709078727; cv=pass; d=google.com; s=arc-20160816; b=K4iA1FdRJJNYRBVD/Xp9Nk+pyu/yjVG3DNEQca5BxjJ05/KY09D9XMG4x2q9BRXkbc qLx/Ogt60zi5Pph+HTKzDGkIan5KHUH2rdUU4SMHGr5zEEKj5p6OZNo7rT1sZ6ly5PyC ohlgAyGgZhDWN5ra8xyGDa5L27s4xfeOMNcteHk0I6MDWkAQQPulVN2T4acOW7jLqSU0 hGLX7TcpbxXP3BaAZ/ddW+aRzvGFRHwomnXi9WAd/ITGX7l+zHpI3HCyDsIl0ReKM3CS c96mjO78TzcJC44X727302NDAkxi3wjcd8kfuJIxI4eB0cyeXsv6h524yue4Y2oww++f WUTQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84255-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u9-20020a170906408900b00a3eaaee4befsi1088667ejj.812.2024.02.27.16.05.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 16:05:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84255-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3A7011F25707 for ; Wed, 28 Feb 2024 00:05:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3445236F; Wed, 28 Feb 2024 00:05:18 +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 ; 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 ; 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: List-Subscribe: List-Unsubscribe: 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 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 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@vger.kernel.org Cc: Mark Brown Signed-off-by: Badhri Jagan Sridharan --- Changes since V1: * Fix CC for linux stable --- 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