From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 E2CC2373C17 for ; Fri, 4 Sep 2026 08:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511340; cv=none; b=GD9qzpnAL/IiBUCWj9Jh18XAv4sYZkQC6yipLb26LhULPExqPHTmMNJkGaTVTp0YVggO1r5qdoLKgLvzzLb2ChywnPJAI0LmUJfeBxGRE7wOHKESpvTHEm/WwYIaEKea4ZGv3NR2A9c4JJQs4iph9SrmROR/vR1SKI1sKm2opNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511340; c=relaxed/simple; bh=RGLL0tPfDP6uNlWVczfepdqpvZGR4BjUGaRZ583Zkzc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I1vONGtY+O+L24qEVIz5FwDCTWAmiaYVnk8ICt6m8d2Ho/fFwII4RbTDPrjxw9iYlbxTDWeRiV7ET406Rq43CrxVskrPEo+A5Zpf7I/ha8mSFM1LaubQFqkqZqSNEx3+GGuSsSfPzPFgo4KQ1TPZszSLllUB+NzjiLlHxM4BnZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=SdoxKF/l; arc=none smtp.client-ip=209.85.215.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SdoxKF/l" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-cc1c8d4a959so659073a12.3 for ; Fri, 04 Sep 2026 01:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511337; x=1789116137; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WRetEA2OXFI4SKJH2CBFzorRJvZCDQyI99zumpuCSb8=; b=SdoxKF/l8oxoFHgKxIo2orVm21tVNJeFZDYAAxz/og1s6K6/DLU1+vy+GxEnQ+d0O0 fH3coiOH9Oliz/lEqLyhSc1d8a8rS/4hCT7ewMQ+3J5qSbEMzkxbHxURGEcATdhgisYI P4/Zw0UjWnATRqqNQXFB8t1U7BgppgBSCHS9Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511337; x=1789116137; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=WRetEA2OXFI4SKJH2CBFzorRJvZCDQyI99zumpuCSb8=; b=gQcj11YvI4tvtldk3oWKukqU5RdBfqPlR+Tzu2nyVxw4Jc69FeVAFZ1j904HLCmxxu Zizm2xqP6V093syYf36JbtiHnJM9H8HjIpBQ6eHEBu7PABQ1bMmbZjDh/wbAop+NMS3k e7snlQOVz3W7MwnRSED534jW9C1Qv4gCEyuquumOHPJpIANFYb0lY5XTJKj+q43bEPeq oixfm8STkjHVYPICqOeDE5DigGQzkA5YKVmVR6xzRhbQYdOJMhuTNKXVzZvNiurjkPHa fSAIb3KFkK2h7jHStuSXE5SSH4YRqSQPJZPj7x+K0WZd4GmPCFze+fMpixMDgoD5aDFb EvcQ== X-Forwarded-Encrypted: i=1; AKwUvByknKtc7pLdS7OSFJA3PzxIihPP1nCf6yjAopjjdHRIWHs+tvfvAHFf/CB9XsodM4s9zmAXkvcj1/ur9TE=@vger.kernel.org X-Gm-Message-State: AFuF++lBqbiocHzRzYtrGgBC9vlCE50AwWYcC1/Kw6Q8DXaS2jmv+OlQ gR5ioYuWnIWeIU2N0/4KIHvtN+8NKs4ceiG8grMZRdD2CnYzNW0mufzr3ZFmtybCxA== X-Gm-Gg: AYBFou3v1Utzm5V/AJJ3KasfWQrpPEX/x3AqTAW7AApX5950NMTVMoUjitPTbeh5tD4 y0QR159YQiOWSzknEeuvwcYE/B+7QeVlVNFC9Zk74Jbua930tcV8HQhR+1GWzeBW5nYkkQEgIpS LTc0FMR2N3PyhMlHJYubraNp6OPEWdvB2SxoEmwYRh5j2gfw3HBvt+Tl0aISvZkpToO7OdYKR5x 80iKxktnAoIGKttiw4Rbh7UmanzdtHaFYils5cF3xWp0zi1Ed2XgjQUADoySzn9102qoahhoAhW pPU02LwUFgejzLqPDDxSK28IM4+qaUV6GTGs/rFWRze2q6S5y7KUW8vObKuiN4gq4rN6MHrI4oc dwCDEB19m7cxBBeyEwmMKwySAI0Z55FKYr6lZIz6rGmtkn3Jc2hRRE9EUmOrvRsLs++aekVT/Q8 lwkGgJO+mEZJajjLJ7032j9equXeBfqXbGuUjRXHoQduQsOeld5+6L0M67aCoX3mx+lHGCTyknG akH7g4eytsJchmmn/FPLWwJ/xesDZDb3f9HI/Ort9zF X-Received: by 2002:a17:90b:314e:b0:38f:efed:5445 with SMTP id 98e67ed59e1d1-39b261500fdmr6024537a91.4.1788511335746; Fri, 04 Sep 2026 01:42:15 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:42:15 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 01/16] device property: Add fwnode_graph_get_port_by_id() Date: Fri, 4 Sep 2026 16:41:40 +0800 Message-ID: <20260904084158.1341550-2-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In some cases the driver needs a reference to the port firmware node. Once such case is the upcoming USB power sequencing integration. The USB hub port is tied to the corresponding port firmware node if it exists. Provide a helper for this. Reviewed-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Signed-off-by: Chen-Yu Tsai Reviewed-by: Sakari Ailus --- Changes since v7: - Mention in kernel-doc that the function does not return ports that have no endpoints (Sakari) Changes since v5: - Dropped left-over declaration in header (Sashiko) Changes since v4: - Added flags parameter so users can specify whether incomplete ports are returned or not (Sashiko) Changes since v2: - Moved "Return:" kernel-doc section to the end. (Andy) Changes since v1: - New patch --- drivers/base/property.c | 31 +++++++++++++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index b136c339ddae..68108805482d 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1353,6 +1353,37 @@ int fwnode_graph_parse_endpoint(const struct fwnode_= handle *fwnode, } EXPORT_SYMBOL(fwnode_graph_parse_endpoint); =20 +/** + * fwnode_graph_get_port_by_id - get the port matching a given id + * @fwnode: parent fwnode_handle containing the graph + * @id: id of the port + * @flags: fwnode lookup flags + * + * The caller is responsible for calling fwnode_handle_put() on the return= ed + * fwnode pointer. + * + * Does not return ports that belong to disabled devices or endpoints that + * are unconnected, unless FWNODE_GRAPH_DEVICE_DISABLED is passed in @flag= s. + * + * Does not return ports that have no endpoints. + * + * Return: A 'port' firmware node pointer with refcount incremented. + */ +struct fwnode_handle *fwnode_graph_get_port_by_id(struct fwnode_handle *fw= node, + u32 id, + unsigned long flags) +{ + struct fwnode_handle *ep; + + ep =3D fwnode_graph_get_endpoint_by_id(fwnode, id, 0, + flags | FWNODE_GRAPH_ENDPOINT_NEXT); + if (!ep) + return NULL; + + return fwnode_get_next_parent(ep); +} +EXPORT_SYMBOL_GPL(fwnode_graph_get_port_by_id); + const void *device_get_match_data(const struct device *dev) { return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev); diff --git a/include/linux/property.h b/include/linux/property.h index 907c790a3f01..3dbbd01a52d0 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -507,6 +507,8 @@ int fwnode_get_phy_mode(const struct fwnode_handle *fwn= ode); =20 void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index); =20 +struct fwnode_handle *fwnode_graph_get_port_by_id(struct fwnode_handle *fw= node, u32 id, + unsigned long flags); struct fwnode_handle *fwnode_graph_get_next_endpoint( const struct fwnode_handle *fwnode, struct fwnode_handle *prev); struct fwnode_handle * --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 2C83C3F65EB for ; Fri, 4 Sep 2026 08:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511344; cv=none; b=DlXv6X3jdtWFrEG5k/KPyRKEK+7aoQf8ZLcalLC4C1Hln/155o+jcbW4Bw5OAi0khQfhO+smUu2O/Yvdpjsqylwe1n/zd3nRRE9gXa7CnmPCZt8lzfVJb4iwzgoL2tokvMbqIkDRj6PQl3Qph4FiSexsxQMUmiBEXvLjqxSMicc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511344; c=relaxed/simple; bh=GQw0KwPblzk4iaOngMKEkViVUNWR4x75q4Pko/xlHfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iJB+UL4uMRK1d7cZMhDDDLhTzoV/Qs2a0759o7XXHkIfOAA6GIC8g7vI/KVOq+hVza7Lmnjxdb0SN8TFQisBtV6Sq1BrZRw7ec1xB8YFGX3GcfwsZQLUPRfKDSrAqRTIt/qBSHlgJsXLMARQjEMUOP2wkbgFv4Cg9twGNfE0+MY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=YzzQLh/R; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="YzzQLh/R" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-39b24d114d4so802345a91.3 for ; Fri, 04 Sep 2026 01:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511341; x=1789116141; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3pQBHHD4SDVq3Y8lclcFUxJTow0FC5oCzcVfD5O1aqE=; b=YzzQLh/R6tpmsB/n+660LvxPg1f9O+pN6SBHytYsV+b0XYOLbwCxFOEA1bPDhvXcnb E3kJZL6kO2gUbjqUxXOuvUXY6xvGiz5hoExGxv9HqTrIFXzT+lVqh7ifU/D16j/+K27+ r4wWFrtoiQq0Yzel2h+NHf35/kJ4gXqPeBaRY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511341; x=1789116141; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=3pQBHHD4SDVq3Y8lclcFUxJTow0FC5oCzcVfD5O1aqE=; b=raRyH2ldhV7PygdHB74mWqgBsOnVHv0b8MLG+2c3hrkebw9ZGLJbstumGS+RTY+P5x CsZ3qBNuE6DsaufUkpulvm4mDTfdh/sKJS7PRdAXJ4ceG/k+8L+yIrKc+TCKqwzL7aac 9S84bBjPy3n4XXZfaKk2FJc04e7PQjCceIF0mw/oHjxdXdRTiZJBb4iXvqHPXtrdHCed v9LUBAqyheKBww/+NyFOTlO4gYpeCM3eJfllOKaFjiJfJmcuvJP82jhLddVaRFs7m1T6 qCSNtiPyxagrQkcjPwIsW5Lc2khIxR03i72LSy0O+taGQUeIhzE06LGs41moALWcueZ2 /h5g== X-Forwarded-Encrypted: i=1; AKwUvBypIEfoMNVGaqJEGRYfpH7lxjJ8BERKAIuQAF3u331oOQgIX55EAGSmf6Ez2j7aZjGAPapvFelV+8p97MY=@vger.kernel.org X-Gm-Message-State: AFuF++mq3UFWF2119VzBUFygv8yqcceRkArPhXXtxCiSWIGGc4L4lGQ8 hZdmPSaq2kSd3aXvOJwnQht522935mkqibQrxTUSnyOVthdjBgXmiTYYd9EO8PZLxQ== X-Gm-Gg: AYBFou3OQteUgfccDfWIHjjbPvqyfyM/fAr6slrm9NSdmco7F9OJgyh1+1b72aazIsx 9prTUbfGVzFVeRZ3WCJQJS6wh2xzagZnvCHdwL3LUaT2+rb7J/RcvRpy4J3p44WJulGjQb5uNl4 QbeQta1DcES9JBgxsaDz/x3FrQJ9+h+3p/r5Qm9HP4lFshBQ95fRu8tn5U5zp4g8PS8JcfiuvEM OC76GfYw4FB0q/gM3GQCNyqOA5yr/26oFjgJIWjXYezob1XeQRcmItsM6FIdhBxrD6dlQ1vuFP2 6KQUA1BLIeyz4I2ey1gsp8ZE3r5Ing5PNMOiDsRSvhMOjopkMmwiyn56RDeCKggcvrvXRs+qsBP FZtDRwfqwi+8xHxGpLqYW5Z68JNWheFmemtPvwnk0We30zqIwaCzMq8/OQIVZGnshpHxGrbfmNC 4fMpo6k236bqkxeD/RFvTz2a5PE6+h2dLY00dSN0CPyLve6qAaz/Eou8LMjxECv426K2ofIykQK QzeHc+vM4qkn/huIj1NEHLUxD3xVBHQolDVSGDW6TG5 X-Received: by 2002:a17:90b:5343:b0:398:e46e:ade3 with SMTP id 98e67ed59e1d1-39b2628fc1amr8001002a91.23.1788511341225; Fri, 04 Sep 2026 01:42:21 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:42:20 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 02/16] device property: Add fwnode_graph_get_next_port_endpoint() Date: Fri, 4 Sep 2026 16:41:41 +0800 Message-ID: <20260904084158.1341550-3-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Due to design constraints of the power sequencing API, the consumer must first be sure that the other side is actually a provider, or it will continually get -EPROBE_DEFER when requesting the power sequencing descriptor. In the upcoming USB power sequencing integration, the USB hub driver first needs to check whether a graph connection exists, and whether the other side of the connection is a supported connector type. The USB port is tied to a "port" firmware node, and this new helper will be used to get the endpoint under the known "port" firmware node. Sashiko points out that the |prev| reference put is not done if |port| is NULL. However it seems that the fwnode_*() and of_*() API design implicitly makes the functions no-ops if the passed in node is NULL. So this new addition follows the same pattern. Cc: Sakari Ailus Reviewed-by: Andy Shevchenko Reviewed-by: Bartosz Golaszewski Signed-off-by: Chen-Yu Tsai Reviewed-by: Sakari Ailus --- Changes since v2: - Dropped unused |ep| variable - Rewrote as do {} while() - Dropped WARN() use --- drivers/base/property.c | 25 +++++++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 68108805482d..fe7c403e3fa9 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1109,6 +1109,31 @@ int fwnode_irq_get_byname(const struct fwnode_handle= *fwnode, const char *name) } EXPORT_SYMBOL(fwnode_irq_get_byname); =20 +/** + * fwnode_graph_get_next_port_endpoint - Get next endpoint firmware node i= n port + * @port: Pointer to the target port firmware node + * @prev: Previous endpoint node or %NULL to get the first + * + * The caller is responsible for calling fwnode_handle_put() on the return= ed + * fwnode pointer. Note that this function also puts a reference to @prev + * unconditionally. + * + * Return: an endpoint firmware node pointer or %NULL if no more endpoints + * are available. + */ +struct fwnode_handle *fwnode_graph_get_next_port_endpoint(const struct fwn= ode_handle *port, + struct fwnode_handle *prev) +{ + do { + prev =3D fwnode_get_next_child_node(port, prev); + if (fwnode_name_eq(prev, "endpoint")) + break; + } while (prev); + + return prev; +} +EXPORT_SYMBOL_GPL(fwnode_graph_get_next_port_endpoint); + /** * fwnode_graph_get_next_endpoint - Get next endpoint firmware node * @fwnode: Pointer to the parent firmware node diff --git a/include/linux/property.h b/include/linux/property.h index 3dbbd01a52d0..691e792775d5 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -509,6 +509,8 @@ void __iomem *fwnode_iomap(struct fwnode_handle *fwnode= , int index); =20 struct fwnode_handle *fwnode_graph_get_port_by_id(struct fwnode_handle *fw= node, u32 id, unsigned long flags); +struct fwnode_handle *fwnode_graph_get_next_port_endpoint( + const struct fwnode_handle *port, struct fwnode_handle *prev); struct fwnode_handle *fwnode_graph_get_next_endpoint( const struct fwnode_handle *fwnode, struct fwnode_handle *prev); struct fwnode_handle * --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 C1D5F41A50B for ; Fri, 4 Sep 2026 08:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511349; cv=none; b=EJRk32H3OttP2rqogDMBGJnEzz8OBj5jyojWn65S0chgLt1kJqefLD/tCFaGFKRtJ3jxexg+GgK/b2MFV1A/NN/CRW3SAU0Ae/dPVxQKxDbT5LEXwDhzpgDJWA1a38yzeYGtxrJtkpB9NPbShEF6KxGAcNNDsh2XONSkyz+SeMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511349; c=relaxed/simple; bh=yg835mCmcfMqyyZMo2K7NS9o2JVbGcnLZ8ClgruKi9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cAzHAxWFIuCHivQPpiwc92UK3aPaW9HU/X+69UQpF56vFgCAu62KxtYMT8Nom8HlqWh8k9BHWdfoEtV5XXGXt/gATg+JIsSVGZH2rnV3gNLfSRzOSLSU1/vfBpB8FLFIjO2N0V3Ekl2D4sJSUbDheyZFrcEMQCvWr+YAkMCQp50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=evdxVCBc; arc=none smtp.client-ip=209.85.215.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="evdxVCBc" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-cbb8b54fcf8so1094717a12.0 for ; Fri, 04 Sep 2026 01:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511347; x=1789116147; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=jUco8k8loeDw75nokYqtCIPRhQuEjxppf2mE5m0ZQ1k=; b=evdxVCBcqS+HCayUlvdKFyn97wTgOKWdKmoENSJrTiTSvNwm/ZLcz2dhJ47UbjcN9B 0GEKf7qxQ/JMNrREgojXwHExamElQBxuFeinGcVvfXD6voLptR/ES0KmBOvduKBXxFIO 6DPePZR0Mo6qC3TFN5rEnx+Q8EljE5B5dI0mc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511347; x=1789116147; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=jUco8k8loeDw75nokYqtCIPRhQuEjxppf2mE5m0ZQ1k=; b=Kc6BO8a3YodtUGMYBjNECAlQ+9dk4Ga4BpMFgADXIN3YCXOE0y+PwK0/FSdVHbqJYN +6/L7OxfQA60xB1jN37BrLNu42txbTaXVcJBrZdgQ1LRxr2bhL0HNRHLC0JmGvpcP3JY xM+TIsTOLIU7Nf0tV6WYjHHwgcBps6eScENm49dwx+Qjqp38fZLAgT9EmLEtfnRcRqe4 XPC5sPRlOk6ibEKC8MMUoEDSaXrn0uAIExqVKbZUYuNKQOraQZqKyv9TTHAsGobqmpFs Kj5qS8SOmBBvun8SmpjYHI2BgOABWSov/OsTVH53KNRQBeenP1VI/Cp22SZjQMaUIJHs Fexw== X-Forwarded-Encrypted: i=1; AKwUvBxYOrfHViEI4gDEh6QnMVXZb3unsPGVtoSSoKQ/8KqmqGKO4XYGgj/fjDJlcpjFOxtfHGbc1PSWiPph5Zc=@vger.kernel.org X-Gm-Message-State: AFuF++kzOC6Q9bRcRLjoIxs29QPk8IRhRMc61ysp0CHJJ0uncHrmojoO hqc3SViNJOOHDjbtsAQWnjIm1Z55ONvJdbNAPXhavJhmiDZwBhfjVvBV4aMsTTo8/A== X-Gm-Gg: AYBFou1IHmcq0r31oyf8+rrjatCX5Nd4PdOgJ66KMaulUjg1VKX69hINBKkSdzytIyL ccaa6WKbEVfUYgDQ0D4ein4qK2d34d0cAFDM4z5nxkgoxQolmrocrg6tl3JPCs104aYSX4JeuAA 1QC7eDQaQr46oJguuz30X07ZNsRGkABy5vx2gBo/zTc+7bZvOgJq6bVCu+u8T0ToPkeNgIjUbNO G6OBrkPujfdxWROuwIxxLPeenwaJL+SP/rtlFJ4M6Q2uXMB9O8EKkVfJJZJNIKsn4qygSC1Veni oEgHX1lWIM5pPwZ8aDABdhxMjPBhmPskDZ0UpRJdrm2W+XsZXcQM550tHtzBmboxJt6HcjLrY0z OPkxoCdxQ02wMb7ioCfGndUvO10KhnU8xQZUxaS0e14pfhc6Xg35CNHWwGPb2u574yTakyPG7Ol i4ZqNzzHsL6S+h+np9NbUUiHTMtlTLW9nQ7xqk+G5qEM7uL5ipflpYEPAPwL9R15fqBPHO39ZG6 Rza8l+diIEiql5/B3CR7YBcUEcVz2sdQ5LVHEiQUvSs X-Received: by 2002:a17:90b:3a8e:b0:390:8361:a532 with SMTP id 98e67ed59e1d1-39b260d2eb3mr6786889a91.7.1788511346596; Fri, 04 Sep 2026 01:42:26 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:42:26 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski , Manivannan Sadhasivam Subject: [PATCH v8 03/16] power: sequencing: Add pwrseq_get_state() Date: Fri, 4 Sep 2026 16:41:42 +0800 Message-ID: <20260904084158.1341550-4-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The power sequencing consumer API already does power on state tracking internally. Expose the state to consumers through pwrseq_get_state() so that they don't have to reimplement it locally. Instead of just on/off and error codes, the function can also return "unknown" state. This is in anticipation for "uncontrollable" power sequencers (such as GPIOs left unconnected). Acked-by: Bartosz Golaszewski Reviewed-by: Manivannan Sadhasivam Signed-off-by: Chen-Yu Tsai --- Changes since v7: - Adapted to pwrseq_enable/disable() rename Changes since v6: - Changed to pwrseq_get_state() with enum return value Changes since v5: - Reverted back to returning -EINVAL if descriptor is NULL Changes since v4: - Make pwrseq_power_is_on() return 1 if descriptor is NULL, i.e. if the descriptor is optional, matching the other pwrseq consumer APIs Changes since v3: - Added missing stub function for !POWER_SEQUENCING Changes since v2: - New patch Needs to go in with "usb: hub: Power on connected M.2 E-key connectors" as it is a build time dependency. Bartosz wants the change on an immutable branch to pull into the pwrseq tree. --- drivers/power/sequencing/core.c | 19 +++++++++++++++++++ include/linux/pwrseq/consumer.h | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/power/sequencing/core.c b/drivers/power/sequencing/cor= e.c index 721e888b658d..dbb2bd2f8864 100644 --- a/drivers/power/sequencing/core.c +++ b/drivers/power/sequencing/core.c @@ -968,6 +968,25 @@ int pwrseq_disable(struct pwrseq_desc *desc) } EXPORT_SYMBOL_GPL(pwrseq_disable); =20 +/** + * pwrseq_get_state() - Queries the last requested state of the power sequ= encer. + * @desc: Descriptor referencing the power sequencer. + * + * This returns the last requested state of the power sequencer. + * + * Returns: + * On success, PWRSEQ_STATE_ON for on and PWRSEQ_STATE_OFF for off; + * negative error number on failure. + */ +int pwrseq_get_state(struct pwrseq_desc *desc) +{ + if (!desc) + return -EINVAL; + + return desc->powered_on ? PWRSEQ_STATE_ON : PWRSEQ_STATE_OFF; +} +EXPORT_SYMBOL_GPL(pwrseq_get_state); + /** * pwrseq_to_device() - Get the pwrseq device pointer from a descriptor. * @desc: Descriptor referencing the power sequencer. diff --git a/include/linux/pwrseq/consumer.h b/include/linux/pwrseq/consume= r.h index 16fad5f3e3ab..e2a2991b20c2 100644 --- a/include/linux/pwrseq/consumer.h +++ b/include/linux/pwrseq/consumer.h @@ -11,6 +11,12 @@ struct device; struct pwrseq_desc; =20 +enum { + PWRSEQ_STATE_UNKNOWN, + PWRSEQ_STATE_ON, + PWRSEQ_STATE_OFF, +}; + #if IS_ENABLED(CONFIG_POWER_SEQUENCING) =20 struct pwrseq_desc * __must_check @@ -22,6 +28,7 @@ devm_pwrseq_get(struct device *dev, const char *target); =20 int pwrseq_enable(struct pwrseq_desc *desc); int pwrseq_disable(struct pwrseq_desc *desc); +int pwrseq_get_state(struct pwrseq_desc *desc); =20 struct device *pwrseq_to_device(struct pwrseq_desc *desc); =20 @@ -53,6 +60,11 @@ static inline int pwrseq_disable(struct pwrseq_desc *des= c) return -ENOSYS; } =20 +static inline int pwrseq_get_state(struct pwrseq_desc *desc) +{ + return -ENOSYS; +} + static inline struct device *pwrseq_to_device(struct pwrseq_desc *desc) { return NULL; --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 8AACB3FF1B7 for ; Fri, 4 Sep 2026 08:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511355; cv=none; b=P5et0Bf5FTdyt+pt2/gANaJ+73ukUqy8IooKlAA5IYRSm0U9ryFBNZ3nTLzb6uHKzvHaXOaZqYAfuIqHRlOh28Fjqc1n4Z5h4QR4YMJDJMk2ge776R4U+63cdjPr8wP0DwVWCiQpYJMgXhfG+Fahy3AbDY9eRhdHoMzo8GIeXe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511355; c=relaxed/simple; bh=B7Lu+PyhQKrwbSeiWnA/FCibSLvQ75jT0I67pSzcZQ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o9dzpKyHUIVX20j+Y5cr+eyu5VU7sc+3WGwR5zqUxpc9urW4ssLHgYLqtGdCUSBfcoPPlKC26MkbrzBC2B3Kx2Cs1R7O4dG04MOHDxh4RiVNezJ70pGaSBhKpyJ1HlWkw6v6GxW3CABb6Lmo+JSYUgh5UYwUD9Crpok9vEIkd5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=h+g1pKBE; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="h+g1pKBE" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-3964e480f76so935090a91.1 for ; Fri, 04 Sep 2026 01:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511352; x=1789116152; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RQ5BUQyX60lAwoXOtJvq7hs8kBNzpXHT7+FU5vNuJYE=; b=h+g1pKBEmSf20QLY5llg49jgQylsjtbjFvxfP/fbBHy4rESg23r/liAcIo5ecMNYYA Z/FSNmOWFnd01kkoitWsqbWItWzuQgyEUEmMNTsvksJdk2SVFDLxWPkXZ+D4kfaIxFtC nRNKUdCW0bNipWdS7AzycmJwEy0AxLgkBTVzo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511352; x=1789116152; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RQ5BUQyX60lAwoXOtJvq7hs8kBNzpXHT7+FU5vNuJYE=; b=AesD1i9F1M7+J+IZ/+UnesPNfL7iHD44UK7531+fyNNnp64EvXKX7wDMcJhE0XJP4v WgYbfscOchJIz++r823F6rwa6r026Uz10OqrhNCHwj+RiBOeWYedeVxzK7jgk82Afe+9 5oHWGna+KkbKphjI0bs1fWkdhbUz6T/elmy9hW7Ho4TCnSuaGs4ihH2YeXeVRbRxD94d iv9gljzHeIDmHirFKIoO7DpW0hEAhMi1C+0V9o9BoDd9FGWi0iRO74JqF53EB7k7+zkA T027A4YwMhs+wSmZONiBjJRSFLPI95ZHxjIL4eWaqIz4dJlszFUYGtpdIXl8Yv4N7lkk 5R1w== X-Forwarded-Encrypted: i=1; AKwUvBx4N9OKIxG9VgA7ahDn65AsuzwgTKZKTqgnm9/0j/ivY/69GC7KME7mg5aV6unicYN/Ts5QVAi8Cfo8/SE=@vger.kernel.org X-Gm-Message-State: AFuF++m6EHB6e2CEBV/YIv8HFgOvYARQrHjQ/J/PQwRHuBDflxsH1i9g jPSf5aWpYsVWR3eh6eUeFLkuzxgnEBy71hSzyGYwTW3orxJhHP5cY0QZCmolqL46rA== X-Gm-Gg: AYBFou0nkN2h4CIKDWXohCR+zHFUhMONFCtwJR6bQtyUznqpKGsH3DzeTDPOSiqW4SV Xi5D3TW6EslskfKMRBU6OKbfGfUeLNVdOtBXcDrAHS6BYwS4IvH9hXadSsK3DxVscj12nvWMY7d t+ORjo/oVyaCR2uCmY0h0g173Y8Hi7ktSz0QWECSRxvil2JVzPow1mZEb1ZRLx/o8O3wgvSXiyJ 0TI7/G+TcwwQwWRwIEY1nz5GjQZ0BFD/tMU/Aj71I/g6kjsHijfSaGJpBmsKorwcBzBhBLECpae C1MTCgbks4v8UselJbGtlYl/pbL/RV7kMiXmj4kDr6p/JT8XYJgETNNDGPIxuiW2+0wyGVl705N wrFnMNkdGqKetLu3Vzc7pndFfsdPu4IOlc3ReVIVFpvgDqFWeOmkf+rMu+Ixxn2BdORzkaARJ3E 4NlQnZkXDor2EQMmtqssQxJMKc/c3GzuCjfgicuM0F6ukI4GQcAEynuhmwwGE2EhkEzCyz+g31v qRIkQ++ltyMH9d8XLJdHYHybvoccu3vxFlA8F+8VBtB X-Received: by 2002:a17:90b:1d4f:b0:398:9be5:b417 with SMTP id 98e67ed59e1d1-39b26221eb1mr7387796a91.18.1788511351714; Fri, 04 Sep 2026 01:42:31 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:42:31 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 04/16] usb: hub: Use assign_bit() in usb_hub_set_port_power() Date: Fri, 4 Sep 2026 16:41:43 +0800 Message-ID: <20260904084158.1341550-5-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" usb_hub_set_port_power() open-codes assign_bit(). Just use the assign_bit() macro instead. This makes subsequent additions to usb_hub_set_port_power() easier to read. This change does not introduce any functional changes. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Reviewed-by: Bartosz Golaszewski Signed-off-by: Chen-Yu Tsai --- Attributing suggestion to Andy, since the change was originally requested as part of a review. Changes since v4: - New patch (split out from "usb: hub: Power on connected M.2 E-key connectors with power sequencing API") (Andy) --- drivers/usb/core/hub.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 3345b3298daf..16e03ec8d1ab 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -10,6 +10,7 @@ * Released under the GPLv2 only. */ =20 +#include #include #include #include @@ -899,10 +900,7 @@ int usb_hub_set_port_power(struct usb_device *hdev, st= ruct usb_hub *hub, if (ret) return ret; =20 - if (set) - set_bit(port1, hub->power_bits); - else - clear_bit(port1, hub->power_bits); + assign_bit(port1, hub->power_bits, set); return 0; } =20 --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 D08BF3AA182 for ; Fri, 4 Sep 2026 08:43:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511391; cv=none; b=eb59nIWsxWrrlne38uKQ85GSkD0X+tfhG+Fjmx+sBJxP4kH5RBlFGSdgBE3V+jX8ROpkiVOGvMyzzBU7Xsx4SvQi1EaBGMUlMciOOSaGeY4hwMuKN9pZokxHt5hMrio6Z1XTc0DNnStmi8U/FPZvTFT2LeFw913204pwc03EwfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511391; c=relaxed/simple; bh=k4P8O6O1bZN0BviRcm5rHj8gLkm4KLla0pyDEJs44j0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tanEUXFH7Yy94cPhjhQrB17DXorf4V37Z7kUpVYWBbnJ3Z/Hcc9RNksxX2ng0km+a/jyU07Fj/Lluq7c6aikVIYC2OnTJD0XgI8Z1KsXPpKgRWARHLWmEIftbwV/X/MNidA22Tj56GZ/Ek4n9TzrvapylGrBAEGUITtYs1nwYm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=b9I83p3G; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="b9I83p3G" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2db18e5cb56so4078405ad.0 for ; Fri, 04 Sep 2026 01:43:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511387; x=1789116187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Bo+9+1CvfJ71hhRjJqHX7wWrfIVVnPJvwTAuLV2zMPo=; b=b9I83p3GB2Np56mdhqhsSbTAz+2Z1AvsREg4rzk71ni1TKMmew2j+w4krqcYmavOpW W4B72lpYkAqvp8a72htsbsfGYPqVeWsr8/7WWY6RuN+XD7PXQAPnZE5vCmY9HXs2dYzu LdHIezwu3hboKSvIrwnTyAuCMj1jaoKZN1C4A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511387; x=1789116187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Bo+9+1CvfJ71hhRjJqHX7wWrfIVVnPJvwTAuLV2zMPo=; b=QTYW4zBZEbmKiiSbQ+34HTJjq6yLGY+d5uN/iQMpRXjK5/0VghX2vpVvKfRkLGZ6Ir iEqbp+dfixY9svwEt3IWdj97SKj9ke4CYkwlYrJhyWU784UAx8FJgsWHbBXztL7zrpDI OYQ2qDHm30PnrMsPbshNH3yDooU1+UN89Pd+btFEVYNI5aeiaeVlWeHMFdACjeIAgtkQ 8sgFANWaWf1gZJeiwJBTNuIWJfllb+hzbGYJYrRhkKotSjpgeph2q5dw28SyZFE1f0bO YPKGO13H9lS/D1FU3BvfE9EFbTxAjcCn44afbnFATgYeade3g/+5HKEsMW2oAU1Se/Av rEcA== X-Forwarded-Encrypted: i=1; AKwUvByoNd/JO7w9BY33ELzK5C5AADJ/iyxJq4/xXKA7R9KZLrS9gi2AFNlPL+cV0mXHrHOjiDt9AXf2thRLgZs=@vger.kernel.org X-Gm-Message-State: AFuF++ndNbnspSc8NhTxLf7FISe8RRt5djeyqUMYdI2fvVG8ZIf+MXPV NrxfZ6D3A3y6Vgf/UmywFWxSkv7F+OBt9FYLH3vTQB6+0sC8b8a+zn0IZmfd/j6ZJQ== X-Gm-Gg: AYBFou2XN1jO2Bh8kc9FWMdf6pt/kBjGTVYkWmsrHtBHN0hu9SmtR/j6oZHaXctCUQK LyQhvpY3EMW0ahtFvAE6gKkCxHuuWWfKQygmqbzJn3DcLHG2zOn9wSQYe3/G7YS8JdGz0Yx8aXj w6ZLiElTXfo+Yq/XWR63cd/7tvEP1rR8pLbNOA+LrOV0snB2spH6KkZoTaGx3o9cYFu4gVo6UEl 838sj2Y4/5ORECxCQuJDsSzXQ5XPIdo/FP8I5RBkyKZyxJvq1dCmIaXfsVefajzXC+HXnCKUk5s +/Dm3OlntUJ7Zhc8ghyhCTQXS7L6gCMvM52C2aKuBLC/Lgzd1mmLp2C6HyDLtKTtf2yqwtprkkp 2x9fLLiXRxUi9vkZ72bJm679P/MZ9ojv1/Gd4+GfWBmfxWTdXk1n/Tmu+RyG1ScF2M37/0Hliwc SkMLFcG/Ysk2+lDOKTsdpBORr6h9QOdRwIyJKRlOtI1hViSNizFeE/IidqDumexdq1LdwJmBgzw Qw3J60T5mlDFevcwpWQ3pAXibWa9HHWstvoa27my6uZ X-Received: by 2002:a17:90b:1d52:b0:38f:de97:b06 with SMTP id 98e67ed59e1d1-39b260d338bmr6986016a91.5.1788511386742; Fri, 04 Sep 2026 01:43:06 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:42:36 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 05/16] usb: hub: Return actual error from hub_configure() in hub_probe() Date: Fri, 4 Sep 2026 16:41:44 +0800 Message-ID: <20260904084158.1341550-6-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The addition of power sequencing descriptor handling in the USB hub code requires dealing with deferred probing from pwrseq_get(). The power sequencing provider may not yet be available when the USB hub probes. Return the actual error code from hub_configure() when it fails, so that the driver core can notice the deferred probe request. Also rewrite this section into the standard error handling pattern: if (error) { # handle error return error; } # do more work return 0; Reviewed-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Signed-off-by: Chen-Yu Tsai --- Changes since v2: - Rewrite into standard error handling pattern Changes since v1: - Moved "int ret" declaration in hub_configure() over here from the next patch --- drivers/usb/core/hub.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 16e03ec8d1ab..c19c9912c740 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1870,6 +1870,7 @@ static int hub_probe(struct usb_interface *intf, cons= t struct usb_device_id *id) struct usb_host_interface *desc; struct usb_device *hdev; struct usb_hub *hub; + int ret; =20 desc =3D intf->cur_altsetting; hdev =3D interface_to_usbdev(intf); @@ -2001,14 +2002,15 @@ static int hub_probe(struct usb_interface *intf, co= nst struct usb_device_id *id) usb_set_interface(hdev, 0, 0); } =20 - if (hub_configure(hub, &desc->endpoint[0].desc) >=3D 0) { - onboard_dev_create_pdevs(hdev, &hub->onboard_devs); - - return 0; + ret =3D hub_configure(hub, &desc->endpoint[0].desc); + if (ret < 0) { + hub_disconnect(intf); + return ret; } =20 - hub_disconnect(intf); - return -ENODEV; + onboard_dev_create_pdevs(hdev, &hub->onboard_devs); + + return 0; } =20 static int --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 EEBCF3E9C17 for ; Fri, 4 Sep 2026 08:43:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511436; cv=none; b=Fyf9GOSp/hi9BfNA4zNNrjpw+3fa7ObiUX4KMuevXgYQsN8WsFUkXm51YTTGHMLDpsbSualHR4XzUx6w887DGsN5I1f1QQW7eKfLkGG3S6e4kE/jsMRfw7pj63LfAriBddLNZMpA6pM8jYLtEkn/JrTQ6z8u9/bno2GvEZEcPGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511436; c=relaxed/simple; bh=iO3DF4u+63xTtKP4FxOejaFf7KwQ2Ou9YoxBchLW4e0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eBaCMmF4LZsbL/rPtWiWajzD+kGEVTQD4a89e/QqOR0PBrDmp35FmMRJcM3NafrseiYjjlvTHIE0VeJOOjqduMFw8m/n6km8YQJZee/zTAl5449j0CqZHcThes1yg3Qp0zrOqDaDgwytTbtIuBWNBH0Tpy5KGxX6oDa/oA4Gb3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=dYjq7UOt; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dYjq7UOt" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-3964dfb5b9aso972009a91.1 for ; Fri, 04 Sep 2026 01:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511431; x=1789116231; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7FkHDnS01ZrIUIFEZvu4Ez5qiW1Xnkoau5FbL5ZwNaU=; b=dYjq7UOtAqLocf3FOvhgglj1glz1QpzT+8NmUIjHKDL4o6bznah3F3Mk8Ewh3I4OVU CK5SfApSRvz/kDQILfkZEKqIhoMGNyT8MWsmRnnc4Xit0tFZlnI/O5JT1hk6R/HecQ4G hTa1DZ834h4gkzwAGuYleNwW7+MoqXk0F47t0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511431; x=1789116231; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7FkHDnS01ZrIUIFEZvu4Ez5qiW1Xnkoau5FbL5ZwNaU=; b=nAtWqj93U93pPmcV99EEB+bn8opDIW3aAmL3SqlZlRDavvumEw4T0Ai1OoBY8J2lW6 mkOWmtQHp3AShA0mmWPxUUhzP8u7Pzi8FqRuFw+oHCmk4YPkuTRPtkkse/55GnGg4HLN RFQSpfDUHnGEoy6XvCId2pMA9LCqaCjhpHaqGUCj9qH6NqFHypR+mA6ugZWP3TaKWUyv mYH4fVQ0JJjkeYDlrwe7SREnelYxkDqM2juTpG0RUruBM5u4Z4yp/dXGR3rJnT4q+PmQ qaOYxWneLd06MmFRtJapWVbkL7Vosqmraq54gPGe5MUjdpD4vYvGE7z6lu1XKDqBufSE psQw== X-Forwarded-Encrypted: i=1; AKwUvByTuVxQK5PGd8gsvD7xM09k/RJijgN1qryviKy/MZ2uIl/En7f9+89/HgIysmfmz1U2vhNa8McEg7j5JHk=@vger.kernel.org X-Gm-Message-State: AFuF++niN5YpQ1zpCa6qg0/28xGHxu6u0Km5mEuHatkp350OO36g8eBQ MBbK0P9tHLmdcRaxq+bUecdIZlbOigURQDP/zdN1bMTnmZBXASn0GFbXAgxXquv+6Q== X-Gm-Gg: AYBFou2cuOJKu+78br5NelAVeGzOOGXl+UCnLCNOoqbAbnBvTSAo7F1uU5y9NG55nwK 0EtMOiqnK/1Ntv8Ouenk/L7RkOiF/FNF0BNn1+8HG2QueESlVAuf2Z7Zqmnx4DpAHWdalBCBvRo 4eDw212FCO0gl+b3QB0b+Vgj21IPY4Bt1yPzttg6DuWlzawtNURRE6x8i2oBLv6KVwSnKVSPYOv 9fYwhVyteryf9tXATQPr1QI2j6L0b4xcdeHPorRzcbbKGsgmnC9WPzVnfpSs1VJdFkYUaPzmpVd 3CE0vxe/ob6CAfiAsIEsmcIiAyVule/WaxLjHxoCySYw5zOhU4G2SMGx+v+8UMqikF2yhBikBzj n5iWN2ooc5gu9MMObRIS/Vi8BDq4NnaTOB6b9sySBfkSDC+4jOlpfSUa5nw8TJDX/8V6NzwlJZ6 S+Qyw2LqZCEyMb2/wQS1gtt3U4s9v7Ld6kDip6iLW41Mz5nsOeluNARyAdQimjV5egaEzR1akVU ramPNZyfTDhiDYuSmxnPp0TD1yuAKPZrxrFUyBPavsOB1wrJwEbFRE= X-Received: by 2002:a17:90b:264c:b0:36b:bec8:94c5 with SMTP id 98e67ed59e1d1-39b2612f7dbmr7487531a91.10.1788511431512; Fri, 04 Sep 2026 01:43:51 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:43:11 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 06/16] usb: hub: Associate port@ fwnode with USB port device Date: Fri, 4 Sep 2026 16:41:45 +0800 Message-ID: <20260904084158.1341550-7-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a USB hub port is connected to a connector in a firmware node graph, the port itself has a node in the graph. Associate the port's firmware node with the USB port's device, usb_port::dev. This is used in later changes for the M.2 slot power sequencing provider to match against the requesting port. To avoid potential conflicts with ACPI firmware nodes and then causing power management issues, only assign the firmware node if the hub's firmware node is not an ACPI firmware node. Reviewed-by: Andy Shevchenko Reviewed-by: Bartosz Golaszewski Signed-off-by: Chen-Yu Tsai --- Changes since v5: - Added extra |struct fwnode_handle *| local variables to shorten lines (Andy) - Added comment about passing fwnode_graph_get_port_by_id() return value directly to device_set_node() (Andy) Changes since v4: - Dropped unused |hdev| variable - Added flags for fwnode_graph_get_port_by_id() with FWNODE_GRAPH_DEVICE_DISABLED so that even incomplete ports can be connected Changes since v3: - Added missing fwnode_handle_put() Changes since v2: - Skip assignment if hub firmware node is ACPI node --- drivers/usb/core/port.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index b4452b665f59..c0a51d9b06a6 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -7,6 +7,7 @@ * Author: Lan Tianyu */ =20 +#include #include #include #include @@ -358,6 +359,11 @@ static void usb_port_device_release(struct device *dev) { struct usb_port *port_dev =3D to_usb_port(dev); =20 + /* + * At this point ACPI nodes and swnodes have been removed by + * device_platform_notify_remove() in device_del(). + */ + fwnode_handle_put(dev_fwnode(dev)); kfree(port_dev->req); kfree(port_dev); } @@ -754,6 +760,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int= port1) { struct usb_port *port_dev; struct usb_device *hdev =3D hub->hdev; + struct fwnode_handle *fwnode =3D dev_fwnode(&hdev->dev); int retval; =20 port_dev =3D kzalloc_obj(*port_dev); @@ -782,6 +789,24 @@ int usb_hub_create_port_device(struct usb_hub *hub, in= t port1) port_dev->dev.driver =3D &usb_port_driver; dev_set_name(&port_dev->dev, "%s-port%d", dev_name(&hub->hdev->dev), port1); + + /* + * ACPI FW nodes are associated later when device_register() happens. + * Skip assigning one here to avoid potential conflicts. + */ + if (!is_acpi_node(fwnode)) { + struct fwnode_handle *port; + + /* + * fwnode_graph_get_port_by_id() returns either a valid fwnode handle + * or NULL. Passing NULL to device_set_node() clears any associated + * fwnode. It is effectively a no-op here, since no fwnode has been + * assigned to the newly created device yet. + */ + port =3D fwnode_graph_get_port_by_id(fwnode, port1, FWNODE_GRAPH_DEVICE_= DISABLED); + device_set_node(&port_dev->dev, port); + } + mutex_init(&port_dev->status_lock); retval =3D device_register(&port_dev->dev); if (retval) { --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 2D71E3D45F7 for ; Fri, 4 Sep 2026 08:43:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511443; cv=none; b=C5f5nSjxscHusF3L0Rbr83+l6DNd6KomaWywcdYY34YaAMvDZgYXjoE7WbG8mjd4wVctEvh82ZlKa50Gq39K9IyMtcCoTIH7b6krLlW8ls4KbJeXErPj2a44WIlZOSJNLGekS9DaF9qsYeduCA/0AQqevSEU3LpXg/WSHwJVRII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511443; c=relaxed/simple; bh=mVnW+34H8pDaAYsu6do3l4kmcFOsUXTOE/2T16cFwQo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IWwdV+3tb6QLxjruI0U1FxgP/+wtVgC24Z3/CZAbBxS2caAQo6BqJK4722hK08zvB0SuxzbzYUzpr5nFlzN8pb7fvcFMmyOHOYFHRc7cutniiFoO2iItbKYGaTl6z2XfFSBeWf24M8p2y+ggCKxrq6nn44lr/Q8DJuU+D49nBIc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=GrmTRetE; arc=none smtp.client-ip=209.85.215.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="GrmTRetE" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-cc1b838f9b6so964407a12.3 for ; Fri, 04 Sep 2026 01:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511437; x=1789116237; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KKk9MsFCuRaE3YN06XOCWIV3dU/ufhZe2dVPkS7i8qI=; b=GrmTRetE+kFEaUk1sorhFQn9CXM41ShZZou7wUOJSzaj4iBXGBX1UgwkUfXFnf2I+P rRvkugn/21uICQFt1kBfDnYL26zfFzi1asC9W+Ze58ekTX0mwjrjlIVExx8sQIPp53/S V2A1jPpxrZmcSVQ0u6ZedtPiP3RZ068Fzfa60= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511437; x=1789116237; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=KKk9MsFCuRaE3YN06XOCWIV3dU/ufhZe2dVPkS7i8qI=; b=oZEwT47amwboQQD7mSRhLWzVKyGo1SfDTieoSXkO9peB0wdvZrWG1/3kbIouqRK0fn qPOEgHHma8j+S3FM9WWyEVfb0fsKQUcyH2zx4+omCAiIU8jRaquumB7mCAFO5JjVDokl qDcUKOxGZMILjc5+FELq3dAo5fRaqO39jsPwfJWljN2rfaGsR0gtaG/QgqXVUn7P4oUI AbXq7bSn/uMy4iClBYfOVd0vBDQ2Yun+H3UIcH/mVi/vWrL2XKP5/4Lvyo+V8Z+ksAdV MlHJLpMeVuGrQnETyXAhdykIv2sHl8PQrtpnjFViPydotTEUy57E9J2mUACdtRHru94g BlJA== X-Forwarded-Encrypted: i=1; AKwUvBxvycSupAFfDVmUmWq7tvzUgR8yGwx0F36XhrtTJhExicfY8id8v/UtyvRwFN10Rc14M0qDukBH4OVSwg4=@vger.kernel.org X-Gm-Message-State: AFuF++lryjT+hMtti0Hs1SbigP0zZQwoUfKhFm+37ktznkNpTOtWqPXU G4MpWwM/jIIn7sZrXIdA0Bh3zGxyKga1jz8YQapU4Ip/Q63imElZvg+ONdScHrghag== X-Gm-Gg: AYBFou2vpDNLemFe/Xd5JStMUsI/2Z3zFXl4K5fV5hF2ieo3mXf9vAgyH+EDDJG8n5g CEMvrTwwncV+KyMWjAxa7Drs0R66dLgcws/OgrHmzzah0Yk/7wlfk07/g244j/rp25P+UvMANsg iUHMa2nSmkCbB8sIyJ20y75i49sjrbuZ446KjmWEHe22Cj8zi300XxOhI9eSkVHR66eqLLdog5w snzSEc3TwPdaal/GSdz0odQI5y/GiDUL70fh9LukD7a2/xnwcJORHyx9n52zE+ign+mAlFBsTKY y4p88nSUjk0ESWiZvGFiE15sF8KSpaVukI38DYhO98+mLDMyKFWs9Y/YqVH85qdZKksuFVApFft eorf1TGuNIiYO3S/GcLiO+iolrLqfUy8t1XnqkikUSbHJ5TMkhBFOzPdXPNC1vSM8rhxd6dBald Btcn5a+4axGqjUSwA+1kexXNE68ZhhPlCYjFSbEIyGPIV0J3nSXNokBEODUDNA/UJuYqxS6kbCd endzHgYXhALNtR7rBmXb4q55tr9oc3AsgUs0WnxDPYt X-Received: by 2002:a17:90a:d004:b0:398:c9be:cca8 with SMTP id 98e67ed59e1d1-39b2609f363mr7918987a91.2.1788511436740; Fri, 04 Sep 2026 01:43:56 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:43:56 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 07/16] usb: core: Move struct usb_port and related APIs to port.h Date: Fri, 4 Sep 2026 16:41:46 +0800 Message-ID: <20260904084158.1341550-8-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" |struct usb_port| and its matching container_of() macro should live in its own port.h, matching the split we have for .c files. Move them as described. Also move usb_port_is_power_on(), since in the next change its |struct usb_hub *| parameter will be changed to |struct usb_port *|, and becomes a non-static function that only references |struct usb_port|. port.h is only included from hub.h, as a subsequent patch will directly use fields from |struct usb_port| in a static inline helper in hub.h. The USB internal headers don't have header guards to help with this. Also drop 'extern' from the header declaration of usb_port_is_power_on(). This is not needed in modern C. Suggested-by: Andy Shevchenko Reviewed-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Signed-off-by: Chen-Yu Tsai --- Changes since v4: - Dropped 'extern' (Andy) Changes since v3: - New patch (Andy) --- drivers/usb/core/hub.c | 16 ---------- drivers/usb/core/hub.h | 48 ++--------------------------- drivers/usb/core/port.c | 16 ++++++++++ drivers/usb/core/port.h | 68 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 62 deletions(-) create mode 100644 drivers/usb/core/port.h diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index c19c9912c740..7f58d753d77a 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3243,22 +3243,6 @@ static bool hub_port_stop_enumerate(struct usb_hub *= hub, int port1, int retries) return port_dev->ignore_event; } =20 -/* Check if a port is power on */ -int usb_port_is_power_on(struct usb_hub *hub, unsigned int portstatus) -{ - int ret =3D 0; - - if (hub_is_superspeed(hub->hdev)) { - if (portstatus & USB_SS_PORT_STAT_POWER) - ret =3D 1; - } else { - if (portstatus & USB_PORT_STAT_POWER) - ret =3D 1; - } - - return ret; -} - static void usb_lock_port(struct usb_port *port_dev) __acquires(&port_dev->status_lock) { diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index 9ebc5ef54a32..de524c6da9fc 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h @@ -15,7 +15,9 @@ #include #include #include + #include "usb.h" +#include "port.h" =20 struct usb_hub { struct device *intfdev; /* the "interface" device */ @@ -78,51 +80,6 @@ struct usb_hub { struct list_head onboard_devs; }; =20 -/** - * struct usb port - kernel's representation of a usb port - * @child: usb device attached to the port - * @dev: generic device interface - * @port_owner: port's owner - * @peer: related usb2 and usb3 ports (share the same connector) - * @connector: USB Type-C connector - * @req: default pm qos request for hubs without port power control - * @connect_type: port's connect type - * @state: device state of the usb device attached to the port - * @state_kn: kernfs_node of the sysfs attribute that accesses @state - * @location: opaque representation of platform connector location - * @status_lock: synchronize port_event() vs usb_port_{suspend|resume} - * @portnum: port index num based one - * @is_superspeed cache super-speed status - * @usb3_lpm_u1_permit: whether USB3 U1 LPM is permitted. - * @usb3_lpm_u2_permit: whether USB3 U2 LPM is permitted. - * @early_stop: whether port initialization will be stopped earlier. - * @ignore_event: whether events of the port are ignored. - */ -struct usb_port { - struct usb_device *child; - struct device dev; - struct usb_dev_state *port_owner; - struct usb_port *peer; - struct typec_connector *connector; - struct dev_pm_qos_request *req; - enum usb_port_connect_type connect_type; - enum usb_device_state state; - struct kernfs_node *state_kn; - usb_port_location_t location; - struct mutex status_lock; - u32 over_current_count; - u8 portnum; - u32 quirks; - unsigned int early_stop:1; - unsigned int ignore_event:1; - unsigned int is_superspeed:1; - unsigned int usb3_lpm_u1_permit:1; - unsigned int usb3_lpm_u2_permit:1; -}; - -#define to_usb_port(_dev) \ - container_of(_dev, struct usb_port, dev) - extern int usb_hub_create_port_device(struct usb_hub *hub, int port1); extern void usb_hub_remove_port_device(struct usb_hub *hub, @@ -138,7 +95,6 @@ extern int usb_clear_port_feature(struct usb_device *hde= v, int port1, int feature); extern int usb_hub_port_status(struct usb_hub *hub, int port1, u16 *status, u16 *change); -extern int usb_port_is_power_on(struct usb_hub *hub, unsigned int portstat= us); =20 static inline bool hub_is_port_power_switchable(struct usb_hub *hub) { diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index c0a51d9b06a6..b2e953f137f8 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -22,6 +22,22 @@ static int usb_port_block_power_off; =20 static const struct attribute_group *port_dev_group[]; =20 +/* Check if a port is power on */ +int usb_port_is_power_on(struct usb_hub *hub, unsigned int portstatus) +{ + int ret =3D 0; + + if (hub_is_superspeed(hub->hdev)) { + if (portstatus & USB_SS_PORT_STAT_POWER) + ret =3D 1; + } else { + if (portstatus & USB_PORT_STAT_POWER) + ret =3D 1; + } + + return ret; +} + static bool usb_port_allow_power_off(struct usb_device *hdev, struct usb_hub *hub, struct usb_port *port_dev) diff --git a/drivers/usb/core/port.h b/drivers/usb/core/port.h new file mode 100644 index 000000000000..00f7500af336 --- /dev/null +++ b/drivers/usb/core/port.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * usb hub driver head file + * + * Copyright (C) 1999 Linus Torvalds + * Copyright (C) 1999 Johannes Erdfelt + * Copyright (C) 1999 Gregory P. Smith + * Copyright (C) 2001 Brad Hards (bhards@bigpond.net.au) + * Copyright (C) 2012 Intel Corp (tianyu.lan@intel.com) + * + * move struct usb_port to this file. + */ + +#include +#include +#include +#include + +#include + +/** + * struct usb port - kernel's representation of a usb port + * @child: usb device attached to the port + * @dev: generic device interface + * @port_owner: port's owner + * @peer: related usb2 and usb3 ports (share the same connector) + * @connector: USB Type-C connector + * @req: default pm qos request for hubs without port power control + * @connect_type: port's connect type + * @state: device state of the usb device attached to the port + * @state_kn: kernfs_node of the sysfs attribute that accesses @state + * @location: opaque representation of platform connector location + * @status_lock: synchronize port_event() vs usb_port_{suspend|resume} + * @portnum: port index num based one + * @is_superspeed cache super-speed status + * @usb3_lpm_u1_permit: whether USB3 U1 LPM is permitted. + * @usb3_lpm_u2_permit: whether USB3 U2 LPM is permitted. + * @early_stop: whether port initialization will be stopped earlier. + * @ignore_event: whether events of the port are ignored. + */ +struct usb_port { + struct usb_device *child; + struct device dev; + struct usb_dev_state *port_owner; + struct usb_port *peer; + struct typec_connector *connector; + struct dev_pm_qos_request *req; + enum usb_port_connect_type connect_type; + enum usb_device_state state; + struct kernfs_node *state_kn; + usb_port_location_t location; + struct mutex status_lock; + u32 over_current_count; + u8 portnum; + u32 quirks; + unsigned int early_stop:1; + unsigned int ignore_event:1; + unsigned int is_superspeed:1; + unsigned int usb3_lpm_u1_permit:1; + unsigned int usb3_lpm_u2_permit:1; +}; + +#define to_usb_port(_dev) \ + container_of(_dev, struct usb_port, dev) + +struct usb_hub; + +int usb_port_is_power_on(struct usb_hub *hub, unsigned int portstatus); --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 7CD6D3F4822 for ; Fri, 4 Sep 2026 08:44:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511448; cv=none; b=IMeK1gIXwqy08mYoVZ1J3PSQzzf8rHvzqaiQCIIBgAxsPpalnpJW418uaSLAInpTd6om0Hl4NvmQkuixf/Un50MVlVUsAhPEUR8iJwgr5eJKxxw8wvhyckys9q6m8byi71rF7kQQ2uXSQ8jkOGAx3VvYdJjYHM4rRbIoIltsa6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511448; c=relaxed/simple; bh=Eylu6JRP3t0c2eW94X4vuzvx/0pFZPIhGAAA4G//4lk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WycPN0VHn5DaHbr7Wk61XjTujHQCv0f2qwFQDpQkKkB8EQcl1eD3Z8t4nHgQvk8+qp59QmQSaTK/bPIN3D8KWurMus28LqfsCEieo9xu0qmLJXM54lyKR4YtRw9IHSBv48gti/sEOXmPFMdr0m0IRAxU8vk4BBQ9DF+fT0gjwlI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=T3vRex2Y; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="T3vRex2Y" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-3966791a6eeso873640a91.3 for ; Fri, 04 Sep 2026 01:44:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511442; x=1789116242; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=W3sj2cYUAVCTd2rqI36VhEFdVQ+OlkMrPyaumoKtPAY=; b=T3vRex2YCMXJtVE0r/aqaVZpQEhbLdU7pNXhu3vVJGwZ60LlQ5efSp1AFDHQALE2sY Dbwz4UyqRYv4Nou1d1txqmRuVoSNqJY22E+AUHXaYzO5zokUPcEeCgw1nzyxL6CEiexf Z69hGXRcRB3Px1kSHRqXaMlPvqL1yCpQxQOmA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511442; x=1789116242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=W3sj2cYUAVCTd2rqI36VhEFdVQ+OlkMrPyaumoKtPAY=; b=bAcKuuKysoIc/OcE49l6mcIGsz506llk0aGcMiRtuqU/reIltq/WjkXlYnacDSZXKS KBrwQucQcnGLEfKATSp4wC+Ex7fEjOZI7nl5acrHiX8bZoGdA7wlycM1x1jw0gR1mF3O b76Rs7fU3fy521Xd/SRWab1UXLR7qqGIWa1qxTRwr5DjqoRVSDGWtUkn3hm5LxbjNUw9 6in2TqkG/9K9bOi9LSjkt7y97e09QMahU8Ozq7fhDhEAwxMjgSmUP7ThCI3A3Zo7c6jv DWvvJuttozxy84oX/I0hTmKzq7tZ3looqQGRyZnH1PFYQfrnVcjTTJLP7wXouuA9+/HO ucWQ== X-Forwarded-Encrypted: i=1; AKwUvBwX5iAH1UFRl/c/CrcYKzQzV91f1vrrjj52P/L+NBWJ/LSe+wEkdVMXhXecJJCHpC2bxM+hhQ5qTxn+jEg=@vger.kernel.org X-Gm-Message-State: AFuF++n0+yByCp+YApCQ0ISvQPXpatuOTslM8Qp1sC65dSmX58QA4OOP 7vecbFQvSQyFnKOIwNgfAA4zPTmnNHGUDfvaVxVdsHPU0W5Nb0r2zruUTrrshYJ7ow== X-Gm-Gg: AYBFou2XRL5WS7ZVyfFSEii2FvefW7gqpTA3TM+ySQ9Bzn3KzC+mhlh4dFuNwDrWzQ1 1dmKViBwrxgmWu5Njk0tMdLz4g+ioVpqMd21AhmLZY/vQwP1LQc11CFAvJLi/Lr1jdwmJczvjNN Lkx2/SqMbLrvUi8kVdHX7ODjzr7MODAVySsQy+pjeO+lhebTuxQrLV3SUqYYzN8cLGAu74OaNTA 2M/MBjFo8dDKwjr/gb+udD6p2K4tIrCtf+A7B6t8jHMDFctMEOLGOpodKhE5UeyePmKidAjhghi ix8TiKRYR3UldYeMXT/5CG5p9R8fO9veXzYp/duwZIXrrHtRKuM8L6idnNH/0+ysslkdfmhZ6Rd Byiq4cfvSsxzWkLGPGsnPVr2eT2tNsQfb0xCYtt4pYLoX+Hx7DYEpRc7usMeOdovTzhlxDYQ6bo jVU0zUeDIqzpLqJs0g0kQkIIK6jxHzN8NYXKeW87ZKEQyLeePU37w8M2zBWPhT/8Xz/a8gdEPob MhxVqad+jP8F7FqA2bDjCOgu4nIf2aAk6H7rL69VI10 X-Received: by 2002:a17:90b:4c51:b0:38e:57a3:f218 with SMTP id 98e67ed59e1d1-39b26204e5bmr5803481a91.13.1788511442063; Fri, 04 Sep 2026 01:44:02 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:44:01 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 08/16] usb: hub: Pass |struct usb_port*| to usb_port_is_power_on() Date: Fri, 4 Sep 2026 16:41:47 +0800 Message-ID: <20260904084158.1341550-9-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" usb_port_is_power_on() currently takes |struct usb_hub*|, but only needs it to tell if the hub/port is SuperSpeed or not. In a subsequent change, usb_port_is_power_on() needs access to a pwrseq state tracking field in |struct usb_port|. Either structure can be used to identify whether a port/hub is SuperSpeed or not, as the field in |struct usb_port| is inherited from the hub: port->is_superspeed =3D hub_is_superspeed(hub) Replace usb_port_is_power_on()'s |struct usb_hub*| parameter with |struct usb_port*| so a subsequent change can use it. Reviewed-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Signed-off-by: Chen-Yu Tsai --- Changes since v3: - Adapted to move of usb_port_is_power_on() to port.c and port.h --- drivers/usb/core/hub.c | 7 ++++--- drivers/usb/core/port.c | 6 +++--- drivers/usb/core/port.h | 4 +--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 7f58d753d77a..1b891088a653 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3294,7 +3294,7 @@ static int check_port_resume_type(struct usb_device *= udev, } /* Is the device still present? */ else if (status || port_is_suspended(hub, portstatus) || - !usb_port_is_power_on(hub, portstatus)) { + !usb_port_is_power_on(port_dev, portstatus)) { if (status >=3D 0) status =3D -ENODEV; } else if (!(portstatus & USB_PORT_STAT_CONNECTION)) { @@ -3736,12 +3736,13 @@ static int wait_for_connected(struct usb_device *ud= ev, struct usb_hub *hub, int port1, u16 *portchange, u16 *portstatus) { + struct usb_port *port_dev =3D hub->ports[port1 - 1]; int status =3D 0, delay_ms =3D 0; =20 while (delay_ms < 2000) { if (status || *portstatus & USB_PORT_STAT_CONNECTION) break; - if (!usb_port_is_power_on(hub, *portstatus)) { + if (!usb_port_is_power_on(port_dev, *portstatus)) { status =3D -ENODEV; break; } @@ -5437,7 +5438,7 @@ static void hub_port_connect(struct usb_hub *hub, int= port1, u16 portstatus, * but only if the port isn't owned by someone else. */ if (hub_is_port_power_switchable(hub) - && !usb_port_is_power_on(hub, portstatus) + && !usb_port_is_power_on(port_dev, portstatus) && !port_dev->port_owner) set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); =20 diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index b2e953f137f8..8d686d43e996 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -23,11 +23,11 @@ static int usb_port_block_power_off; static const struct attribute_group *port_dev_group[]; =20 /* Check if a port is power on */ -int usb_port_is_power_on(struct usb_hub *hub, unsigned int portstatus) +int usb_port_is_power_on(struct usb_port *port, unsigned int portstatus) { int ret =3D 0; =20 - if (hub_is_superspeed(hub->hdev)) { + if (port->is_superspeed) { if (portstatus & USB_SS_PORT_STAT_POWER) ret =3D 1; } else { @@ -114,7 +114,7 @@ static ssize_t disable_show(struct device *dev, } =20 usb_hub_port_status(hub, port1, &portstatus, &unused); - disabled =3D !usb_port_is_power_on(hub, portstatus); + disabled =3D !usb_port_is_power_on(port_dev, portstatus); =20 out_hdev_lock: usb_unlock_device(hdev); diff --git a/drivers/usb/core/port.h b/drivers/usb/core/port.h index 00f7500af336..2f4349b3ce6b 100644 --- a/drivers/usb/core/port.h +++ b/drivers/usb/core/port.h @@ -63,6 +63,4 @@ struct usb_port { #define to_usb_port(_dev) \ container_of(_dev, struct usb_port, dev) =20 -struct usb_hub; - -int usb_port_is_power_on(struct usb_hub *hub, unsigned int portstatus); +int usb_port_is_power_on(struct usb_port *port, unsigned int portstatus); --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 350A141D13D for ; Fri, 4 Sep 2026 08:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511452; cv=none; b=ZF7djnP+Y6VgfbVSKPT59LYIViGuCDlsLw8OWQFca7ul8ChDFOCZnnWLN6AdrJsEl1LpezaviQTCMCdZgfkWhkKudNglzU1gJi2Jh6Ee4f6Sst9Zcac3weM/dNSY4N3WKabfAU+28ZL0K0jXNjf04yJ3nnFuiGXhJ3ykqwJs0Ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511452; c=relaxed/simple; bh=GKxlf1sAAAtK88H6DAU3sh0iIYsWYsT2IYOx5SXsE3A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XjT1Gydm7ZxmXsIWQFepPLbUJKM84JETKcI0jmjhNryaD41dngI8116BMa7UDLZuo5ZIRVwpZGuHwNP+rwhNSkQIbQ4am3tRR/25jKOQJsJWokE1kS4e2c4BxXLIrsWn9+IfouknrJobOdJMo1xrUuVUyIw8wL6BoANM95t7JIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=VdY0iG85; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="VdY0iG85" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-398e9698a70so665795a91.0 for ; Fri, 04 Sep 2026 01:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511447; x=1789116247; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xFmIb/8YvdtZL49BMQqQktnO00n+EPHrLzK7Dg1eMRc=; b=VdY0iG85RNkm9SkCaEqHCBCPJvjQCFRiRTVVxyJRlLXY6gFLiobguT2Ne1w6cUvCEM D3gEkgdol74YqaYwgxJXUdsCppnNHpFiUmzVvQrESERRM8iklThb3xVXk/Rppwa7UjPv +vVBhxRX6VVvPxyF1/pgk2dEHHC2eEOOggwpo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511447; x=1789116247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=xFmIb/8YvdtZL49BMQqQktnO00n+EPHrLzK7Dg1eMRc=; b=XiBSWYi5KKosnvLNCJ8lI9kImaGHXrEGgeHaB6C/x/V0tcISRFyxpI1wjMfZoDJuJF sp1cXKbdauCkkyh46YLwyeYINzTdfK6Xd3il1ASGzamCrUngsk9LdrrmxRJZDaUkkbAk 4JtjEUmNsc4U0y+A4txZQKZFuzI0RlKDYgHqqgQ0fLbBwKiUbx+TYSj64YMI/G8vwp7x GjOm38fADCKMMWD0LXjA9PkYRG6+CI2InN3YYO8FavexF6CkBYgoc6QwXFoklfM8rXbq zBmys6+Er6BT2Ss8ThvW9vrhatyDeMrqi5XlHo1s+utNrWuwVCsSg2jYd9YFNgfMgQ1c PEeA== X-Forwarded-Encrypted: i=1; AKwUvBwRc8W5r3PfAg9Q8xvE3S2KMX2UGjZUMQVzzQZZoOVIGENfAOwSmWdySOppr6Iq8BMa2ELj0dW8kOKzwjA=@vger.kernel.org X-Gm-Message-State: AFuF++nZa7ENmwi2EclH7Sp/hJidx3d6+eam6i3dqqi0ivA7mM+f9Mfk YoV1Lf+P0eZRNjRaGUeqV3/tkek2Zu9jichE6WGMbhYbMqN79LoOtgKtkLmH437SeQ== X-Gm-Gg: AYBFou09GmFSz05CD2X91MyQYNdjYVDuhlXAPtthk2d/IxC2gepkgdfJ1BzdNEcRzsi bAveowAreaq53HxBGBAKGxMhXv0zWHeS84U5GwkVukchq9YVeq6gbQ8LdW63jlsitMny7CZVLuw s8pm2kzrIUXDJZWLp6Z5lwyWcOx5deAZT7mcOHo6kthIuzdzAbwZlm8YE7qeP6PqyXaPAiuHyBn G6OmD89ptnk0yBY5+4MJvt+l1MRuoJf8DWCJl8K+hpBFo79K43RbXekaWor1BI1h95RxQor863R 22ckyDWDAkIAC+DZqrEZwuepe8wqmgCuHSvF+NVssALyCY2wgM7hSVpqmzVXDwGOonRVP5QJhpc /miFukbuDwKHTd/giDEOe2x/6UWre6xANfyunm3j3GVxtW33mKgkGLeB7AaUdQ9qDGM7U0X6t81 mQkGhNKKnlbFQOr4F2iv48eE4huB8Ph5wau2tmSZ1lVliZKDKxbY4pLYFjyz5PCd4Oqhh2HWATE FW0mXaXpGmBK+uUOEqGQ9U/pAxu0aR679Bz6CJOEaYZ X-Received: by 2002:a17:90b:2d0b:b0:398:c794:ca26 with SMTP id 98e67ed59e1d1-39b263167f7mr7127157a91.25.1788511447090; Fri, 04 Sep 2026 01:44:07 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:44:06 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 09/16] usb: hub: Use usb_hub_set_port_power() to control port power everywhere Date: Fri, 4 Sep 2026 16:41:48 +0800 Message-ID: <20260904084158.1341550-10-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are still some instances in the USB hub driver where port power is directly controlled by toggling the USB_PORT_FEAT_POWER feature flag. Switch these instances over to usb_hub_set_port_power() so that only one unified function to do this exists. This makes adding external power control with the power sequencing API easier and consistently applied. Reviewed-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Signed-off-by: Chen-Yu Tsai --- Changes since v2: - New patch --- drivers/usb/core/hub.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 1b891088a653..b7991eb53197 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -976,11 +976,8 @@ static void hub_power_on(struct usb_hub *hub, bool do_= delay) dev_dbg(hub->intfdev, "trying to enable port power on " "non-switchable hub\n"); for (port1 =3D 1; port1 <=3D hub->hdev->maxchild; port1++) - if (test_bit(port1, hub->power_bits)) - set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); - else - usb_clear_port_feature(hub->hdev, port1, - USB_PORT_FEAT_POWER); + usb_hub_set_port_power(hub->hdev, hub, port1, + test_bit(port1, hub->power_bits)); if (do_delay) msleep(hub_power_on_good_delay(hub)); } @@ -5440,7 +5437,7 @@ static void hub_port_connect(struct usb_hub *hub, int= port1, u16 portstatus, if (hub_is_port_power_switchable(hub) && !usb_port_is_power_on(port_dev, portstatus) && !port_dev->port_owner) - set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); + usb_hub_set_port_power(hdev, hub, port1, true); =20 if (portstatus & USB_PORT_STAT_ENABLE) goto done; --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 1420641A55F for ; Fri, 4 Sep 2026 08:44:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511462; cv=none; b=GhD3PidL8nKtW/HZvKIFr5laBMH9yykRxIBOv4IA3f03kTFZQmIwkzwWU8Oc5t4bruSB5DwNFWyzkMzn6xc9ibidnIEKr0HYnmIKF6cG+E76+BIQeLWsh7dfgCb9mUUTLyxQ7LhQbr5+N5Lip8fmXuPMBCD4DLV4+XhKi1W6phs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511462; c=relaxed/simple; bh=NZYE+zwBe6PvNiXnjnCPf58f/FT8HXa4kHKgAvLId1I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cs1KdXnbHKrQelobrsO3q0NdJYVOruoGl5QRj2Gif/FJOym1069Ejw48c6J/BUIOrSWi9RpVW7Pv0BMVXxc4iLQqjL3ViEqf++qj6JDHbsC7GUBoQp+WraTLfqjPu2eUjRn4rLf/u2sQG4RgN3zzZbK7VDKNqMnKR/AeWHBtHwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=C7xFC+KJ; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="C7xFC+KJ" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2d6f9e2f681so8664615ad.3 for ; Fri, 04 Sep 2026 01:44:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511452; x=1789116252; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OZ/mMm4H1zhFaAFXYcb3A8+wTINaihRcWRsvqZe1lvI=; b=C7xFC+KJKI7aqeb0uTKLnjcF8NiKAiXaalJ+XRC6uz4rsSc7feh2JJ7swqhPjk6Op7 xmZYhOM9DJW3fkzbjJ1ovjTuAWPECvXLXpbNU5nEvqHY7n/sNEuYvEELwF6FX0jiDI6a qMnFvscm3tdOh1YobqPbU0SWgaK/Qpw4oKdNE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511452; x=1789116252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=OZ/mMm4H1zhFaAFXYcb3A8+wTINaihRcWRsvqZe1lvI=; b=Y077xvszzrhVHeYzdyR3CjQfDQ9LqcnN6MxyTwTEEsnU9Tzlay9DO8OYV+OjXOWOk5 62zsGYyhsbRstkgg5qmv17WvtiItb3y8CXdDjSjN5UF1EAbj0fZmYnhQ7hB+06ahDFNB eqlMqv6aXdu/tC1ljUWdF0JdXw8a4rZ7WfyEWmvBC4hfsIjTmyoZCixOU1EGcbsV51Gy IxEVQBGAADj+PlqRaoqEF+17Z01CwEJOmUKbliwjvPuUVnq8hqXeW6vBq8si54MfZzep 4NDfGiKLI+4Bm4iA8QqntsJ+btEp8wt5RcCh7HdoHfVEQxKvur2aHzOngjMm+GJLZv88 bRdA== X-Forwarded-Encrypted: i=1; AKwUvBw9KuYpH7QkBRfuqRQmXiP8u3OjWlmTH/a7Yg8+hAhztuhu6cN27cvVBb5BPoF9ZTnGp5YzuSxxI7ykfSA=@vger.kernel.org X-Gm-Message-State: AFuF++ncjZtGWR+DRK/z09Zn4Q7uYR52iUXBCiBwOTUJ8pfgJ1ymFLO1 97ZSe7UHJykWtVtViREShNVMF8QsVYPrWmu3KTw89XEggMiG132IHC4PR7CtcDCJfA== X-Gm-Gg: AYBFou2FpkGKrvhemdPTLTolqyFQ4PDNbds17qbHrBqf6HZ0s/ULzBTfLeLzCCskWoN c6EpBJTR7werLUFIQoKJ3uCQke5oHXoz+UEijPAbh9whmuwyk+sfhKTQR7YCg8cDBfVH9lqim1z 6TwcezS/AAonvUxEwhBcfo0ewVb0sAdR6/ChQR29RdxmafCraQqNDkAAeBUJRJEREdKFfkiw7ZU DQdjQiyMc3cQU+ebcd5D8AjkQRHA+mIMwj6c7lRNQO5BS5teDx7jOh6gK1e9393FGoLszV4/Zil PPQoMJdn+FhmcmuuqtOIe1XhnFRcr7kKWkqmPnpRXzcKvKVs85pVcb1bZbaU9coID/YoIwfULpj Pb/q7D/tns/SK2varT39KOp0Agb0qdARocTgLPK3psN0hXVJH+ozc2R7N/caSsIAxzfRuGVin17 0SR96d6tAEZmBPGXglhoi+A2T7sG3H0LDE6yuk+Tlq/ZQZZs79d0p25LmEoDLQP72AZqjMNC5zC whc/zf+AOLCmWWJRHsWou+pTN6RH2A9KhKhdIAWIU61MuATq+a97E8= X-Received: by 2002:a17:90b:5343:b0:398:e46e:ade3 with SMTP id 98e67ed59e1d1-39b2628fc1amr8012560a91.23.1788511452363; Fri, 04 Sep 2026 01:44:12 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:44:11 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 10/16] usb: hub: Power on connected M.2 E-key connectors with power sequencing API Date: Fri, 4 Sep 2026 16:41:49 +0800 Message-ID: <20260904084158.1341550-11-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The new M.2 E-key connector can have a USB connection. For the USB device on this connector to work, its power must be enabled and the W_DISABLE2# signal deasserted. The connector driver handles this and provides a toggle over the power sequencing API. This feature currently only supports a directly connected (no mux in between) M.2 E-key connector. Existing USB connector types are not covered. The USB A connector was recently added to the onboard devices driver. USB B connectors have historically been managed by the USB gadget or dual-role device controller drivers. USB C connectors are handled by TCPM drivers. The power sequencing API does not know whether a power sequence provider is not needed or not available yet, so we only request it for connectors that we know need it, which at this time is just the E-key connector. On the USB side, the port firmware node (if present) is tied to the usb_port device. This device is used to acquire the power sequencing descriptor. This allows the provider to tell the different ports on one hub apart. This feature is not implemented in the onboard USB devices driver. The power sequencing API expects the consumer device to make the request, but there is no device node to instantiate a platform device to tie the driver to. The connector is not a child node of the USB host or hub, and the graph connection is from a USB port to the connector. And the connector itself already has a driver. Power sequencing is not directly enabled in the connector driver as that would completely decouple the timing of it from the USB subsystem. It would not be possible for the USB subsystem to toggle the power for a power cycle or to disable the port. Sashiko mentions possible use-after-free of hub->ports from the sysfs callbacks. This is actually not possible, since the sysfs callbacks acquire the hub device and its lock, and then check if it is in the process of disconnect / removal. If it is, then the callbacks just error out. Reviewed-by: Bartosz Golaszewski Link: https://lore.kernel.org/all/20260610084053.2059858-1-wenst@chromium.o= rg/ Link: https://lore.kernel.org/all/20260515090149.3169406-1-wenst@chromium.o= rg/ Signed-off-by: Chen-Yu Tsai --- Changes since v7: - Adapted to pwrseq_enable/disable() rename Changes since v6: - Added braces ("{}") to for loop in hub_is_port_power_switchable() (Andy) - Adapted usb_port_is_power_on() to new pwrseq_get_state() function return values (Bartosz) Changes since v5: - Only assign port_dev->pwrseq if successfully retrieved pwrseq descriptor (Andy) - Dropped the pwrseq error pointer check in the release function (Andy) - Added check for port->pwrseq !=3D NULL before calling pwrseq_is_power_on() (API change in patch 3) Changes since v4: - Rewrote usb_port_is_power_on() to better express intent and restrictions of pwrseq API (Andy) - Switched to dev_fwnode() in port_pwrseq_is_supported() (Andy) - Added blank line separating normal variable declarations and __free() type declarations (Andy) - Split out assign_bit() rewrite (Andy) - Moved pwrseq_put() to release function to avoid UAF (Sashiko) - Added back pwrseq_power_off() call in usb_hub_remove_port_device(); otherwise power off could be delayed to object release - Don't clear hub->ports[port1 - 1] in main error path; by that time the port device is registered and sysfs attributes are available to userspace (Sashiko) Changes since v3: - Adapted to move of usb_port_is_power_on() to port.c and port.h - Simplified usb_hub_set_port_pwrseq() (Andy) - Renamed usb_hub_set_port_pwrseq()'s "set" parameter to "on" - Dropped usb_hub_restore_port_pwrseq() (use usb_hub_set_port_pwrseq() with inverted argument) - Fixed off-by-one access in hub_is_port_power_switchable() (Sashiko) - Assign retval from dev_err_probe() instead of the other way around (Andy) - Clear hub->ports[port1 - 1] in USB port error and remove paths to avoid other threads from accidental UAF while the USB hub device is being unwound (Sashiko) - Short-circuit out of helpers if !IS_ENABLED(CONFIG_POWER_SEQUENCING) to avoid errors from stub functions (Sashiko) Changes since v2: - Expanded subject to mention power sequencing API - Dropped commit message bit about power sequencing Kconfig symbol change to bool - Added optional dependency on POWER_SEQUENCING to USB - Split out pwrseq_power_*() calls into separate helpers - Rewrote set_bit() and clear_bit() branches with assign_bit() - Dropped the pwrseq_power_off() before pwrseq_put(): pwrseq_put() does it automatically. - Removed pwrseq_power_on() from usb_hub_create_port_device(); it will get called through usb_hub_set_port_power() in hub_activate(). - Added checks for port->pwrseq in hub_is_port_power_switchable() - Use separate pwrseq descriptors for HighSpeed and SuperSpeed ports. This makes things simpler. On the other hand to power cycle a port userspace needs to toggle it on both the HS and SS ports together. - Dropped pwrseq state tracking again The power sequencing consumer API already tracks the state internally; doing it again in |struct usb_port| is not necessary especially now that the descriptors aren't shared. It's unclear to me how actual hubs reconcile USB_PORT_FEAT_POWER settings from the HS side and SS side. One hub chip vendor said that VBUS_EN for a port is on if the flag is set on either side; however actually testing on one of their hubs showed that VBUS was cut as soon as the flag is cleared on the HS port. Maybe it could be different if a SS device was connected? That scenario was not tested. Testing on another retail bought hub seemed to work exactly as described though: USB_PORT_FEAT_POWER needed to be clear on both HS and SS ports to turn off VBUS. Under this scheme, I'm not sure how the power cycle in hub_port_connect() would work correctly. - Link to v2: https://lore.kernel.org/all/20260610084053.2059858-1-wenst@chromium.org/ Changes since v1: - Switch to fwnode instead of OF - Tie port@ fwnode to usb_port device - Move remote node compatible checking to separate helper - Use usb_port device to request power sequencing descriptor - Drop "index" parameter from pwrseq_get() - Do not get pwrseq descriptor for SuperSpeed port; share one for one physical port - Add pwrseq state tracking - Link to v1: https://lore.kernel.org/all/20260515090149.3169406-1-wenst@chromium.org/ --- drivers/usb/Kconfig | 1 + drivers/usb/core/hub.c | 20 ++++++++++++- drivers/usb/core/hub.h | 10 ++++++- drivers/usb/core/port.c | 62 ++++++++++++++++++++++++++++++++++++++++- drivers/usb/core/port.h | 2 ++ 5 files changed, 92 insertions(+), 3 deletions(-) diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index abf8c6cdea9e..ef1959363fb1 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -44,6 +44,7 @@ config USB_ARCH_HAS_HCD config USB tristate "Support for Host-side USB" depends on USB_ARCH_HAS_HCD + depends on POWER_SEQUENCING if POWER_SEQUENCING select GENERIC_ALLOCATOR select USB_COMMON select NLS # for UTF-8 strings diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index b7991eb53197..a231cc076ebd 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -33,6 +33,7 @@ #include #include #include +#include #include =20 #include @@ -875,6 +876,16 @@ static void hub_tt_work(struct work_struct *work) spin_unlock_irqrestore(&hub->tt.lock, flags); } =20 +static int usb_hub_set_port_pwrseq(struct usb_port *port, bool on) +{ + if (!IS_ENABLED(CONFIG_POWER_SEQUENCING)) + return 0; + + if (on) + return pwrseq_enable(port->pwrseq); + return pwrseq_disable(port->pwrseq); +} + /** * usb_hub_set_port_power - control hub port's power state * @hdev: USB device belonging to the usb hub @@ -890,15 +901,22 @@ static void hub_tt_work(struct work_struct *work) int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub, int port1, bool set) { + struct usb_port *pwrseq_port =3D hub->ports[port1 - 1]; int ret; =20 + ret =3D usb_hub_set_port_pwrseq(pwrseq_port, set); + if (ret) + return ret; + if (set) ret =3D set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); else ret =3D usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_POWER); =20 - if (ret) + if (ret) { + usb_hub_set_port_pwrseq(pwrseq_port, !set); return ret; + } =20 assign_bit(port1, hub->power_bits, set); return 0; diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index de524c6da9fc..3f403a56e5f7 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h @@ -103,7 +103,15 @@ static inline bool hub_is_port_power_switchable(struct= usb_hub *hub) if (!hub) return false; hcs =3D hub->descriptor->wHubCharacteristics; - return (le16_to_cpu(hcs) & HUB_CHAR_LPSM) < HUB_CHAR_NO_LPSM; + if ((le16_to_cpu(hcs) & HUB_CHAR_LPSM) < HUB_CHAR_NO_LPSM) + return true; + /* check for controllable external power sequencers */ + for (unsigned int i =3D 0; i < hub->hdev->maxchild; i++) { + if (hub->ports[i] && hub->ports[i]->pwrseq) + return true; + } + + return false; } =20 static inline int hub_is_superspeed(struct usb_device *hdev) diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 8d686d43e996..8e95a6c09615 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -8,11 +8,14 @@ */ =20 #include +#include #include #include #include #include #include +#include +#include #include #include =20 @@ -26,6 +29,7 @@ static const struct attribute_group *port_dev_group[]; int usb_port_is_power_on(struct usb_port *port, unsigned int portstatus) { int ret =3D 0; + int pwrseq_state; =20 if (port->is_superspeed) { if (portstatus & USB_SS_PORT_STAT_POWER) @@ -35,7 +39,13 @@ int usb_port_is_power_on(struct usb_port *port, unsigned= int portstatus) ret =3D 1; } =20 - return ret; + /* stub function returns error */ + pwrseq_state =3D pwrseq_get_state(port->pwrseq); + /* fall back to port status if pwrseq is in unknown state */ + if (pwrseq_state < 0 || pwrseq_state =3D=3D PWRSEQ_STATE_UNKNOWN) + return ret; + + return ret && pwrseq_state =3D=3D PWRSEQ_STATE_ON; } =20 static bool usb_port_allow_power_off(struct usb_device *hdev, @@ -45,6 +55,9 @@ static bool usb_port_allow_power_off(struct usb_device *h= dev, if (hub_is_port_power_switchable(hub)) return true; =20 + if (port_dev->pwrseq) + return true; + if (!IS_ENABLED(CONFIG_ACPI)) return false; =20 @@ -380,6 +393,8 @@ static void usb_port_device_release(struct device *dev) * device_platform_notify_remove() in device_del(). */ fwnode_handle_put(dev_fwnode(dev)); + /* usb_hub_create_port_device() could leave an error value */ + pwrseq_put(port_dev->pwrseq); kfree(port_dev->req); kfree(port_dev); } @@ -772,11 +787,46 @@ static const struct component_ops connector_ops =3D { .unbind =3D connector_unbind, }; =20 +static bool port_pwrseq_is_supported(struct usb_port *port_dev) +{ + struct device *dev =3D &port_dev->dev; + struct fwnode_handle *port =3D dev_fwnode(dev); + + struct fwnode_handle *ep __free(fwnode_handle) =3D + fwnode_graph_get_next_port_endpoint(port, NULL); + if (!ep) + return false; + + struct fwnode_handle *remote __free(fwnode_handle) =3D + fwnode_graph_get_remote_port_parent(ep); + if (!remote) + return false; + + if (!fwnode_device_is_compatible(remote, "pcie-m2-e-connector")) { + dev_dbg(dev, "remote endpoint %pfw is not a supported connector", remote= ); + return false; + } + + return true; +} + +static struct pwrseq_desc *usb_hub_port_pwrseq_get(struct usb_port *port_d= ev) +{ + if (!IS_ENABLED(CONFIG_POWER_SEQUENCING)) + return NULL; + + if (!port_pwrseq_is_supported(port_dev)) + return NULL; + + return pwrseq_get(&port_dev->dev, "usb"); +} + int usb_hub_create_port_device(struct usb_hub *hub, int port1) { struct usb_port *port_dev; struct usb_device *hdev =3D hub->hdev; struct fwnode_handle *fwnode =3D dev_fwnode(&hdev->dev); + struct pwrseq_desc *pwrseq; int retval; =20 port_dev =3D kzalloc_obj(*port_dev); @@ -827,6 +877,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int= port1) retval =3D device_register(&port_dev->dev); if (retval) { put_device(&port_dev->dev); + hub->ports[port1 - 1] =3D NULL; return retval; } =20 @@ -844,6 +895,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, in= t port1) goto err_put_kn; } =20 + pwrseq =3D usb_hub_port_pwrseq_get(port_dev); + if (IS_ERR(pwrseq)) { + retval =3D dev_err_probe(&port_dev->dev, PTR_ERR(pwrseq), + "failed to get power sequencing descriptor\n"); + goto err_put_kn; + } + port_dev->pwrseq =3D pwrseq; + retval =3D component_add(&port_dev->dev, &connector_ops); if (retval) { dev_warn(&port_dev->dev, "failed to add component\n"); @@ -901,6 +960,7 @@ void usb_hub_remove_port_device(struct usb_hub *hub, in= t port1) peer =3D port_dev->peer; if (peer) unlink_peers(port_dev, peer); + pwrseq_disable(port_dev->pwrseq); component_del(&port_dev->dev, &connector_ops); sysfs_put(port_dev->state_kn); device_unregister(&port_dev->dev); diff --git a/drivers/usb/core/port.h b/drivers/usb/core/port.h index 2f4349b3ce6b..088a182332d4 100644 --- a/drivers/usb/core/port.h +++ b/drivers/usb/core/port.h @@ -25,6 +25,7 @@ * @port_owner: port's owner * @peer: related usb2 and usb3 ports (share the same connector) * @connector: USB Type-C connector + * @pwrseq: power sequencing descriptor for the port * @req: default pm qos request for hubs without port power control * @connect_type: port's connect type * @state: device state of the usb device attached to the port @@ -44,6 +45,7 @@ struct usb_port { struct usb_dev_state *port_owner; struct usb_port *peer; struct typec_connector *connector; + struct pwrseq_desc *pwrseq; struct dev_pm_qos_request *req; enum usb_port_connect_type connect_type; enum usb_device_state state; --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 D89863F660F for ; Fri, 4 Sep 2026 08:44:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511463; cv=none; b=qptWin+VFy2paDb24BkYR3C1AvDRvT33lJmFNXzcCTpPeksP3QO9DicrZ5tEpmNlf5CdvcD99/zZlNQwAZetjJlh/I+Hz1sU+aKfSHYW1IV45KdGsf74VCwlgnWkJ1o9+ifjZBbdJjtWEPIUgNSlFuCh1avu+lKXixGw8KQBrQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511463; c=relaxed/simple; bh=evX7eHGckJlWiDjaLlRDSEr7EUj3T3hqiY287BkHQLE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tMe9RIYBKbL4jelhdekJEFK9XrprUUDD+idCfJW0k5vF7IMYBGWyPJZTMbSihzJZxDGrsp21IEeRaX08qLvDT9IYYL6Uinu26JyRBU+oa1punX1kyqLkegkH5LPgFqjfWo4iK+AtL7w+jRFL2N9FQNYP2T+RD0y+Z2FbMkTZ6+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Ka2DzsTP; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Ka2DzsTP" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-38e041ea211so597954a91.0 for ; Fri, 04 Sep 2026 01:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511457; x=1789116257; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ObFYxd9MufAeOT7Yw9/ly+HXxu6y+wv2diiZ0sB4OhA=; b=Ka2DzsTPOYkfLQgnSpArl8sTLhy9gXY5HzNB17WAEfxOiZ4+A6zd/jKUPvA26Nf98w O3zAOQpJiKyxYBVZVQ1craECrAkhoqcmwEwoatmiB7yXgTTHaJYSUi+wPNJk5iNwzKms v0qAQYbSzjTQn5XO0zaU7os1tx1mdF2L6MXo0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511457; x=1789116257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ObFYxd9MufAeOT7Yw9/ly+HXxu6y+wv2diiZ0sB4OhA=; b=oMJnCO+nvXAOSshv4GZa8pnSu6prggcTGfBLX56BV9Q3fbeDnzwNYs2pMsYl+LQkb/ Krqs/dgT04pplNPotxIF5iGm6C5Ad87OgUmEs9nEUclIrP+RGgqUg3M32/iqi2lrV8em Z1AxRtnbib5wmBWBjllvXwx0/M3VOxEgVBKlYndzHM1a4nJB2vxHXhM2y11EVg+P04OA O8yBYKpl4DlB7csHsYKDNHPEjzE4h8P0MqnQnaD0xDtD1nRsy5MsA7QaISkIqiAcoe5K kYiu66ygLS3s6ZOk3Pn5jH7zxk06c1dKd1wGtEGwacwH7z5M61p/W1NrJnSxLxLHZCa5 z+MA== X-Forwarded-Encrypted: i=1; AKwUvBzCrvm/kJg+NF3kdoUzQKrPVcelDMxRHNn6aDEG19bkiCz0EHhVZ2vFGM1xC2He7jZPUjqB71egViB3/c0=@vger.kernel.org X-Gm-Message-State: AFuF++nEJ7rfcxP6YuCOHNppcXqWHzuiiSHILXwLGZMzBeOiHizVuYFt Jj/yRtg/+RrgSi8RIhZ4uQzV9gDCs4KFJsQrySdkHsuPy5z1TxnFVLr7UBgdHzZh8Q== X-Gm-Gg: AYBFou2h7LvT7x53PXWMquyJ+QeqPD5Q3DJy9H4Eg7WY0f8xcWicyuDkddaGAMHZpHA jyWo0gvyfW4H8dNXBZf5u3BFKV22Uy47EleeSumfu24t8G6tYdP//hH0fWHfUGd6H0EftTQFaM+ /MG5cGqQPIb+QlKWdtl2rO/bJJa8ELhFw+FcCXujQVirF6087AHRnKs2Dz1Iq0oYSEII9WeWAAn 1UOf84ZUA5cpnTsy1Jh4mnj0rJTTKUH3qi4fv5tYkZ2pI/ucR1/51Li8wTYnIdHtAs8++qADfJH 8EEoOLC/+DKpq6BbVjLbApTUt/UB+su8W5+BrRlaAcgLxrIPqbVvWSR5531PcRHua4jb44joKY4 gJoML6FfCAj5pfDBiaw2RkkcC4iLiCGBOpLAYXgj/vk5jSk+0QbPFtkh/LjhvyWMJpo4pO+Ucma Tw+X0AFobxZHy66cPI6de1kYGFw+PcYqm3g4a8XBB+C6sXxdOcAChagOVEdCUW6HSSx1zQyfjKc iDFIcOHQ07kq2W0F71cPe97rKC7dSyHwoY0QyHoTD7o X-Received: by 2002:a17:90b:2808:b0:398:b46d:48c0 with SMTP id 98e67ed59e1d1-39b262aaeb7mr7039451a91.18.1788511457565; Fri, 04 Sep 2026 01:44:17 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:44:17 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Krzysztof Kozlowski , Bartosz Golaszewski Subject: [PATCH v8 11/16] dt-bindings: usb: mediatek,mtk-xhci: Switch to ports for USB connections Date: Fri, 4 Sep 2026 16:41:50 +0800 Message-ID: <20260904084158.1341550-12-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This reverts commit 454a1e3cd36c113341d7b71e8e691c6e47ab4a8a. MediaTek's XHCI implementation supports both USB 2.0 High Speed (HS) and USB 3.x Super Speed (SS). The block can also be synthesized with either HS-only capability or HS+SS capability. The SSUSB controller handles the device or gadget mode. Saying that SSUSB handles the HS portion is wrong. For example, on the MT8195, the first two instances support both HS and SS, while the latter two instances support only HS. Switch to a "ports" sub-node for describing USB connections. Port 1 is Super Speed if the controller is SS-capable, otherwise it is High Speed. Port 2 is High Speed if SS-capable. This port mapping scheme directly matches what the hardware returns in its capability registers. Fixes: 454a1e3cd36c ("dt-bindings: usb: mediatek,mtk-xhci: Add port for Sup= erSpeed EP") Cc: AngeloGioacchino Del Regno Reviewed-by: Krzysztof Kozlowski Reviewed-by: Bartosz Golaszewski Signed-off-by: Chen-Yu Tsai --- Changes since v1: - Squashed DT binding revert and addition together - Dropped reviewed-by from Bartosz --- .../bindings/usb/mediatek,mtk-xhci.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml b= /Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml index 231e6f35a986..d6c75bd20b78 100644 --- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml +++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml @@ -107,10 +107,6 @@ properties: - description: USB3/SS(P) PHY - description: USB2/HS PHY =20 - port: - $ref: /schemas/graph.yaml#/properties/port - description: Super Speed (SS) Output endpoint to a Type-C connector - vusb33-supply: description: Regulator of USB AVDD3.3v =20 @@ -188,6 +184,19 @@ properties: "#size-cells": const: 0 =20 + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Super Speed (SS) data bus if SS-capable; + otherwise High Speed (HS) data bus. + + port@2: + $ref: /schemas/graph.yaml#/properties/port + description: High Speed (HS) data bus if controller is SS-capable. + patternProperties: "@[0-9a-f]{1}$": type: object --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 2E3DD412BE7 for ; Fri, 4 Sep 2026 08:44:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511469; cv=none; b=Mj7atnhiFyBjB8t4oQB28LJodyzLREMAm6VVN55skCDjJyCz7dbNtHEMl1viY6HsbmbnmpTzF/tFIthexUo2glGjeLShDp825MV2TPjEjNND6YKdMfHrVJB5++0KAgTFIuNx4g8VjnGXr9mDKHCzkh9SOX1cqFMCzQtae+St3u4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511469; c=relaxed/simple; bh=xBV8QPVdEcBZnuBIzyHhldDQGO+nq6BHDmKFvSTohgk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QS/MxrmTXl+Uxmu4cERBzEigeePxRezoinuNIYHpDvJG6g0nnoILisWAHVumGXAwhjqyj+W5ulk36/zVOKwWcyNI0JiA4gzFwQoCUn/l89TTJRKpYbdSs1MBvkwFj9c11oD0v8dOWgkLzXXZ9AOT32gCfYk5F2KoTmRrnkPUjnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=gOyGqnpZ; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gOyGqnpZ" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-382ef647e20so753365a91.1 for ; Fri, 04 Sep 2026 01:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511467; x=1789116267; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1exL3htqf+GpZcCvUWENBQmRfzXhNWdoVzfZaiBanSc=; b=gOyGqnpZzfwLkK5A+xKyem7ZFzFwRRNhmEa/Bb2q5P0FH8aoiXR0DuvWhSSldr0srd VShMkTtxqM+Yrug6RUw9sakxDg9N+pbzouqSkIPCcJfcczAK2Z1I+RfmBJEtn/LTCtvP C/SgYX4EQVe9BVv5GTWfAHAIVad6KTsg8Q4EE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511467; x=1789116267; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=1exL3htqf+GpZcCvUWENBQmRfzXhNWdoVzfZaiBanSc=; b=TiK/5JGEzxFzmATZ0ekmu/POQEjXVZt5OF1FL0/q+spoz3eifedLw6mrvVFdYkkodH Vw8FnzWFWQ6YCcf6ZqKczJrahmE3vinlO00yDh22pJtqu5Xn95bRAi7x3m972jenJPUz MPwtuln4WA8AEqqR8Q4vw+D1ogPG57TqrLcTAs6bgrR+OVkCQnwGarzm+sOcpLutlPYF Zoa2Q09ALC4Y7lY/UhhBVTwBk3SNTw6/YGb1RNLbbL3C47o1LctL+0Mq0rCgPYat5h1u in7oEJOVYeTFJ44G+22DmEvPa2ETqqHGiEz78AwkTtnaGADs8ZVs17rRYMKzM5tmhxxs grYw== X-Forwarded-Encrypted: i=1; AKwUvByo/BChTr39SXka1/o/xYUX7Tbe/n1h0ZAEb6Qv3UjCbihY4HuZcG9JVX6lBwdECpRy/R2W6Rl1xXTkJ48=@vger.kernel.org X-Gm-Message-State: AFuF++l7xqOUXKBcyycmSG0H7S3c0V6WKmyK8h8uED026ckXp6/kUZv9 YJ6iH9bLjN4F7lkxFZuX+YEB5syESJTxY+BHdlYb5ZEFBChOflYhOdLN0IFAFhtdBw== X-Gm-Gg: AYBFou1c7wTy4f93I1SjYy/ESOCYrjmQGK0yatmijMILAy1IjoRNC6bXpSRHaTMWZVJ kWVEE/7z8x3sMKKTEQ27yqjOBQLdcelnKvXWkSblvSYLU/ix3HhigbbzhXuayUX2XZ7GdHTcTS2 3+X8G7JWROex8xJtv9ZRy56eh8p2E+l0hr9KJtIG+G8tKioZ9qa6QfgTnSR2sUf9wKVclkI7qfG ch5Qz17U9igB2GWE0ZfTMo5H47X84byIEMDmf/Tp+1QSy0tuM5dovdzU/6ki0bED8ZdCYcrRuqa O7HhRoG05sPp83yNPP6VBnX74rb4T3iPpkZSZUhmrxlv5zKd9LYj9/IudpD3HPdfqu7rlu2W/FR 0X8/iHHbZ6/gnMY7J8CuH1o0Q5hSpGl8CryEjPPN5XWw286cN0BE55Ov7jXpERceSpNkSKpj0kc DdlE/gdfGbcs+5o4HQcERIytdMLW01MXL/cQiLvkDLs0RWfNz35weVYV5ocOhKzDGkPgTNwYTIk EwvHiQuCX3OzECsyqxHJrwjI9qL6sxvk2d4hDBogUkL X-Received: by 2002:a17:90a:d646:b0:398:9bd5:490d with SMTP id 98e67ed59e1d1-39b26214798mr7405740a91.20.1788511462630; Fri, 04 Sep 2026 01:44:22 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:44:22 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Manivannan Sadhasivam Subject: [PATCH v8 12/16] power: sequencing: pcie-m2: support matching on remote "port" node Date: Fri, 4 Sep 2026 16:41:51 +0800 Message-ID: <20260904084158.1341550-13-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A USB hub can have multiple ports, and this driver needs to differentiate which port is being matched to. The USB hub driver now associates the "port" node with the usb_port device, so here we can use the remote "port" node to check for a match. Then fall back to the remote device node for the other connection types. Also rewrite the existing "remote =3D=3D dev_of_node(dev)" with device_match_of_node() for consistency. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Chen-Yu Tsai --- Changes since v4: - Dropped blank line between __free() variable declaration and subsequent use of the variable in conditional Changes since v3: - Drop redundant device node validity check; device_match_of_node() does it internally Changes since v2: - Use device_match_of_node() --- drivers/power/sequencing/pwrseq-pcie-m2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequ= encing/pwrseq-pcie-m2.c index de9848a9a9f1..43b2328a6661 100644 --- a/drivers/power/sequencing/pwrseq-pcie-m2.c +++ b/drivers/power/sequencing/pwrseq-pcie-m2.c @@ -175,9 +175,16 @@ static int pwrseq_pcie_m2_match(struct pwrseq_device *= pwrseq, * parent matches the OF node of 'dev'. */ for_each_endpoint_of_node(ctx->of_node, endpoint) { + /* USB port devices are tied to the port nodes. */ + struct device_node *remote_port __free(device_node) =3D + of_graph_get_remote_port(endpoint); + if (device_match_of_node(dev, remote_port)) + return PWRSEQ_MATCH_OK; + + /* Try the remote port parent for other types. */ struct device_node *remote __free(device_node) =3D of_graph_get_remote_port_parent(endpoint); - if (remote && (remote =3D=3D dev_of_node(dev))) + if (device_match_of_node(dev, remote)) return PWRSEQ_MATCH_OK; } =20 --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 77D3541A55F for ; Fri, 4 Sep 2026 08:44:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511471; cv=none; b=YhcGqhdEpLmLGMlXIvIZkaiG6J/6z+UgUwHgwuxYRagUC2LuUj/v8hICl/90vUJsmwOrzwbeksYxt5Wgi3NHFuPLE5WX/gssyksIXdLlhqf4nsun7+phzjP9oZSuNmucWr8MdndVweP+33Daaq7QH3JVZvfdgBOmxK4XA1TkfQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511471; c=relaxed/simple; bh=u12auxpxANOpkxu9usV3zVUsre8MM64CpWgx+x9ARHk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LXzRGpl4smRNyAPyMKlmDuB3mKN/woSgF7wNmAi9WvjxyuACBFliAZC/5T/Xj399qQnavMplhMDPyaa+11ulHZqOHDNGmGOIo62jrcOfypl1uBU7HxMxRwwKgsRhtwuzQm8v6B+eJxZwnkjc9jqMUONsbB7HOvPD4N8GkqU2byU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=DxydsGSV; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DxydsGSV" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-38e58034d05so601503a91.2 for ; Fri, 04 Sep 2026 01:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511468; x=1789116268; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QXiJKGEMuTwqwy42qG7uMnjSfbdcOoA9DAqQks+0PHc=; b=DxydsGSV51i5/UV7fZspU9PTFi1HT8u8l/K2z/jFAIxHGIxbnN+KYRRluHQcGahpn4 lzfgcO7KsAvSGx1KuLGnCDv0RKbF5Hdrjxvunbfw47xTxxLOCJO1EqGZZau+vkTsAccX 2FA2pZDAlpS0Rbd9j9/CucpcuNOo1+OUUwl88= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511468; x=1789116268; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=QXiJKGEMuTwqwy42qG7uMnjSfbdcOoA9DAqQks+0PHc=; b=QmGR7rGp/EdHhPdgEgMLwo9S/jHnMxI+E2S0fBxP+ojutDNda+GFLgY1gHeeFasFth eb9xPqgLe95uiFvlpkISvky7Qjz+ijqg21zpjf38AvPeuB/iNDllLLrUGEeXFdlYA9Tu Fq6S/ozzEL2dH28m/4T83iivnqPaTgZA5+HP28GcAj/sfSYw17Vs5atBUwO8EcZoVEFb V06kGH7i2s1vLkJ+n7W9jiECAzNhcHeJMQ32cq4rbS+tZhfWwG2JRZ5VVbSAzJuajwja gUJ+gwXDZ+8bvUg4M2MFyOIfl/CnmQOxBDga8QaVCY7yLBZ4tfW9d6VqsJLV2Fe8INSQ pBeQ== X-Forwarded-Encrypted: i=1; AKwUvBwytmdKAXg9GqWyNk7Lm85dlfN2rxBxxlpt9GCa/ONsUfdXvh4HKjwFYBLGdDr/LmxmxeEEIIaVQltMcvw=@vger.kernel.org X-Gm-Message-State: AFuF++lGKPj0fMZSDRuN/F59DASg3G9myxi2TqlC0KQhLeS3qqdMrh24 zGGbElUFFtHRzFfR16rlBLAqzN6usAguHTyVssJ8QGDho7pLEvJz+7yGIHL8OLU3Qw== X-Gm-Gg: AYBFou0LntBwdhW6wowhoKxsN7siLfG8Z8GvpFPYrOKRLGwwo2qI/Lpjh/4LUgK8xJD L2Sc4b2u3cPMWZlKxJvdfp15gDAgc5a7oeO5Yb0V/0+4XNwgoTjaz58PG657mYxRBUME8wZndwF DFyQu/pwT6iHMVq7Ws0sbUWiwyq1nAcjHCQjF03/LdyAszu18owMA7Uk52zDUE57KC7kEM03lSg tL584KRp/+/KFUZzbTZSOjE8FlyfkhsYFqaSLd2U1FxJxFM5ySxmjTws2hHoKg6vO/g7jlw4jBB as2OSmxg5jdYgO29Nz8jL4RxqzgxPI8FotrSK+UxV49yyUblV0qQJ/1jtYqTdtJbfsPOFooMC6V GTNuhC/l4QedXtWsXaS/AUsL5e1pUiiE95NT5F/A5o73sMaK3R201nPj0fnDdgu8qVEhd7mXk0P kfnytGQdYSy+Xqb5y7OThYK1DdudfMgEBydbClD9rQk8DMQsBLFhiLSB1CS3WEp7U7AdTXCuGu6 /BUZgI2Q6/yTpkIqDnQjLGvofev5DQQ5YjLfs88q6Nj X-Received: by 2002:a17:90b:2b8c:b0:398:9be6:f995 with SMTP id 98e67ed59e1d1-39b262aaf48mr7479557a91.20.1788511467843; Fri, 04 Sep 2026 01:44:27 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:44:27 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Manivannan Sadhasivam Subject: [PATCH v8 13/16] power: sequencing: pcie-m2: Add usb and sdio targets for E-key connector Date: Fri, 4 Sep 2026 16:41:52 +0800 Message-ID: <20260904084158.1341550-14-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The M.2 E-key connector allows either PCIe or SDIO for WiFi and USB or UART for BT. Currently the driver only supports PCIe and UART. Add power sequencing targets for SDIO and USB. To avoid adding a complicated dependency tree, rename the existing power sequencing units "pcie" and "uart" to "wifi" and "bt". The existing target names are left untouched. The new "sdio" and "usb" targets just point to the renamed "wifi" and "bt" units. The "unit" names are internal to the power sequencing framework, and should be confined to a single provider. The names are only informational. Dependencies are tracked with pointers to other units. The "target" names are the strings that the consumer uses to acquire a descriptor with. As these remain the same, existing users will continue to work. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Chen-Yu Tsai --- Changes since v2: - Expand commit message --- drivers/power/sequencing/pwrseq-pcie-m2.c | 41 +++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequ= encing/pwrseq-pcie-m2.c index 43b2328a6661..987faa9f3b3b 100644 --- a/drivers/power/sequencing/pwrseq-pcie-m2.c +++ b/drivers/power/sequencing/pwrseq-pcie-m2.c @@ -69,46 +69,46 @@ static const struct pwrseq_unit_data *pwrseq_pcie_m2_un= it_deps[] =3D { NULL }; =20 -static int pwrseq_pci_m2_e_uart_enable(struct pwrseq_device *pwrseq) +static int pwrseq_pci_m2_e_bt_enable(struct pwrseq_device *pwrseq) { struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); =20 return gpiod_set_value_cansleep(ctx->w_disable2_gpio, 0); } =20 -static int pwrseq_pci_m2_e_uart_disable(struct pwrseq_device *pwrseq) +static int pwrseq_pci_m2_e_bt_disable(struct pwrseq_device *pwrseq) { struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); =20 return gpiod_set_value_cansleep(ctx->w_disable2_gpio, 1); } =20 -static const struct pwrseq_unit_data pwrseq_pcie_m2_e_uart_unit_data =3D { - .name =3D "uart-enable", +static const struct pwrseq_unit_data pwrseq_pcie_m2_e_bt_unit_data =3D { + .name =3D "bt-enable", .deps =3D pwrseq_pcie_m2_unit_deps, - .enable =3D pwrseq_pci_m2_e_uart_enable, - .disable =3D pwrseq_pci_m2_e_uart_disable, + .enable =3D pwrseq_pci_m2_e_bt_enable, + .disable =3D pwrseq_pci_m2_e_bt_disable, }; =20 -static int pwrseq_pci_m2_e_pcie_enable(struct pwrseq_device *pwrseq) +static int pwrseq_pci_m2_e_wifi_enable(struct pwrseq_device *pwrseq) { struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); =20 return gpiod_set_value_cansleep(ctx->w_disable1_gpio, 0); } =20 -static int pwrseq_pci_m2_e_pcie_disable(struct pwrseq_device *pwrseq) +static int pwrseq_pci_m2_e_wifi_disable(struct pwrseq_device *pwrseq) { struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); =20 return gpiod_set_value_cansleep(ctx->w_disable1_gpio, 1); } =20 -static const struct pwrseq_unit_data pwrseq_pcie_m2_e_pcie_unit_data =3D { - .name =3D "pcie-enable", +static const struct pwrseq_unit_data pwrseq_pcie_m2_e_wifi_unit_data =3D { + .name =3D "wifi-enable", .deps =3D pwrseq_pcie_m2_unit_deps, - .enable =3D pwrseq_pci_m2_e_pcie_enable, - .disable =3D pwrseq_pci_m2_e_pcie_disable, + .enable =3D pwrseq_pci_m2_e_wifi_enable, + .disable =3D pwrseq_pci_m2_e_wifi_disable, }; =20 static const struct pwrseq_unit_data pwrseq_pcie_m2_m_pcie_unit_data =3D { @@ -130,13 +130,24 @@ static int pwrseq_pcie_m2_e_pwup_delay(struct pwrseq_= device *pwrseq) =20 static const struct pwrseq_target_data pwrseq_pcie_m2_e_uart_target_data = =3D { .name =3D "uart", - .unit =3D &pwrseq_pcie_m2_e_uart_unit_data, + .unit =3D &pwrseq_pcie_m2_e_bt_unit_data, .post_enable =3D pwrseq_pcie_m2_e_pwup_delay, }; =20 +static const struct pwrseq_target_data pwrseq_pcie_m2_e_usb_target_data = =3D { + .name =3D "usb", + .unit =3D &pwrseq_pcie_m2_e_bt_unit_data, +}; + static const struct pwrseq_target_data pwrseq_pcie_m2_e_pcie_target_data = =3D { .name =3D "pcie", - .unit =3D &pwrseq_pcie_m2_e_pcie_unit_data, + .unit =3D &pwrseq_pcie_m2_e_wifi_unit_data, + .post_enable =3D pwrseq_pcie_m2_e_pwup_delay, +}; + +static const struct pwrseq_target_data pwrseq_pcie_m2_e_sdio_target_data = =3D { + .name =3D "sdio", + .unit =3D &pwrseq_pcie_m2_e_wifi_unit_data, .post_enable =3D pwrseq_pcie_m2_e_pwup_delay, }; =20 @@ -147,7 +158,9 @@ static const struct pwrseq_target_data pwrseq_pcie_m2_m= _pcie_target_data =3D { =20 static const struct pwrseq_target_data *pwrseq_pcie_m2_e_targets[] =3D { &pwrseq_pcie_m2_e_pcie_target_data, + &pwrseq_pcie_m2_e_sdio_target_data, &pwrseq_pcie_m2_e_uart_target_data, + &pwrseq_pcie_m2_e_usb_target_data, NULL }; =20 --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 0AB9C41D63C for ; Fri, 4 Sep 2026 08:44:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511476; cv=none; b=eKQWAGSlQoUlq2dQeEzSoI/dwQLuXZqb6h3fN6zwHKGeiRP0jPDx+8jHYJJYdp4ISglQcyboLVAU5vf82h4qCg+JnLIyXQ9R2jfpoJuwI1cUv9fUrfmewu2iHl1HvH3jm2B/yFgYZl7BWjQVA11LQCI4lXld60M99Io94o77UAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511476; c=relaxed/simple; bh=iMNgXmNz+LIwXhN5Tpbg3zFAHcxrNG+nhFvPP6LiEEA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PDA/4WHIy/0wxi5N4p6bTASUFIt40//fnUphRiUVyW9QzNyF/zJVDQayHF5DZ2ccez/mq9F9P7HLFav5zAbWajubBbYJlBbavxtLqpfDDngLl4elnKTPf+W2EDDwdKCfUzJQUY0EW1cLm/aNozHbMVrRpu51Ei16qW1I526VHe0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=SM8/8je9; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SM8/8je9" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-38dc4553f62so817874a91.0 for ; Fri, 04 Sep 2026 01:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511473; x=1789116273; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FBs9AvV8VgFuyAyigj5QfCqQvbDEoRbP4Si3r+fhDas=; b=SM8/8je9k5QR752Ca+9eYmAIadauFZkGm2Z8Tj3NOdWja/SrdSazSUtLOw5jTZAlgw WyNxTJacR1mIo+ko5PshEIErmMZW3JG0zQ+bM1FtKgOAumC5NhDPw+BWD+HgWctIhUSi 5G7d7uTvlhFoJVQkIU1sP4jJhg2gOZYYhvOLQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511473; x=1789116273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=FBs9AvV8VgFuyAyigj5QfCqQvbDEoRbP4Si3r+fhDas=; b=TJXDFWed/8HOLVaKkhagKaRQz6xcW7WXzUvb/YJPAFCGCQP07GaDHlCNmIonOaYTnK BFRoS+X1qgQSTI4T6Irod50diwdqQsunVhOlHHntJHtWEPXi7vuSs1FbNFH0B4U0aRab m2Yrt9fhgr0CduzMRgwi77tT4c9kzIR8IN3vACL+YWNIdrfsu++9QQZoo2EXnHZFxQkp TCVjv9EuFP1mPeh8X648luI4ONYyblq7D0y7AUpsMbF8rTmcY7znew3oDeILnOAsQvmp 2ifqfUkZ1YTvMAQhS9qt+1AvBndPa/xJW+MApHUY9VBRuQMBQcQ1pSb60FDqrHm4BvEQ a8yg== X-Forwarded-Encrypted: i=1; AKwUvBxWAD0F44ejFZSlxp1Z3AyK93mlmhhMOn6K7aghLHoXf+Ehifw0l8E1vPPbiTX7vaR6Ww/PdQlHVytEa3o=@vger.kernel.org X-Gm-Message-State: AFuF++kJAbxkZT0kXW76BbcKE/GFwDLjfX07yA6o301eOywg0N3yOQnD p6pD8VVSNCbPb9D/rpAaK0KDyB/s3gJ2O4lu+x5/otAlrni41Dc5i1unZVvqG2BjjQ== X-Gm-Gg: AYBFou0CXPRnHceFf/uR9iobpPpfr2VNyuNgUmh+FQN8ZYWQYVXY4qdQCjRSLpJQ2DL 5dk1KekYev1H6D0YCr+oMZl/dAk3rRxxh2iGa3IiNmUB2PvAQvpaIYeTFNagG6TAfmCYkwrJZSJ vqk/xeIlv48p9kWDAE2QHWpnTAIehWJjhJ0coilOajA2PdbkRzavFejvgnj65kRANCOAKvrzoU5 DGYP7uG/bEAukJuL8odYQAaWVnx6n75cnI00VibGYG6ErxQr4fAm52zNIQYQY+UbQAspAK3k7Pv ncP0DwIrWL7CdPWBWIt9fHKto9Vibfx9YctNIceeLfUSixe4chbnpJpDHKsF0O6MWylZaADJvtM peHd1HWN9c7aMxjv8RMW92odMV3NP4/D6qGQWbX1ees5HQ8YEXqEvnfIPdXgFpR7KAw/n38i7tq zxP28e3exTbPzRWEzOqSTTITL7cfisEUZV9noPvKSpF7ivWGk/lgQARBtfuh9Uzs+BHJtjRUhX6 jTDOlWWYmq1UkwpgkmRJmhttgVHc5AYMNjajeOb5GLlkv2MDdCPYnNg X-Received: by 2002:a17:90a:e18b:b0:398:ab03:95b2 with SMTP id 98e67ed59e1d1-39b26155274mr6523995a91.10.1788511473366; Fri, 04 Sep 2026 01:44:33 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:44:32 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Manivannan Sadhasivam Subject: [PATCH v8 14/16] power: sequencing: pcie-m2: Split Bluetooth unit based on interface Date: Fri, 4 Sep 2026 16:41:53 +0800 Message-ID: <20260904084158.1341550-15-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some UART / serdev based Bluetooth drivers need to be able to reset the hardware during initialization or recovery. This is not possible with the current power sequencing API if a unit is shared between USB and UART interfaces. For now, split the Bluetooth unit into two, one for each interface. This allows either interface to independently toggle the power, with the last action prevailing, thereby unbreaking the Qualcomm Bluetooth serdev driver. This is also needed for the Realtek Bluetooth serdev driver (hci_h5). Having independent control from either interface unfortunately means that userspace is able to shut down the controller from sysfs using the USB port's "disable" setting without the serdev driver knowing about it. On the USB side, independent control is also desired, as it allows the USB core to power cycle the port/device during faults, and for userspace to initiate reset and recovery using the aforementioned "disable" setting. However when USB is used, a serdev device is not created, and there is no conflicting usage, which allows the power sequencing to work even without the split unit. Suggested-by: Wei Deng Reviewed-by: Manivannan Sadhasivam Signed-off-by: Chen-Yu Tsai --- Changes since v4: - New patch This patch is _not_ squashed into the previous to provide clear context on the change, and the less than perfect nature of it. I think what we need in this case is some sort of lockout. The serdev consumer would want "exclusive" access, locking out the USB consumer, which can tolerate "shared" access. Something similar would be needed for the WiFi if we ever add support for SDIO for toggling the state of W_DISABLE#1. At least the SDIO and PCIe reset signals are separate. --- drivers/power/sequencing/pwrseq-pcie-m2.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequ= encing/pwrseq-pcie-m2.c index 987faa9f3b3b..f7bcc8bb4c77 100644 --- a/drivers/power/sequencing/pwrseq-pcie-m2.c +++ b/drivers/power/sequencing/pwrseq-pcie-m2.c @@ -83,8 +83,22 @@ static int pwrseq_pci_m2_e_bt_disable(struct pwrseq_devi= ce *pwrseq) return gpiod_set_value_cansleep(ctx->w_disable2_gpio, 1); } =20 -static const struct pwrseq_unit_data pwrseq_pcie_m2_e_bt_unit_data =3D { - .name =3D "bt-enable", +/* + * XXX There are two Bluetooth units to allow either one to be able to pow= er + * off and thus reset the controller. In practice only one of the interfac= es + * is used, so there is no conflict. However userspace could power off the + * USB unit by disabling the associated USB port, without the UART unit or + * its consumer ever knowing. + */ +static const struct pwrseq_unit_data pwrseq_pcie_m2_e_bt_uart_unit_data = =3D { + .name =3D "bt-uart-enable", + .deps =3D pwrseq_pcie_m2_unit_deps, + .enable =3D pwrseq_pci_m2_e_bt_enable, + .disable =3D pwrseq_pci_m2_e_bt_disable, +}; + +static const struct pwrseq_unit_data pwrseq_pcie_m2_e_bt_usb_unit_data =3D= { + .name =3D "bt-usb-enable", .deps =3D pwrseq_pcie_m2_unit_deps, .enable =3D pwrseq_pci_m2_e_bt_enable, .disable =3D pwrseq_pci_m2_e_bt_disable, @@ -130,13 +144,13 @@ static int pwrseq_pcie_m2_e_pwup_delay(struct pwrseq_= device *pwrseq) =20 static const struct pwrseq_target_data pwrseq_pcie_m2_e_uart_target_data = =3D { .name =3D "uart", - .unit =3D &pwrseq_pcie_m2_e_bt_unit_data, + .unit =3D &pwrseq_pcie_m2_e_bt_uart_unit_data, .post_enable =3D pwrseq_pcie_m2_e_pwup_delay, }; =20 static const struct pwrseq_target_data pwrseq_pcie_m2_e_usb_target_data = =3D { .name =3D "usb", - .unit =3D &pwrseq_pcie_m2_e_bt_unit_data, + .unit =3D &pwrseq_pcie_m2_e_bt_usb_unit_data, }; =20 static const struct pwrseq_target_data pwrseq_pcie_m2_e_pcie_target_data = =3D { --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 3C76E440644 for ; Fri, 4 Sep 2026 08:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511480; cv=none; b=lMCZKVjiOUDD9I2N1bkWQcliUryoWJETvDoCs3BcxisjeEDOib7dXtZmht+Bl3GoDLeI0mThVV61IMlysoNAKAwXRKO4o4yPEVTTXS7zjJuZvW2s/9WFDKvqLuugN0WV/WPF030WdaSNgjdwfCQsONU1YIjA7meF1+5KuKqMVwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511480; c=relaxed/simple; bh=CRlSobqjLvG/xHwYpbxmBUCf/wNp/RdtxeWAo9rwuVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YQxWuFpx4bjsv1tPOKtgk689LVVCp7PbaS7SOBMVavEPhWfYeDHhThaVZKzrrKIM7BrnbCzLyDJtzCi2/tnmpWiZ1/RrdcD4E1ddVNJhdE1SDGfDgpFTD7RnO+dDcpRjP0h+Y6RUh3kYxl7p2Qiz83dow/VL22KMW/8h+0v8DD0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=ejcto05J; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ejcto05J" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-38e42560ebcso632416a91.1 for ; Fri, 04 Sep 2026 01:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511479; x=1789116279; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=u+z8Cwnd44tBSJzkmGNNNosSpCrM38d+qGnlF9iz0lg=; b=ejcto05Jmgp+knRk6VbQ1zifZbTGFi+36PBgB0fQ/sIRv/SxqN5feAPCkr7BE160eI aQKgQxbNj2BigmsBmubn1e+zLpFKbAW6dStb8cVXCVSx34dHPscdzcwlInRWM33fFtmt KP/n2PRb0JTP28N17kcFaTv17F1xtcMGBe5W4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511479; x=1789116279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=u+z8Cwnd44tBSJzkmGNNNosSpCrM38d+qGnlF9iz0lg=; b=KmnZZK4jOoCoDTnlZY8ZStU1hRsd0amN5Bk5GBbAhiVawsw6blKG5bm11cYHZ1o8YV 9dG//f+hxwC96sBaiFy8n0YePrUsirKvs04RGPOlCJ22MGDdU6957IuirlIQDlyzPZ21 SyqF02yg9LeD/e6/ksUNxqjDI07ndRjYoCK8w1/WJiNNEFSKI7kD26pszpP7r1OXK+r2 feYaBSkeP4vB0rMzOF0mxejpox/TnzV4+5o1hRMT1zkwaP8qyl4J95CE4yZbdwXjVvVD bVNk3H9HfzxWc4YLiGljEKm17OCItEs+VjMmkMQn3FctLDvGBLcy3hc5zT7L9AGCdfeI 0FDQ== X-Forwarded-Encrypted: i=1; AKwUvBwQN4/WrPjI8dPSU8xP10d0fHjuUERjO5VNhlvYtPlgdnKsBiSbjBNodYa77xIjlZAIIpDA5czG7tVtMs0=@vger.kernel.org X-Gm-Message-State: AFuF++kxEh6AjIHinOWejyQKTegVsqrnJ/WerKFNPDoaxA03oRhvvd1U IgLOGHkWeD7XcKZgJeNX+bE4CVkrWsFhP/C59QmSnExyGge1cUAEzJ4zKgLKA7lXAg== X-Gm-Gg: AYBFou1epCAnQ14HBGrYy/u4MoKzXz1Gv8xIjtO35NfeSiUGSVFHppLQ+ZXar6eB+dH AMCsazZDjSLSkwRKXvGd2jfhYsA9BAjW2Cy3MLcCC2StvRBKe5Rk5yQ3WaBzUPaa7MvxLusxoI1 S6KmuUQzE1LcIWAaFR031YDa073m74SVtl45d0EsyfSglKol7zQAGctkHX7/+g5/CkH3WJWSGWk s0xEMiYID0d7/tzV4KsV5bMD2Y09uJRAAQ1pgBZwbzeL54/NvwXfZJHUwj15Xhofej5wlpalqDw x6+HWgg2BDZ8+GFDLSlmVvtLErQNNfG1OOsSL4NPLug4NvWq9jdrF85RqXjmHZX45JD66PEI9JC M3ZrXzQTVy9n0w3kCMMJrg7kfwlAaeH4/MPDRrQL5CyRmDwUfo5Zn7uLKooUICVYEkveh3tzM0q ShMQ4cf+UoZ+Fhaa22pKWZlmm5S7C+OPKvfjqyZekv46hkgkaYy0Ajar+ZnWbljQSL1FA4Xn1M/ 7PnblmqM4ODsj0r9OMdZh9UxKOYJ/h9GaC9nALbsqzN X-Received: by 2002:a17:90b:1643:b0:380:21b7:e727 with SMTP id 98e67ed59e1d1-39b26272f04mr6897920a91.14.1788511478517; Fri, 04 Sep 2026 01:44:38 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:44:38 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 15/16] arm64: dts: mediatek: mt8195-cherry: Add M.2 E-key slot Date: Fri, 4 Sep 2026 16:41:54 +0800 Message-ID: <20260904084158.1341550-16-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Mt8195 Cherry design features an M.2 E-key slot for WiFi/BT combo cards. Only PCIe and USB are wired from the SoC to the slot, along with some auxiliary signals. Add the proper representation for it, replacing the PCIe wifi node and vpcie3v3-supply property under the PCIe controller, and the vbus-supply property under the xhci3 node. Reviewed-by: Bartosz Golaszewski Signed-off-by: Chen-Yu Tsai --- Changes since v2: - Drop default GPIO output state from kill pins pinconfig --- .../boot/dts/mediatek/mt8195-cherry.dtsi | 73 +++++++++++++++++-- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/b= oot/dts/mediatek/mt8195-cherry.dtsi index ef7afc436aef..8d4cc30d91e4 100644 --- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi @@ -266,6 +266,47 @@ tboard_thermistor2: thermal-sensor-t2 { 120000 51 125000 44>; }; + + wifi-bt-connector { + compatible =3D "pcie-m2-e-connector"; + pinctrl-names =3D "default"; + pinctrl-0 =3D <&m2_e_key_kill_pins>; + vpcie3v3-supply =3D <&pp3300_wlan>; + w-disable1-gpios =3D <&pio 61 GPIO_ACTIVE_LOW>; + w-disable2-gpios =3D <&pio 59 GPIO_ACTIVE_LOW>; + /* PCIe auxiliary signals wired to controller. */ + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* PCIe for WiFi */ + port@0 { + reg =3D <0>; + #address-cells =3D <1>; + #size-cells =3D <0>; + + wifi_ep: endpoint@0 { + reg =3D <0>; + remote-endpoint =3D <&pcie1_ep>; + }; + }; + + /* USB for Bluetooth */ + port@2 { + reg =3D <2>; + #address-cells =3D <1>; + #size-cells =3D <0>; + + bt_ep: endpoint@0 { + reg =3D <0>; + remote-endpoint =3D <&usb3_ep>; + }; + }; + + /* SDIO, UART and I2S not implemented */ + }; + }; }; =20 &adsp { @@ -791,14 +832,14 @@ pcie@0 { reg =3D <0 0 0 0 0>; device_type =3D "pci"; num-lanes =3D <1>; - vpcie3v3-supply =3D <&pp3300_wlan>; #address-cells =3D <3>; #size-cells =3D <2>; ranges; =20 - wifi@0 { - reg =3D <0 0 0 0 0>; - wakeup-source; + port { + pcie1_ep: endpoint { + remote-endpoint =3D <&wifi_ep>; + }; }; }; }; @@ -1085,6 +1126,13 @@ pins-bus { }; }; =20 + m2_e_key_kill_pins: m2-e-key-kill-pins { + pins-kill { + pinmux =3D , + ; + }; + }; + mmc0_pins_default: mmc0-default-pins { pins-cmd-dat { pinmux =3D , @@ -1637,9 +1685,24 @@ &xhci2 { &xhci3 { /* MT7921's USB Bluetooth has issues with USB2 LPM */ usb2-lpm-disable; - vbus-supply =3D <&pp3300_wlan>; vusb33-supply =3D <&mt6359_vusb_ldo_reg>; status =3D "okay"; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@1 { + reg =3D <1>; + #address-cells =3D <1>; + #size-cells =3D <0>; + + usb3_ep: endpoint@0 { + reg =3D <0>; + remote-endpoint =3D <&bt_ep>; + }; + }; + }; }; =20 #include --=20 2.55.0.979.g7e5102b832-goog From nobody Sat Sep 26 05:34:08 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 4EA3A442FC9 for ; Fri, 4 Sep 2026 08:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511486; cv=none; b=fTqnQZOtE6Mc5WV52jmHwEMxnnHzJuRK2l266+1U5GCIWfgXRMyzJmfYsmtQcFH/Utz5jWu2jqzribAK7arf38rGoBn8BMbhs7PDb51KK50Akfk1GpfJdfMu8B3qpQndB6a87DKM0p3rBTBvVDIWWrCB5IFUTXBZfbxLXbmOs/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788511486; c=relaxed/simple; bh=dBf9woEenUcrdHpAE9+HbQwGhboCEhnqgSoXFFUAH9o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GgxPxou8wAZ4tqZlr3XKg8oh0jKssfVUS630zihBxvq5WwtdusbqucaZTqfddnT2jHtN1nBXAnAABWSqPdSaQ4cCVCMk5PF/ObSph6QqfEyCLKDIiG/MumSJXgXrWdnmY2ZieBVcFRWUhdiTkwgl84TQ5fTEJA00TWUwyXni3gI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=SF5MTBuZ; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SF5MTBuZ" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2d58efc7356so9789975ad.1 for ; Fri, 04 Sep 2026 01:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511484; x=1789116284; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7ZE0hpHw4voLLfSdVdvFiuLaZ8hcT2SD2vYw6zXNC1k=; b=SF5MTBuZWyWtolBU8hwRzQtiqFDWqnIOJbeCm+yn+Qjncv1TdgPXr/ruQVd+QYC32f Avoc1jlnOk16JeS8qRIbVUf4cx4uEwjtFTwtLInB/CV216DTqOFPLYsJ7MXFscn3hpNW bE8I5ZQSwsGXqmnpb8JxpKQp9kKwVy2VKpVNM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511484; x=1789116284; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7ZE0hpHw4voLLfSdVdvFiuLaZ8hcT2SD2vYw6zXNC1k=; b=qh+HxiIECB3bsChDn4Ja+h60qBjPp7BD6zBQzVpK7XhtwGq+n+vJO3n3Av0fDBeQbE 5QUfmMgXUsIfLoAapQN3bQ8ShOPP1wGohqbt3rao200GVromlBaVxtZF33mCcnEeTPST w40e02/RELhWGk3xYLjwGdkrG+S+Cxu3yzeafedlntBEHQFTKL1ijd4QOZtbdGdc25i/ B45/EIHfkNsfQn9xeFFfDPkCxxnJsPajdiw0aTkeWUhfjtYiXcd1AzyBsVoyedUyGSO5 +r1j8gZ19K7m/F/SlOtpvVEluYx8RYfWyIEZxkBZnqTfujz9+USqy2TXuF82tSgKxLZr mQfA== X-Forwarded-Encrypted: i=1; AKwUvBw049j5OIvRxq0U1RRVdTigdNzLepo3y9l9HtWRdx1IMLGQeLJq0lBb/gGjAPR5XpNtsFTIp7bB6oL85rw=@vger.kernel.org X-Gm-Message-State: AFuF++n8RJk9nplqcT/Q5hfWauGLlCkoTlq9yJF4P92NdJYS+08pHMI3 fZrtyucaZKVQqVSwcHkN4hbSkkMIpTN+CYyODOo2MwfrQaJwkf1npAMEgZEVbkQtEw== X-Gm-Gg: AYBFou2QCdPTcfKSUX0HyY3Wg57VbbVbHr61YZhVYSiyvzSjRdfZ6xrYkXOnYbE9/n8 nDuSt/GtNexfKNrRKJSmOEEIlxUByVKx0gH45U1LJG98dRXwxFdw7ASuyzetWkLlqSXjBDIMgzE u93u+dRgr9BfgLpAgX/1PjbSH4qDx6f4vbw/mGkVdlOOmAPli6vV27oRyERxI4Nap7O5U3zRWZG kgHpLeQHWXAFhE97QmJNUzneqE5rKBAM6TG/qxpP0P9+73J3ZZTuIO3XV4OaP8dDi4JvbVWQZb6 ySutY9wFFX194XQpHkk/ZUBC8ipNpvFBTJhzcqPef0x2HnuLAx7J7iCqPjiLrEuJWhV9W6eIN+3 EYjj61m5WTlejjifF4DBT5Or4d5TMiCgyqd1f9mWMAkJQUAmmCldeeqjL1wzxygKwSEUiv5nscf YmEbicYaJkbOgH47hFvY1mAW7MTCXuvCT5IAPjtPL6dtnudpaJ5RHkQCULJP59O6RCjuynd4v0y Qgf7iht5GeS67m3ceIhiFaw8W1vdxiYgIBgIXDR6rsq X-Received: by 2002:a17:90b:1c8b:b0:398:9bd5:490c with SMTP id 98e67ed59e1d1-39b26214502mr5922699a91.19.1788511483659; Fri, 04 Sep 2026 01:44:43 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:44:43 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 16/16] arm64: dts: mediatek: mt8188-geralt: Add WiFi/BT as M.2 E-key slot Date: Fri, 4 Sep 2026 16:41:55 +0800 Message-ID: <20260904084158.1341550-17-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The MT8188 Geralt design features a chip-on-board WiFi/BT solution. This is a M.2 E-key WiFi/BT board layout directly inserted into the mainboard design. The connections to the rest of the board are almost the same as if it were a separate M.2 card. The only addition is the PMU_EN pin on the chip; on M.2 cards this would be tied to the primary power source. Model the chip-on-board WiFi/BT solution as a M.2 E-key slot with PCIe, USB and auxiliary signals. The PMU_EN pin, which enables the internal power controls and regulators, is modeled as a regulator fed by the pp3300_wlan regulator. Since power sequencing is now correctly modeled using the M.2 E-key slot, drop the "regulator-always-on" property one pp3300_wlan regulator. Also drop the comment in xhci2 saying "MT7921's power is controlled by PCIe". Also drop the voltage range on the pp3300_wlan regulator. This "regulator" is just a load switch and does not provide any regulation. Reviewed-by: Bartosz Golaszewski Signed-off-by: Chen-Yu Tsai --- Changes since v2: - Drop default GPIO output state from kill pins pinconfig --- .../boot/dts/mediatek/mt8188-geralt.dtsi | 92 ++++++++++++++++++- 1 file changed, 88 insertions(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8188-geralt.dtsi b/arch/arm64/b= oot/dts/mediatek/mt8188-geralt.dtsi index dee946309121..73b5c0fdeae6 100644 --- a/arch/arm64/boot/dts/mediatek/mt8188-geralt.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8188-geralt.dtsi @@ -88,13 +88,11 @@ pp3300_z1: regulator-pp3300-z1 { pp3300_wlan: regulator-pp3300-wlan { compatible =3D "regulator-fixed"; regulator-name =3D "pp3300_wlan"; - regulator-always-on; - regulator-min-microvolt =3D <3300000>; - regulator-max-microvolt =3D <3300000>; enable-active-high; gpio =3D <&pio 12 GPIO_ACTIVE_HIGH>; pinctrl-0 =3D <&wlan_en>; pinctrl-names =3D "default"; + /* load switch */ vin-supply =3D <&pp3300_z1>; }; =20 @@ -161,6 +159,17 @@ ppvar_mipi_disp_avee: regulator-ppvar-mipi-disp-avee { vin-supply =3D <&pp5000_z1>; }; =20 + /* PMU_EN pin controls internal regulators and power sequence */ + wlan_pmu: regulator-wlan-pmu { + compatible =3D "regulator-fixed"; + regulator-name =3D "wlan-pmu"; + enable-active-high; + gpio =3D <&pio 145 GPIO_ACTIVE_HIGH>; + pinctrl-0 =3D <&wlan_pmu_en>; + pinctrl-names =3D "default"; + vin-supply =3D <&pp3300_wlan>; + }; + reserved_memory: reserved-memory { #address-cells =3D <2>; #size-cells =3D <2>; @@ -195,6 +204,39 @@ adsp_dma_mem: memory@61000000 { no-map; }; }; + + wifi-bt-connector { + compatible =3D "pcie-m2-e-connector"; + pinctrl-names =3D "default"; + pinctrl-0 =3D <&m2_e_key_kill_pins>; + vpcie1v8-supply =3D <&mt6359_vcn18_ldo_reg>; + vpcie3v3-supply =3D <&wlan_pmu>; + w-disable1-gpios =3D <&pio 13 GPIO_ACTIVE_LOW>; + w-disable2-gpios =3D <&pio 14 GPIO_ACTIVE_LOW>; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* PCIe for WiFi */ + port@0 { + reg =3D <0>; + + wifi_ep: endpoint { + remote-endpoint =3D <&pcie_ep>; + }; + }; + + /* USB for Bluetooth */ + port@2 { + reg =3D <2>; + + bt_ep: endpoint { + remote-endpoint =3D <&usb2_ep>; + }; + }; + }; + }; }; =20 &adsp { @@ -659,6 +701,22 @@ &pcie { pinctrl-names =3D "default"; pinctrl-0 =3D <&pcie_pins>; status =3D "okay"; + + pcie@0 { + compatible =3D "pciclass,0604"; + reg =3D <0 0 0 0 0>; + device_type =3D "pci"; + num-lanes =3D <1>; + #address-cells =3D <3>; + #size-cells =3D <2>; + ranges; + + port { + pcie_ep: endpoint { + remote-endpoint =3D <&wifi_ep>; + }; + }; + }; }; =20 &pciephy { @@ -1002,6 +1060,13 @@ pins-bus { }; }; =20 + m2_e_key_kill_pins: m2-e-key-kill-pins { + pins-kill { + pinmux =3D , + ; + }; + }; + mipi_disp_avdd_en: mipi-disp-avdd-en-pins { pins-en-ppvar-mipi-disp { pinmux =3D ; @@ -1174,6 +1239,13 @@ pins-bus { }; }; =20 + wlan_pmu_en: wlan-pmu-en-pins { + pins-wlan-pmu-en { + pinmux =3D ; + output-low; + }; + }; + wlan_en: wlan-en-pins { pins-en-pp3300-wlan { pinmux =3D ; @@ -1417,10 +1489,22 @@ vdosys1_ep_ext: endpoint@1 { }; =20 &xhci2 { - /* no power supply since MT7921's power is controlled by PCIe */ /* MT7921's USB BT has issues with USB2 LPM */ usb2-lpm-disable; status =3D "okay"; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@1 { + reg =3D <1>; + + usb2_ep: endpoint { + remote-endpoint =3D <&bt_ep>; + }; + }; + }; }; =20 #include --=20 2.55.0.979.g7e5102b832-goog