aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javier.martinez@collabora.co.uk>2014-10-16 12:48:47 -0400
committerMark Brown <broonie@kernel.org>2014-10-20 07:23:50 -0400
commitefbe519945746371f92f5c3796818bf3e24c80ad (patch)
tree7467b57dd71f6b0a8b4eb61e24cdc61cc8aa29b1
parentb0615f1da543500f8442fa6e5adacb8c54b34c5f (diff)
regulator: max77802: Add .{get,set}_mode callbacks
Some max77802 LDOs (1, 3, 20 and 21) support to be configured in Low Power Mode during system normal operation. Add function handlers for the .get_mode and .set_mode operations to set the mode on these LDOs. Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/max77802.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
index 8425c0d520a8..6eabb954ec7c 100644
--- a/drivers/regulator/max77802.c
+++ b/drivers/regulator/max77802.c
@@ -70,6 +70,12 @@ struct max77802_regulator_prv {
70 unsigned int opmode[MAX77802_REG_MAX]; 70 unsigned int opmode[MAX77802_REG_MAX];
71}; 71};
72 72
73static inline int max77802_map_mode(int mode)
74{
75 return mode == MAX77802_OPMODE_NORMAL ?
76 REGULATOR_MODE_NORMAL : REGULATOR_MODE_STANDBY;
77}
78
73static int max77802_get_opmode_shift(int id) 79static int max77802_get_opmode_shift(int id)
74{ 80{
75 if (id == MAX77802_BUCK1 || (id >= MAX77802_BUCK5 && 81 if (id == MAX77802_BUCK1 || (id >= MAX77802_BUCK5 &&
@@ -105,6 +111,44 @@ static int max77802_set_suspend_disable(struct regulator_dev *rdev)
105} 111}
106 112
107/* 113/*
114 * Some LDOs support Low Power Mode while the system is running.
115 *
116 * LDOs 1, 3, 20, 21.
117 */
118static int max77802_set_mode(struct regulator_dev *rdev, unsigned int mode)
119{
120 struct max77802_regulator_prv *max77802 = rdev_get_drvdata(rdev);
121 int id = rdev_get_id(rdev);
122 unsigned int val;
123 int shift = max77802_get_opmode_shift(id);
124
125 switch (mode) {
126 case REGULATOR_MODE_STANDBY:
127 val = MAX77802_OPMODE_LP; /* ON in Low Power Mode */
128 break;
129 case REGULATOR_MODE_NORMAL:
130 val = MAX77802_OPMODE_NORMAL; /* ON in Normal Mode */
131 break;
132 default:
133 dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n",
134 rdev->desc->name, mode);
135 return -EINVAL;
136 }
137
138 max77802->opmode[id] = val;
139 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
140 rdev->desc->enable_mask, val << shift);
141}
142
143static unsigned max77802_get_mode(struct regulator_dev *rdev)
144{
145 struct max77802_regulator_prv *max77802 = rdev_get_drvdata(rdev);
146 int id = rdev_get_id(rdev);
147
148 return max77802_map_mode(max77802->opmode[id]);
149}
150
151/*
108 * Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state 152 * Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state
109 * (Enable Control Logic1 by PWRREQ) 153 * (Enable Control Logic1 by PWRREQ)
110 * 154 *
@@ -268,6 +312,8 @@ static struct regulator_ops max77802_ldo_ops_logic2 = {
268 .get_voltage_sel = regulator_get_voltage_sel_regmap, 312 .get_voltage_sel = regulator_get_voltage_sel_regmap,
269 .set_voltage_sel = regulator_set_voltage_sel_regmap, 313 .set_voltage_sel = regulator_set_voltage_sel_regmap,
270 .set_voltage_time_sel = regulator_set_voltage_time_sel, 314 .set_voltage_time_sel = regulator_set_voltage_time_sel,
315 .set_mode = max77802_set_mode,
316 .get_mode = max77802_get_mode,
271 .set_suspend_mode = max77802_ldo_set_suspend_mode_logic2, 317 .set_suspend_mode = max77802_ldo_set_suspend_mode_logic2,
272}; 318};
273 319