diff options
author | MyungJoo Ham <myungjoo.ham@samsung.com> | 2011-03-10 20:13:59 -0500 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-03-26 10:15:04 -0400 |
commit | 7a32b589a9c856493bccb02db55047edc04eee7b (patch) | |
tree | a47d83f3d1320de5a18c513072c17cdc070d2bbf /drivers/regulator | |
parent | fb7c18cac8608983168a7f4f55193cea190c83c8 (diff) |
Regulator: add suspend-finish API for regulator core.
The regulator core had suspend-prepare that turns off the regulators
when entering a system-wide suspend. However, it did not have
suspend-finish that pairs with suspend-prepare and the regulator core
has assumed that the regulator devices and their drivers support
autonomous recover at resume.
This patch adds regulator_suspend_finish that pairs with the
previously-existed regulator_suspend_prepare. The function
regulator_suspend_finish turns on the regulators that have always_on set
or positive use_count so that we can reset the regulator states
appropriately at resume.
In regulator_suspend_finish, if has_full_constraints, it disables
unnecessary regulators.
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
--
Updates
v3
comments corrected (Thanks to Igor)
v2
disable unnecessary regulators (Thanks to Mark)
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a2dc6223e8d2..e611f6797e6a 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -2656,6 +2656,47 @@ out: | |||
2656 | EXPORT_SYMBOL_GPL(regulator_suspend_prepare); | 2656 | EXPORT_SYMBOL_GPL(regulator_suspend_prepare); |
2657 | 2657 | ||
2658 | /** | 2658 | /** |
2659 | * regulator_suspend_finish - resume regulators from system wide suspend | ||
2660 | * | ||
2661 | * Turn on regulators that might be turned off by regulator_suspend_prepare | ||
2662 | * and that should be turned on according to the regulators properties. | ||
2663 | */ | ||
2664 | int regulator_suspend_finish(void) | ||
2665 | { | ||
2666 | struct regulator_dev *rdev; | ||
2667 | int ret = 0, error; | ||
2668 | |||
2669 | mutex_lock(®ulator_list_mutex); | ||
2670 | list_for_each_entry(rdev, ®ulator_list, list) { | ||
2671 | struct regulator_ops *ops = rdev->desc->ops; | ||
2672 | |||
2673 | mutex_lock(&rdev->mutex); | ||
2674 | if ((rdev->use_count > 0 || rdev->constraints->always_on) && | ||
2675 | ops->enable) { | ||
2676 | error = ops->enable(rdev); | ||
2677 | if (error) | ||
2678 | ret = error; | ||
2679 | } else { | ||
2680 | if (!has_full_constraints) | ||
2681 | goto unlock; | ||
2682 | if (!ops->disable) | ||
2683 | goto unlock; | ||
2684 | if (ops->is_enabled && !ops->is_enabled(rdev)) | ||
2685 | goto unlock; | ||
2686 | |||
2687 | error = ops->disable(rdev); | ||
2688 | if (error) | ||
2689 | ret = error; | ||
2690 | } | ||
2691 | unlock: | ||
2692 | mutex_unlock(&rdev->mutex); | ||
2693 | } | ||
2694 | mutex_unlock(®ulator_list_mutex); | ||
2695 | return ret; | ||
2696 | } | ||
2697 | EXPORT_SYMBOL_GPL(regulator_suspend_finish); | ||
2698 | |||
2699 | /** | ||
2659 | * regulator_has_full_constraints - the system has fully specified constraints | 2700 | * regulator_has_full_constraints - the system has fully specified constraints |
2660 | * | 2701 | * |
2661 | * Calling this function will cause the regulator API to disable all | 2702 | * Calling this function will cause the regulator API to disable all |