From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B537606A31C for ; Mon, 30 Nov 2026 06:38:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ts09RGwu; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZllbxH/A DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=8nVYNqWkX9B8q1VXFmAqMBglKtn7e9sgPnXzNcnQxKk=; b=ts09RGwuWR4WIT lojatrlohGegp9F2615s0Vag+8sPFblggRLbTYGi/LsviH7tTPCHYj6qDTVbecG7zna5N2u9SDJ8U PPpRlZGlPtNVQn9xAMMn1SFChFDz762TKksOknSawNaVqul9WRCtHfekzPl9OQ6aNMi+2+2jL1hdW lhoAtwLhdjdsoXcpNXy78zKux2Lr+8G2I/Ce6IYtkWzlcARInJ84xXlbYIL25arxbEXkjuRzopH1s dOfLFssXMvozUKDcpC/2Yoz3LATPwaoKerQCpdl1K00szuk9Ykg6nJFePjDJh3rqo3Tqzl2ZZdy3C Yv4UBjtASHnihArU/iRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXv1W-00000003SA3-3jdt; Mon, 30 Nov 2026 06:38:02 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXv0N-00000003RWx-1UE1 for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2026 06:36:52 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-8ca6a12efd9so3703045b3a.1 for ; Sun, 29 Nov 2026 22:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796020610; x=1796625410; darn=lists.infradead.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=8nVYNqWkX9B8q1VXFmAqMBglKtn7e9sgPnXzNcnQxKk=; b=ZllbxH/AC3hr342FRP/VgA33rSn0hj665k1xD70EUUiFBfzqLCosm2BbM1X/SGV1/K 8+kyz5N28OTi1LF+kKn+KHtQg3yNAONwUByUkiDtrJIuDDb1ZyP9jMKXko++/MlUhCpT Cz5aK+1X0HFGw76GgTKAxf/G9HsDE5oknCBZCXwiKlI7y34zKjsL4DZ8Cu7WoUtPMO6k qMXx1qQaMoEeJAN09iHqlZ0bsjyHxabNQQbjzjYtkI732kReSE2q5G5eMf6IrwqV7Lpu pbWZkhbMzaXhkUYW6gOTEjEs+lOBj8UfZQ/yIP19IN0l0UWq/DtaZ5ZIiCaafjYRu7f1 NxSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796020610; x=1796625410; 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=8nVYNqWkX9B8q1VXFmAqMBglKtn7e9sgPnXzNcnQxKk=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Ydk3AsNiw6rQUH248mc4MONqD8Wi+SfSOOPuPGi4YgcEeQTTPc83iDq/0Egy+ xFPUNMdytICncWk/Uo6OD8zlgXkWsnPGTYEwmYNqbIxwR5ULwnFlGmDvPrJAiJqye/JduoNpxo5 61VUN2l334eKO/JLWNNFu7SqUik= X-Received: by 2002:a05:6a00:f8a:b0:8a0:20e0:b11f with SMTP id d2e1a72fcca58-8c87bac549fmr26142333b3a.20.1796020610400; Sun, 29 Nov 2026 22:36:50 -0800 (PST) Received: from localhost ([2001:19f0:8000:4ce8:5400:7ff:fe0e:e6b2]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8d3ba36fb92sm4371208b3a.46.2026.11.29.22.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 22:36:50 -0800 (PST) From: Inochi Amaoto To: Andy Shevchenko , Jonathan Corbet , Shuah Khan , Randy Dunlap , Damien Le Moal , Niklas Cassel , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Aksh Garg , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Vinod Koul , Neil Armstrong , Vladimir Oltean , Rhys Tumelty , Inochi Amaoto , Qiang Yu , Manikandan K Pillai , "vladimir.oltean@nxp.com" , Hans Zhang <18255117159@163.com>, Yao Zi Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-phy@lists.infradead.org, Yixun Lan , Longbin Li Subject: [PATCH v6 6/8] doc: phy: Document some bulk helper functions Date: Mon, 30 Nov 2026 14:36:05 +0800 Message-ID: <20261130063607.294823-7-inochiama@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130063607.294823-1-inochiama@gmail.com> References: <20261130063607.294823-1-inochiama@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261129_223651_411640_997FD741 X-CRM114-Status: GOOD ( 21.38 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Document all newly added bulk helper function, it can be used to manage a set of PHYs automatically. This is useful when the driver want to simplify the management of multiple PHYs. Signed-off-by: Inochi Amaoto Reviewed-by: Vladimir Oltean --- Documentation/driver-api/phy/phy.rst | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Documentation/driver-api/phy/phy.rst b/Documentation/driver-api/phy/phy.rst index 0865c2e94eec..512bf8bc7471 100644 --- a/Documentation/driver-api/phy/phy.rst +++ b/Documentation/driver-api/phy/phy.rst @@ -114,6 +114,12 @@ it. This framework provides the following APIs to get a reference to the PHY. struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, int index); + int devm_phy_bulk_get(struct device *dev, int num_phys, + struct phy_bulk_data *phys); + int devm_phy_bulk_get_all(struct device *dev, + struct phy_bulk_data **phys); + int devm_of_phy_bulk_get_all(struct device *dev, struct device_node *np, + struct phy_bulk_data **phys); phy_get, devm_phy_get and devm_phy_optional_get can be used to get the PHY. In the case of dt boot, the string arguments @@ -129,6 +135,21 @@ Some generic drivers, such as ehci, may use multiple phys. In this case, devm_of_phy_get or devm_of_phy_get_by_index can be used to get a phy reference based on name or index. +The bulk helpers are useful when a controller operates several PHYs together, +for example the lanes of a single PCIe port. To get a set of PHYs by name, +the driver supplies an array of ``struct phy_bulk_data`` with the ``id`` of +each entry set to the corresponding PHY name. devm_phy_bulk_get() returns +zero if it obtains all the requested PHYs or a negative error code on failure. +The driver owns the array and keeps it valid until driver detach, when the +PHY references are released. + +When a controller needs every PHY listed in a device node's ``phys`` property, +devm_phy_bulk_get_all() obtains them from the controller's device node. +devm_of_phy_bulk_get_all() does the same for an explicitly supplied device +node. These functions return the number of PHYs listed in the node, which may +be zero, or a negative error code on failure. They store the allocated array +in ``*phys`` only when the return value is positive. + It should be noted that NULL is a valid phy reference. All phy consumer calls on the NULL phy become NOPs. That is the release calls, the phy_init() and phy_exit() calls, and phy_power_on() and @@ -149,6 +170,14 @@ The general order of calls should be:: phy_exit() [[of_]phy_put()] +After acquiring a set of PHYs with a bulk helper, the order is:: + + phy_bulk_init() + phy_bulk_power_on() + ... + phy_bulk_power_off() + phy_bulk_exit() + Some PHY drivers may not implement :c:func:`phy_init` or :c:func:`phy_power_on`, but controllers should always call these functions to be compatible with other PHYs. Some PHYs may require :c:func:`phy_set_mode `, while @@ -172,6 +201,12 @@ PHY framework provides 2 APIs to release a reference to the PHY. Both these APIs are used to release a reference to the PHY and devm_phy_put destroys the devres associated with this PHY. +For devm_phy_bulk_get_all() and devm_of_phy_bulk_get_all(), driver detach +releases both the PHY references and the allocated array. To release them +earlier, use:: + + void devm_phy_bulk_put_all(struct device *dev, struct phy_bulk_data *phy); + Destroying the PHY ================== @@ -221,3 +256,8 @@ DeviceTree Binding The documentation for PHY dt binding can be found @ Documentation/devicetree/bindings/phy/phy-bindings.txt + +Missing Bulk Helpers +==================== +Currently, only a few bulk helper functions are added as they have users. +Functions not upstreamed can be found at https://lore.kernel.org/linux-phy/20260904083709.425893-1-inochiama@gmail.com/ -- 2.56.1