devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert+renesas@glider.be>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	Tomasz Figa <tomasz.figa@gmail.com>,
	Philipp Zabel <philipp.zabel@gmail.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Kevin Hilman <khilman@linaro.org>,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH/RFC v2 04/12] PM / Domains: Add genpd attach/detach callbacks
Date: Tue, 16 Sep 2014 20:48:51 +0200	[thread overview]
Message-ID: <1410893339-6361-5-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1410893339-6361-1-git-send-email-geert+renesas@glider.be>

While a PM domain can enable PM runtime management of its devices' module
clocks by setting

	genpd->dev_ops.stop = pm_clk_suspend;
	genpd->dev_ops.start = pm_clk_resume;

this also requires registering the clocks with the pm_clk subsystem.
In the legacy case, this is handled by the platform code, after
attaching the device to its PM domain.

When the devices are instantiated from DT, devices are attached to their
PM domains by generic code, leaving no method for the platform-specific
PM domain code to register their clocks.

Add two callbacks, allowing a PM domain to perform platform-specific
tasks when a device is attached to or detached from a PM domain.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New
---
 drivers/base/power/domain.c | 12 ++++++++++++
 include/linux/pm_domain.h   |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index f09b615e61515d11..3fa15b6c54f09b36 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1418,6 +1418,12 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
 	if (ret)
 		goto out;
 
+	if (genpd->attach_dev) {
+		ret = genpd->attach_dev(genpd, dev);
+		if (ret)
+			goto out;
+	}
+
 	genpd->device_count++;
 	genpd->max_off_time_changed = true;
 
@@ -1541,6 +1547,12 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
 
 	spin_unlock_irq(&dev->power.lock);
 
+	if (genpd->detach_dev) {
+		ret = genpd->detach_dev(genpd, dev);
+		if (ret)
+			goto out;
+	}
+
 	mutex_lock(&gpd_data->lock);
 	pdd->dev = NULL;
 	mutex_unlock(&gpd_data->lock);
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index ff128c1ec0de231c..ac07918f907b7495 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -73,6 +73,8 @@ struct generic_pm_domain {
 	bool cached_power_down_ok;
 	struct device_node *of_node; /* Node in device tree */
 	struct gpd_cpu_data *cpu_data;
+	int (*attach_dev)(struct generic_pm_domain *domain, struct device *dev);
+	int (*detach_dev)(struct generic_pm_domain *domain, struct device *dev);
 };
 
 static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
-- 
1.9.1


  parent reply	other threads:[~2014-09-16 18:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16 18:48 [PATCH/RFC v2 00/12] ARM: shmobile: R-Mobile: Prototype DT PM domain support Geert Uytterhoeven
2014-09-16 18:48 ` [PATCH/RFC v2 01/12] PM / Domains: Add DT bindings for power-on/off latencies Geert Uytterhoeven
2014-09-16 18:48 ` [PATCH/RFC v2 02/12] PM / Domains: Add DT bindings for PM QoS device latencies Geert Uytterhoeven
2014-09-25 21:31   ` Kevin Hilman
2014-09-26  6:25     ` Geert Uytterhoeven
2014-09-16 18:48 ` [PATCH/RFC v2 03/12] PM / Domains: Add DT bindings for the R-Mobile System Controller Geert Uytterhoeven
2014-09-16 18:48 ` Geert Uytterhoeven [this message]
2014-09-17 17:44   ` [PATCH/RFC v2 04/12] PM / Domains: Add genpd attach/detach callbacks Ulf Hansson
2014-09-25 21:33   ` Kevin Hilman
2014-09-16 18:48 ` [PATCH/RFC v2 05/12] PM / Domains: Add helper variable np = dev->of_node Geert Uytterhoeven
2014-09-25 21:36   ` Kevin Hilman
2014-09-16 18:48 ` [PATCH/RFC v2 06/12] PM / Domains: Retrieve PM QoS device latencies from DT Geert Uytterhoeven
2014-09-16 18:48 ` [PATCH/RFC v2 07/12] ARM: shmobile: R-Mobile: Use generic_pm_domain.attach_dev() for pm_clk setup Geert Uytterhoeven
2014-09-16 18:48 ` [PATCH/RFC v2 08/12] ARM: shmobile: R-Mobile: Store SYSC base address in rmobile_pm_domain Geert Uytterhoeven
2014-09-16 18:48 ` [PATCH/RFC v2 09/12] ARM: shmobile: R-Mobile: Add DT support for PM domains Geert Uytterhoeven
2014-09-16 18:48 ` [PATCH/RFC v2 10/12] ARM: shmobile: r8a7740 dtsi: Add PM domain support Geert Uytterhoeven
2014-09-16 18:48 ` [PATCH/RFC v2 11/12] ARM: shmobile: r8a7740 dtsi: Add PM QoS device latencies Geert Uytterhoeven
     [not found] ` <1410893339-6361-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-09-16 18:48   ` [PATCH/RFC v2 12/12] drivers: sh: Disable PM runtime for multi-platform r8a7740 with genpd Geert Uytterhoeven

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=1410893339-6361-5-git-send-email-geert+renesas@glider.be \
    --to=geert+renesas@glider.be \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=grygorii.strashko@ti.com \
    --cc=horms@verge.net.au \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=khilman@linaro.org \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=pavel@ucw.cz \
    --cc=pawel.moll@arm.com \
    --cc=philipp.zabel@gmail.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=tomasz.figa@gmail.com \
    --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).