diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2013-02-18 20:09:00 +0530 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2013-03-11 14:59:22 -0700 |
commit | 776ddb6691c30e76a55daf48380a54083cc0a9b6 (patch) | |
tree | 542a29ad5393528f956e2320bd133b8cd29eb089 | |
parent | 47c490614a56c46042210736b9d1d3b08dfb4d16 (diff) |
regulator: palmas: implement sleep mode configuration
Palma is having different set of bits to configure sleep mode.
Implement the set_sleep_mode for core to configure these bits.
Change-Id: If78c95a3da5a1f875d8588a997c85f1bf01c9638
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
(cherry picked from commit 66cfad6d8df30cc33ad0858718edb84dbeb14e99)
Reviewed-on: http://git-master/r/207831
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Wen Yi <wyi@nvidia.com>
Tested-by: Wen Yi <wyi@nvidia.com>
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index b543df1d2864..c768b837871c 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -205,6 +205,11 @@ static unsigned int palmas_smps_ramp_delay[4] = {0, 10000, 5000, 2500}; #define SMPS_CTRL_MODE_ECO 0x02 #define SMPS_CTRL_MODE_PWM 0x03 +#define SMPS_CTRL_SLEEP_MODE_OFF 0x00 +#define SMPS_CTRL_SLEEP_MODE_ON 0x04 +#define SMPS_CTRL_SLEEP_MODE_ECO 0x08 +#define SMPS_CTRL_SLEEP_MODE_PWM 0x0C + /* These values are derived from the data sheet. And are the number of steps * where there is a voltage change, the ranges at beginning and end of register * max/min values where there are no change are ommitted. @@ -388,6 +393,37 @@ static unsigned int palmas_get_mode_smps(struct regulator_dev *dev) return 0; } +static int palmas_set_sleep_mode_smps(struct regulator_dev *dev, + unsigned int mode) +{ + struct palmas_pmic *pmic = rdev_get_drvdata(dev); + int id = rdev_get_id(dev); + unsigned int reg; + + palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); + reg &= ~PALMAS_SMPS12_CTRL_MODE_SLEEP_MASK; + + switch (mode) { + case REGULATOR_MODE_NORMAL: + reg |= SMPS_CTRL_SLEEP_MODE_ON; + break; + case REGULATOR_MODE_IDLE: + reg |= SMPS_CTRL_SLEEP_MODE_ECO; + break; + case REGULATOR_MODE_FAST: + reg |= SMPS_CTRL_SLEEP_MODE_PWM; + break; + case REGULATOR_MODE_STANDBY: + case REGULATOR_MODE_OFF: + reg |= SMPS_CTRL_SLEEP_MODE_OFF; + break; + default: + return -EINVAL; + } + palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); + return 0; +} + static int palmas_list_voltage_smps(struct regulator_dev *dev, unsigned selector) { @@ -519,6 +555,7 @@ static struct regulator_ops palmas_ops_smps = { .disable = palmas_disable_smps, .set_mode = palmas_set_mode_smps, .get_mode = palmas_get_mode_smps, + .set_sleep_mode = palmas_set_sleep_mode_smps, .get_voltage_sel = palmas_get_voltage_smps_sel, .set_voltage_sel = palmas_set_voltage_smps_sel, .list_voltage = palmas_list_voltage_smps, |