Skip to content

Commit

Permalink
regulator: wm8994: Use core voltage selector operations
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
  • Loading branch information
Mark Brown committed Apr 16, 2012
1 parent ac663b4 commit 633b6fc
Showing 1 changed file with 9 additions and 50 deletions.
59 changes: 9 additions & 50 deletions drivers/regulator/wm8994-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,15 @@ static int wm8994_ldo1_list_voltage(struct regulator_dev *rdev,
return (selector * 100000) + 2400000;
}

static int wm8994_ldo1_get_voltage_sel(struct regulator_dev *rdev)
{
struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);
int val;

val = wm8994_reg_read(ldo->wm8994, WM8994_LDO_1);
if (val < 0)
return val;

return (val & WM8994_LDO1_VSEL_MASK) >> WM8994_LDO1_VSEL_SHIFT;
}

static int wm8994_ldo1_set_voltage_sel(struct regulator_dev *rdev,
unsigned selector)
{
struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);

selector <<= WM8994_LDO1_VSEL_SHIFT;

return wm8994_set_bits(ldo->wm8994, WM8994_LDO_1,
WM8994_LDO1_VSEL_MASK, selector);
}

static struct regulator_ops wm8994_ldo1_ops = {
.enable = wm8994_ldo_enable,
.disable = wm8994_ldo_disable,
.is_enabled = wm8994_ldo_is_enabled,
.enable_time = wm8994_ldo_enable_time,

.list_voltage = wm8994_ldo1_list_voltage,
.get_voltage_sel = wm8994_ldo1_get_voltage_sel,
.set_voltage_sel = wm8994_ldo1_set_voltage_sel,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
};

static int wm8994_ldo2_list_voltage(struct regulator_dev *rdev,
Expand Down Expand Up @@ -146,38 +123,15 @@ static int wm8994_ldo2_list_voltage(struct regulator_dev *rdev,
}
}

static int wm8994_ldo2_get_voltage_sel(struct regulator_dev *rdev)
{
struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);
int val;

val = wm8994_reg_read(ldo->wm8994, WM8994_LDO_2);
if (val < 0)
return val;

return (val & WM8994_LDO2_VSEL_MASK) >> WM8994_LDO2_VSEL_SHIFT;
}

static int wm8994_ldo2_set_voltage_sel(struct regulator_dev *rdev,
unsigned selector)
{
struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);

selector <<= WM8994_LDO2_VSEL_SHIFT;

return wm8994_set_bits(ldo->wm8994, WM8994_LDO_2,
WM8994_LDO2_VSEL_MASK, selector);
}

static struct regulator_ops wm8994_ldo2_ops = {
.enable = wm8994_ldo_enable,
.disable = wm8994_ldo_disable,
.is_enabled = wm8994_ldo_is_enabled,
.enable_time = wm8994_ldo_enable_time,

.list_voltage = wm8994_ldo2_list_voltage,
.get_voltage_sel = wm8994_ldo2_get_voltage_sel,
.set_voltage_sel = wm8994_ldo2_set_voltage_sel,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
};

static const struct regulator_desc wm8994_ldo_desc[] = {
Expand All @@ -186,6 +140,8 @@ static const struct regulator_desc wm8994_ldo_desc[] = {
.id = 1,
.type = REGULATOR_VOLTAGE,
.n_voltages = WM8994_LDO1_MAX_SELECTOR + 1,
.vsel_reg = WM8994_LDO_1,
.vsel_mask = WM8994_LDO1_VSEL_MASK,
.ops = &wm8994_ldo1_ops,
.owner = THIS_MODULE,
},
Expand All @@ -194,6 +150,8 @@ static const struct regulator_desc wm8994_ldo_desc[] = {
.id = 2,
.type = REGULATOR_VOLTAGE,
.n_voltages = WM8994_LDO2_MAX_SELECTOR + 1,
.vsel_reg = WM8994_LDO_2,
.vsel_mask = WM8994_LDO2_VSEL_MASK,
.ops = &wm8994_ldo2_ops,
.owner = THIS_MODULE,
},
Expand Down Expand Up @@ -243,6 +201,7 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev)
config.dev = &pdev->dev;
config.init_data = pdata->ldo[id].init_data;
config.driver_data = ldo;
config.regmap = wm8994->regmap;

ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config);
if (IS_ERR(ldo->regulator)) {
Expand Down

0 comments on commit 633b6fc

Please sign in to comment.