diff options
author | Chris Zhong <zyw@rock-chips.com> | 2014-10-10 18:35:06 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-10-20 07:23:55 -0400 |
commit | 251ce318df3c07dbb3e484378a136a29e2f9bec1 (patch) | |
tree | b872e80a40d8a4e381a245e7d8ffa1305c16f80a /drivers/regulator | |
parent | f114040e3ea6e07372334ade75d1ee0775c355e1 (diff) |
regulator: rk808: Add support setting suspend voltage
support setting suspend voltage and disable regulator in suspend.
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/rk808-regulator.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index e305416d7697..8d1dc48ed8a9 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c | |||
@@ -36,6 +36,12 @@ | |||
36 | #define RK808_RAMP_RATE_6MV_PER_US (2 << RK808_RAMP_RATE_OFFSET) | 36 | #define RK808_RAMP_RATE_6MV_PER_US (2 << RK808_RAMP_RATE_OFFSET) |
37 | #define RK808_RAMP_RATE_10MV_PER_US (3 << RK808_RAMP_RATE_OFFSET) | 37 | #define RK808_RAMP_RATE_10MV_PER_US (3 << RK808_RAMP_RATE_OFFSET) |
38 | 38 | ||
39 | /* Offset from XXX_ON_VSEL to XXX_SLP_VSEL */ | ||
40 | #define RK808_SLP_REG_OFFSET 1 | ||
41 | |||
42 | /* Offset from XXX_EN_REG to SLEEP_SET_OFF_XXX */ | ||
43 | #define RK808_SLP_SET_OFF_REG_OFFSET 2 | ||
44 | |||
39 | static const int rk808_buck_config_regs[] = { | 45 | static const int rk808_buck_config_regs[] = { |
40 | RK808_BUCK1_CONFIG_REG, | 46 | RK808_BUCK1_CONFIG_REG, |
41 | RK808_BUCK2_CONFIG_REG, | 47 | RK808_BUCK2_CONFIG_REG, |
@@ -91,6 +97,43 @@ static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) | |||
91 | RK808_RAMP_RATE_MASK, ramp_value); | 97 | RK808_RAMP_RATE_MASK, ramp_value); |
92 | } | 98 | } |
93 | 99 | ||
100 | int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv) | ||
101 | { | ||
102 | unsigned int reg; | ||
103 | int sel = regulator_map_voltage_linear_range(rdev, uv, uv); | ||
104 | |||
105 | if (sel < 0) | ||
106 | return -EINVAL; | ||
107 | |||
108 | reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET; | ||
109 | |||
110 | return regmap_update_bits(rdev->regmap, reg, | ||
111 | rdev->desc->vsel_mask, | ||
112 | sel); | ||
113 | } | ||
114 | |||
115 | int rk808_set_suspend_enable(struct regulator_dev *rdev) | ||
116 | { | ||
117 | unsigned int reg; | ||
118 | |||
119 | reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; | ||
120 | |||
121 | return regmap_update_bits(rdev->regmap, reg, | ||
122 | rdev->desc->enable_mask, | ||
123 | 0); | ||
124 | } | ||
125 | |||
126 | int rk808_set_suspend_disable(struct regulator_dev *rdev) | ||
127 | { | ||
128 | unsigned int reg; | ||
129 | |||
130 | reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; | ||
131 | |||
132 | return regmap_update_bits(rdev->regmap, reg, | ||
133 | rdev->desc->enable_mask, | ||
134 | rdev->desc->enable_mask); | ||
135 | } | ||
136 | |||
94 | static struct regulator_ops rk808_buck1_2_ops = { | 137 | static struct regulator_ops rk808_buck1_2_ops = { |
95 | .list_voltage = regulator_list_voltage_linear_range, | 138 | .list_voltage = regulator_list_voltage_linear_range, |
96 | .map_voltage = regulator_map_voltage_linear_range, | 139 | .map_voltage = regulator_map_voltage_linear_range, |
@@ -100,6 +143,9 @@ static struct regulator_ops rk808_buck1_2_ops = { | |||
100 | .disable = regulator_disable_regmap, | 143 | .disable = regulator_disable_regmap, |
101 | .is_enabled = regulator_is_enabled_regmap, | 144 | .is_enabled = regulator_is_enabled_regmap, |
102 | .set_ramp_delay = rk808_set_ramp_delay, | 145 | .set_ramp_delay = rk808_set_ramp_delay, |
146 | .set_suspend_voltage = rk808_set_suspend_voltage, | ||
147 | .set_suspend_enable = rk808_set_suspend_enable, | ||
148 | .set_suspend_disable = rk808_set_suspend_disable, | ||
103 | }; | 149 | }; |
104 | 150 | ||
105 | static struct regulator_ops rk808_reg_ops = { | 151 | static struct regulator_ops rk808_reg_ops = { |
@@ -110,12 +156,17 @@ static struct regulator_ops rk808_reg_ops = { | |||
110 | .enable = regulator_enable_regmap, | 156 | .enable = regulator_enable_regmap, |
111 | .disable = regulator_disable_regmap, | 157 | .disable = regulator_disable_regmap, |
112 | .is_enabled = regulator_is_enabled_regmap, | 158 | .is_enabled = regulator_is_enabled_regmap, |
159 | .set_suspend_voltage = rk808_set_suspend_voltage, | ||
160 | .set_suspend_enable = rk808_set_suspend_enable, | ||
161 | .set_suspend_disable = rk808_set_suspend_disable, | ||
113 | }; | 162 | }; |
114 | 163 | ||
115 | static struct regulator_ops rk808_switch_ops = { | 164 | static struct regulator_ops rk808_switch_ops = { |
116 | .enable = regulator_enable_regmap, | 165 | .enable = regulator_enable_regmap, |
117 | .disable = regulator_disable_regmap, | 166 | .disable = regulator_disable_regmap, |
118 | .is_enabled = regulator_is_enabled_regmap, | 167 | .is_enabled = regulator_is_enabled_regmap, |
168 | .set_suspend_enable = rk808_set_suspend_enable, | ||
169 | .set_suspend_disable = rk808_set_suspend_disable, | ||
119 | }; | 170 | }; |
120 | 171 | ||
121 | static const struct regulator_desc rk808_reg[] = { | 172 | static const struct regulator_desc rk808_reg[] = { |