[PATCH RFC 01/12] power: sequencing: Add index parameter for getting power sequencer
Chen-Yu Tsai
wenst at chromium.org
Fri May 15 02:01:37 PDT 2026
In some cases more than one sequencer could be associated with a
particular device. For example, a USB hub has multiple downstream ports,
and each port could be connected to a different M.2 E-key slot. In this
case the index would be the port number. The index tells power
sequencers for different slots (connected to different hub ports) apart.
For the consumer API, add a new pwrseq_get_index() for new users. The
original pwrseq_get() now calls pwrseq_get_index() with index = -1.
For the provider API, add the index parameter to the .match function
signature, and tweak all existing providers to match. Actual use of
the new index parameter will be introduced in the next change.
Other than the API change, no functional changes are intended.
Signed-off-by: Chen-Yu Tsai <wenst at chromium.org>
---
drivers/power/sequencing/core.c | 12 ++++++++----
drivers/power/sequencing/pwrseq-pcie-m2.c | 2 +-
drivers/power/sequencing/pwrseq-qcom-wcn.c | 6 +++---
drivers/power/sequencing/pwrseq-thead-gpu.c | 2 +-
include/linux/pwrseq/consumer.h | 6 ++++--
include/linux/pwrseq/provider.h | 2 +-
6 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/drivers/power/sequencing/core.c b/drivers/power/sequencing/core.c
index 14335c4f813e..1a91ee6d416f 100644
--- a/drivers/power/sequencing/core.c
+++ b/drivers/power/sequencing/core.c
@@ -612,6 +612,7 @@ struct pwrseq_match_data {
struct pwrseq_desc *desc;
struct device *dev;
const char *target;
+ int index;
};
static int pwrseq_match_device(struct device *pwrseq_dev, void *data)
@@ -627,7 +628,7 @@ static int pwrseq_match_device(struct device *pwrseq_dev, void *data)
if (!device_is_registered(&pwrseq->dev))
return 0;
- ret = pwrseq->match(pwrseq, match_data->dev);
+ ret = pwrseq->match(pwrseq, match_data->dev, match_data->index);
if (ret == PWRSEQ_NO_MATCH || ret < 0)
return ret;
@@ -655,16 +656,18 @@ static int pwrseq_match_device(struct device *pwrseq_dev, void *data)
}
/**
- * pwrseq_get() - Get the power sequencer associated with this device.
+ * pwrseq_get_index() - Get the power sequencer associated with this device.
* @dev: Device for which to get the sequencer.
* @target: Name of the target exposed by the sequencer this device wants to
* reach.
+ * @index: Index of the sequencer associated with the device.
*
* Returns:
* New power sequencer descriptor for use by the consumer driver or ERR_PTR()
* on failure.
*/
-struct pwrseq_desc *pwrseq_get(struct device *dev, const char *target)
+struct pwrseq_desc *pwrseq_get_index(struct device *dev, const char *target,
+ int index)
{
struct pwrseq_match_data match_data;
int ret;
@@ -676,6 +679,7 @@ struct pwrseq_desc *pwrseq_get(struct device *dev, const char *target)
match_data.desc = desc;
match_data.dev = dev;
match_data.target = target;
+ match_data.index = index;
guard(rwsem_read)(&pwrseq_sem);
@@ -689,7 +693,7 @@ struct pwrseq_desc *pwrseq_get(struct device *dev, const char *target)
return_ptr(desc);
}
-EXPORT_SYMBOL_GPL(pwrseq_get);
+EXPORT_SYMBOL_GPL(pwrseq_get_index);
/**
* pwrseq_put() - Release the power sequencer descriptor.
diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequencing/pwrseq-pcie-m2.c
index ef69ae268059..16a332f9da7d 100644
--- a/drivers/power/sequencing/pwrseq-pcie-m2.c
+++ b/drivers/power/sequencing/pwrseq-pcie-m2.c
@@ -158,7 +158,7 @@ static const struct pwrseq_pcie_m2_pdata pwrseq_pcie_m2_m_of_data = {
};
static int pwrseq_pcie_m2_match(struct pwrseq_device *pwrseq,
- struct device *dev)
+ struct device *dev, int index)
{
struct pwrseq_pcie_m2_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);
struct device_node *endpoint __free(device_node) = NULL;
diff --git a/drivers/power/sequencing/pwrseq-qcom-wcn.c b/drivers/power/sequencing/pwrseq-qcom-wcn.c
index b55b4317e21b..ac6b34e01c51 100644
--- a/drivers/power/sequencing/pwrseq-qcom-wcn.c
+++ b/drivers/power/sequencing/pwrseq-qcom-wcn.c
@@ -335,7 +335,7 @@ static const char *const pwrseq_wcn3990_vregs[] = {
};
static int pwrseq_qcom_wcn3990_match(struct pwrseq_device *pwrseq,
- struct device *dev);
+ struct device *dev, int index);
static const struct pwrseq_qcom_wcn_pdata pwrseq_wcn3990_of_data = {
.vregs = pwrseq_wcn3990_vregs,
@@ -436,13 +436,13 @@ static int pwrseq_qcom_wcn_match_regulator(struct pwrseq_device *pwrseq,
}
static int pwrseq_qcom_wcn_match(struct pwrseq_device *pwrseq,
- struct device *dev)
+ struct device *dev, int index)
{
return pwrseq_qcom_wcn_match_regulator(pwrseq, dev, "vddaon-supply");
}
static int pwrseq_qcom_wcn3990_match(struct pwrseq_device *pwrseq,
- struct device *dev)
+ struct device *dev, int index)
{
int ret;
diff --git a/drivers/power/sequencing/pwrseq-thead-gpu.c b/drivers/power/sequencing/pwrseq-thead-gpu.c
index a45318b4b2c1..cb7a6ea66c4b 100644
--- a/drivers/power/sequencing/pwrseq-thead-gpu.c
+++ b/drivers/power/sequencing/pwrseq-thead-gpu.c
@@ -115,7 +115,7 @@ static const struct pwrseq_target_data *pwrseq_thead_gpu_targets[] = {
};
static int pwrseq_thead_gpu_match(struct pwrseq_device *pwrseq,
- struct device *dev)
+ struct device *dev, int index)
{
struct pwrseq_thead_gpu_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);
static const char *const clk_names[] = { "core", "sys" };
diff --git a/include/linux/pwrseq/consumer.h b/include/linux/pwrseq/consumer.h
index 7d583b4f266e..d5d57cdb0c8e 100644
--- a/include/linux/pwrseq/consumer.h
+++ b/include/linux/pwrseq/consumer.h
@@ -11,10 +11,12 @@
struct device;
struct pwrseq_desc;
+#define pwrseq_get(dev, target) pwrseq_get_index(dev, target, -1)
+
#if IS_ENABLED(CONFIG_POWER_SEQUENCING)
struct pwrseq_desc * __must_check
-pwrseq_get(struct device *dev, const char *target);
+pwrseq_get_index(struct device *dev, const char *target, int index);
void pwrseq_put(struct pwrseq_desc *desc);
struct pwrseq_desc * __must_check
@@ -26,7 +28,7 @@ int pwrseq_power_off(struct pwrseq_desc *desc);
#else /* CONFIG_POWER_SEQUENCING */
static inline struct pwrseq_desc * __must_check
-pwrseq_get(struct device *dev, const char *target)
+pwrseq_get_index(struct device *dev, const char *target, int index)
{
return ERR_PTR(-ENOSYS);
}
diff --git a/include/linux/pwrseq/provider.h b/include/linux/pwrseq/provider.h
index 33b3d2c2e39d..a2ec6c612c8b 100644
--- a/include/linux/pwrseq/provider.h
+++ b/include/linux/pwrseq/provider.h
@@ -11,7 +11,7 @@ struct module;
struct pwrseq_device;
typedef int (*pwrseq_power_state_func)(struct pwrseq_device *);
-typedef int (*pwrseq_match_func)(struct pwrseq_device *, struct device *);
+typedef int (*pwrseq_match_func)(struct pwrseq_device *, struct device *, int);
#define PWRSEQ_NO_MATCH 0
#define PWRSEQ_MATCH_OK 1
--
2.54.0.563.g4f69b47b94-goog
More information about the Linux-mediatek
mailing list