regulator: da9052: Convert to set_voltage_sel and map_voltage

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Axel Lin 2012-05-16 13:12:35 +08:00 committed by Mark Brown
parent 372de4aa5e
commit 4923b48b27
1 changed files with 24 additions and 13 deletions

View File

@ -179,14 +179,13 @@ static int da9052_list_voltage(struct regulator_dev *rdev,
return volt_uV;
}
static int da9052_regulator_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV,
unsigned int *selector)
static int da9052_map_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
struct da9052_regulator_info *info = regulator->info;
int id = rdev_get_id(rdev);
int ret;
int ret, sel;
ret = verify_range(info, min_uV, max_uV);
if (ret < 0)
@ -197,19 +196,30 @@ static int da9052_regulator_set_voltage(struct regulator_dev *rdev,
if ((id == DA9052_ID_BUCK4) && (regulator->da9052->chip_id == DA9052)
&& (min_uV >= DA9052_CONST_3uV)) {
*selector = DA9052_BUCK_PERI_REG_MAP_UPTO_3uV +
sel = DA9052_BUCK_PERI_REG_MAP_UPTO_3uV +
DIV_ROUND_UP(min_uV - DA9052_CONST_3uV,
DA9052_BUCK_PERI_3uV_STEP);
} else {
*selector = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
sel = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
}
ret = da9052_list_voltage(rdev, *selector);
ret = da9052_list_voltage(rdev, sel);
if (ret < 0)
return ret;
return sel;
}
static int da9052_regulator_set_voltage_sel(struct regulator_dev *rdev,
unsigned int selector)
{
struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
struct da9052_regulator_info *info = regulator->info;
int id = rdev_get_id(rdev);
int ret;
ret = da9052_reg_update(regulator->da9052, rdev->desc->vsel_reg,
rdev->desc->vsel_mask, *selector);
rdev->desc->vsel_mask, selector);
if (ret < 0)
return ret;
@ -231,22 +241,23 @@ static int da9052_regulator_set_voltage(struct regulator_dev *rdev,
}
static struct regulator_ops da9052_dcdc_ops = {
.set_voltage = da9052_regulator_set_voltage,
.get_current_limit = da9052_dcdc_get_current_limit,
.set_current_limit = da9052_dcdc_set_current_limit,
.list_voltage = da9052_list_voltage,
.map_voltage = da9052_map_voltage,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = da9052_regulator_set_voltage_sel,
.is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
};
static struct regulator_ops da9052_ldo_ops = {
.set_voltage = da9052_regulator_set_voltage,
.list_voltage = da9052_list_voltage,
.map_voltage = da9052_map_voltage,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = da9052_regulator_set_voltage_sel,
.is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,