Commit fc492f9b authored by Mark Brown's avatar Mark Brown

regulator: wm8350: Convert LDOs to set_voltage_sel()

Since there are two linear ranges for the LDO voltages provide a voltage
mapping function and then use regulator_set_voltage_sel_regmap().
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 2e3f7f26
...@@ -671,13 +671,12 @@ static int wm8350_ldo_set_suspend_disable(struct regulator_dev *rdev) ...@@ -671,13 +671,12 @@ static int wm8350_ldo_set_suspend_disable(struct regulator_dev *rdev)
return 0; return 0;
} }
static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV, static int wm8350_ldo_map_voltage(struct regulator_dev *rdev, int min_uV,
int max_uV, unsigned *selector) int max_uV)
{ {
struct wm8350 *wm8350 = rdev_get_drvdata(rdev); int mV;
int volt_reg, ldo = rdev_get_id(rdev), mV, min_mV = min_uV / 1000, int min_mV = min_uV / 1000;
max_mV = max_uV / 1000; int max_mV = max_uV / 1000;
u16 val;
if (min_mV < 900 || min_mV > 3300) if (min_mV < 900 || min_mV > 3300)
return -EINVAL; return -EINVAL;
...@@ -698,29 +697,7 @@ static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV, ...@@ -698,29 +697,7 @@ static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV,
BUG_ON(wm8350_ldo_val_to_mvolts(mV) < min_mV); BUG_ON(wm8350_ldo_val_to_mvolts(mV) < min_mV);
} }
switch (ldo) { return mV;
case WM8350_LDO_1:
volt_reg = WM8350_LDO1_CONTROL;
break;
case WM8350_LDO_2:
volt_reg = WM8350_LDO2_CONTROL;
break;
case WM8350_LDO_3:
volt_reg = WM8350_LDO3_CONTROL;
break;
case WM8350_LDO_4:
volt_reg = WM8350_LDO4_CONTROL;
break;
default:
return -EINVAL;
}
*selector = mV;
/* all LDOs have same mV bits */
val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_VSEL_MASK;
wm8350_reg_write(wm8350, volt_reg, val | mV);
return 0;
} }
static int wm8350_ldo_list_voltage(struct regulator_dev *rdev, static int wm8350_ldo_list_voltage(struct regulator_dev *rdev,
...@@ -1058,7 +1035,8 @@ static struct regulator_ops wm8350_dcdc2_5_ops = { ...@@ -1058,7 +1035,8 @@ 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, .map_voltage = wm8350_ldo_map_voltage,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap,
.list_voltage = wm8350_ldo_list_voltage, .list_voltage = wm8350_ldo_list_voltage,
.enable = regulator_enable_regmap, .enable = regulator_enable_regmap,
......
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