mirror of
https://github.com/torvalds/linux.git
synced 2024-10-31 17:21:49 +00:00
regulator: max77686: Add set_suspend_disable/set_suspend_mode callbacks.
This patch implements set_suspend_disable callback for BUCKs which support only switch ON/OFF modes during system suspend state, and set_suspend_mode callbacks for LDOs which also suport Low power mode and switch ON/OFF modes. Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
6d2c896b72
commit
15282ba9ea
@ -70,6 +70,82 @@ struct max77686_data {
|
||||
unsigned int opmode[MAX77686_REGULATORS];
|
||||
};
|
||||
|
||||
/* Some BUCKS supports Normal[ON/OFF] mode during suspend */
|
||||
static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev)
|
||||
{
|
||||
unsigned int val;
|
||||
struct max77686_data *max77686 = rdev_get_drvdata(rdev);
|
||||
|
||||
if (rdev->desc->id == MAX77686_BUCK1)
|
||||
val = 0x1;
|
||||
else
|
||||
val = 0x1 << MAX77686_OPMODE_BUCK234_SHIFT;
|
||||
|
||||
max77686->opmode[rdev->desc->id] = val;
|
||||
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||
rdev->desc->enable_mask,
|
||||
val);
|
||||
}
|
||||
|
||||
/* Some LDOs supports [LPM/Normal]ON mode during suspend state */
|
||||
static int max77686_set_suspend_mode(struct regulator_dev *rdev,
|
||||
unsigned int mode)
|
||||
{
|
||||
struct max77686_data *max77686 = rdev_get_drvdata(rdev);
|
||||
unsigned int val;
|
||||
|
||||
/* BUCK[5-9] doesn't support this feature */
|
||||
if (rdev->desc->id >= MAX77686_BUCK5)
|
||||
return 0;
|
||||
|
||||
switch (mode) {
|
||||
case REGULATOR_MODE_IDLE: /* ON in LP Mode */
|
||||
val = 0x2 << MAX77686_OPMODE_SHIFT;
|
||||
break;
|
||||
case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */
|
||||
val = 0x3 << MAX77686_OPMODE_SHIFT;
|
||||
break;
|
||||
default:
|
||||
pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n",
|
||||
rdev->desc->name, mode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
max77686->opmode[rdev->desc->id] = val;
|
||||
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||
rdev->desc->enable_mask,
|
||||
val);
|
||||
}
|
||||
|
||||
/* Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state */
|
||||
static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev,
|
||||
unsigned int mode)
|
||||
{
|
||||
unsigned int val;
|
||||
struct max77686_data *max77686 = rdev_get_drvdata(rdev);
|
||||
|
||||
switch (mode) {
|
||||
case REGULATOR_MODE_STANDBY: /* switch off */
|
||||
val = 0x1 << MAX77686_OPMODE_SHIFT;
|
||||
break;
|
||||
case REGULATOR_MODE_IDLE: /* ON in LP Mode */
|
||||
val = 0x2 << MAX77686_OPMODE_SHIFT;
|
||||
break;
|
||||
case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */
|
||||
val = 0x3 << MAX77686_OPMODE_SHIFT;
|
||||
break;
|
||||
default:
|
||||
pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n",
|
||||
rdev->desc->name, mode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
max77686->opmode[rdev->desc->id] = val;
|
||||
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||
rdev->desc->enable_mask,
|
||||
val);
|
||||
}
|
||||
|
||||
int max77686_enable(struct regulator_dev *rdev)
|
||||
{
|
||||
struct max77686_data *max77686 = rdev_get_drvdata(rdev);
|
||||
@ -113,6 +189,31 @@ static struct regulator_ops max77686_ops = {
|
||||
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
||||
.set_voltage_sel = regulator_set_voltage_sel_regmap,
|
||||
.set_voltage_time_sel = regulator_set_voltage_time_sel,
|
||||
.set_suspend_mode = max77686_set_suspend_mode,
|
||||
};
|
||||
|
||||
static struct regulator_ops max77686_ldo_ops = {
|
||||
.list_voltage = regulator_list_voltage_linear,
|
||||
.map_voltage = regulator_map_voltage_linear,
|
||||
.is_enabled = regulator_is_enabled_regmap,
|
||||
.enable = max77686_enable,
|
||||
.disable = regulator_disable_regmap,
|
||||
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
||||
.set_voltage_sel = regulator_set_voltage_sel_regmap,
|
||||
.set_voltage_time_sel = regulator_set_voltage_time_sel,
|
||||
.set_suspend_mode = max77686_ldo_set_suspend_mode,
|
||||
};
|
||||
|
||||
static struct regulator_ops max77686_buck1_ops = {
|
||||
.list_voltage = regulator_list_voltage_linear,
|
||||
.map_voltage = regulator_map_voltage_linear,
|
||||
.is_enabled = regulator_is_enabled_regmap,
|
||||
.enable = max77686_enable,
|
||||
.disable = regulator_disable_regmap,
|
||||
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
||||
.set_voltage_sel = regulator_set_voltage_sel_regmap,
|
||||
.set_voltage_time_sel = regulator_set_voltage_time_sel,
|
||||
.set_suspend_disable = max77686_buck_set_suspend_disable,
|
||||
};
|
||||
|
||||
static struct regulator_ops max77686_buck_dvs_ops = {
|
||||
@ -125,6 +226,7 @@ static struct regulator_ops max77686_buck_dvs_ops = {
|
||||
.set_voltage_sel = regulator_set_voltage_sel_regmap,
|
||||
.set_voltage_time_sel = regulator_set_voltage_time_sel,
|
||||
.set_ramp_delay = max77686_set_ramp_delay,
|
||||
.set_suspend_disable = max77686_buck_set_suspend_disable,
|
||||
};
|
||||
|
||||
#define regulator_desc_ldo(num) { \
|
||||
@ -143,7 +245,39 @@ static struct regulator_ops max77686_buck_dvs_ops = {
|
||||
.enable_mask = MAX77686_OPMODE_MASK \
|
||||
<< MAX77686_OPMODE_SHIFT, \
|
||||
}
|
||||
#define regulator_desc_lpm_ldo(num) { \
|
||||
.name = "LDO"#num, \
|
||||
.id = MAX77686_LDO##num, \
|
||||
.ops = &max77686_ldo_ops, \
|
||||
.type = REGULATOR_VOLTAGE, \
|
||||
.owner = THIS_MODULE, \
|
||||
.min_uV = MAX77686_LDO_MINUV, \
|
||||
.uV_step = MAX77686_LDO_UVSTEP, \
|
||||
.ramp_delay = MAX77686_RAMP_DELAY, \
|
||||
.n_voltages = MAX77686_VSEL_MASK + 1, \
|
||||
.vsel_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \
|
||||
.vsel_mask = MAX77686_VSEL_MASK, \
|
||||
.enable_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \
|
||||
.enable_mask = MAX77686_OPMODE_MASK \
|
||||
<< MAX77686_OPMODE_SHIFT, \
|
||||
}
|
||||
#define regulator_desc_ldo_low(num) { \
|
||||
.name = "LDO"#num, \
|
||||
.id = MAX77686_LDO##num, \
|
||||
.ops = &max77686_ldo_ops, \
|
||||
.type = REGULATOR_VOLTAGE, \
|
||||
.owner = THIS_MODULE, \
|
||||
.min_uV = MAX77686_LDO_LOW_MINUV, \
|
||||
.uV_step = MAX77686_LDO_LOW_UVSTEP, \
|
||||
.ramp_delay = MAX77686_RAMP_DELAY, \
|
||||
.n_voltages = MAX77686_VSEL_MASK + 1, \
|
||||
.vsel_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \
|
||||
.vsel_mask = MAX77686_VSEL_MASK, \
|
||||
.enable_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \
|
||||
.enable_mask = MAX77686_OPMODE_MASK \
|
||||
<< MAX77686_OPMODE_SHIFT, \
|
||||
}
|
||||
#define regulator_desc_ldo1_low(num) { \
|
||||
.name = "LDO"#num, \
|
||||
.id = MAX77686_LDO##num, \
|
||||
.ops = &max77686_ops, \
|
||||
@ -177,7 +311,7 @@ static struct regulator_ops max77686_buck_dvs_ops = {
|
||||
#define regulator_desc_buck1(num) { \
|
||||
.name = "BUCK"#num, \
|
||||
.id = MAX77686_BUCK##num, \
|
||||
.ops = &max77686_ops, \
|
||||
.ops = &max77686_buck1_ops, \
|
||||
.type = REGULATOR_VOLTAGE, \
|
||||
.owner = THIS_MODULE, \
|
||||
.min_uV = MAX77686_BUCK_MINUV, \
|
||||
@ -207,7 +341,7 @@ static struct regulator_ops max77686_buck_dvs_ops = {
|
||||
}
|
||||
|
||||
static struct regulator_desc regulators[] = {
|
||||
regulator_desc_ldo_low(1),
|
||||
regulator_desc_ldo1_low(1),
|
||||
regulator_desc_ldo_low(2),
|
||||
regulator_desc_ldo(3),
|
||||
regulator_desc_ldo(4),
|
||||
@ -216,13 +350,13 @@ static struct regulator_desc regulators[] = {
|
||||
regulator_desc_ldo_low(7),
|
||||
regulator_desc_ldo_low(8),
|
||||
regulator_desc_ldo(9),
|
||||
regulator_desc_ldo(10),
|
||||
regulator_desc_ldo(11),
|
||||
regulator_desc_ldo(12),
|
||||
regulator_desc_lpm_ldo(10),
|
||||
regulator_desc_lpm_ldo(11),
|
||||
regulator_desc_lpm_ldo(12),
|
||||
regulator_desc_ldo(13),
|
||||
regulator_desc_ldo(14),
|
||||
regulator_desc_lpm_ldo(14),
|
||||
regulator_desc_ldo_low(15),
|
||||
regulator_desc_ldo(16),
|
||||
regulator_desc_lpm_ldo(16),
|
||||
regulator_desc_ldo(17),
|
||||
regulator_desc_ldo(18),
|
||||
regulator_desc_ldo(19),
|
||||
|
Loading…
Reference in New Issue
Block a user