[PATCH 35/50] pm_domains: Enable explicitly when we have power-domain providers

Sascha Hauer s.hauer at pengutronix.de
Fri Mar 3 01:21:16 PST 2023


Many SoCs provide power-domains in their device trees. In barebox
we most of the time do not have drivers for the power-domains. This
is no problem for most of the time as the necessary power domains
are either default on or enabled during early SoC init.
With multi-arch support it can happen that we compile in SoCs for
which we do not have power-domain drivers and other SoCs where we
need a power-domain driver. The example I stumbled upon is the
i.MX7 on the one hand which has a driver and OMAP on the other hand
which has power-domains described in the device tree for which
we do not have (and do not currently need) a driver.

To be able to handle both situations let's enable pm_domain support
explicitly on SoCs we know we have a driver for.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/imx7.c  |  3 +++
 arch/arm/mach-imx/imx8m.c |  3 +++
 drivers/base/power.c      | 10 ++++++++++
 include/pm_domain.h       |  6 ++++++
 4 files changed, 22 insertions(+)

diff --git a/arch/arm/mach-imx/imx7.c b/arch/arm/mach-imx/imx7.c
index 31d49c35e7..fbbed423c0 100644
--- a/arch/arm/mach-imx/imx7.c
+++ b/arch/arm/mach-imx/imx7.c
@@ -3,6 +3,7 @@
 #include <init.h>
 #include <common.h>
 #include <io.h>
+#include <pm_domain.h>
 #include <linux/sizes.h>
 #include <asm/psci.h>
 #include <mach/imx/imx7.h>
@@ -161,5 +162,7 @@ int imx7_init(void)
 	imx_set_silicon_revision(cputypestr, imx7_cpu_revision());
 	imx_set_reset_reason(src + IMX7_SRC_SRSR, imx7_reset_reasons);
 
+	genpd_activate();
+
 	return 0;
 }
diff --git a/arch/arm/mach-imx/imx8m.c b/arch/arm/mach-imx/imx8m.c
index 37ef17bc8e..32f1896b89 100644
--- a/arch/arm/mach-imx/imx8m.c
+++ b/arch/arm/mach-imx/imx8m.c
@@ -3,6 +3,7 @@
 #include <init.h>
 #include <common.h>
 #include <io.h>
+#include <pm_domain.h>
 #include <asm/syscounter.h>
 #include <asm/system.h>
 #include <mach/imx/generic.h>
@@ -54,6 +55,8 @@ static int imx8m_init(const char *cputypestr)
 	void __iomem *src = IOMEM(MX8M_SRC_BASE_ADDR);
 	struct arm_smccc_res res;
 
+	genpd_activate();
+
 	/*
 	 * Reset reasons seem to be identical to that of i.MX7
 	 */
diff --git a/drivers/base/power.c b/drivers/base/power.c
index 8e999c3e14..2db24329dd 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -237,6 +237,13 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
 	return ret ?: 1;
 }
 
+static bool have_genpd_providers;
+
+void genpd_activate(void)
+{
+	have_genpd_providers = true;
+}
+
 /**
  * genpd_dev_pm_attach - Attach a device to its PM domain using DT.
  * @dev: Device to attach.
@@ -255,6 +262,9 @@ int genpd_dev_pm_attach(struct device *dev)
 	if (!dev->of_node)
 		return 0;
 
+	if (!have_genpd_providers)
+		return 0;
+
 	/*
 	 * Devices with multiple PM domains must be attached separately, as we
 	 * can only attach one PM domain per device.
diff --git a/include/pm_domain.h b/include/pm_domain.h
index fac7f99227..d297053531 100644
--- a/include/pm_domain.h
+++ b/include/pm_domain.h
@@ -23,6 +23,8 @@ typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS
 
+void genpd_activate(void);
+
 int genpd_dev_pm_attach(struct device *dev);
 
 /**
@@ -58,6 +60,10 @@ void pm_genpd_print(void);
 
 #else
 
+static inline void genpd_activate(void)
+{
+}
+
 static inline int pm_genpd_init(struct generic_pm_domain *genpd,
 				void *gov, bool is_off)
 {
-- 
2.30.2




More information about the barebox mailing list