Commit 1896a134 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6: (45 commits)
  regulator: missing index in PTR_ERR() in isl6271a_probe()
  regulator: Assign return value of mc13xxx_reg_rmw to ret
  regulator: Add initial per-regulator debugfs support
  regulator: Make regulator_has_full_constraints a bool
  regulator: Clean up logging a bit
  regulator: Optimise out noop voltage changes
  regulator: Add API to re-apply voltage to hardware
  regulator: Staticise non-exported functions in mc13892
  regulator: Only notify voltage changes when they succeed
  regulator: Provide a selector based set_voltage_sel() operation
  regulator: Factor out voltage set operation into a separate function
  regulator: Convert WM8994 to use get_voltage_sel()
  regulator: Convert WM835x to use get_voltage_sel()
  regulator: Allow modular build of mc13xxx-core
  regulator: support PMIC mc13892
  make mc13783 regulator code generic
  Change the register name definitions for mc13783
  mach-ux500: Updated and connected ab8500 regulator board configuration
  regulators: Removed macros for initialization of ab8500 regulators
  regulators: Added verbose debug messages to ab8500 regulators
  ...
parents e691d24e fa63bd4a
...@@ -254,10 +254,10 @@ static struct regulator_init_data cam_data = { ...@@ -254,10 +254,10 @@ static struct regulator_init_data cam_data = {
static struct mc13783_regulator_init_data pcm038_regulators[] = { static struct mc13783_regulator_init_data pcm038_regulators[] = {
{ {
.id = MC13783_REGU_VCAM, .id = MC13783_REG_VCAM,
.init_data = &cam_data, .init_data = &cam_data,
}, { }, {
.id = MC13783_REGU_VMMC1, .id = MC13783_REG_VMMC1,
.init_data = &sdhc1_data, .init_data = &sdhc1_data,
}, },
}; };
......
...@@ -140,10 +140,10 @@ static struct regulator_init_data gpo_init = { ...@@ -140,10 +140,10 @@ static struct regulator_init_data gpo_init = {
static struct mc13783_regulator_init_data mx31_3ds_regulators[] = { static struct mc13783_regulator_init_data mx31_3ds_regulators[] = {
{ {
.id = MC13783_REGU_PWGT1SPI, /* Power Gate for ARM core. */ .id = MC13783_REG_PWGT1SPI, /* Power Gate for ARM core. */
.init_data = &pwgtx_init, .init_data = &pwgtx_init,
}, { }, {
.id = MC13783_REGU_PWGT2SPI, /* Power Gate for L2 Cache. */ .id = MC13783_REG_PWGT2SPI, /* Power Gate for L2 Cache. */
.init_data = &pwgtx_init, .init_data = &pwgtx_init,
}, { }, {
......
...@@ -216,11 +216,11 @@ static struct regulator_init_data cam_vreg_data = { ...@@ -216,11 +216,11 @@ static struct regulator_init_data cam_vreg_data = {
static struct mc13783_regulator_init_data moboard_regulators[] = { static struct mc13783_regulator_init_data moboard_regulators[] = {
{ {
.id = MC13783_REGU_VMMC1, .id = MC13783_REG_VMMC1,
.init_data = &sdhc_vreg_data, .init_data = &sdhc_vreg_data,
}, },
{ {
.id = MC13783_REGU_VCAM, .id = MC13783_REG_VCAM,
.init_data = &cam_vreg_data, .init_data = &cam_vreg_data,
}, },
}; };
......
...@@ -3,99 +3,94 @@ ...@@ -3,99 +3,94 @@
* *
* License Terms: GNU General Public License v2 * License Terms: GNU General Public License v2
* *
* Author: Sundar Iyer <sundar.iyer@stericsson.com> * Authors: Sundar Iyer <sundar.iyer@stericsson.com>
* Bengt Jonsson <bengt.g.jonsson@stericsson.com>
* *
* MOP500 board specific initialization for regulators * MOP500 board specific initialization for regulators
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/regulator/ab8500.h>
/* supplies to the display/camera */ /* AB8500 regulators */
static struct regulator_init_data ab8500_vaux1_regulator = { struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
/* supplies to the display/camera */
[AB8500_LDO_AUX1] = {
.constraints = { .constraints = {
.name = "V-DISPLAY", .name = "V-DISPLAY",
.min_uV = 2500000, .min_uV = 2500000,
.max_uV = 2900000, .max_uV = 2900000,
.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE| .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
REGULATOR_CHANGE_STATUS, REGULATOR_CHANGE_STATUS,
}, },
}; },
/* supplies to the on-board eMMC */
/* supplies to the on-board eMMC */ [AB8500_LDO_AUX2] = {
static struct regulator_init_data ab8500_vaux2_regulator = {
.constraints = { .constraints = {
.name = "V-eMMC1", .name = "V-eMMC1",
.min_uV = 1100000, .min_uV = 1100000,
.max_uV = 3300000, .max_uV = 3300000,
.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE| .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
REGULATOR_CHANGE_STATUS, REGULATOR_CHANGE_STATUS,
}, },
}; },
/* supply for VAUX3, supplies to SDcard slots */
/* supply for VAUX3, supplies to SDcard slots */ [AB8500_LDO_AUX3] = {
static struct regulator_init_data ab8500_vaux3_regulator = {
.constraints = { .constraints = {
.name = "V-MMC-SD", .name = "V-MMC-SD",
.min_uV = 1100000, .min_uV = 1100000,
.max_uV = 3300000, .max_uV = 3300000,
.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE| .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
REGULATOR_CHANGE_STATUS, REGULATOR_CHANGE_STATUS,
}, },
}; },
/* supply for tvout, gpadc, TVOUT LDO */
/* supply for tvout, gpadc, TVOUT LDO */ [AB8500_LDO_TVOUT] = {
static struct regulator_init_data ab8500_vtvout_init = {
.constraints = { .constraints = {
.name = "V-TVOUT", .name = "V-TVOUT",
.valid_ops_mask = REGULATOR_CHANGE_STATUS, .valid_ops_mask = REGULATOR_CHANGE_STATUS,
}, },
}; },
/* supply for ab8500-vaudio, VAUDIO LDO */
/* supply for ab8500-vaudio, VAUDIO LDO */ [AB8500_LDO_AUDIO] = {
static struct regulator_init_data ab8500_vaudio_init = {
.constraints = { .constraints = {
.name = "V-AUD", .name = "V-AUD",
.valid_ops_mask = REGULATOR_CHANGE_STATUS, .valid_ops_mask = REGULATOR_CHANGE_STATUS,
}, },
}; },
/* supply for v-anamic1 VAMic1-LDO */
/* supply for v-anamic1 VAMic1-LDO */ [AB8500_LDO_ANAMIC1] = {
static struct regulator_init_data ab8500_vamic1_init = {
.constraints = { .constraints = {
.name = "V-AMIC1", .name = "V-AMIC1",
.valid_ops_mask = REGULATOR_CHANGE_STATUS, .valid_ops_mask = REGULATOR_CHANGE_STATUS,
}, },
}; },
/* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */
/* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */ [AB8500_LDO_ANAMIC2] = {
static struct regulator_init_data ab8500_vamic2_init = {
.constraints = { .constraints = {
.name = "V-AMIC2", .name = "V-AMIC2",
.valid_ops_mask = REGULATOR_CHANGE_STATUS, .valid_ops_mask = REGULATOR_CHANGE_STATUS,
}, },
}; },
/* supply for v-dmic, VDMIC LDO */
/* supply for v-dmic, VDMIC LDO */ [AB8500_LDO_DMIC] = {
static struct regulator_init_data ab8500_vdmic_init = {
.constraints = { .constraints = {
.name = "V-DMIC", .name = "V-DMIC",
.valid_ops_mask = REGULATOR_CHANGE_STATUS, .valid_ops_mask = REGULATOR_CHANGE_STATUS,
}, },
}; },
/* supply for v-intcore12, VINTCORE12 LDO */
/* supply for v-intcore12, VINTCORE12 LDO */ [AB8500_LDO_INTCORE] = {
static struct regulator_init_data ab8500_vintcore_init = {
.constraints = { .constraints = {
.name = "V-INTCORE", .name = "V-INTCORE",
.valid_ops_mask = REGULATOR_CHANGE_STATUS, .valid_ops_mask = REGULATOR_CHANGE_STATUS,
}, },
}; },
/* supply for U8500 CSI/DSI, VANA LDO */
/* supply for U8500 CSI/DSI, VANA LDO */ [AB8500_LDO_ANA] = {
static struct regulator_init_data ab8500_vana_init = {
.constraints = { .constraints = {
.name = "V-CSI/DSI", .name = "V-CSI/DSI",
.valid_ops_mask = REGULATOR_CHANGE_STATUS, .valid_ops_mask = REGULATOR_CHANGE_STATUS,
}, },
},
}; };
/*
* Copyright (C) ST-Ericsson SA 2010
*
* License Terms: GNU General Public License v2
*
* Author: Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
*
* MOP500 board specific initialization for regulators
*/
#ifndef __BOARD_MOP500_REGULATORS_H
#define __BOARD_MOP500_REGULATORS_H
#include <linux/regulator/machine.h>
#include <linux/regulator/ab8500.h>
extern struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS];
#endif
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "devices-db8500.h" #include "devices-db8500.h"
#include "pins-db8500.h" #include "pins-db8500.h"
#include "board-mop500.h" #include "board-mop500.h"
#include "board-mop500-regulators.h"
static pin_cfg_t mop500_pins[] = { static pin_cfg_t mop500_pins[] = {
/* SSP0 */ /* SSP0 */
...@@ -80,6 +81,8 @@ static pin_cfg_t mop500_pins[] = { ...@@ -80,6 +81,8 @@ static pin_cfg_t mop500_pins[] = {
static struct ab8500_platform_data ab8500_platdata = { static struct ab8500_platform_data ab8500_platdata = {
.irq_base = MOP500_AB8500_IRQ_BASE, .irq_base = MOP500_AB8500_IRQ_BASE,
.regulator = ab8500_regulators,
.num_regulator = ARRAY_SIZE(ab8500_regulators),
}; };
static struct resource ab8500_resources[] = { static struct resource ab8500_resources[] = {
......
...@@ -249,7 +249,7 @@ static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) ...@@ -249,7 +249,7 @@ static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
} }
static int pm8607_set_voltage(struct regulator_dev *rdev, static int pm8607_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
uint8_t val, mask; uint8_t val, mask;
...@@ -263,6 +263,7 @@ static int pm8607_set_voltage(struct regulator_dev *rdev, ...@@ -263,6 +263,7 @@ static int pm8607_set_voltage(struct regulator_dev *rdev,
ret = choose_voltage(rdev, min_uV, max_uV); ret = choose_voltage(rdev, min_uV, max_uV);
if (ret < 0) if (ret < 0)
return -EINVAL; return -EINVAL;
*selector = ret;
val = (uint8_t)(ret << info->vol_shift); val = (uint8_t)(ret << info->vol_shift);
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
......
...@@ -186,13 +186,25 @@ config REGULATOR_PCAP ...@@ -186,13 +186,25 @@ config REGULATOR_PCAP
This driver provides support for the voltage regulators of the This driver provides support for the voltage regulators of the
PCAP2 PMIC. PCAP2 PMIC.
config REGULATOR_MC13XXX_CORE
tristate
config REGULATOR_MC13783 config REGULATOR_MC13783
tristate "Support regulators on Freescale MC13783 PMIC" tristate "Support regulators on Freescale MC13783 PMIC"
depends on MFD_MC13783 depends on MFD_MC13783
select REGULATOR_MC13XXX_CORE
help help
Say y here to support the regulators found on the Freescale MC13783 Say y here to support the regulators found on the Freescale MC13783
PMIC. PMIC.
config REGULATOR_MC13892
tristate "Support regulators on Freescale MC13892 PMIC"
depends on MFD_MC13XXX
select REGULATOR_MC13XXX_CORE
help
Say y here to support the regulators found on the Freescale MC13892
PMIC.
config REGULATOR_AB3100 config REGULATOR_AB3100
tristate "ST-Ericsson AB3100 Regulator functions" tristate "ST-Ericsson AB3100 Regulator functions"
depends on AB3100_CORE depends on AB3100_CORE
...@@ -250,5 +262,15 @@ config REGULATOR_TPS6586X ...@@ -250,5 +262,15 @@ config REGULATOR_TPS6586X
help help
This driver supports TPS6586X voltage regulator chips. This driver supports TPS6586X voltage regulator chips.
config REGULATOR_TPS6524X
tristate "TI TPS6524X Power regulators"
depends on SPI
help
This driver supports TPS6524X voltage regulator chips. TPS6524X
provides three step-down converters and two general-purpose LDO
voltage regulators. This device is interfaced using a customized
serial interface currently supported on the sequencer serial
port controller.
endif endif
...@@ -30,10 +30,13 @@ obj-$(CONFIG_REGULATOR_DA903X) += da903x.o ...@@ -30,10 +30,13 @@ obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o
obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o
obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o
obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
......
...@@ -362,7 +362,8 @@ static int ab3100_get_best_voltage_index(struct regulator_dev *reg, ...@@ -362,7 +362,8 @@ static int ab3100_get_best_voltage_index(struct regulator_dev *reg,
} }
static int ab3100_set_voltage_regulator(struct regulator_dev *reg, static int ab3100_set_voltage_regulator(struct regulator_dev *reg,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct ab3100_regulator *abreg = reg->reg_data; struct ab3100_regulator *abreg = reg->reg_data;
u8 regval; u8 regval;
...@@ -373,6 +374,8 @@ static int ab3100_set_voltage_regulator(struct regulator_dev *reg, ...@@ -373,6 +374,8 @@ static int ab3100_set_voltage_regulator(struct regulator_dev *reg,
if (bestindex < 0) if (bestindex < 0)
return bestindex; return bestindex;
*selector = bestindex;
err = abx500_get_register_interruptible(abreg->dev, 0, err = abx500_get_register_interruptible(abreg->dev, 0,
abreg->regreg, &regval); abreg->regreg, &regval);
if (err) { if (err) {
......
This diff is collapsed.
This diff is collapsed.
...@@ -107,7 +107,7 @@ static inline int check_range(struct da903x_regulator_info *info, ...@@ -107,7 +107,7 @@ static inline int check_range(struct da903x_regulator_info *info,
/* DA9030/DA9034 common operations */ /* DA9030/DA9034 common operations */
static int da903x_set_ldo_voltage(struct regulator_dev *rdev, static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct da903x_regulator_info *info = rdev_get_drvdata(rdev); struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
struct device *da9034_dev = to_da903x_dev(rdev); struct device *da9034_dev = to_da903x_dev(rdev);
...@@ -119,6 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev, ...@@ -119,6 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
*selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -187,7 +188,8 @@ static int da903x_list_voltage(struct regulator_dev *rdev, unsigned selector) ...@@ -187,7 +188,8 @@ static int da903x_list_voltage(struct regulator_dev *rdev, unsigned selector)
/* DA9030 specific operations */ /* DA9030 specific operations */
static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct da903x_regulator_info *info = rdev_get_drvdata(rdev); struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
struct device *da903x_dev = to_da903x_dev(rdev); struct device *da903x_dev = to_da903x_dev(rdev);
...@@ -200,6 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, ...@@ -200,6 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
*selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
val |= DA9030_LDO_UNLOCK; /* have to set UNLOCK bits */ val |= DA9030_LDO_UNLOCK; /* have to set UNLOCK bits */
...@@ -214,7 +217,8 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, ...@@ -214,7 +217,8 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
} }
static int da9030_set_ldo14_voltage(struct regulator_dev *rdev, static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct da903x_regulator_info *info = rdev_get_drvdata(rdev); struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
struct device *da903x_dev = to_da903x_dev(rdev); struct device *da903x_dev = to_da903x_dev(rdev);
...@@ -234,6 +238,7 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev, ...@@ -234,6 +238,7 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
val = (min_uV - thresh + info->step_uV - 1) / info->step_uV; val = (min_uV - thresh + info->step_uV - 1) / info->step_uV;
} }
*selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -263,7 +268,7 @@ static int da9030_get_ldo14_voltage(struct regulator_dev *rdev) ...@@ -263,7 +268,7 @@ static int da9030_get_ldo14_voltage(struct regulator_dev *rdev)
/* DA9034 specific operations */ /* DA9034 specific operations */
static int da9034_set_dvc_voltage(struct regulator_dev *rdev, static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct da903x_regulator_info *info = rdev_get_drvdata(rdev); struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
struct device *da9034_dev = to_da903x_dev(rdev); struct device *da9034_dev = to_da903x_dev(rdev);
...@@ -276,6 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev, ...@@ -276,6 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
*selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -289,7 +295,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev, ...@@ -289,7 +295,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
} }
static int da9034_set_ldo12_voltage(struct regulator_dev *rdev, static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct da903x_regulator_info *info = rdev_get_drvdata(rdev); struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
struct device *da9034_dev = to_da903x_dev(rdev); struct device *da9034_dev = to_da903x_dev(rdev);
...@@ -302,6 +308,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev, ...@@ -302,6 +308,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val); val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val);
*selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
......
...@@ -58,7 +58,9 @@ static int isl6271a_get_voltage(struct regulator_dev *dev) ...@@ -58,7 +58,9 @@ static int isl6271a_get_voltage(struct regulator_dev *dev)
return data; return data;
} }
static int isl6271a_set_voltage(struct regulator_dev *dev, int minuV, int maxuV) static int isl6271a_set_voltage(struct regulator_dev *dev,
int minuV, int maxuV,
unsigned *selector)
{ {
struct isl_pmic *pmic = rdev_get_drvdata(dev); struct isl_pmic *pmic = rdev_get_drvdata(dev);
int vsel, err, data; int vsel, err, data;
...@@ -78,6 +80,8 @@ static int isl6271a_set_voltage(struct regulator_dev *dev, int minuV, int maxuV) ...@@ -78,6 +80,8 @@ static int isl6271a_set_voltage(struct regulator_dev *dev, int minuV, int maxuV)
/* Convert the microvolts to data for the chip */ /* Convert the microvolts to data for the chip */
data = (vsel - ISL6271A_VOLTAGE_MIN) / ISL6271A_VOLTAGE_STEP; data = (vsel - ISL6271A_VOLTAGE_MIN) / ISL6271A_VOLTAGE_STEP;
*selector = data;
mutex_lock(&pmic->mtx); mutex_lock(&pmic->mtx);
err = i2c_smbus_write_byte(pmic->client, data); err = i2c_smbus_write_byte(pmic->client, data);
...@@ -169,7 +173,7 @@ static int __devinit isl6271a_probe(struct i2c_client *i2c, ...@@ -169,7 +173,7 @@ static int __devinit isl6271a_probe(struct i2c_client *i2c,
init_data, pmic); init_data, pmic);
if (IS_ERR(pmic->rdev[i])) { if (IS_ERR(pmic->rdev[i])) {
dev_err(&i2c->dev, "failed to register %s\n", id->name); dev_err(&i2c->dev, "failed to register %s\n", id->name);
err = PTR_ERR(pmic->rdev); err = PTR_ERR(pmic->rdev[i]);
goto error; goto error;
} }
} }
......
...@@ -168,7 +168,8 @@ static int lp3971_ldo_get_voltage(struct regulator_dev *dev) ...@@ -168,7 +168,8 @@ static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
} }
static int lp3971_ldo_set_voltage(struct regulator_dev *dev, static int lp3971_ldo_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned int *selector)
{ {
struct lp3971 *lp3971 = rdev_get_drvdata(dev); struct lp3971 *lp3971 = rdev_get_drvdata(dev);
int ldo = rdev_get_id(dev) - LP3971_LDO1; int ldo = rdev_get_id(dev) - LP3971_LDO1;
...@@ -187,6 +188,8 @@ static int lp3971_ldo_set_voltage(struct regulator_dev *dev, ...@@ -187,6 +188,8 @@ static int lp3971_ldo_set_voltage(struct regulator_dev *dev,
if (val > LDO_VOL_MAX_IDX || vol_map[val] > max_vol) if (val > LDO_VOL_MAX_IDX || vol_map[val] > max_vol)
return -EINVAL; return -EINVAL;
*selector = val;
return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo), return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo),
LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo), LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo),
val << LDO_VOL_CONTR_SHIFT(ldo)); val << LDO_VOL_CONTR_SHIFT(ldo));
...@@ -256,7 +259,8 @@ static int lp3971_dcdc_get_voltage(struct regulator_dev *dev) ...@@ -256,7 +259,8 @@ static int lp3971_dcdc_get_voltage(struct regulator_dev *dev)
} }
static int lp3971_dcdc_set_voltage(struct regulator_dev *dev, static int lp3971_dcdc_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned int *selector)
{ {
struct lp3971 *lp3971 = rdev_get_drvdata(dev); struct lp3971 *lp3971 = rdev_get_drvdata(dev);
int buck = rdev_get_id(dev) - LP3971_DCDC1; int buck = rdev_get_id(dev) - LP3971_DCDC1;
...@@ -277,6 +281,8 @@ static int lp3971_dcdc_set_voltage(struct regulator_dev *dev, ...@@ -277,6 +281,8 @@ static int lp3971_dcdc_set_voltage(struct regulator_dev *dev,
if (val > BUCK_TARGET_VOL_MAX_IDX || vol_map[val] > max_vol) if (val > BUCK_TARGET_VOL_MAX_IDX || vol_map[val] > max_vol)
return -EINVAL; return -EINVAL;
*selector = val;
ret = lp3971_set_bits(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck), ret = lp3971_set_bits(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck),
BUCK_TARGET_VOL_MASK, val); BUCK_TARGET_VOL_MASK, val);
if (ret) if (ret)
......
...@@ -292,7 +292,8 @@ static int lp3972_ldo_get_voltage(struct regulator_dev *dev) ...@@ -292,7 +292,8 @@ static int lp3972_ldo_get_voltage(struct regulator_dev *dev)
} }
static int lp3972_ldo_set_voltage(struct regulator_dev *dev, static int lp3972_ldo_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned int *selector)
{ {
struct lp3972 *lp3972 = rdev_get_drvdata(dev); struct lp3972 *lp3972 = rdev_get_drvdata(dev);
int ldo = rdev_get_id(dev) - LP3972_LDO1; int ldo = rdev_get_id(dev) - LP3972_LDO1;
...@@ -313,6 +314,8 @@ static int lp3972_ldo_set_voltage(struct regulator_dev *dev, ...@@ -313,6 +314,8 @@ static int lp3972_ldo_set_voltage(struct regulator_dev *dev,
if (val > LP3972_LDO_VOL_MAX_IDX(ldo) || vol_map[val] > max_vol) if (val > LP3972_LDO_VOL_MAX_IDX(ldo) || vol_map[val] > max_vol)
return -EINVAL; return -EINVAL;
*selector = val;
shift = LP3972_LDO_VOL_CONTR_SHIFT(ldo); shift = LP3972_LDO_VOL_CONTR_SHIFT(ldo);
ret = lp3972_set_bits(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo), ret = lp3972_set_bits(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo),
LP3972_LDO_VOL_MASK(ldo) << shift, val << shift); LP3972_LDO_VOL_MASK(ldo) << shift, val << shift);
...@@ -416,7 +419,8 @@ static int lp3972_dcdc_get_voltage(struct regulator_dev *dev) ...@@ -416,7 +419,8 @@ static int lp3972_dcdc_get_voltage(struct regulator_dev *dev)
} }
static int lp3972_dcdc_set_voltage(struct regulator_dev *dev, static int lp3972_dcdc_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned int *selector)
{ {
struct lp3972 *lp3972 = rdev_get_drvdata(dev); struct lp3972 *lp3972 = rdev_get_drvdata(dev);
int buck = rdev_get_id(dev) - LP3972_DCDC1; int buck = rdev_get_id(dev) - LP3972_DCDC1;
...@@ -438,6 +442,8 @@ static int lp3972_dcdc_set_voltage(struct regulator_dev *dev, ...@@ -438,6 +442,8 @@ static int lp3972_dcdc_set_voltage(struct regulator_dev *dev,
vol_map[val] > max_vol) vol_map[val] > max_vol)
return -EINVAL; return -EINVAL;
*selector = val;
ret = lp3972_set_bits(lp3972, LP3972_BUCK_VOL1_REG(buck), ret = lp3972_set_bits(lp3972, LP3972_BUCK_VOL1_REG(buck),
LP3972_BUCK_VOL_MASK, val); LP3972_BUCK_VOL_MASK, val);
if (ret) if (ret)
......
...@@ -63,12 +63,12 @@ static int max1586_v3_calc_voltage(struct max1586_data *max1586, ...@@ -63,12 +63,12 @@ static int max1586_v3_calc_voltage(struct max1586_data *max1586,
return max1586->min_uV + (selector * range_uV / MAX1586_V3_MAX_VSEL); return max1586->min_uV + (selector * range_uV / MAX1586_V3_MAX_VSEL);
} }
static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV) static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV,
unsigned *selector)
{ {
struct max1586_data *max1586 = rdev_get_drvdata(rdev); struct max1586_data *max1586 = rdev_get_drvdata(rdev);
struct i2c_client *client = max1586->client; struct i2c_client *client = max1586->client;
unsigned range_uV = max1586->max_uV - max1586->min_uV; unsigned range_uV = max1586->max_uV - max1586->min_uV;
unsigned selector;
u8 v3_prog; u8 v3_prog;
if (min_uV > max1586->max_uV || max_uV < max1586->min_uV) if (min_uV > max1586->max_uV || max_uV < max1586->min_uV)
...@@ -76,15 +76,15 @@ static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV) ...@@ -76,15 +76,15 @@ static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV)
if (min_uV < max1586->min_uV) if (min_uV < max1586->min_uV)
min_uV = max1586->min_uV; min_uV = max1586->min_uV;
selector = ((min_uV - max1586->min_uV) * MAX1586_V3_MAX_VSEL + *selector = ((min_uV - max1586->min_uV) * MAX1586_V3_MAX_VSEL +
range_uV - 1) / range_uV; range_uV - 1) / range_uV;
if (max1586_v3_calc_voltage(max1586, selector) > max_uV) if (max1586_v3_calc_voltage(max1586, *selector) > max_uV)
return -EINVAL; return -EINVAL;
dev_dbg(&client->dev, "changing voltage v3 to %dmv\n", dev_dbg(&client->dev, "changing voltage v3 to %dmv\n",
max1586_v3_calc_voltage(max1586, selector) / 1000); max1586_v3_calc_voltage(max1586, *selector) / 1000);
v3_prog = I2C_V3_SELECT | (u8) selector; v3_prog = I2C_V3_SELECT | (u8) *selector;
return i2c_smbus_write_byte(client, v3_prog); return i2c_smbus_write_byte(client, v3_prog);
} }
...@@ -110,10 +110,10 @@ static int max1586_v6_calc_voltage(unsigned selector) ...@@ -110,10 +110,10 @@ static int max1586_v6_calc_voltage(unsigned selector)
return voltages_uv[selector]; return voltages_uv[selector];
} }
static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV) static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV,
unsigned int *selector)
{ {
struct i2c_client *client = rdev_get_drvdata(rdev); struct i2c_client *client = rdev_get_drvdata(rdev);
unsigned selector;
u8 v6_prog; u8 v6_prog;
if (min_uV < MAX1586_V6_MIN_UV || min_uV > MAX1586_V6_MAX_UV) if (min_uV < MAX1586_V6_MIN_UV || min_uV > MAX1586_V6_MAX_UV)
...@@ -122,21 +122,21 @@ static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV) ...@@ -122,21 +122,21 @@ static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV)
return -EINVAL; return -EINVAL;
if (min_uV < 1800000) if (min_uV < 1800000)
selector = 0; *selector = 0;
else if (min_uV < 2500000) else if (min_uV < 2500000)
selector = 1; *selector = 1;
else if (min_uV < 3000000) else if (min_uV < 3000000)
selector = 2; *selector = 2;
else if (min_uV >= 3000000) else if (min_uV >= 3000000)
selector = 3; *selector = 3;
if (max1586_v6_calc_voltage(selector) > max_uV) if (max1586_v6_calc_voltage(*selector) > max_uV)
return -EINVAL; return -EINVAL;
dev_dbg(&client->dev, "changing voltage v6 to %dmv\n", dev_dbg(&client->dev, "changing voltage v6 to %dmv\n",
max1586_v6_calc_voltage(selector) / 1000); max1586_v6_calc_voltage(*selector) / 1000);
v6_prog = I2C_V6_SELECT | (u8) selector; v6_prog = I2C_V6_SELECT | (u8) *selector;
return i2c_smbus_write_byte(client, v6_prog); return i2c_smbus_write_byte(client, v6_prog);
} }
......
...@@ -155,7 +155,7 @@ static int max8649_get_voltage(struct regulator_dev *rdev) ...@@ -155,7 +155,7 @@ static int max8649_get_voltage(struct regulator_dev *rdev)
} }
static int max8649_set_voltage(struct regulator_dev *rdev, static int max8649_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct max8649_regulator_info *info = rdev_get_drvdata(rdev); struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
unsigned char data, mask; unsigned char data, mask;
...@@ -168,6 +168,7 @@ static int max8649_set_voltage(struct regulator_dev *rdev, ...@@ -168,6 +168,7 @@ static int max8649_set_voltage(struct regulator_dev *rdev,
data = (min_uV - MAX8649_DCDC_VMIN + MAX8649_DCDC_STEP - 1) data = (min_uV - MAX8649_DCDC_VMIN + MAX8649_DCDC_STEP - 1)
/ MAX8649_DCDC_STEP; / MAX8649_DCDC_STEP;
mask = MAX8649_VOL_MASK; mask = MAX8649_VOL_MASK;
*selector = data & mask;
return max8649_set_bits(info->i2c, info->vol_reg, mask, data); return max8649_set_bits(info->i2c, info->vol_reg, mask, data);
} }
......
...@@ -141,7 +141,8 @@ static int max8660_dcdc_get(struct regulator_dev *rdev) ...@@ -141,7 +141,8 @@ static int max8660_dcdc_get(struct regulator_dev *rdev)
return MAX8660_DCDC_MIN_UV + selector * MAX8660_DCDC_STEP; return MAX8660_DCDC_MIN_UV + selector * MAX8660_DCDC_STEP;
} }
static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV) static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV,
unsigned int *s)
{ {
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 reg, selector, bits; u8 reg, selector, bits;
...@@ -154,6 +155,7 @@ static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV) ...@@ -154,6 +155,7 @@ static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV)
selector = (min_uV - (MAX8660_DCDC_MIN_UV - MAX8660_DCDC_STEP + 1)) selector = (min_uV - (MAX8660_DCDC_MIN_UV - MAX8660_DCDC_STEP + 1))
/ MAX8660_DCDC_STEP; / MAX8660_DCDC_STEP;
*s = selector;
ret = max8660_dcdc_list(rdev, selector); ret = max8660_dcdc_list(rdev, selector);
if (ret < 0 || ret > max_uV) if (ret < 0 || ret > max_uV)
...@@ -196,7 +198,8 @@ static int max8660_ldo5_get(struct regulator_dev *rdev) ...@@ -196,7 +198,8 @@ static int max8660_ldo5_get(struct regulator_dev *rdev)
return MAX8660_LDO5_MIN_UV + selector * MAX8660_LDO5_STEP; return MAX8660_LDO5_MIN_UV + selector * MAX8660_LDO5_STEP;
} }
static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV) static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV,
unsigned int *s)
{ {
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 selector; u8 selector;
...@@ -213,6 +216,8 @@ static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV) ...@@ -213,6 +216,8 @@ static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV)
if (ret < 0 || ret > max_uV) if (ret < 0 || ret > max_uV)
return -EINVAL; return -EINVAL;
*s = selector;
ret = max8660_write(max8660, MAX8660_MDTV2, 0, selector); ret = max8660_write(max8660, MAX8660_MDTV2, 0, selector);
if (ret) if (ret)
return ret; return ret;
...@@ -270,7 +275,8 @@ static int max8660_ldo67_get(struct regulator_dev *rdev) ...@@ -270,7 +275,8 @@ static int max8660_ldo67_get(struct regulator_dev *rdev)
return MAX8660_LDO67_MIN_UV + selector * MAX8660_LDO67_STEP; return MAX8660_LDO67_MIN_UV + selector * MAX8660_LDO67_STEP;
} }
static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV, int max_uV) static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV,
int max_uV, unsigned int *s)
{ {
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 selector; u8 selector;
...@@ -288,6 +294,8 @@ static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV, int max_uV) ...@@ -288,6 +294,8 @@ static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV, int max_uV)
if (ret < 0 || ret > max_uV) if (ret < 0 || ret > max_uV)
return -EINVAL; return -EINVAL;
*s = selector;
if (rdev_get_id(rdev) == MAX8660_V6) if (rdev_get_id(rdev) == MAX8660_V6)
return max8660_write(max8660, MAX8660_L12VCR, 0xf0, selector); return max8660_write(max8660, MAX8660_L12VCR, 0xf0, selector);
else else
......
...@@ -55,7 +55,7 @@ static int max8925_list_voltage(struct regulator_dev *rdev, unsigned index) ...@@ -55,7 +55,7 @@ static int max8925_list_voltage(struct regulator_dev *rdev, unsigned index)
} }
static int max8925_set_voltage(struct regulator_dev *rdev, static int max8925_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned int *selector)
{ {
struct max8925_regulator_info *info = rdev_get_drvdata(rdev); struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
unsigned char data, mask; unsigned char data, mask;
...@@ -66,6 +66,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev, ...@@ -66,6 +66,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
data = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; data = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
*selector = data;
data <<= info->vol_shift; data <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
......
...@@ -133,7 +133,7 @@ static int max8952_get_voltage(struct regulator_dev *rdev) ...@@ -133,7 +133,7 @@ static int max8952_get_voltage(struct regulator_dev *rdev)
} }
static int max8952_set_voltage(struct regulator_dev *rdev, static int max8952_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct max8952_data *max8952 = rdev_get_drvdata(rdev); struct max8952_data *max8952 = rdev_get_drvdata(rdev);
s8 vid = -1, i; s8 vid = -1, i;
...@@ -156,6 +156,7 @@ static int max8952_set_voltage(struct regulator_dev *rdev, ...@@ -156,6 +156,7 @@ static int max8952_set_voltage(struct regulator_dev *rdev,
if (vid >= 0 && vid < MAX8952_NUM_DVS_MODE) { if (vid >= 0 && vid < MAX8952_NUM_DVS_MODE) {
max8952->vid0 = (vid % 2 == 1); max8952->vid0 = (vid % 2 == 1);
max8952->vid1 = (((vid >> 1) % 2) == 1); max8952->vid1 = (((vid >> 1) % 2) == 1);
*selector = vid;
gpio_set_value(max8952->pdata->gpio_vid0, max8952->vid0); gpio_set_value(max8952->pdata->gpio_vid0, max8952->vid0);
gpio_set_value(max8952->pdata->gpio_vid1, max8952->vid1); gpio_set_value(max8952->pdata->gpio_vid1, max8952->vid1);
} else } else
......
...@@ -304,7 +304,7 @@ static int max8998_get_voltage(struct regulator_dev *rdev) ...@@ -304,7 +304,7 @@ static int max8998_get_voltage(struct regulator_dev *rdev)
} }
static int max8998_set_voltage_ldo(struct regulator_dev *rdev, static int max8998_set_voltage_ldo(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct max8998_data *max8998 = rdev_get_drvdata(rdev); struct max8998_data *max8998 = rdev_get_drvdata(rdev);
struct i2c_client *i2c = max8998->iodev->i2c; struct i2c_client *i2c = max8998->iodev->i2c;
...@@ -331,6 +331,8 @@ static int max8998_set_voltage_ldo(struct regulator_dev *rdev, ...@@ -331,6 +331,8 @@ static int max8998_set_voltage_ldo(struct regulator_dev *rdev,
if (desc->min + desc->step*i > max_vol) if (desc->min + desc->step*i > max_vol)
return -EINVAL; return -EINVAL;
*selector = i;
ret = max8998_get_voltage_register(rdev, &reg, &shift, &mask); ret = max8998_get_voltage_register(rdev, &reg, &shift, &mask);
if (ret) if (ret)
return ret; return ret;
...@@ -352,7 +354,7 @@ static inline void buck2_gpio_set(int gpio, int v) ...@@ -352,7 +354,7 @@ static inline void buck2_gpio_set(int gpio, int v)
} }
static int max8998_set_voltage_buck(struct regulator_dev *rdev, static int max8998_set_voltage_buck(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct max8998_data *max8998 = rdev_get_drvdata(rdev); struct max8998_data *max8998 = rdev_get_drvdata(rdev);
struct max8998_platform_data *pdata = struct max8998_platform_data *pdata =
...@@ -384,6 +386,8 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev, ...@@ -384,6 +386,8 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev,
if (desc->min + desc->step*i > max_vol) if (desc->min + desc->step*i > max_vol)
return -EINVAL; return -EINVAL;
*selector = i;
ret = max8998_get_voltage_register(rdev, &reg, &shift, &mask); ret = max8998_get_voltage_register(rdev, &reg, &shift, &mask);
if (ret) if (ret)
return ret; return ret;
......
This diff is collapsed.
This diff is collapsed.
/*
* Regulator Driver for Freescale MC13xxx PMIC
*
* Copyright 2010 Yong Shen <yong.shen@linaro.org>
*
* Based on mc13783 regulator driver :
* Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
* Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Regs infos taken from mc13xxx drivers from freescale and mc13xxx.pdf file
* from freescale
*/
#include <linux/mfd/mc13xxx.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/driver.h>
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/err.h>
#include "mc13xxx.h"
static int mc13xxx_regulator_enable(struct regulator_dev *rdev)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int id = rdev_get_id(rdev);
int ret;
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
mc13xxx_lock(priv->mc13xxx);
ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].reg,
mc13xxx_regulators[id].enable_bit,
mc13xxx_regulators[id].enable_bit);
mc13xxx_unlock(priv->mc13xxx);
return ret;
}
static int mc13xxx_regulator_disable(struct regulator_dev *rdev)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int id = rdev_get_id(rdev);
int ret;
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
mc13xxx_lock(priv->mc13xxx);
ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].reg,
mc13xxx_regulators[id].enable_bit, 0);
mc13xxx_unlock(priv->mc13xxx);
return ret;
}
static int mc13xxx_regulator_is_enabled(struct regulator_dev *rdev)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int ret, id = rdev_get_id(rdev);
unsigned int val;
mc13xxx_lock(priv->mc13xxx);
ret = mc13xxx_reg_read(priv->mc13xxx, mc13xxx_regulators[id].reg, &val);
mc13xxx_unlock(priv->mc13xxx);
if (ret)
return ret;
return (val & mc13xxx_regulators[id].enable_bit) != 0;
}
int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev,
unsigned selector)
{
int id = rdev_get_id(rdev);
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
if (selector >= mc13xxx_regulators[id].desc.n_voltages)
return -EINVAL;
return mc13xxx_regulators[id].voltages[selector];
}
EXPORT_SYMBOL_GPL(mc13xxx_regulator_list_voltage);
int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int reg_id = rdev_get_id(rdev);
int i;
int bestmatch;
int bestindex;
/*
* Locate the minimum voltage fitting the criteria on
* this regulator. The switchable voltages are not
* in strict falling order so we need to check them
* all for the best match.
*/
bestmatch = INT_MAX;
bestindex = -1;
for (i = 0; i < mc13xxx_regulators[reg_id].desc.n_voltages; i++) {
if (mc13xxx_regulators[reg_id].voltages[i] >= min_uV &&
mc13xxx_regulators[reg_id].voltages[i] < bestmatch) {
bestmatch = mc13xxx_regulators[reg_id].voltages[i];
bestindex = i;
}
}
if (bestindex < 0 || bestmatch > max_uV) {
dev_warn(&rdev->dev, "no possible value for %d<=x<=%d uV\n",
min_uV, max_uV);
return -EINVAL;
}
return bestindex;
}
EXPORT_SYMBOL_GPL(mc13xxx_get_best_voltage_index);
static int mc13xxx_regulator_set_voltage(struct regulator_dev *rdev, int min_uV,
int max_uV, unsigned *selector)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int value, id = rdev_get_id(rdev);
int ret;
dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n",
__func__, id, min_uV, max_uV);
/* Find the best index */
value = mc13xxx_get_best_voltage_index(rdev, min_uV, max_uV);
dev_dbg(rdev_get_dev(rdev), "%s best value: %d\n", __func__, value);
if (value < 0)
return value;
mc13xxx_lock(priv->mc13xxx);
ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].vsel_reg,
mc13xxx_regulators[id].vsel_mask,
value << mc13xxx_regulators[id].vsel_shift);
mc13xxx_unlock(priv->mc13xxx);
return ret;
}
static int mc13xxx_regulator_get_voltage(struct regulator_dev *rdev)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int ret, id = rdev_get_id(rdev);
unsigned int val;
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
mc13xxx_lock(priv->mc13xxx);
ret = mc13xxx_reg_read(priv->mc13xxx,
mc13xxx_regulators[id].vsel_reg, &val);
mc13xxx_unlock(priv->mc13xxx);
if (ret)
return ret;
val = (val & mc13xxx_regulators[id].vsel_mask)
>> mc13xxx_regulators[id].vsel_shift;
dev_dbg(rdev_get_dev(rdev), "%s id: %d val: %d\n", __func__, id, val);
BUG_ON(val < 0 || val > mc13xxx_regulators[id].desc.n_voltages);
return mc13xxx_regulators[id].voltages[val];
}
struct regulator_ops mc13xxx_regulator_ops = {
.enable = mc13xxx_regulator_enable,
.disable = mc13xxx_regulator_disable,
.is_enabled = mc13xxx_regulator_is_enabled,
.list_voltage = mc13xxx_regulator_list_voltage,
.set_voltage = mc13xxx_regulator_set_voltage,
.get_voltage = mc13xxx_regulator_get_voltage,
};
EXPORT_SYMBOL_GPL(mc13xxx_regulator_ops);
int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev, int min_uV,
int max_uV, unsigned *selector)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int id = rdev_get_id(rdev);
dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n",
__func__, id, min_uV, max_uV);
if (min_uV >= mc13xxx_regulators[id].voltages[0] &&
max_uV <= mc13xxx_regulators[id].voltages[0])
return 0;
else
return -EINVAL;
}
EXPORT_SYMBOL_GPL(mc13xxx_fixed_regulator_set_voltage);
int mc13xxx_fixed_regulator_get_voltage(struct regulator_dev *rdev)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int id = rdev_get_id(rdev);
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
return mc13xxx_regulators[id].voltages[0];
}
EXPORT_SYMBOL_GPL(mc13xxx_fixed_regulator_get_voltage);
struct regulator_ops mc13xxx_fixed_regulator_ops = {
.enable = mc13xxx_regulator_enable,
.disable = mc13xxx_regulator_disable,
.is_enabled = mc13xxx_regulator_is_enabled,
.list_voltage = mc13xxx_regulator_list_voltage,
.set_voltage = mc13xxx_fixed_regulator_set_voltage,
.get_voltage = mc13xxx_fixed_regulator_get_voltage,
};
EXPORT_SYMBOL_GPL(mc13xxx_fixed_regulator_ops);
int mc13xxx_sw_regulator_is_enabled(struct regulator_dev *rdev)
{
return 1;
}
EXPORT_SYMBOL_GPL(mc13xxx_sw_regulator_is_enabled);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Yong Shen <yong.shen@linaro.org>");
MODULE_DESCRIPTION("Regulator Driver for Freescale MC13xxx PMIC");
MODULE_ALIAS("mc13xxx-regulator-core");
/*
* mc13xxx.h - regulators for the Freescale mc13xxx PMIC
*
* Copyright (C) 2010 Yong Shen <yong.shen@linaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef __LINUX_REGULATOR_MC13XXX_H
#define __LINUX_REGULATOR_MC13XXX_H
#include <linux/regulator/driver.h>
struct mc13xxx_regulator {
struct regulator_desc desc;
int reg;
int enable_bit;
int vsel_reg;
int vsel_shift;
int vsel_mask;
int hi_bit;
int const *voltages;
};
struct mc13xxx_regulator_priv {
struct mc13xxx *mc13xxx;
u32 powermisc_pwgt_state;
struct mc13xxx_regulator *mc13xxx_regulators;
struct regulator_dev *regulators[];
};
extern int mc13xxx_sw_regulator(struct regulator_dev *rdev);
extern int mc13xxx_sw_regulator_is_enabled(struct regulator_dev *rdev);
extern int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev,
int min_uV, int max_uV);
extern int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev,
unsigned selector);
extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV, unsigned *selector);
extern int mc13xxx_fixed_regulator_get_voltage(struct regulator_dev *rdev);
extern struct regulator_ops mc13xxx_regulator_ops;
extern struct regulator_ops mc13xxx_fixed_regulator_ops;
#define MC13xxx_DEFINE(prefix, _name, _reg, _vsel_reg, _voltages, _ops) \
[prefix ## _name] = { \
.desc = { \
.name = #prefix "_" #_name, \
.n_voltages = ARRAY_SIZE(_voltages), \
.ops = &_ops, \
.type = REGULATOR_VOLTAGE, \
.id = prefix ## _name, \
.owner = THIS_MODULE, \
}, \
.reg = prefix ## _reg, \
.enable_bit = prefix ## _reg ## _ ## _name ## EN, \
.vsel_reg = prefix ## _vsel_reg, \
.vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\
.vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\
.voltages = _voltages, \
}
#define MC13xxx_FIXED_DEFINE(prefix, _name, _reg, _voltages, _ops) \
[prefix ## _name] = { \
.desc = { \
.name = #prefix "_" #_name, \
.n_voltages = ARRAY_SIZE(_voltages), \
.ops = &_ops, \
.type = REGULATOR_VOLTAGE, \
.id = prefix ## _name, \
.owner = THIS_MODULE, \
}, \
.reg = prefix ## _reg, \
.enable_bit = prefix ## _reg ## _ ## _name ## EN, \
.voltages = _voltages, \
}
#define MC13xxx_GPO_DEFINE(prefix, _name, _reg, _voltages, _ops) \
[prefix ## _name] = { \
.desc = { \
.name = #prefix "_" #_name, \
.n_voltages = ARRAY_SIZE(_voltages), \
.ops = &_ops, \
.type = REGULATOR_VOLTAGE, \
.id = prefix ## _name, \
.owner = THIS_MODULE, \
}, \
.reg = prefix ## _reg, \
.enable_bit = prefix ## _reg ## _ ## _name ## EN, \
.voltages = _voltages, \
}
#define MC13xxx_DEFINE_SW(_name, _reg, _vsel_reg, _voltages, ops) \
MC13xxx_DEFINE(SW, _name, _reg, _vsel_reg, _voltages, ops)
#define MC13xxx_DEFINE_REGU(_name, _reg, _vsel_reg, _voltages, ops) \
MC13xxx_DEFINE(REGU, _name, _reg, _vsel_reg, _voltages, ops)
#endif
...@@ -151,7 +151,8 @@ static struct pcap_regulator vreg_table[] = { ...@@ -151,7 +151,8 @@ static struct pcap_regulator vreg_table[] = {
}; };
static int pcap_regulator_set_voltage(struct regulator_dev *rdev, static int pcap_regulator_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)]; struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)];
void *pcap = rdev_get_drvdata(rdev); void *pcap = rdev_get_drvdata(rdev);
...@@ -170,10 +171,12 @@ static int pcap_regulator_set_voltage(struct regulator_dev *rdev, ...@@ -170,10 +171,12 @@ static int pcap_regulator_set_voltage(struct regulator_dev *rdev,
i = 0; i = 0;
uV = vreg->voltage_table[i] * 1000; uV = vreg->voltage_table[i] * 1000;
if (min_uV <= uV && uV <= max_uV) if (min_uV <= uV && uV <= max_uV) {
*selector = i;
return ezx_pcap_set_bits(pcap, vreg->reg, return ezx_pcap_set_bits(pcap, vreg->reg,
(vreg->n_voltages - 1) << vreg->index, (vreg->n_voltages - 1) << vreg->index,
i << vreg->index); i << vreg->index);
}
if (i == 0 && rdev_get_id(rdev) == V1) if (i == 0 && rdev_get_id(rdev) == V1)
i = vreg->n_voltages - 1; i = vreg->n_voltages - 1;
......
...@@ -108,7 +108,8 @@ static unsigned int ldo_voltage_value(u8 bits) ...@@ -108,7 +108,8 @@ static unsigned int ldo_voltage_value(u8 bits)
} }
static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev, static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct pcf50633 *pcf; struct pcf50633 *pcf;
int regulator_id, millivolts; int regulator_id, millivolts;
...@@ -147,6 +148,8 @@ static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev, ...@@ -147,6 +148,8 @@ static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
*selector = volt_bits;
return pcf50633_reg_write(pcf, regnr, volt_bits); return pcf50633_reg_write(pcf, regnr, volt_bits);
} }
......
...@@ -321,7 +321,8 @@ static int tps65023_dcdc_get_voltage(struct regulator_dev *dev) ...@@ -321,7 +321,8 @@ static int tps65023_dcdc_get_voltage(struct regulator_dev *dev)
} }
static int tps65023_dcdc_set_voltage(struct regulator_dev *dev, static int tps65023_dcdc_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps_pmic *tps = rdev_get_drvdata(dev);
int dcdc = rdev_get_id(dev); int dcdc = rdev_get_id(dev);
...@@ -346,6 +347,8 @@ static int tps65023_dcdc_set_voltage(struct regulator_dev *dev, ...@@ -346,6 +347,8 @@ static int tps65023_dcdc_set_voltage(struct regulator_dev *dev,
break; break;
} }
*selector = vsel;
/* write to the register in case we found a match */ /* write to the register in case we found a match */
if (vsel == tps->info[dcdc]->table_len) if (vsel == tps->info[dcdc]->table_len)
return -EINVAL; return -EINVAL;
...@@ -371,7 +374,7 @@ static int tps65023_ldo_get_voltage(struct regulator_dev *dev) ...@@ -371,7 +374,7 @@ static int tps65023_ldo_get_voltage(struct regulator_dev *dev)
} }
static int tps65023_ldo_set_voltage(struct regulator_dev *dev, static int tps65023_ldo_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps_pmic *tps = rdev_get_drvdata(dev);
int data, vsel, ldo = rdev_get_id(dev); int data, vsel, ldo = rdev_get_id(dev);
...@@ -396,6 +399,8 @@ static int tps65023_ldo_set_voltage(struct regulator_dev *dev, ...@@ -396,6 +399,8 @@ static int tps65023_ldo_set_voltage(struct regulator_dev *dev,
if (vsel == tps->info[ldo]->table_len) if (vsel == tps->info[ldo]->table_len)
return -EINVAL; return -EINVAL;
*selector = vsel;
data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL); data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL);
if (data < 0) if (data < 0)
return data; return data;
......
...@@ -369,7 +369,8 @@ static int tps6507x_pmic_dcdc_get_voltage(struct regulator_dev *dev) ...@@ -369,7 +369,8 @@ static int tps6507x_pmic_dcdc_get_voltage(struct regulator_dev *dev)
} }
static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev, static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct tps6507x_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int data, vsel, dcdc = rdev_get_id(dev); int data, vsel, dcdc = rdev_get_id(dev);
...@@ -415,6 +416,8 @@ static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev, ...@@ -415,6 +416,8 @@ static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev,
if (vsel == tps->info[dcdc]->table_len) if (vsel == tps->info[dcdc]->table_len)
return -EINVAL; return -EINVAL;
*selector = vsel;
data = tps6507x_pmic_reg_read(tps, reg); data = tps6507x_pmic_reg_read(tps, reg);
if (data < 0) if (data < 0)
return data; return data;
...@@ -450,7 +453,8 @@ static int tps6507x_pmic_ldo_get_voltage(struct regulator_dev *dev) ...@@ -450,7 +453,8 @@ static int tps6507x_pmic_ldo_get_voltage(struct regulator_dev *dev)
} }
static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev, static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct tps6507x_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int data, vsel, ldo = rdev_get_id(dev); int data, vsel, ldo = rdev_get_id(dev);
...@@ -483,6 +487,8 @@ static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev, ...@@ -483,6 +487,8 @@ static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev,
if (vsel == tps->info[ldo]->table_len) if (vsel == tps->info[ldo]->table_len)
return -EINVAL; return -EINVAL;
*selector = vsel;
data = tps6507x_pmic_reg_read(tps, reg); data = tps6507x_pmic_reg_read(tps, reg);
if (data < 0) if (data < 0)
return data; return data;
......
This diff is collapsed.
...@@ -85,7 +85,8 @@ static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev, ...@@ -85,7 +85,8 @@ static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev,
static int __tps6586x_ldo_set_voltage(struct device *parent, static int __tps6586x_ldo_set_voltage(struct device *parent,
struct tps6586x_regulator *ri, struct tps6586x_regulator *ri,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
int val, uV; int val, uV;
uint8_t mask; uint8_t mask;
...@@ -100,6 +101,8 @@ static int __tps6586x_ldo_set_voltage(struct device *parent, ...@@ -100,6 +101,8 @@ static int __tps6586x_ldo_set_voltage(struct device *parent,
/* use the first in-range value */ /* use the first in-range value */
if (min_uV <= uV && uV <= max_uV) { if (min_uV <= uV && uV <= max_uV) {
*selector = val;
val <<= ri->volt_shift; val <<= ri->volt_shift;
mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift;
...@@ -111,12 +114,13 @@ static int __tps6586x_ldo_set_voltage(struct device *parent, ...@@ -111,12 +114,13 @@ static int __tps6586x_ldo_set_voltage(struct device *parent,
} }
static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev, static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); struct tps6586x_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_tps6586x_dev(rdev); struct device *parent = to_tps6586x_dev(rdev);
return __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); return __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV,
selector);
} }
static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev)
...@@ -140,13 +144,14 @@ static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) ...@@ -140,13 +144,14 @@ static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev)
} }
static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev, static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); struct tps6586x_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_tps6586x_dev(rdev); struct device *parent = to_tps6586x_dev(rdev);
int ret; int ret;
ret = __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); ret = __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV,
selector);
if (ret) if (ret)
return ret; return ret;
......
...@@ -329,7 +329,8 @@ static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) ...@@ -329,7 +329,8 @@ static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
} }
static int static int
twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
unsigned *selector)
{ {
struct twlreg_info *info = rdev_get_drvdata(rdev); struct twlreg_info *info = rdev_get_drvdata(rdev);
int vsel; int vsel;
...@@ -345,10 +346,12 @@ twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) ...@@ -345,10 +346,12 @@ twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
/* REVISIT for VAUX2, first match may not be best/lowest */ /* REVISIT for VAUX2, first match may not be best/lowest */
/* use the first in-range value */ /* use the first in-range value */
if (min_uV <= uV && uV <= max_uV) if (min_uV <= uV && uV <= max_uV) {
*selector = vsel;
return twlreg_write(info, TWL_MODULE_PM_RECEIVER, return twlreg_write(info, TWL_MODULE_PM_RECEIVER,
VREG_VOLTAGE, vsel); VREG_VOLTAGE, vsel);
} }
}
return -EDOM; return -EDOM;
} }
...@@ -389,7 +392,8 @@ static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) ...@@ -389,7 +392,8 @@ static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
} }
static int static int
twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
unsigned *selector)
{ {
struct twlreg_info *info = rdev_get_drvdata(rdev); struct twlreg_info *info = rdev_get_drvdata(rdev);
int vsel; int vsel;
...@@ -402,6 +406,7 @@ twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) ...@@ -402,6 +406,7 @@ twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
* mV = 1000mv + 100mv * (vsel - 1) * mV = 1000mv + 100mv * (vsel - 1)
*/ */
vsel = (min_uV/1000 - 1000)/100 + 1; vsel = (min_uV/1000 - 1000)/100 + 1;
*selector = vsel;
return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel); return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel);
} }
......
...@@ -302,7 +302,7 @@ static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state) ...@@ -302,7 +302,7 @@ static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state)
} }
static int wm831x_buckv_set_voltage(struct regulator_dev *rdev, static int wm831x_buckv_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
struct wm831x *wm831x = dcdc->wm831x; struct wm831x *wm831x = dcdc->wm831x;
...@@ -314,6 +314,8 @@ static int wm831x_buckv_set_voltage(struct regulator_dev *rdev, ...@@ -314,6 +314,8 @@ static int wm831x_buckv_set_voltage(struct regulator_dev *rdev,
if (vsel < 0) if (vsel < 0)
return vsel; return vsel;
*selector = vsel;
/* If this value is already set then do a GPIO update if we can */ /* If this value is already set then do a GPIO update if we can */
if (dcdc->dvs_gpio && dcdc->on_vsel == vsel) if (dcdc->dvs_gpio && dcdc->on_vsel == vsel)
return wm831x_buckv_set_dvs(rdev, 0); return wm831x_buckv_set_dvs(rdev, 0);
...@@ -375,14 +377,14 @@ static int wm831x_buckv_set_suspend_voltage(struct regulator_dev *rdev, ...@@ -375,14 +377,14 @@ static int wm831x_buckv_set_suspend_voltage(struct regulator_dev *rdev,
return wm831x_set_bits(wm831x, reg, WM831X_DC1_SLP_VSEL_MASK, vsel); return wm831x_set_bits(wm831x, reg, WM831X_DC1_SLP_VSEL_MASK, vsel);
} }
static int wm831x_buckv_get_voltage(struct regulator_dev *rdev) static int wm831x_buckv_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
if (dcdc->dvs_gpio && dcdc->dvs_gpio_state) if (dcdc->dvs_gpio && dcdc->dvs_gpio_state)
return wm831x_buckv_list_voltage(rdev, dcdc->dvs_vsel); return dcdc->dvs_vsel;
else else
return wm831x_buckv_list_voltage(rdev, dcdc->on_vsel); return dcdc->on_vsel;
} }
/* Current limit options */ /* Current limit options */
...@@ -424,7 +426,7 @@ static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev) ...@@ -424,7 +426,7 @@ static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
static struct regulator_ops wm831x_buckv_ops = { static struct regulator_ops wm831x_buckv_ops = {
.set_voltage = wm831x_buckv_set_voltage, .set_voltage = wm831x_buckv_set_voltage,
.get_voltage = wm831x_buckv_get_voltage, .get_voltage_sel = wm831x_buckv_get_voltage_sel,
.list_voltage = wm831x_buckv_list_voltage, .list_voltage = wm831x_buckv_list_voltage,
.set_suspend_voltage = wm831x_buckv_set_suspend_voltage, .set_suspend_voltage = wm831x_buckv_set_suspend_voltage,
.set_current_limit = wm831x_buckv_set_current_limit, .set_current_limit = wm831x_buckv_set_current_limit,
...@@ -636,7 +638,7 @@ static int wm831x_buckp_list_voltage(struct regulator_dev *rdev, ...@@ -636,7 +638,7 @@ static int wm831x_buckp_list_voltage(struct regulator_dev *rdev,
} }
static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg, static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg,
int min_uV, int max_uV) int min_uV, int max_uV, int *selector)
{ {
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
struct wm831x *wm831x = dcdc->wm831x; struct wm831x *wm831x = dcdc->wm831x;
...@@ -650,16 +652,20 @@ static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg, ...@@ -650,16 +652,20 @@ static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg,
if (wm831x_buckp_list_voltage(rdev, vsel) > max_uV) if (wm831x_buckp_list_voltage(rdev, vsel) > max_uV)
return -EINVAL; return -EINVAL;
*selector = vsel;
return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, vsel); return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, vsel);
} }
static int wm831x_buckp_set_voltage(struct regulator_dev *rdev, static int wm831x_buckp_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG; u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV); return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV,
selector);
} }
static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev,
...@@ -667,11 +673,12 @@ static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, ...@@ -667,11 +673,12 @@ static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev,
{ {
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL; u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
unsigned selector;
return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV); return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV, &selector);
} }
static int wm831x_buckp_get_voltage(struct regulator_dev *rdev) static int wm831x_buckp_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
struct wm831x *wm831x = dcdc->wm831x; struct wm831x *wm831x = dcdc->wm831x;
...@@ -682,12 +689,12 @@ static int wm831x_buckp_get_voltage(struct regulator_dev *rdev) ...@@ -682,12 +689,12 @@ static int wm831x_buckp_get_voltage(struct regulator_dev *rdev)
if (val < 0) if (val < 0)
return val; return val;
return wm831x_buckp_list_voltage(rdev, val & WM831X_DC3_ON_VSEL_MASK); return val & WM831X_DC3_ON_VSEL_MASK;
} }
static struct regulator_ops wm831x_buckp_ops = { static struct regulator_ops wm831x_buckp_ops = {
.set_voltage = wm831x_buckp_set_voltage, .set_voltage = wm831x_buckp_set_voltage,
.get_voltage = wm831x_buckp_get_voltage, .get_voltage_sel = wm831x_buckp_get_voltage_sel,
.list_voltage = wm831x_buckp_list_voltage, .list_voltage = wm831x_buckp_list_voltage,
.set_suspend_voltage = wm831x_buckp_set_suspend_voltage, .set_suspend_voltage = wm831x_buckp_set_suspend_voltage,
......
...@@ -113,7 +113,8 @@ static int wm831x_gp_ldo_list_voltage(struct regulator_dev *rdev, ...@@ -113,7 +113,8 @@ static int wm831x_gp_ldo_list_voltage(struct regulator_dev *rdev,
} }
static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev *rdev, int reg, static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev *rdev, int reg,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
struct wm831x *wm831x = ldo->wm831x; struct wm831x *wm831x = ldo->wm831x;
...@@ -133,16 +134,20 @@ static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev *rdev, int reg, ...@@ -133,16 +134,20 @@ static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev *rdev, int reg,
if (ret < min_uV || ret > max_uV) if (ret < min_uV || ret > max_uV)
return -EINVAL; return -EINVAL;
*selector = vsel;
return wm831x_set_bits(wm831x, reg, WM831X_LDO1_ON_VSEL_MASK, vsel); return wm831x_set_bits(wm831x, reg, WM831X_LDO1_ON_VSEL_MASK, vsel);
} }
static int wm831x_gp_ldo_set_voltage(struct regulator_dev *rdev, static int wm831x_gp_ldo_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
int reg = ldo->base + WM831X_LDO_ON_CONTROL; int reg = ldo->base + WM831X_LDO_ON_CONTROL;
return wm831x_gp_ldo_set_voltage_int(rdev, reg, min_uV, max_uV); return wm831x_gp_ldo_set_voltage_int(rdev, reg, min_uV, max_uV,
selector);
} }
static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev,
...@@ -150,11 +155,12 @@ static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, ...@@ -150,11 +155,12 @@ static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev,
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL;
unsigned int selector;
return wm831x_gp_ldo_set_voltage_int(rdev, reg, uV, uV); return wm831x_gp_ldo_set_voltage_int(rdev, reg, uV, uV, &selector);
} }
static int wm831x_gp_ldo_get_voltage(struct regulator_dev *rdev) static int wm831x_gp_ldo_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
struct wm831x *wm831x = ldo->wm831x; struct wm831x *wm831x = ldo->wm831x;
...@@ -167,7 +173,7 @@ static int wm831x_gp_ldo_get_voltage(struct regulator_dev *rdev) ...@@ -167,7 +173,7 @@ static int wm831x_gp_ldo_get_voltage(struct regulator_dev *rdev)
ret &= WM831X_LDO1_ON_VSEL_MASK; ret &= WM831X_LDO1_ON_VSEL_MASK;
return wm831x_gp_ldo_list_voltage(rdev, ret); return ret;
} }
static unsigned int wm831x_gp_ldo_get_mode(struct regulator_dev *rdev) static unsigned int wm831x_gp_ldo_get_mode(struct regulator_dev *rdev)
...@@ -287,7 +293,7 @@ static unsigned int wm831x_gp_ldo_get_optimum_mode(struct regulator_dev *rdev, ...@@ -287,7 +293,7 @@ static unsigned int wm831x_gp_ldo_get_optimum_mode(struct regulator_dev *rdev,
static struct regulator_ops wm831x_gp_ldo_ops = { static struct regulator_ops wm831x_gp_ldo_ops = {
.list_voltage = wm831x_gp_ldo_list_voltage, .list_voltage = wm831x_gp_ldo_list_voltage,
.get_voltage = wm831x_gp_ldo_get_voltage, .get_voltage_sel = wm831x_gp_ldo_get_voltage_sel,
.set_voltage = wm831x_gp_ldo_set_voltage, .set_voltage = wm831x_gp_ldo_set_voltage,
.set_suspend_voltage = wm831x_gp_ldo_set_suspend_voltage, .set_suspend_voltage = wm831x_gp_ldo_set_suspend_voltage,
.get_mode = wm831x_gp_ldo_get_mode, .get_mode = wm831x_gp_ldo_get_mode,
...@@ -413,7 +419,8 @@ static int wm831x_aldo_list_voltage(struct regulator_dev *rdev, ...@@ -413,7 +419,8 @@ static int wm831x_aldo_list_voltage(struct regulator_dev *rdev,
} }
static int wm831x_aldo_set_voltage_int(struct regulator_dev *rdev, int reg, static int wm831x_aldo_set_voltage_int(struct regulator_dev *rdev, int reg,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
struct wm831x *wm831x = ldo->wm831x; struct wm831x *wm831x = ldo->wm831x;
...@@ -433,16 +440,19 @@ static int wm831x_aldo_set_voltage_int(struct regulator_dev *rdev, int reg, ...@@ -433,16 +440,19 @@ static int wm831x_aldo_set_voltage_int(struct regulator_dev *rdev, int reg,
if (ret < min_uV || ret > max_uV) if (ret < min_uV || ret > max_uV)
return -EINVAL; return -EINVAL;
*selector = vsel;
return wm831x_set_bits(wm831x, reg, WM831X_LDO7_ON_VSEL_MASK, vsel); return wm831x_set_bits(wm831x, reg, WM831X_LDO7_ON_VSEL_MASK, vsel);
} }
static int wm831x_aldo_set_voltage(struct regulator_dev *rdev, static int wm831x_aldo_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV, unsigned *selector)
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
int reg = ldo->base + WM831X_LDO_ON_CONTROL; int reg = ldo->base + WM831X_LDO_ON_CONTROL;
return wm831x_aldo_set_voltage_int(rdev, reg, min_uV, max_uV); return wm831x_aldo_set_voltage_int(rdev, reg, min_uV, max_uV,
selector);
} }
static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev,
...@@ -450,11 +460,12 @@ static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, ...@@ -450,11 +460,12 @@ static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev,
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL;
unsigned int selector;
return wm831x_aldo_set_voltage_int(rdev, reg, uV, uV); return wm831x_aldo_set_voltage_int(rdev, reg, uV, uV, &selector);
} }
static int wm831x_aldo_get_voltage(struct regulator_dev *rdev) static int wm831x_aldo_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
struct wm831x *wm831x = ldo->wm831x; struct wm831x *wm831x = ldo->wm831x;
...@@ -467,7 +478,7 @@ static int wm831x_aldo_get_voltage(struct regulator_dev *rdev) ...@@ -467,7 +478,7 @@ static int wm831x_aldo_get_voltage(struct regulator_dev *rdev)
ret &= WM831X_LDO7_ON_VSEL_MASK; ret &= WM831X_LDO7_ON_VSEL_MASK;
return wm831x_aldo_list_voltage(rdev, ret); return ret;
} }
static unsigned int wm831x_aldo_get_mode(struct regulator_dev *rdev) static unsigned int wm831x_aldo_get_mode(struct regulator_dev *rdev)
...@@ -548,7 +559,7 @@ static int wm831x_aldo_get_status(struct regulator_dev *rdev) ...@@ -548,7 +559,7 @@ static int wm831x_aldo_get_status(struct regulator_dev *rdev)
static struct regulator_ops wm831x_aldo_ops = { static struct regulator_ops wm831x_aldo_ops = {
.list_voltage = wm831x_aldo_list_voltage, .list_voltage = wm831x_aldo_list_voltage,
.get_voltage = wm831x_aldo_get_voltage, .get_voltage_sel = wm831x_aldo_get_voltage_sel,
.set_voltage = wm831x_aldo_set_voltage, .set_voltage = wm831x_aldo_set_voltage,
.set_suspend_voltage = wm831x_aldo_set_suspend_voltage, .set_suspend_voltage = wm831x_aldo_set_suspend_voltage,
.get_mode = wm831x_aldo_get_mode, .get_mode = wm831x_aldo_get_mode,
...@@ -666,7 +677,8 @@ static int wm831x_alive_ldo_list_voltage(struct regulator_dev *rdev, ...@@ -666,7 +677,8 @@ static int wm831x_alive_ldo_list_voltage(struct regulator_dev *rdev,
static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev *rdev, static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev *rdev,
int reg, int reg,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
struct wm831x *wm831x = ldo->wm831x; struct wm831x *wm831x = ldo->wm831x;
...@@ -680,16 +692,20 @@ static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev *rdev, ...@@ -680,16 +692,20 @@ static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev *rdev,
if (ret < min_uV || ret > max_uV) if (ret < min_uV || ret > max_uV)
return -EINVAL; return -EINVAL;
*selector = vsel;
return wm831x_set_bits(wm831x, reg, WM831X_LDO11_ON_VSEL_MASK, vsel); return wm831x_set_bits(wm831x, reg, WM831X_LDO11_ON_VSEL_MASK, vsel);
} }
static int wm831x_alive_ldo_set_voltage(struct regulator_dev *rdev, static int wm831x_alive_ldo_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV) int min_uV, int max_uV,
unsigned *selector)
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
int reg = ldo->base + WM831X_ALIVE_LDO_ON_CONTROL; int reg = ldo->base + WM831X_ALIVE_LDO_ON_CONTROL;
return wm831x_alive_ldo_set_voltage_int(rdev, reg, min_uV, max_uV); return wm831x_alive_ldo_set_voltage_int(rdev, reg, min_uV, max_uV,
selector);
} }
static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev *rdev, static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev *rdev,
...@@ -697,11 +713,12 @@ static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev *rdev, ...@@ -697,11 +713,12 @@ static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev *rdev,
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
int reg = ldo->base + WM831X_ALIVE_LDO_SLEEP_CONTROL; int reg = ldo->base + WM831X_ALIVE_LDO_SLEEP_CONTROL;
unsigned selector;
return wm831x_alive_ldo_set_voltage_int(rdev, reg, uV, uV); return wm831x_alive_ldo_set_voltage_int(rdev, reg, uV, uV, &selector);
} }
static int wm831x_alive_ldo_get_voltage(struct regulator_dev *rdev) static int wm831x_alive_ldo_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
struct wm831x *wm831x = ldo->wm831x; struct wm831x *wm831x = ldo->wm831x;
...@@ -714,7 +731,7 @@ static int wm831x_alive_ldo_get_voltage(struct regulator_dev *rdev) ...@@ -714,7 +731,7 @@ static int wm831x_alive_ldo_get_voltage(struct regulator_dev *rdev)
ret &= WM831X_LDO11_ON_VSEL_MASK; ret &= WM831X_LDO11_ON_VSEL_MASK;
return wm831x_alive_ldo_list_voltage(rdev, ret); return ret;
} }
static int wm831x_alive_ldo_get_status(struct regulator_dev *rdev) static int wm831x_alive_ldo_get_status(struct regulator_dev *rdev)
...@@ -736,7 +753,7 @@ static int wm831x_alive_ldo_get_status(struct regulator_dev *rdev) ...@@ -736,7 +753,7 @@ static int wm831x_alive_ldo_get_status(struct regulator_dev *rdev)
static struct regulator_ops wm831x_alive_ldo_ops = { static struct regulator_ops wm831x_alive_ldo_ops = {
.list_voltage = wm831x_alive_ldo_list_voltage, .list_voltage = wm831x_alive_ldo_list_voltage,
.get_voltage = wm831x_alive_ldo_get_voltage, .get_voltage_sel = wm831x_alive_ldo_get_voltage_sel,
.set_voltage = wm831x_alive_ldo_set_voltage, .set_voltage = wm831x_alive_ldo_set_voltage,
.set_suspend_voltage = wm831x_alive_ldo_set_suspend_voltage, .set_suspend_voltage = wm831x_alive_ldo_set_suspend_voltage,
.get_status = wm831x_alive_ldo_get_status, .get_status = wm831x_alive_ldo_get_status,
......
...@@ -360,7 +360,7 @@ int wm8350_isink_set_flash(struct wm8350 *wm8350, int isink, u16 mode, ...@@ -360,7 +360,7 @@ int wm8350_isink_set_flash(struct wm8350 *wm8350, int isink, u16 mode,
EXPORT_SYMBOL_GPL(wm8350_isink_set_flash); EXPORT_SYMBOL_GPL(wm8350_isink_set_flash);
static int wm8350_dcdc_set_voltage(struct regulator_dev *rdev, int min_uV, static int wm8350_dcdc_set_voltage(struct regulator_dev *rdev, int min_uV,
int max_uV) int max_uV, unsigned *selector)
{ {
struct wm8350 *wm8350 = rdev_get_drvdata(rdev); struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
int volt_reg, dcdc = rdev_get_id(rdev), mV, int volt_reg, dcdc = rdev_get_id(rdev), mV,
...@@ -397,17 +397,18 @@ static int wm8350_dcdc_set_voltage(struct regulator_dev *rdev, int min_uV, ...@@ -397,17 +397,18 @@ static int wm8350_dcdc_set_voltage(struct regulator_dev *rdev, int min_uV,
return -EINVAL; return -EINVAL;
} }
*selector = mV;
/* all DCDCs have same mV bits */ /* all DCDCs have same mV bits */
val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_DC1_VSEL_MASK; val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_DC1_VSEL_MASK;
wm8350_reg_write(wm8350, volt_reg, val | mV); wm8350_reg_write(wm8350, volt_reg, val | mV);
return 0; return 0;
} }
static int wm8350_dcdc_get_voltage(struct regulator_dev *rdev) static int wm8350_dcdc_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct wm8350 *wm8350 = rdev_get_drvdata(rdev); struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
int volt_reg, dcdc = rdev_get_id(rdev); int volt_reg, dcdc = rdev_get_id(rdev);
u16 val;
switch (dcdc) { switch (dcdc) {
case WM8350_DCDC_1: case WM8350_DCDC_1:
...@@ -429,8 +430,7 @@ static int wm8350_dcdc_get_voltage(struct regulator_dev *rdev) ...@@ -429,8 +430,7 @@ static int wm8350_dcdc_get_voltage(struct regulator_dev *rdev)
} }
/* all DCDCs have same mV bits */ /* all DCDCs have same mV bits */
val = wm8350_reg_read(wm8350, volt_reg) & WM8350_DC1_VSEL_MASK; return wm8350_reg_read(wm8350, volt_reg) & WM8350_DC1_VSEL_MASK;
return wm8350_dcdc_val_to_mvolts(val) * 1000;
} }
static int wm8350_dcdc_list_voltage(struct regulator_dev *rdev, static int wm8350_dcdc_list_voltage(struct regulator_dev *rdev,
...@@ -754,7 +754,7 @@ static int wm8350_ldo_set_suspend_disable(struct regulator_dev *rdev) ...@@ -754,7 +754,7 @@ static int wm8350_ldo_set_suspend_disable(struct regulator_dev *rdev)
} }
static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV, static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV,
int max_uV) int max_uV, unsigned *selector)
{ {
struct wm8350 *wm8350 = rdev_get_drvdata(rdev); struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
int volt_reg, ldo = rdev_get_id(rdev), mV, min_mV = min_uV / 1000, int volt_reg, ldo = rdev_get_id(rdev), mV, min_mV = min_uV / 1000,
...@@ -797,17 +797,18 @@ static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV, ...@@ -797,17 +797,18 @@ static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV,
return -EINVAL; return -EINVAL;
} }
*selector = mV;
/* all LDOs have same mV bits */ /* all LDOs have same mV bits */
val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_VSEL_MASK; val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_VSEL_MASK;
wm8350_reg_write(wm8350, volt_reg, val | mV); wm8350_reg_write(wm8350, volt_reg, val | mV);
return 0; return 0;
} }
static int wm8350_ldo_get_voltage(struct regulator_dev *rdev) static int wm8350_ldo_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct wm8350 *wm8350 = rdev_get_drvdata(rdev); struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
int volt_reg, ldo = rdev_get_id(rdev); int volt_reg, ldo = rdev_get_id(rdev);
u16 val;
switch (ldo) { switch (ldo) {
case WM8350_LDO_1: case WM8350_LDO_1:
...@@ -827,8 +828,7 @@ static int wm8350_ldo_get_voltage(struct regulator_dev *rdev) ...@@ -827,8 +828,7 @@ static int wm8350_ldo_get_voltage(struct regulator_dev *rdev)
} }
/* all LDOs have same mV bits */ /* all LDOs have same mV bits */
val = wm8350_reg_read(wm8350, volt_reg) & WM8350_LDO1_VSEL_MASK; return wm8350_reg_read(wm8350, volt_reg) & WM8350_LDO1_VSEL_MASK;
return wm8350_ldo_val_to_mvolts(val) * 1000;
} }
static int wm8350_ldo_list_voltage(struct regulator_dev *rdev, static int wm8350_ldo_list_voltage(struct regulator_dev *rdev,
...@@ -1225,7 +1225,7 @@ static int wm8350_ldo_is_enabled(struct regulator_dev *rdev) ...@@ -1225,7 +1225,7 @@ static int wm8350_ldo_is_enabled(struct regulator_dev *rdev)
static struct regulator_ops wm8350_dcdc_ops = { static struct regulator_ops wm8350_dcdc_ops = {
.set_voltage = wm8350_dcdc_set_voltage, .set_voltage = wm8350_dcdc_set_voltage,
.get_voltage = wm8350_dcdc_get_voltage, .get_voltage_sel = wm8350_dcdc_get_voltage_sel,
.list_voltage = wm8350_dcdc_list_voltage, .list_voltage = wm8350_dcdc_list_voltage,
.enable = wm8350_dcdc_enable, .enable = wm8350_dcdc_enable,
.disable = wm8350_dcdc_disable, .disable = wm8350_dcdc_disable,
...@@ -1249,7 +1249,7 @@ static struct regulator_ops wm8350_dcdc2_5_ops = { ...@@ -1249,7 +1249,7 @@ static struct regulator_ops wm8350_dcdc2_5_ops = {
static struct regulator_ops wm8350_ldo_ops = { static struct regulator_ops wm8350_ldo_ops = {
.set_voltage = wm8350_ldo_set_voltage, .set_voltage = wm8350_ldo_set_voltage,
.get_voltage = wm8350_ldo_get_voltage, .get_voltage_sel = wm8350_ldo_get_voltage_sel,
.list_voltage = wm8350_ldo_list_voltage, .list_voltage = wm8350_ldo_list_voltage,
.enable = wm8350_ldo_enable, .enable = wm8350_ldo_enable,
.disable = wm8350_ldo_disable, .disable = wm8350_ldo_disable,
......
This diff is collapsed.
This diff is collapsed.
...@@ -99,8 +99,6 @@ ...@@ -99,8 +99,6 @@
#define AB8500_NR_IRQS 104 #define AB8500_NR_IRQS 104
#define AB8500_NUM_IRQ_REGS 13 #define AB8500_NUM_IRQ_REGS 13
#define AB8500_NUM_REGULATORS 15
/** /**
* struct ab8500 - ab8500 internal structure * struct ab8500 - ab8500 internal structure
* @dev: parent device * @dev: parent device
...@@ -145,7 +143,8 @@ struct regulator_init_data; ...@@ -145,7 +143,8 @@ struct regulator_init_data;
struct ab8500_platform_data { struct ab8500_platform_data {
int irq_base; int irq_base;
void (*init) (struct ab8500 *); void (*init) (struct ab8500 *);
struct regulator_init_data *regulator[AB8500_NUM_REGULATORS]; int num_regulator;
struct regulator_init_data *regulator;
}; };
extern int __devinit ab8500_init(struct ab8500 *ab8500); extern int __devinit ab8500_init(struct ab8500 *ab8500);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -154,6 +154,7 @@ int regulator_is_supported_voltage(struct regulator *regulator, ...@@ -154,6 +154,7 @@ int regulator_is_supported_voltage(struct regulator *regulator,
int min_uV, int max_uV); int min_uV, int max_uV);
int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
int regulator_get_voltage(struct regulator *regulator); int regulator_get_voltage(struct regulator *regulator);
int regulator_sync_voltage(struct regulator *regulator);
int regulator_set_current_limit(struct regulator *regulator, int regulator_set_current_limit(struct regulator *regulator,
int min_uA, int max_uA); int min_uA, int max_uA);
int regulator_get_current_limit(struct regulator *regulator); int regulator_get_current_limit(struct regulator *regulator);
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment