PM / Domains: Add dev_pm_domain_attach_by_id() to manage multi PM domains
authorUlf Hansson <ulf.hansson@linaro.org>
Thu, 31 May 2018 10:59:59 +0000 (12:59 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 6 Jun 2018 07:09:22 +0000 (09:09 +0200)
commit82e12d9e0bd59f3d24be9c735258e2e98e4f54f6
tree76a065ced0f8b58fd6e7081915b8fdd4bc7c9a09
parent3c095f32a92be4d07f3172a777dab1aacdb6a728
PM / Domains: Add dev_pm_domain_attach_by_id() to manage multi PM domains

The existing dev_pm_domain_attach() function, allows a single PM domain to
be attached per device. To be able to support devices that are partitioned
across multiple PM domains, let's introduce a new interface,
dev_pm_domain_attach_by_id().

The dev_pm_domain_attach_by_id() returns a new allocated struct device with
the corresponding attached PM domain. This enables for example a driver to
operate on the new device from a power management point of view. The driver
may then also benefit from using the received device, to set up so called
device-links towards its original device. Depending on the situation, these
links may then be dynamically changed.

The new interface is typically called by drivers during their probe phase,
in case they manages devices which uses multiple PM domains. If that is the
case, the driver also becomes responsible of managing the detaching of the
PM domains, which typically should be done at the remove phase. Detaching
is done by calling the existing dev_pm_domain_detach() function and for
each of the received devices from dev_pm_domain_attach_by_id().

Note, currently its only genpd that supports multiple PM domains per
device, but dev_pm_domain_attach_by_id() can easily by extended to cover
other PM domain types, if/when needed.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/common.c
include/linux/pm_domain.h