* [PATCH v3 0/2] Add new phy_notify_state() api
@ 2025-08-13 15:00 Peter Griffin
2025-08-13 15:00 ` [PATCH v3 1/2] phy: add " Peter Griffin
2025-08-13 15:00 ` [PATCH v3 2/2] phy: samsung: gs101-ufs: Add .notify_phystate() & hibern8 enter/exit values Peter Griffin
0 siblings, 2 replies; 5+ messages in thread
From: Peter Griffin @ 2025-08-13 15:00 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, André Draszik,
Tudor Ambarus, Alim Akhtar, Krzysztof Kozlowski
Cc: linux-phy, linux-kernel, linux-arm-kernel, linux-samsung-soc,
kernel-team, William Mcvicker, Manivannan Sadhasivam,
neil.armstrong, Peter Griffin
This series adds a new phy_notify_state() API to the phy subsystem. It is
designed to be used when some specific runtime configuration parameters
need to be changed when transitioning to the desired state which can't be
handled by phy_calibrate()or phy_power_{on|off}().
The first user of the new API is phy-samsung-ufs and phy-gs101-ufs which
need to issue some register writes when entering and exiting the hibern8
link state.
A separate patch will be sent for ufs-exynos driver to make use of this new
API in the hibern8 callbacks.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
Changes in v3:
- Rename API to phy_notify_state(). (Mani/Neil)
- Remove inline kerneldoc comment (Mani)
- s/phy/PHY (Mani)
- peripheral specific enums in phy.h (Vinod)
- Link to v2: https://lore.kernel.org/r/20250703-phy-notify-pmstate-v2-0-fc1690439117@linaro.org
Changes in v2:
- Add new phy_notify_pmstate API() instead of using phy_set_mode() (Vinod)
- Link to v1: https://lore.kernel.org/r/20241002201555.3332138-1-peter.griffin@linaro.org
---
Peter Griffin (2):
phy: add new phy_notify_state() api
phy: samsung: gs101-ufs: Add .notify_phystate() & hibern8 enter/exit values
drivers/phy/phy-core.c | 25 +++++++++++++++++++++++
drivers/phy/samsung/phy-gs101-ufs.c | 28 ++++++++++++++++++++++++++
drivers/phy/samsung/phy-samsung-ufs.c | 38 +++++++++++++++++++++++++++++++++++
drivers/phy/samsung/phy-samsung-ufs.h | 7 +++++++
include/linux/phy/phy.h | 19 ++++++++++++++++++
5 files changed, 117 insertions(+)
---
base-commit: 43c3c17f0c805882d1b48818b1085747a68c80ec
change-id: 20250703-phy-notify-pmstate-f02ba5582f65
Best regards,
--
Peter Griffin <peter.griffin@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/2] phy: add new phy_notify_state() api
2025-08-13 15:00 [PATCH v3 0/2] Add new phy_notify_state() api Peter Griffin
@ 2025-08-13 15:00 ` Peter Griffin
2025-08-20 16:34 ` Vinod Koul
2025-08-13 15:00 ` [PATCH v3 2/2] phy: samsung: gs101-ufs: Add .notify_phystate() & hibern8 enter/exit values Peter Griffin
1 sibling, 1 reply; 5+ messages in thread
From: Peter Griffin @ 2025-08-13 15:00 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, André Draszik,
Tudor Ambarus, Alim Akhtar, Krzysztof Kozlowski
Cc: linux-phy, linux-kernel, linux-arm-kernel, linux-samsung-soc,
kernel-team, William Mcvicker, Manivannan Sadhasivam,
neil.armstrong, Peter Griffin
Add a new phy_notify_state() api that notifies and configures a phy for a
given state transition.
This is intended to be 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>
---
drivers/phy/phy-core.c | 25 +++++++++++++++++++++++++
include/linux/phy/phy.h | 19 +++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 04a5a34e7a950ae94fae915673c25d476fc071c1..60be8af984bf06649ef00e695d0ed4ced597cdb9 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -520,6 +520,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()
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 13add0c2c40721fe9ca3f0350d13c035cd25af45..664d0864c3a5042949cb121e982368fe0a97827f 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -53,6 +53,15 @@ enum phy_media {
PHY_MEDIA_DAC,
};
+enum phy_ufs_state {
+ PHY_UFS_HIBERN8_ENTER,
+ PHY_UFS_HIBERN8_EXIT,
+};
+
+union phy_notify {
+ enum phy_ufs_state ufs_state;
+};
+
/**
* union phy_configure_opts - Opaque generic phy configuration
*
@@ -83,6 +92,7 @@ union phy_configure_opts {
* @set_speed: set the speed of the phy (optional)
* @reset: resetting the phy
* @calibrate: calibrate the phy
+ * @notify_phystate: notify and configure the phy for a particular state
* @release: ops to be performed while the consumer relinquishes the PHY
* @owner: the module owner containing the ops
*/
@@ -132,6 +142,7 @@ struct phy_ops {
int (*connect)(struct phy *phy, int port);
int (*disconnect)(struct phy *phy, int port);
+ int (*notify_phystate)(struct phy *phy, union phy_notify state);
void (*release)(struct phy *phy);
struct module *owner;
};
@@ -255,6 +266,7 @@ int phy_reset(struct phy *phy);
int phy_calibrate(struct phy *phy);
int phy_notify_connect(struct phy *phy, int port);
int phy_notify_disconnect(struct phy *phy, int port);
+int phy_notify_state(struct phy *phy, union phy_notify state);
static inline int phy_get_bus_width(struct phy *phy)
{
return phy->attrs.bus_width;
@@ -412,6 +424,13 @@ static inline int phy_notify_disconnect(struct phy *phy, int index)
return -ENOSYS;
}
+static inline int phy_notify_phystate(struct phy *phy, union phy_notify state)
+{
+ if (!phy)
+ return 0;
+ return -ENOSYS;
+}
+
static inline int phy_configure(struct phy *phy,
union phy_configure_opts *opts)
{
--
2.51.0.rc0.205.g4a044479a3-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] phy: samsung: gs101-ufs: Add .notify_phystate() & hibern8 enter/exit values
2025-08-13 15:00 [PATCH v3 0/2] Add new phy_notify_state() api Peter Griffin
2025-08-13 15:00 ` [PATCH v3 1/2] phy: add " Peter Griffin
@ 2025-08-13 15:00 ` Peter Griffin
2025-08-14 8:15 ` kernel test robot
1 sibling, 1 reply; 5+ messages in thread
From: Peter Griffin @ 2025-08-13 15:00 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, André Draszik,
Tudor Ambarus, Alim Akhtar, Krzysztof Kozlowski
Cc: linux-phy, linux-kernel, linux-arm-kernel, linux-samsung-soc,
kernel-team, William Mcvicker, Manivannan Sadhasivam,
neil.armstrong, Peter Griffin
Implement the .notify_phystate() callback and provide the gs101 specific
phy values that need to be programmed when entering and exiting the hibern8
state.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/phy/samsung/phy-gs101-ufs.c | 28 ++++++++++++++++++++++++++
drivers/phy/samsung/phy-samsung-ufs.c | 38 +++++++++++++++++++++++++++++++++++
drivers/phy/samsung/phy-samsung-ufs.h | 7 +++++++
3 files changed, 73 insertions(+)
diff --git a/drivers/phy/samsung/phy-gs101-ufs.c b/drivers/phy/samsung/phy-gs101-ufs.c
index 17b798da5b5761f8e367599517d2d97bf0bb6b74..a15e1f453f7f3cecd6d3aa75217633ac4b6085d0 100644
--- a/drivers/phy/samsung/phy-gs101-ufs.c
+++ b/drivers/phy/samsung/phy-gs101-ufs.c
@@ -108,12 +108,39 @@ static const struct samsung_ufs_phy_cfg tensor_gs101_post_pwr_hs_config[] = {
END_UFS_PHY_CFG,
};
+static const struct samsung_ufs_phy_cfg tensor_gs101_post_h8_enter[] = {
+ PHY_TRSV_REG_CFG_GS101(0x262, 0x08, PWR_MODE_ANY),
+ PHY_TRSV_REG_CFG_GS101(0x265, 0x0A, PWR_MODE_ANY),
+ PHY_COMN_REG_CFG(0x1, 0x8, PWR_MODE_ANY),
+ PHY_COMN_REG_CFG(0x0, 0x86, PWR_MODE_ANY),
+ PHY_COMN_REG_CFG(0x8, 0x60, PWR_MODE_HS_ANY),
+ PHY_TRSV_REG_CFG_GS101(0x222, 0x08, PWR_MODE_HS_ANY),
+ PHY_TRSV_REG_CFG_GS101(0x246, 0x01, PWR_MODE_HS_ANY),
+ END_UFS_PHY_CFG,
+};
+
+static const struct samsung_ufs_phy_cfg tensor_gs101_pre_h8_exit[] = {
+ PHY_COMN_REG_CFG(0x0, 0xC6, PWR_MODE_ANY),
+ PHY_COMN_REG_CFG(0x1, 0x0C, PWR_MODE_ANY),
+ PHY_TRSV_REG_CFG_GS101(0x262, 0x00, PWR_MODE_ANY),
+ PHY_TRSV_REG_CFG_GS101(0x265, 0x00, PWR_MODE_ANY),
+ PHY_COMN_REG_CFG(0x8, 0xE0, PWR_MODE_HS_ANY),
+ PHY_TRSV_REG_CFG_GS101(0x246, 0x03, PWR_MODE_HS_ANY),
+ PHY_TRSV_REG_CFG_GS101(0x222, 0x18, PWR_MODE_HS_ANY),
+ END_UFS_PHY_CFG,
+};
+
static const struct samsung_ufs_phy_cfg *tensor_gs101_ufs_phy_cfgs[CFG_TAG_MAX] = {
[CFG_PRE_INIT] = tensor_gs101_pre_init_cfg,
[CFG_PRE_PWR_HS] = tensor_gs101_pre_pwr_hs_config,
[CFG_POST_PWR_HS] = tensor_gs101_post_pwr_hs_config,
};
+static const struct samsung_ufs_phy_cfg *tensor_gs101_hibern8_cfgs[] = {
+ [CFG_POST_HIBERN8_ENTER] = tensor_gs101_post_h8_enter,
+ [CFG_PRE_HIBERN8_EXIT] = tensor_gs101_pre_h8_exit,
+};
+
static const char * const tensor_gs101_ufs_phy_clks[] = {
"ref_clk",
};
@@ -170,6 +197,7 @@ static int gs101_phy_wait_for_cdr_lock(struct phy *phy, u8 lane)
const struct samsung_ufs_phy_drvdata tensor_gs101_ufs_phy = {
.cfgs = tensor_gs101_ufs_phy_cfgs,
+ .cfgs_hibern8 = tensor_gs101_hibern8_cfgs,
.isol = {
.offset = TENSOR_GS101_PHY_CTRL,
.mask = TENSOR_GS101_PHY_CTRL_MASK,
diff --git a/drivers/phy/samsung/phy-samsung-ufs.c b/drivers/phy/samsung/phy-samsung-ufs.c
index f3cbe6b17b235bb181b3fae628d75822f0c9183a..192ea408f787bb31912a2c7dd90cc1b61c4237c4 100644
--- a/drivers/phy/samsung/phy-samsung-ufs.c
+++ b/drivers/phy/samsung/phy-samsung-ufs.c
@@ -217,6 +217,42 @@ static int samsung_ufs_phy_set_mode(struct phy *generic_phy,
return 0;
}
+static int samsung_ufs_phy_notify_state(struct phy *phy,
+ union phy_notify state)
+{
+ struct samsung_ufs_phy *ufs_phy = get_samsung_ufs_phy(phy);
+ const struct samsung_ufs_phy_cfg *cfg;
+ int i, err;
+
+ if (!ufs_phy->cfgs_hibern8)
+ return 0;
+
+ if (state.ufs_state == PHY_UFS_HIBERN8_ENTER)
+ cfg = ufs_phy->cfgs_hibern8[CFG_POST_HIBERN8_ENTER];
+ else if (state.ufs_state == PHY_UFS_HIBERN8_EXIT)
+ cfg = ufs_phy->cfgs_hibern8[CFG_PRE_HIBERN8_EXIT];
+
+ for_each_phy_cfg(cfg) {
+ for_each_phy_lane(ufs_phy, i) {
+ samsung_ufs_phy_config(ufs_phy, cfg, i);
+ }
+ }
+
+ if (state.ufs_state == PHY_UFS_HIBERN8_EXIT) {
+ for_each_phy_lane(ufs_phy, i) {
+ if (ufs_phy->drvdata->wait_for_cdr) {
+ err = ufs_phy->drvdata->wait_for_cdr(phy, i);
+ if (err)
+ goto err_out;
+ }
+ }
+ }
+
+ return 0;
+err_out:
+ return err;
+}
+
static int samsung_ufs_phy_exit(struct phy *phy)
{
struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy);
@@ -233,6 +269,7 @@ static const struct phy_ops samsung_ufs_phy_ops = {
.power_off = samsung_ufs_phy_power_off,
.calibrate = samsung_ufs_phy_calibrate,
.set_mode = samsung_ufs_phy_set_mode,
+ .notify_phystate = samsung_ufs_phy_notify_state,
.owner = THIS_MODULE,
};
@@ -287,6 +324,7 @@ static int samsung_ufs_phy_probe(struct platform_device *pdev)
phy->dev = dev;
phy->drvdata = drvdata;
phy->cfgs = drvdata->cfgs;
+ phy->cfgs_hibern8 = drvdata->cfgs_hibern8;
memcpy(&phy->isol, &drvdata->isol, sizeof(phy->isol));
if (!of_property_read_u32_index(dev->of_node, "samsung,pmu-syscon", 1,
diff --git a/drivers/phy/samsung/phy-samsung-ufs.h b/drivers/phy/samsung/phy-samsung-ufs.h
index a28f148081d168344b47f2798b00cb098f0a8574..f2c2e744e5bae87c9cfcaa17f4a09456f134966a 100644
--- a/drivers/phy/samsung/phy-samsung-ufs.h
+++ b/drivers/phy/samsung/phy-samsung-ufs.h
@@ -92,6 +92,11 @@ enum {
CFG_TAG_MAX,
};
+enum {
+ CFG_POST_HIBERN8_ENTER,
+ CFG_PRE_HIBERN8_EXIT,
+};
+
struct samsung_ufs_phy_cfg {
u32 off_0;
u32 off_1;
@@ -108,6 +113,7 @@ struct samsung_ufs_phy_pmu_isol {
struct samsung_ufs_phy_drvdata {
const struct samsung_ufs_phy_cfg **cfgs;
+ const struct samsung_ufs_phy_cfg **cfgs_hibern8;
struct samsung_ufs_phy_pmu_isol isol;
const char * const *clk_list;
int num_clks;
@@ -124,6 +130,7 @@ struct samsung_ufs_phy {
struct clk_bulk_data *clks;
const struct samsung_ufs_phy_drvdata *drvdata;
const struct samsung_ufs_phy_cfg * const *cfgs;
+ const struct samsung_ufs_phy_cfg * const *cfgs_hibern8;
struct samsung_ufs_phy_pmu_isol isol;
u8 lane_cnt;
int ufs_phy_state;
--
2.51.0.rc0.205.g4a044479a3-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 2/2] phy: samsung: gs101-ufs: Add .notify_phystate() & hibern8 enter/exit values
2025-08-13 15:00 ` [PATCH v3 2/2] phy: samsung: gs101-ufs: Add .notify_phystate() & hibern8 enter/exit values Peter Griffin
@ 2025-08-14 8:15 ` kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-08-14 8:15 UTC (permalink / raw)
To: Peter Griffin, Vinod Koul, Kishon Vijay Abraham I,
André Draszik, Tudor Ambarus, Alim Akhtar,
Krzysztof Kozlowski
Cc: llvm, oe-kbuild-all, linux-phy, linux-kernel, linux-arm-kernel,
linux-samsung-soc, kernel-team, William Mcvicker,
Manivannan Sadhasivam, neil.armstrong, Peter Griffin
Hi Peter,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 43c3c17f0c805882d1b48818b1085747a68c80ec]
url: https://github.com/intel-lab-lkp/linux/commits/Peter-Griffin/phy-add-new-phy_notify_state-api/20250813-231312
base: 43c3c17f0c805882d1b48818b1085747a68c80ec
patch link: https://lore.kernel.org/r/20250813-phy-notify-pmstate-v3-2-3bda59055dd3%40linaro.org
patch subject: [PATCH v3 2/2] phy: samsung: gs101-ufs: Add .notify_phystate() & hibern8 enter/exit values
config: arm-randconfig-001-20250814 (https://download.01.org/0day-ci/archive/20250814/202508141555.NJvU2oYQ-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 3769ce013be2879bf0b329c14a16f5cb766f26ce)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250814/202508141555.NJvU2oYQ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202508141555.NJvU2oYQ-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/phy/samsung/phy-samsung-ufs.c:232:11: warning: variable 'cfg' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
232 | else if (state.ufs_state == PHY_UFS_HIBERN8_EXIT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/phy/samsung/phy-samsung-ufs.c:235:19: note: uninitialized use occurs here
235 | for_each_phy_cfg(cfg) {
| ^~~
drivers/phy/samsung/phy-samsung-ufs.c:232:7: note: remove the 'if' if its condition is always true
232 | else if (state.ufs_state == PHY_UFS_HIBERN8_EXIT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233 | cfg = ufs_phy->cfgs_hibern8[CFG_PRE_HIBERN8_EXIT];
drivers/phy/samsung/phy-samsung-ufs.c:224:39: note: initialize the variable 'cfg' to silence this warning
224 | const struct samsung_ufs_phy_cfg *cfg;
| ^
| = NULL
1 warning generated.
vim +232 drivers/phy/samsung/phy-samsung-ufs.c
219
220 static int samsung_ufs_phy_notify_state(struct phy *phy,
221 union phy_notify state)
222 {
223 struct samsung_ufs_phy *ufs_phy = get_samsung_ufs_phy(phy);
224 const struct samsung_ufs_phy_cfg *cfg;
225 int i, err;
226
227 if (!ufs_phy->cfgs_hibern8)
228 return 0;
229
230 if (state.ufs_state == PHY_UFS_HIBERN8_ENTER)
231 cfg = ufs_phy->cfgs_hibern8[CFG_POST_HIBERN8_ENTER];
> 232 else if (state.ufs_state == PHY_UFS_HIBERN8_EXIT)
233 cfg = ufs_phy->cfgs_hibern8[CFG_PRE_HIBERN8_EXIT];
234
235 for_each_phy_cfg(cfg) {
236 for_each_phy_lane(ufs_phy, i) {
237 samsung_ufs_phy_config(ufs_phy, cfg, i);
238 }
239 }
240
241 if (state.ufs_state == PHY_UFS_HIBERN8_EXIT) {
242 for_each_phy_lane(ufs_phy, i) {
243 if (ufs_phy->drvdata->wait_for_cdr) {
244 err = ufs_phy->drvdata->wait_for_cdr(phy, i);
245 if (err)
246 goto err_out;
247 }
248 }
249 }
250
251 return 0;
252 err_out:
253 return err;
254 }
255
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] phy: add new phy_notify_state() api
2025-08-13 15:00 ` [PATCH v3 1/2] phy: add " Peter Griffin
@ 2025-08-20 16:34 ` Vinod Koul
0 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2025-08-20 16:34 UTC (permalink / raw)
To: Peter Griffin
Cc: Kishon Vijay Abraham I, André Draszik, Tudor Ambarus,
Alim Akhtar, Krzysztof Kozlowski, linux-phy, linux-kernel,
linux-arm-kernel, linux-samsung-soc, kernel-team,
William Mcvicker, Manivannan Sadhasivam, neil.armstrong
On 13-08-25, 16:00, Peter Griffin wrote:
> Add a new phy_notify_state() api that notifies and configures a phy for a
> given state transition.
>
> This is intended to be by phy drivers which need to do some runtime
^^^^^^^^^^
Missing 'used' possibly?
> 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>
> ---
> drivers/phy/phy-core.c | 25 +++++++++++++++++++++++++
> include/linux/phy/phy.h | 19 +++++++++++++++++++
> 2 files changed, 44 insertions(+)
>
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index 04a5a34e7a950ae94fae915673c25d476fc071c1..60be8af984bf06649ef00e695d0ed4ced597cdb9 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -520,6 +520,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()
> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> index 13add0c2c40721fe9ca3f0350d13c035cd25af45..664d0864c3a5042949cb121e982368fe0a97827f 100644
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -53,6 +53,15 @@ enum phy_media {
> PHY_MEDIA_DAC,
> };
>
> +enum phy_ufs_state {
> + PHY_UFS_HIBERN8_ENTER,
> + PHY_UFS_HIBERN8_EXIT,
> +};
> +
> +union phy_notify {
> + enum phy_ufs_state ufs_state;
> +};
> +
> /**
> * union phy_configure_opts - Opaque generic phy configuration
> *
> @@ -83,6 +92,7 @@ union phy_configure_opts {
> * @set_speed: set the speed of the phy (optional)
> * @reset: resetting the phy
> * @calibrate: calibrate the phy
> + * @notify_phystate: notify and configure the phy for a particular state
> * @release: ops to be performed while the consumer relinquishes the PHY
> * @owner: the module owner containing the ops
> */
> @@ -132,6 +142,7 @@ struct phy_ops {
> int (*connect)(struct phy *phy, int port);
> int (*disconnect)(struct phy *phy, int port);
>
> + int (*notify_phystate)(struct phy *phy, union phy_notify state);
> void (*release)(struct phy *phy);
> struct module *owner;
> };
> @@ -255,6 +266,7 @@ int phy_reset(struct phy *phy);
> int phy_calibrate(struct phy *phy);
> int phy_notify_connect(struct phy *phy, int port);
> int phy_notify_disconnect(struct phy *phy, int port);
> +int phy_notify_state(struct phy *phy, union phy_notify state);
> static inline int phy_get_bus_width(struct phy *phy)
> {
> return phy->attrs.bus_width;
> @@ -412,6 +424,13 @@ static inline int phy_notify_disconnect(struct phy *phy, int index)
> return -ENOSYS;
> }
>
> +static inline int phy_notify_phystate(struct phy *phy, union phy_notify state)
> +{
> + if (!phy)
> + return 0;
> + return -ENOSYS;
Should be -ENOSYS either way, right?
--
~Vinod
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-20 20:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 15:00 [PATCH v3 0/2] Add new phy_notify_state() api Peter Griffin
2025-08-13 15:00 ` [PATCH v3 1/2] phy: add " Peter Griffin
2025-08-20 16:34 ` Vinod Koul
2025-08-13 15:00 ` [PATCH v3 2/2] phy: samsung: gs101-ufs: Add .notify_phystate() & hibern8 enter/exit values Peter Griffin
2025-08-14 8:15 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).