Skip to content

Commit

Permalink
PM / Domains: Add genpd attach/detach callbacks
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ulf Hansson <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
geertu authored and rafaeljw committed Sep 25, 2014
1 parent 2bd5306 commit d79b6fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,9 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,

spin_unlock_irq(&dev->power.lock);

if (genpd->attach_dev)
genpd->attach_dev(dev);

mutex_lock(&gpd_data->lock);
gpd_data->base.dev = dev;
list_add_tail(&gpd_data->base.list_node, &genpd->dev_list);
Expand Down Expand Up @@ -1528,6 +1531,9 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
genpd->device_count--;
genpd->max_off_time_changed = true;

if (genpd->detach_dev)
genpd->detach_dev(dev);

spin_lock_irq(&dev->power.lock);

dev->pm_domain = NULL;
Expand Down
2 changes: 2 additions & 0 deletions include/linux/pm_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
void (*attach_dev)(struct device *dev);
void (*detach_dev)(struct device *dev);
};

static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
Expand Down

0 comments on commit d79b6fe

Please sign in to comment.