PM: domains: Introduce dev_pm_domain_set_performance_state()
The generic PM domain is currently the only PM domain variant that supports performance scaling. To allow performance scaling to be supported through a common interface, let's add an optional callback ->set_performance_state(), in the struct dev_pm_domain. Moreover, let's add a function, dev_pm_domain_set_performance_state(), that may be called by consumers to request a new performance state for a device through its PM domain. Note that, in most cases it's preferred that a consumer use the OPP library to request a new performance state for its device. Although, this requires some additional changes to be supported, which are being implemented from subsequent changes. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
committed by
Viresh Kumar
parent
0bb80ecc33
commit
3fbc5c3b85
@@ -228,3 +228,24 @@ void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd)
|
||||
device_pm_check_callbacks(dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dev_pm_domain_set);
|
||||
|
||||
/**
|
||||
* dev_pm_domain_set_performance_state - Request a new performance state.
|
||||
* @dev: The device to make the request for.
|
||||
* @state: Target performance state for the device.
|
||||
*
|
||||
* This function should be called when a new performance state needs to be
|
||||
* requested for a device that is attached to a PM domain. Note that, the
|
||||
* support for performance scaling for PM domains is optional.
|
||||
*
|
||||
* Returns 0 on success and when performance scaling isn't supported, negative
|
||||
* error code on failure.
|
||||
*/
|
||||
int dev_pm_domain_set_performance_state(struct device *dev, unsigned int state)
|
||||
{
|
||||
if (dev->pm_domain && dev->pm_domain->set_performance_state)
|
||||
return dev->pm_domain->set_performance_state(dev, state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dev_pm_domain_set_performance_state);
|
||||
|
||||
@@ -719,6 +719,7 @@ extern void dev_pm_put_subsys_data(struct device *dev);
|
||||
* @activate: Called before executing probe routines for bus types and drivers.
|
||||
* @sync: Called after successful driver probe.
|
||||
* @dismiss: Called after unsuccessful driver probe and after driver removal.
|
||||
* @set_performance_state: Called to request a new performance state.
|
||||
*
|
||||
* Power domains provide callbacks that are executed during system suspend,
|
||||
* hibernation, system resume and during runtime PM transitions instead of
|
||||
@@ -731,6 +732,7 @@ struct dev_pm_domain {
|
||||
int (*activate)(struct device *dev);
|
||||
void (*sync)(struct device *dev);
|
||||
void (*dismiss)(struct device *dev);
|
||||
int (*set_performance_state)(struct device *dev, unsigned int state);
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -430,6 +430,7 @@ struct device *dev_pm_domain_attach_by_name(struct device *dev,
|
||||
void dev_pm_domain_detach(struct device *dev, bool power_off);
|
||||
int dev_pm_domain_start(struct device *dev);
|
||||
void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd);
|
||||
int dev_pm_domain_set_performance_state(struct device *dev, unsigned int state);
|
||||
#else
|
||||
static inline int dev_pm_domain_attach(struct device *dev, bool power_on)
|
||||
{
|
||||
@@ -452,6 +453,11 @@ static inline int dev_pm_domain_start(struct device *dev)
|
||||
}
|
||||
static inline void dev_pm_domain_set(struct device *dev,
|
||||
struct dev_pm_domain *pd) {}
|
||||
static inline int dev_pm_domain_set_performance_state(struct device *dev,
|
||||
unsigned int state)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_PM_DOMAIN_H */
|
||||
|
||||
Reference in New Issue
Block a user