summaryrefslogtreecommitdiff
path: root/drivers/phy
diff options
context:
space:
mode:
authorPeter Griffin <peter.griffin@linaro.org>2025-11-12 19:27:06 +0300
committerVinod Koul <vkoul@kernel.org>2025-11-18 19:56:02 +0300
commit4edf654be5471659e3260be0a557eaa2ece668ab (patch)
tree32c14ab3fc9bcae5dbb5a1559379de2f743cba09 /drivers/phy
parent42690b8ec861b502538e425c5a7feb7a38764f04 (diff)
downloadlinux-4edf654be5471659e3260be0a557eaa2ece668ab.tar.xz
phy: add new phy_notify_state() api
Add a new phy_notify_state() api that notifies and configures a phy for a given state transition. This is intended to be used by phy drivers which need to do some runtime configuration of parameters that can't be handled by phy_calibrate() or phy_power_{on|off}(). The first usage of this API is in the Samsung UFS phy that needs to issue some register writes when entering and exiting the hibernate link state. Signed-off-by: Peter Griffin <peter.griffin@linaro.org> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patch.msgid.link/20251112-phy-notify-pmstate-v5-1-39df622d8fcb@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/phy')
-rw-r--r--drivers/phy/phy-core.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 04a5a34e7a95..60be8af984bf 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -521,6 +521,31 @@ int phy_notify_disconnect(struct phy *phy, int port)
EXPORT_SYMBOL_GPL(phy_notify_disconnect);
/**
+ * phy_notify_state() - phy state notification
+ * @phy: the PHY returned by phy_get()
+ * @state: the PHY state
+ *
+ * Notify the PHY of a state transition. Used to notify and
+ * configure the PHY accordingly.
+ *
+ * Returns: %0 if successful, a negative error code otherwise
+ */
+int phy_notify_state(struct phy *phy, union phy_notify state)
+{
+ int ret;
+
+ if (!phy || !phy->ops->notify_phystate)
+ return 0;
+
+ mutex_lock(&phy->mutex);
+ ret = phy->ops->notify_phystate(phy, state);
+ mutex_unlock(&phy->mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(phy_notify_state);
+
+/**
* phy_configure() - Changes the phy parameters
* @phy: the phy returned by phy_get()
* @opts: New configuration to apply