From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: lst@pengutronix.de, mfe@pengutronix.de,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 1/3] drivers: power: ignore power domains with barebox,allow-dummy
Date: Sat, 30 Jul 2022 11:52:09 +0200 [thread overview]
Message-ID: <20220730095211.1769119-1-a.fatoum@pengutronix.de> (raw)
With deep probe enabled, we can know for certain whether a driver will
be found for a device or not. This allows us to specially handle devices
that lack a driver. We already do that for regulators, where the device
tree can specify barebox,allow-dummy-supply for regulators that are
known to be enabled by the time barebox runs. Add the same functionality
for power domains as well.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/base/power.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/base/power.c b/drivers/base/power.c
index 96cac1a091f3..4a206051b137 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -139,14 +139,32 @@ static struct generic_pm_domain *genpd_get_from_provider(
struct of_phandle_args *genpdspec)
{
struct generic_pm_domain *genpd = ERR_PTR(-ENOENT);
+ struct device_node *node = genpdspec->np;
struct of_genpd_provider *provider;
+ int ret;
if (!genpdspec)
return ERR_PTR(-EINVAL);
+ ret = of_device_ensure_probed(node);
+ if (ret) {
+ struct device_node *parent;
+
+ /*
+ * If "barebox,allow-dummy" property is set for power domain
+ * provider, assume it's turned on.
+ */
+ parent = of_get_parent(node);
+ if (of_get_property(node, "barebox,allow-dummy", NULL) ||
+ of_get_property(parent, "barebox,allow-dummy", NULL))
+ return NULL;
+
+ return ERR_PTR(ret);
+ }
+
/* Check if we have such a provider in our array */
list_for_each_entry(provider, &of_genpd_providers, link) {
- if (provider->node == genpdspec->np)
+ if (provider->node == node)
genpd = provider->xlate(genpdspec, provider->data);
if (!IS_ERR(genpd))
break;
@@ -175,7 +193,7 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth)
{
int ret;
- if (genpd_status_on(genpd))
+ if (!genpd || genpd_status_on(genpd))
return 0;
ret = _genpd_power_on(genpd, true);
@@ -211,7 +229,7 @@ static int __genpd_dev_pm_attach(struct device_d *dev, struct device_node *np,
return (ret == -ENOENT) ? -EPROBE_DEFER : ret;
}
- dev_dbg(dev, "adding to PM domain %s\n", pd->name);
+ dev_dbg(dev, "adding to PM domain %s\n", pd ? pd->name : "dummy");
if (power_on)
ret = genpd_power_on(pd, 0);
--
2.30.2
next reply other threads:[~2022-07-30 9:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-30 9:52 Ahmad Fatoum [this message]
2022-07-30 9:52 ` [PATCH master 2/3] ARM: i.MX8MM: assume USBOTG power domains to be powered Ahmad Fatoum
2022-07-30 9:52 ` [PATCH master 3/3] ARM: i.MX8MN: " Ahmad Fatoum
2022-08-05 5:23 ` [PATCH master 1/3] drivers: power: ignore power domains with barebox,allow-dummy Ahmad Fatoum
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=20220730095211.1769119-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=lst@pengutronix.de \
--cc=mfe@pengutronix.de \
/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