mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 4/5] pmdomain: allow callback for when devices are attached
Date: Mon, 27 Oct 2025 07:53:07 +0100	[thread overview]
Message-ID: <20251027065315.2419160-4-a.fatoum@barebox.org> (raw)
In-Reply-To: <20251027065315.2419160-1-a.fatoum@barebox.org>

This will be needed for the incoming Rockchip pmdomain drivers.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 drivers/base/power.c | 10 +++++++++-
 include/pm_domain.h  |  3 +++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/base/power.c b/drivers/base/power.c
index c291f8657cbb..05fb096cf64c 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -331,14 +331,22 @@ int pm_runtime_resume_and_get_genpd(struct device *dev)
 	return genpd_power_on(genpd);
 }
 
-static void genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
+static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
 {
 	dev->pm_domain = genpd;
+
+	if (genpd->attach_dev)
+		return genpd->attach_dev(genpd, dev);
+
+	return 0;
 }
 
 static void genpd_remove_device(struct generic_pm_domain *genpd,
 			       struct device *dev)
 {
+	if (genpd->detach_dev)
+		genpd->detach_dev(genpd, dev);
+
 	dev->pm_domain = NULL;
 }
 
diff --git a/include/pm_domain.h b/include/pm_domain.h
index 3678deb9a76c..13dc926448c8 100644
--- a/include/pm_domain.h
+++ b/include/pm_domain.h
@@ -20,6 +20,9 @@ struct generic_pm_domain {
 
 	int (*power_off)(struct generic_pm_domain *domain);
 	int (*power_on)(struct generic_pm_domain *domain);
+
+	int (*attach_dev)(struct generic_pm_domain *genpd, struct device *dev);
+	void (*detach_dev)(struct generic_pm_domain *genpd, struct device *dev);
 };
 
 typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
-- 
2.47.3




  parent reply	other threads:[~2025-10-27  6:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-27  6:53 [PATCH 1/5] regulator: implement dev_of_regulator_get Ahmad Fatoum
2025-10-27  6:53 ` [PATCH 2/5] pmdomain: look up pmdomain even if not have_genpd_providers Ahmad Fatoum
2025-10-27  7:19   ` Ahmad Fatoum
2025-10-27  6:53 ` [PATCH 3/5] pmdomain: warn if deep probe enabled and driver missing Ahmad Fatoum
2025-10-27  6:53 ` Ahmad Fatoum [this message]
2025-10-27  6:53 ` [PATCH 5/5] pmdomain: add Rockchip power domain support Ahmad Fatoum
2025-10-27 12:27 ` [PATCH 1/5] regulator: implement dev_of_regulator_get 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=20251027065315.2419160-4-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.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