Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796020611; b=gLk7mNzR5lvgxTByguw9PxlM03Foo9s/vkDHbWXhlbAOQbUJxxl8MaSAE/8b0EmSaFDS eMgfbj7z1GN01H06dFqep76swE5h7QC4+wb7HsQjMOlb/hmcspJHgbw4V37B/2qh1C0Ce T6vSHveXyNriS+KY5Nll/grVYDsUZYF8gRISATSaoO1oB6jt+YLH13xPlYtl7EgeWXCRX vrHGFdbmKLCKnbDdiG5M6t1Lmc8Kl4hWT9ayNkx8eU8eD+u6gBwWqU5+ecw83HDgMgvFm acNP/8qabLJTGUD1Cka2THCcbfexw7WG+Hfcumr5qaq+++cw1DINzImTSZ1gKCB/LkQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020611; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=8nVYNqWkX9B8q1VXFmAqMBglKtn7e9sgPnXzNcnQxKk=; b=zLUj0bOAezfgjTrOFVpmky5vN+7bIw/+PAREDwk0dv9NUMgahuTNcJ5mO9kRPhjGB6ZH j66nGnTciRAK5jtjhI2uYlaGDK07djDUy4/QpWDQLJj6I5sVy7uM7TZtcVEo825FtaGUx h9eEuupjRH38Acwbu763ntb2t3GmaOswD6cc9pLyecZYYRCgR7+xEwrK1OxGgLke0dA6R LrSlZ+6YLTWGY4uUbvw5VHOkGvhenJ5wdtaHRVm4O9Pu/OAONIuyjIyZnSdPRx5OCfcN9 K4Kq5lkA2oDeFvGb/Q4BUj2z65ghgaqF6+pB8Ki9R4OxGIfREB9tf8OFFGxr+/Ss/lQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=t3e5WXRi; arc=none smtp.remote-ip=209.85.210.170 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24ABC606A325 for ; Mon, 30 Nov 2026 06:36:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 24ABC606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=t3e5WXRi Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8a06e79e152so4794055b3a.0 for ; Sun, 29 Nov 2026 22:36:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796020610; x=1796625410; darn=lists.linux.dev; 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=t3e5WXRiEOwZPnXpZgadDSwX40iTdv2oO6Iqb+8jir8WzEYScz6aLqDSAVn5H4/2/N BKv5amFJorYsn+yil2Wv1p4M0XJ+pIWsVHlEik5usV9pPKmw+/rugVO2vSio7wFrc0Kf E1FW9OngJdDs9mLqAKvn1GiC27Fc83oyMVvdWIqUUIAaqbmCtS3/sfVXyO+km42ObKWM z9FR81tEyE8dPRg7OCXmtCp+d+StX7OOE1cFgUQEIcJ872R6O6NjdbwhQFUghhlM0SS/ 3qzufoYSqZrpsXxtHO0U+UJfb7f5eVg/qGp2Xo+qRG7+fIfROHVdF78qd2Rq/rRWQQOp 0ZRQ== 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=; b=hRLn/l27F4SCsHKB5Yk5Jzx5OE6ZuNmyKFzogZoaKFu4Hjo/LJ7AWVxm61eZy5gQ2/ oDNpPPNqdWGexjRzfDRs4fgIUI+Oba9oKsVvCZVysK5B2HDSBJK5M4rODC7WZbw0A6SY U1XYn+XC1OFhoRErg+9dyTn4iAr5KMFYrFH+ChLKuu+GVWPxkiBNxeQ62Tw9TvyGl5qk WR1gNLHRk3N/bC54Nt65mOQpxaoy/D+UweTi96s9CJPCItO1hQRpY5NkOhn6h6241tdW Efd5H6DeFPXn+9TACIg27hvz7JsX2F9leeaU8L8o7uJhf77bcw2rzSOaE6utsIU7etSL 1RPA== X-Forwarded-Encrypted: i=1; AL+hErFrU67GGsT6Qy2BrpZM4XX4mKJe/9xVlCk73A5ejJioHtNKH+bCAKjWHyNNU59SZzXJ/Ss=@lists.linux.dev X-Gm-Message-State: APuU4Z9c/GVRr4nslb1gEJIurAoYEoofuBGUWTa7alscIZ+ZCaYuAs6B 3HWy31zqWMJJVwcPgtdgD5JycOUXo1S8q2A8o3brcQiA6PtQ+pQ+fk7z X-Gm-Gg: AZFdTZdaks5APmIxOyT4P/fO4M9QzsRQjvlDdbZYyCGkg8nUg3CazRUrClw5A/GL00f s2QBBYCosQVtFHBqAL5AA/sIcbuJ1ZXFkAErxy0CUn8OIC2PO2EE3iN3TOwbZBm4BrVKhajHIAw 1CUDyZ18/bjvLvdYYJLPWSckCYJQBi7VGHwAvcstGnaVBjseYQk21f/nGWFMJ9beIEduldkIMoO qgk6Ql5xuXrKlRsaoSxsYFynXizzdSZzWWY2411xgRSWz3PQ/Oq+HrxWuEtxyTPP/cgnjq28AqV Spf+/z4rYMxudUxJ+KAn+fHHoOKwwnzws2q6Gf3gvf4AF94BHz/jYp1s03xXfBgSfH85AK5LkJN uRKMg5+9JogDXPuAnECtjBqQW4MNaWUZ5STZlnsHuK6/G6hg6vLTuTOf5e8/vhSqVlLaURkE+3s dST0zNOCebB5jZ6mQj+KtUYjhSqPQvRNR+U5rw2UmJAEy3kusHXsCu+9xUIYYadouPsHh7fCHfW aBbKvl0QvYgexPZ7GLZThLPYAQexjrKmP99mqTvH3DxsCS4UpNsZC8XYfws/FcDHBapYQybT/X/ GZaZfjJv5tND7kewk4zuaW8gD9U= 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-Mailing-List: imx@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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