Lines Matching +full:power +full:- +full:domain +full:-
2 * drivers/base/power/common.c - Common device power management code.
17 #include "power.h"
20 * dev_pm_get_subsys_data - Create or refcount power.subsys_data for device.
23 * If power.subsys_data is NULL, point it to a new object, otherwise increment
33 return -ENOMEM; in dev_pm_get_subsys_data()
35 spin_lock_irq(&dev->power.lock); in dev_pm_get_subsys_data()
37 if (dev->power.subsys_data) { in dev_pm_get_subsys_data()
38 dev->power.subsys_data->refcount++; in dev_pm_get_subsys_data()
40 spin_lock_init(&psd->lock); in dev_pm_get_subsys_data()
41 psd->refcount = 1; in dev_pm_get_subsys_data()
42 dev->power.subsys_data = psd; in dev_pm_get_subsys_data()
47 spin_unlock_irq(&dev->power.lock); in dev_pm_get_subsys_data()
57 * dev_pm_put_subsys_data - Drop reference to power.subsys_data.
60 * If the reference counter of power.subsys_data is zero after dropping the
61 * reference, power.subsys_data is removed.
67 spin_lock_irq(&dev->power.lock); in dev_pm_put_subsys_data()
73 if (--psd->refcount == 0) in dev_pm_put_subsys_data()
74 dev->power.subsys_data = NULL; in dev_pm_put_subsys_data()
79 spin_unlock_irq(&dev->power.lock); in dev_pm_put_subsys_data()
85 * dev_pm_domain_attach - Attach a device to its PM domain.
87 * @power_on: Used to indicate whether we should power on the device.
89 * The @dev may only be attached to a single PM domain. By iterating through
90 * the available alternatives we try to find a valid PM domain for the device.
91 * As attachment succeeds, the ->detach() callback in the struct dev_pm_domain
96 * power management through PM domains.
98 * Callers must ensure proper synchronization of this function with power
101 * Returns 0 on successfully attached PM domain, or when it is found that the
102 * device doesn't need a PM domain, else a negative error code.
108 if (dev->pm_domain) in dev_pm_domain_attach()
120 * dev_pm_domain_attach_by_id - Associate a device with one of its PM domains.
121 * @dev: The device used to lookup the PM domain.
122 * @index: The index of the PM domain.
124 * As @dev may only be attached to a single PM domain, the backend PM domain
126 * the ->detach() callback in the struct dev_pm_domain are assigned by the
131 * in case its device requires power management through multiple PM domains. The
132 * driver may benefit from using the received device, to configure device-links
133 * towards its original device. Depending on the use-case and if needed, the
135 * the power to the PM domains independently from each other.
137 * Callers must ensure proper synchronization of this function with power
141 * domain, NULL in case @dev don't need a PM domain, else an ERR_PTR().
148 if (dev->pm_domain) in dev_pm_domain_attach_by_id()
149 return ERR_PTR(-EEXIST); in dev_pm_domain_attach_by_id()
156 * dev_pm_domain_attach_by_name - Associate a device with one of its PM domains.
157 * @dev: The device used to lookup the PM domain.
158 * @name: The name of the PM domain.
165 if (dev->pm_domain) in dev_pm_domain_attach_by_name()
166 return ERR_PTR(-EEXIST); in dev_pm_domain_attach_by_name()
173 * dev_pm_domain_detach - Detach a device from its PM domain.
175 * @power_off: Used to indicate whether we should power off the device.
178 * dev_pm_domain_attach_by_id(), thus it detaches @dev from its PM domain.
182 * Callers must ensure proper synchronization of this function with power
187 if (dev->pm_domain && dev->pm_domain->detach) in dev_pm_domain_detach()
188 dev->pm_domain->detach(dev, power_off); in dev_pm_domain_detach()
193 * dev_pm_domain_set - Set PM domain of a device.
194 * @dev: Device whose PM domain is to be set.
195 * @pd: PM domain to be set, or NULL.
197 * Sets the PM domain the device belongs to. The PM domain of a device needs
204 if (dev->pm_domain == pd) in dev_pm_domain_set()
209 dev->pm_domain = pd; in dev_pm_domain_set()