regulator: max8649: Use regulator_get_voltage_sel_regmap()

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-15 00:13:10 +08:00 committed by Mark Brown
parent 0f65402b25
commit 817d8c2d9b
1 changed files with 16 additions and 29 deletions

View File

@ -53,7 +53,6 @@ struct max8649_regulator_info {
struct device *dev; struct device *dev;
struct regmap *regmap; struct regmap *regmap;
int vol_reg;
unsigned mode:2; /* bit[1:0] = VID1, VID0 */ unsigned mode:2; /* bit[1:0] = VID1, VID0 */
unsigned extclk_freq:2; unsigned extclk_freq:2;
unsigned extclk:1; unsigned extclk:1;
@ -76,20 +75,6 @@ static int max8649_list_voltage(struct regulator_dev *rdev, unsigned index)
return (MAX8649_DCDC_VMIN + index * MAX8649_DCDC_STEP); return (MAX8649_DCDC_VMIN + index * MAX8649_DCDC_STEP);
} }
static int max8649_get_voltage_sel(struct regulator_dev *rdev)
{
struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
unsigned int val;
unsigned char data;
int ret;
ret = regmap_read(info->regmap, info->vol_reg, &val);
if (ret != 0)
return ret;
data = (unsigned char)val & MAX8649_VOL_MASK;
return data;
}
static int max8649_set_voltage(struct regulator_dev *rdev, static int max8649_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV, unsigned *selector) int min_uV, int max_uV, unsigned *selector)
{ {
@ -105,7 +90,8 @@ static int max8649_set_voltage(struct regulator_dev *rdev,
mask = MAX8649_VOL_MASK; mask = MAX8649_VOL_MASK;
*selector = data & mask; *selector = data & mask;
return regmap_update_bits(info->regmap, info->vol_reg, mask, data); return regmap_update_bits(info->regmap, rdev->desc->vsel_reg, mask,
data);
} }
/* EN_PD means pulldown on EN input */ /* EN_PD means pulldown on EN input */
@ -145,7 +131,7 @@ static int max8649_enable_time(struct regulator_dev *rdev)
unsigned int val; unsigned int val;
/* get voltage */ /* get voltage */
ret = regmap_read(info->regmap, info->vol_reg, &val); ret = regmap_read(info->regmap, rdev->desc->vsel_reg, &val);
if (ret != 0) if (ret != 0)
return ret; return ret;
val &= MAX8649_VOL_MASK; val &= MAX8649_VOL_MASK;
@ -167,11 +153,11 @@ static int max8649_set_mode(struct regulator_dev *rdev, unsigned int mode)
switch (mode) { switch (mode) {
case REGULATOR_MODE_FAST: case REGULATOR_MODE_FAST:
regmap_update_bits(info->regmap, info->vol_reg, MAX8649_FORCE_PWM, regmap_update_bits(info->regmap, rdev->desc->vsel_reg,
MAX8649_FORCE_PWM); MAX8649_FORCE_PWM, MAX8649_FORCE_PWM);
break; break;
case REGULATOR_MODE_NORMAL: case REGULATOR_MODE_NORMAL:
regmap_update_bits(info->regmap, info->vol_reg, regmap_update_bits(info->regmap, rdev->desc->vsel_reg,
MAX8649_FORCE_PWM, 0); MAX8649_FORCE_PWM, 0);
break; break;
default: default:
@ -186,7 +172,7 @@ static unsigned int max8649_get_mode(struct regulator_dev *rdev)
unsigned int val; unsigned int val;
int ret; int ret;
ret = regmap_read(info->regmap, info->vol_reg, &val); ret = regmap_read(info->regmap, rdev->desc->vsel_reg, &val);
if (ret != 0) if (ret != 0)
return ret; return ret;
if (val & MAX8649_FORCE_PWM) if (val & MAX8649_FORCE_PWM)
@ -196,7 +182,7 @@ static unsigned int max8649_get_mode(struct regulator_dev *rdev)
static struct regulator_ops max8649_dcdc_ops = { static struct regulator_ops max8649_dcdc_ops = {
.set_voltage = max8649_set_voltage, .set_voltage = max8649_set_voltage,
.get_voltage_sel = max8649_get_voltage_sel, .get_voltage_sel = regulator_get_voltage_sel_regmap,
.list_voltage = max8649_list_voltage, .list_voltage = max8649_list_voltage,
.enable = max8649_enable, .enable = max8649_enable,
.disable = max8649_disable, .disable = max8649_disable,
@ -207,12 +193,13 @@ static struct regulator_ops max8649_dcdc_ops = {
}; };
static const struct regulator_desc dcdc_desc = { static struct regulator_desc dcdc_desc = {
.name = "max8649", .name = "max8649",
.ops = &max8649_dcdc_ops, .ops = &max8649_dcdc_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.n_voltages = 1 << 6, .n_voltages = 1 << 6,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.vsel_mask = MAX8649_VOL_MASK,
}; };
static struct regmap_config max8649_regmap_config = { static struct regmap_config max8649_regmap_config = {
@ -250,16 +237,16 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
info->mode = pdata->mode; info->mode = pdata->mode;
switch (info->mode) { switch (info->mode) {
case 0: case 0:
info->vol_reg = MAX8649_MODE0; dcdc_desc.vsel_reg = MAX8649_MODE0;
break; break;
case 1: case 1:
info->vol_reg = MAX8649_MODE1; dcdc_desc.vsel_reg = MAX8649_MODE1;
break; break;
case 2: case 2:
info->vol_reg = MAX8649_MODE2; dcdc_desc.vsel_reg = MAX8649_MODE2;
break; break;
case 3: case 3:
info->vol_reg = MAX8649_MODE3; dcdc_desc.vsel_reg = MAX8649_MODE3;
break; break;
default: default:
break; break;
@ -279,7 +266,8 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
/* enable/disable external clock synchronization */ /* enable/disable external clock synchronization */
info->extclk = pdata->extclk; info->extclk = pdata->extclk;
data = (info->extclk) ? MAX8649_SYNC_EXTCLK : 0; data = (info->extclk) ? MAX8649_SYNC_EXTCLK : 0;
regmap_update_bits(info->regmap, info->vol_reg, MAX8649_SYNC_EXTCLK, data); regmap_update_bits(info->regmap, dcdc_desc.vsel_reg,
MAX8649_SYNC_EXTCLK, data);
if (info->extclk) { if (info->extclk) {
/* set external clock frequency */ /* set external clock frequency */
info->extclk_freq = pdata->extclk_freq; info->extclk_freq = pdata->extclk_freq;
@ -356,4 +344,3 @@ module_exit(max8649_exit);
MODULE_DESCRIPTION("MAXIM 8649 voltage regulator driver"); MODULE_DESCRIPTION("MAXIM 8649 voltage regulator driver");
MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");