From: Kevin Hilman <khilman@baylibre.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org,
arm-scmi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH RFC v3 2/2] pmdomain: core: add support for subdomains using power-domain-map
Date: Fri, 13 Jun 2025 15:39:28 -0700 [thread overview]
Message-ID: <20250613-pmdomain-hierarchy-onecell-v3-2-5c770676fce7@baylibre.com> (raw)
In-Reply-To: <20250613-pmdomain-hierarchy-onecell-v3-0-5c770676fce7@baylibre.com>
Currently, PM domains can only support hierarchy for simple
providers (e.g. ones with #power-domain-cells = 0).
Add more generic support for hierarchy by using nexus node
maps (c.f. section 2.5.1 of the DT spec.)
For example, we could describe SCMI PM domains with multiple parents
domains (MAIN_PD and WKUP_PD) like this:
scmi_pds: protocol@11 {
reg = <0x11>;
#power-domain-cells = <1>;
power-domain-map = <15 &MAIN_PD>,
<19 &WKUP_PD>;
};
which should mean that <&scmi_pds 15> is a subdomain of MAIN_PD and
<&scmi_pds 19> is a subdomain of WKUP_PD.
IOW, given an SCMI device which uses SCMI PM domains:
main_timer0: timer@2400000 {
power-domains = <&scmi_pds 15>;
};
it already implies that main_timer0 is PM domain <&scmi_pds 15>
With the new map, this *also* now implies <&scmi_pds 15> is a
subdomain of MAIN_PD.
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
---
drivers/pmdomain/core.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index d6c1ddb807b2..adf022b45d95 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -2998,8 +2998,8 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
unsigned int index, unsigned int num_domains,
bool power_on)
{
- struct of_phandle_args pd_args;
- struct generic_pm_domain *pd;
+ struct of_phandle_args pd_args, parent_args;
+ struct generic_pm_domain *pd, *parent_pd = NULL;
int ret;
ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
@@ -3039,6 +3039,22 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
goto err;
}
+ /*
+ * Check for power-domain-map, which implies the primary
+ * power-doamin is a subdomain of the parent found in the map.
+ */
+ ret = of_parse_phandle_with_args_map(dev->of_node, "power-domains",
+ "power-domain", index, &parent_args);
+ if (!ret && (pd_args.np != parent_args.np)) {
+ parent_pd = genpd_get_from_provider(&parent_args);
+ of_node_put(parent_args.np);
+
+ ret = pm_genpd_add_subdomain(parent_pd, pd);
+ if (!ret)
+ dev_dbg(dev, "adding PM domain %s as subdomain of %s\n",
+ pd->name, parent_pd->name);
+ }
+
ret = genpd_set_required_opp(dev, index);
if (ret)
goto err;
@@ -3056,6 +3072,8 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
dev_gpd_data(dev)->default_pstate = 0;
}
+ if (parent_pd)
+ pm_genpd_remove_subdomain(parent_pd, pd);
genpd_remove_device(pd, dev);
return -EPROBE_DEFER;
}
@@ -3063,6 +3081,8 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
return 1;
err:
+ if (parent_pd)
+ pm_genpd_remove_subdomain(parent_pd, pd);
genpd_remove_device(pd, dev);
return ret;
}
--
2.49.0
next prev parent reply other threads:[~2025-06-13 22:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 22:39 [PATCH RFC v3 0/2] pmdomain: core: add support for domain hierarchies in DT Kevin Hilman
2025-06-13 22:39 ` [PATCH RFC v3 1/2] dt-bindings: power: add nexus map for power-domains Kevin Hilman
2025-06-14 0:44 ` Rob Herring (Arm)
2025-06-13 22:39 ` Kevin Hilman [this message]
2025-06-16 13:48 ` [PATCH RFC v3 2/2] pmdomain: core: add support for subdomains using power-domain-map Ulf Hansson
2025-06-17 0:50 ` Kevin Hilman
2025-06-17 13:41 ` Ulf Hansson
2025-06-18 17:48 ` Kevin Hilman
2025-06-18 18:16 ` Dan Carpenter
2025-06-18 20:00 ` Kevin Hilman
2025-06-19 10:04 ` Ulf Hansson
2025-06-19 10:10 ` Ulf Hansson
2025-06-30 18:17 ` Kevin Hilman
2025-07-02 12:12 ` Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250613-pmdomain-hierarchy-onecell-v3-2-5c770676fce7@baylibre.com \
--to=khilman@baylibre.com \
--cc=arm-scmi@vger.kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=robh@kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).