]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soc: qcom: geni-se: Introduce helper API for attaching power domains
authorPraveen Talari <praveen.talari@oss.qualcomm.com>
Fri, 27 Feb 2026 06:15:37 +0000 (11:45 +0530)
committerBjorn Andersson <andersson@kernel.org>
Fri, 22 May 2026 02:56:38 +0000 (21:56 -0500)
The GENI Serial Engine drivers (I2C, SPI, and SERIAL) currently handle
the attachment of power domains. This often leads to duplicated code
logic across different driver probe functions.

Introduce a new helper API, geni_se_domain_attach(), to centralize
the logic for attaching "power" and "perf" domains to the GENI SE
device.

Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Link: https://lore.kernel.org/r/20260227061544.1785978-7-praveen.talari@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/soc/qcom/qcom-geni-se.c
include/linux/soc/qcom/geni-se.h

index 6e58568701b0a35232a0fabec70f224c28bf4f38..13ad3a51b58c39d95912f2cb958ebecfec50ed79 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/of_platform.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_opp.h>
 #include <linux/soc/qcom/geni-se.h>
 
@@ -1095,6 +1096,36 @@ out_icc_disable:
 }
 EXPORT_SYMBOL_GPL(geni_se_resources_activate);
 
+/**
+ * geni_se_domain_attach() - Attach power domains to a GENI SE device.
+ * @se: Pointer to the geni_se structure representing the GENI SE device.
+ *
+ * This function attaches the power domains ("power" and "perf") required
+ * in the SCMI auto-VM environment to the GENI Serial Engine device. It
+ * initializes se->pd_list with the attached domains.
+ *
+ * Return: 0 on success, or a negative error code on failure.
+ */
+int geni_se_domain_attach(struct geni_se *se)
+{
+       struct dev_pm_domain_attach_data pd_data = {
+               .pd_flags = PD_FLAG_DEV_LINK_ON,
+               .pd_names = (const char*[]) { "power", "perf" },
+               .num_pd_names = 2,
+       };
+       int ret;
+
+       ret = devm_pm_domain_attach_list(se->dev,
+                                        &pd_data, &se->pd_list);
+       if (ret == 0)
+               return -ENODEV;
+       else if (ret < 0)
+               return ret;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(geni_se_domain_attach);
+
 /**
  * geni_se_resources_init() - Initialize resources for a GENI SE device.
  * @se: Pointer to the geni_se structure representing the GENI SE device.
index 36a68149345cf33736444776e0fa7e43dca34f49..5f75159c5531736d8cf01efc6c07fe94690bed8f 100644 (file)
@@ -64,6 +64,7 @@ struct geni_icc_path {
  * @num_clk_levels:    Number of valid clock levels in clk_perf_tbl
  * @clk_perf_tbl:      Table of clock frequency input to serial engine clock
  * @icc_paths:         Array of ICC paths for SE
+ * @pd_list:           Power domain list for managing power domains
  * @has_opp:           Indicates if OPP is supported
  */
 struct geni_se {
@@ -75,6 +76,7 @@ struct geni_se {
        unsigned int num_clk_levels;
        unsigned long *clk_perf_tbl;
        struct geni_icc_path icc_paths[3];
+       struct dev_pm_domain_list *pd_list;
        bool has_opp;
 };
 
@@ -546,5 +548,7 @@ int geni_se_resources_activate(struct geni_se *se);
 int geni_se_resources_deactivate(struct geni_se *se);
 
 int geni_load_se_firmware(struct geni_se *se, enum geni_se_protocol_type protocol);
+
+int geni_se_domain_attach(struct geni_se *se);
 #endif
 #endif