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>
This commit is contained in:
parent
f114040e3e
commit
251ce318df
|
@ -36,6 +36,12 @@
|
|||
#define RK808_RAMP_RATE_6MV_PER_US (2 << RK808_RAMP_RATE_OFFSET)
|
||||
#define RK808_RAMP_RATE_10MV_PER_US (3 << RK808_RAMP_RATE_OFFSET)
|
||||
|
||||
/* Offset from XXX_ON_VSEL to XXX_SLP_VSEL */
|
||||
#define RK808_SLP_REG_OFFSET 1
|
||||
|
||||
/* Offset from XXX_EN_REG to SLEEP_SET_OFF_XXX */
|
||||
#define RK808_SLP_SET_OFF_REG_OFFSET 2
|
||||
|
||||
static const int rk808_buck_config_regs[] = {
|
||||
RK808_BUCK1_CONFIG_REG,
|
||||
RK808_BUCK2_CONFIG_REG,
|
||||
|
@ -91,6 +97,43 @@ static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
|
|||
RK808_RAMP_RATE_MASK, ramp_value);
|
||||
}
|
||||
|
||||
int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv)
|
||||
{
|
||||
unsigned int reg;
|
||||
int sel = regulator_map_voltage_linear_range(rdev, uv, uv);
|
||||
|
||||
if (sel < 0)
|
||||
return -EINVAL;
|
||||
|
||||
reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET;
|
||||
|
||||
return regmap_update_bits(rdev->regmap, reg,
|
||||
rdev->desc->vsel_mask,
|
||||
sel);
|
||||
}
|
||||
|
||||
int rk808_set_suspend_enable(struct regulator_dev *rdev)
|
||||
{
|
||||
unsigned int reg;
|
||||
|
||||
reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
|
||||
|
||||
return regmap_update_bits(rdev->regmap, reg,
|
||||
rdev->desc->enable_mask,
|
||||
0);
|
||||
}
|
||||
|
||||
int rk808_set_suspend_disable(struct regulator_dev *rdev)
|
||||
{
|
||||
unsigned int reg;
|
||||
|
||||
reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
|
||||
|
||||
return regmap_update_bits(rdev->regmap, reg,
|
||||
rdev->desc->enable_mask,
|
||||
rdev->desc->enable_mask);
|
||||
}
|
||||
|
||||
static struct regulator_ops rk808_buck1_2_ops = {
|
||||
.list_voltage = regulator_list_voltage_linear_range,
|
||||
.map_voltage = regulator_map_voltage_linear_range,
|
||||
|
@ -100,6 +143,9 @@ static struct regulator_ops rk808_buck1_2_ops = {
|
|||
.disable = regulator_disable_regmap,
|
||||
.is_enabled = regulator_is_enabled_regmap,
|
||||
.set_ramp_delay = rk808_set_ramp_delay,
|
||||
.set_suspend_voltage = rk808_set_suspend_voltage,
|
||||
.set_suspend_enable = rk808_set_suspend_enable,
|
||||
.set_suspend_disable = rk808_set_suspend_disable,
|
||||
};
|
||||
|
||||
static struct regulator_ops rk808_reg_ops = {
|
||||
|
@ -110,12 +156,17 @@ static struct regulator_ops rk808_reg_ops = {
|
|||
.enable = regulator_enable_regmap,
|
||||
.disable = regulator_disable_regmap,
|
||||
.is_enabled = regulator_is_enabled_regmap,
|
||||
.set_suspend_voltage = rk808_set_suspend_voltage,
|
||||
.set_suspend_enable = rk808_set_suspend_enable,
|
||||
.set_suspend_disable = rk808_set_suspend_disable,
|
||||
};
|
||||
|
||||
static struct regulator_ops rk808_switch_ops = {
|
||||
.enable = regulator_enable_regmap,
|
||||
.disable = regulator_disable_regmap,
|
||||
.is_enabled = regulator_is_enabled_regmap,
|
||||
.enable = regulator_enable_regmap,
|
||||
.disable = regulator_disable_regmap,
|
||||
.is_enabled = regulator_is_enabled_regmap,
|
||||
.set_suspend_enable = rk808_set_suspend_enable,
|
||||
.set_suspend_disable = rk808_set_suspend_disable,
|
||||
};
|
||||
|
||||
static const struct regulator_desc rk808_reg[] = {
|
||||
|
|
Loading…
Reference in a new issue