aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChunyan Zhang <zhang.chunyan@linaro.org>2018-01-26 08:08:45 -0500
committerMark Brown <broonie@kernel.org>2018-01-26 09:43:46 -0500
commit72069f9957a11896e79e95c8b55ec815e97c2187 (patch)
tree4859acc5ba19cd5f438c9c4b931e74f9c9b9c0c4
parentc360a6df02cdba47c0590ffc7d15ec6687183e8c (diff)
regulator: leave one item to record whether regulator is enabled
The items "disabled" and "enabled" are a little redundant, since only one of them would be set to record if the regulator device should keep on or be switched to off in suspend states. So in this patch, the "disabled" was removed, only leave the "enabled": - enabled == 1 for regulator-on-in-suspend - enabled == 0 for regulator-off-in-suspend - enabled == -1 means do nothing when entering suspend mode. Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/core.c14
-rw-r--r--drivers/regulator/of_regulator.c6
-rw-r--r--include/linux/regulator/machine.h19
3 files changed, 25 insertions, 14 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 97bc9f7adf2f..5ea80e94eb69 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -742,21 +742,19 @@ static int suspend_set_state(struct regulator_dev *rdev,
742 * only warn if the driver implements set_suspend_voltage or 742 * only warn if the driver implements set_suspend_voltage or
743 * set_suspend_mode callback. 743 * set_suspend_mode callback.
744 */ 744 */
745 if (!rstate->enabled && !rstate->disabled) { 745 if (rstate->enabled != ENABLE_IN_SUSPEND &&
746 rstate->enabled != DISABLE_IN_SUSPEND) {
746 if (rdev->desc->ops->set_suspend_voltage || 747 if (rdev->desc->ops->set_suspend_voltage ||
747 rdev->desc->ops->set_suspend_mode) 748 rdev->desc->ops->set_suspend_mode)
748 rdev_warn(rdev, "No configuration\n"); 749 rdev_warn(rdev, "No configuration\n");
749 return 0; 750 return 0;
750 } 751 }
751 752
752 if (rstate->enabled && rstate->disabled) { 753 if (rstate->enabled == ENABLE_IN_SUSPEND &&
753 rdev_err(rdev, "invalid configuration\n"); 754 rdev->desc->ops->set_suspend_enable)
754 return -EINVAL;
755 }
756
757 if (rstate->enabled && rdev->desc->ops->set_suspend_enable)
758 ret = rdev->desc->ops->set_suspend_enable(rdev); 755 ret = rdev->desc->ops->set_suspend_enable(rdev);
759 else if (rstate->disabled && rdev->desc->ops->set_suspend_disable) 756 else if (rstate->enabled == DISABLE_IN_SUSPEND &&
757 rdev->desc->ops->set_suspend_disable)
760 ret = rdev->desc->ops->set_suspend_disable(rdev); 758 ret = rdev->desc->ops->set_suspend_disable(rdev);
761 else /* OK if set_suspend_enable or set_suspend_disable is NULL */ 759 else /* OK if set_suspend_enable or set_suspend_disable is NULL */
762 ret = 0; 760 ret = 0;
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 14637a01ba2d..41dad42b18f0 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -177,10 +177,12 @@ static void of_get_regulation_constraints(struct device_node *np,
177 177
178 if (of_property_read_bool(suspend_np, 178 if (of_property_read_bool(suspend_np,
179 "regulator-on-in-suspend")) 179 "regulator-on-in-suspend"))
180 suspend_state->enabled = true; 180 suspend_state->enabled = ENABLE_IN_SUSPEND;
181 else if (of_property_read_bool(suspend_np, 181 else if (of_property_read_bool(suspend_np,
182 "regulator-off-in-suspend")) 182 "regulator-off-in-suspend"))
183 suspend_state->disabled = true; 183 suspend_state->enabled = DISABLE_IN_SUSPEND;
184 else
185 suspend_state->enabled = DO_NOTHING_IN_SUSPEND;
184 186
185 if (!of_property_read_u32(suspend_np, 187 if (!of_property_read_u32(suspend_np,
186 "regulator-suspend-microvolt", &pval)) 188 "regulator-suspend-microvolt", &pval))
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 9cd4fef37203..ce89c5548c89 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -42,6 +42,16 @@ struct regulator;
42#define REGULATOR_CHANGE_DRMS 0x10 42#define REGULATOR_CHANGE_DRMS 0x10
43#define REGULATOR_CHANGE_BYPASS 0x20 43#define REGULATOR_CHANGE_BYPASS 0x20
44 44
45/*
46 * operations in suspend mode
47 * DO_NOTHING_IN_SUSPEND - the default value
48 * DISABLE_IN_SUSPEND - turn off regulator in suspend states
49 * ENABLE_IN_SUSPEND - keep regulator on in suspend states
50 */
51#define DO_NOTHING_IN_SUSPEND (-1)
52#define DISABLE_IN_SUSPEND 0
53#define ENABLE_IN_SUSPEND 1
54
45/* Regulator active discharge flags */ 55/* Regulator active discharge flags */
46enum regulator_active_discharge { 56enum regulator_active_discharge {
47 REGULATOR_ACTIVE_DISCHARGE_DEFAULT, 57 REGULATOR_ACTIVE_DISCHARGE_DEFAULT,
@@ -58,14 +68,15 @@ enum regulator_active_discharge {
58 * 68 *
59 * @uV: Operating voltage during suspend. 69 * @uV: Operating voltage during suspend.
60 * @mode: Operating mode during suspend. 70 * @mode: Operating mode during suspend.
61 * @enabled: Enabled during suspend. 71 * @enabled: operations during suspend.
62 * @disabled: Disabled during suspend. 72 * - DO_NOTHING_IN_SUSPEND
73 * - DISABLE_IN_SUSPEND
74 * - ENABLE_IN_SUSPEND
63 */ 75 */
64struct regulator_state { 76struct regulator_state {
65 int uV; /* suspend voltage */ 77 int uV; /* suspend voltage */
66 unsigned int mode; /* suspend regulator operating mode */ 78 unsigned int mode; /* suspend regulator operating mode */
67 int enabled; /* is regulator enabled in this suspend state */ 79 int enabled;
68 int disabled; /* is the regulator disabled in this suspend state */
69}; 80};
70 81
71/** 82/**