[PATCH v5 6/8] doc: phy: Document some bulk helper functions

From: Inochi Amaoto

Date: Tue Nov 24 2026 - 23:37:43 EST


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 <inochiama@xxxxxxxxx>
---
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..cae3d4700814 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 <phy_set_mode_ext>`, 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.
+Function not upstreamed can be found at https://lore.kernel.org/linux-phy/20260904083709.425893-1-inochiama@xxxxxxxxx/
--
2.56.1