diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-17 05:34:32 +0200 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-23 14:19:51 +0200 |
commit | 0d481f74ab6aa94b0900138525b14e7e2af8e3b1 (patch) | |
tree | e86e1f7b7986e962c98aa266b9c702bf5dab4ce7 /drivers/regulator/da9052-regulator.c | |
parent | regulator: 88pm8607: Use generic regmap enable/disable operations (diff) | |
download | linux-0d481f74ab6aa94b0900138525b14e7e2af8e3b1.tar.xz linux-0d481f74ab6aa94b0900138525b14e7e2af8e3b1.zip |
regulator: da9052: Use generic regmap enable/disable operations
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/da9052-regulator.c')
-rw-r--r-- | drivers/regulator/da9052-regulator.c | 56 |
1 files changed, 11 insertions, 45 deletions
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index 2678cbe91d9d..f6eee2924de9 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c @@ -70,7 +70,6 @@ struct da9052_regulator_info { int min_uV; int max_uV; unsigned char volt_shift; - unsigned char en_bit; unsigned char activate_bit; }; @@ -89,42 +88,6 @@ static int verify_range(struct da9052_regulator_info *info, return 0; } -static int da9052_regulator_enable(struct regulator_dev *rdev) -{ - struct da9052_regulator *regulator = rdev_get_drvdata(rdev); - struct da9052_regulator_info *info = regulator->info; - int offset = rdev_get_id(rdev); - - return da9052_reg_update(regulator->da9052, - DA9052_BUCKCORE_REG + offset, - 1 << info->en_bit, 1 << info->en_bit); -} - -static int da9052_regulator_disable(struct regulator_dev *rdev) -{ - struct da9052_regulator *regulator = rdev_get_drvdata(rdev); - struct da9052_regulator_info *info = regulator->info; - int offset = rdev_get_id(rdev); - - return da9052_reg_update(regulator->da9052, - DA9052_BUCKCORE_REG + offset, - 1 << info->en_bit, 0); -} - -static int da9052_regulator_is_enabled(struct regulator_dev *rdev) -{ - struct da9052_regulator *regulator = rdev_get_drvdata(rdev); - struct da9052_regulator_info *info = regulator->info; - int offset = rdev_get_id(rdev); - int ret; - - ret = da9052_reg_read(regulator->da9052, DA9052_BUCKCORE_REG + offset); - if (ret < 0) - return ret; - - return ret & (1 << info->en_bit); -} - static int da9052_dcdc_get_current_limit(struct regulator_dev *rdev) { struct da9052_regulator *regulator = rdev_get_drvdata(rdev); @@ -291,9 +254,9 @@ static struct regulator_ops da9052_dcdc_ops = { .list_voltage = da9052_list_voltage, .get_voltage_sel = da9052_get_regulator_voltage_sel, - .is_enabled = da9052_regulator_is_enabled, - .enable = da9052_regulator_enable, - .disable = da9052_regulator_disable, + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, }; static struct regulator_ops da9052_ldo_ops = { @@ -301,9 +264,9 @@ static struct regulator_ops da9052_ldo_ops = { .list_voltage = da9052_list_voltage, .get_voltage_sel = da9052_get_regulator_voltage_sel, - .is_enabled = da9052_regulator_is_enabled, - .enable = da9052_regulator_enable, - .disable = da9052_regulator_disable, + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, }; #define DA9052_LDO(_id, step, min, max, sbits, ebits, abits) \ @@ -315,12 +278,13 @@ static struct regulator_ops da9052_ldo_ops = { .id = DA9052_ID_##_id,\ .n_voltages = (max - min) / step + 1, \ .owner = THIS_MODULE,\ + .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ + .enable_mask = 1 << (ebits),\ },\ .min_uV = (min) * 1000,\ .max_uV = (max) * 1000,\ .step_uV = (step) * 1000,\ .volt_shift = (sbits),\ - .en_bit = (ebits),\ .activate_bit = (abits),\ } @@ -333,12 +297,13 @@ static struct regulator_ops da9052_ldo_ops = { .id = DA9052_ID_##_id,\ .n_voltages = (max - min) / step + 1, \ .owner = THIS_MODULE,\ + .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ + .enable_mask = 1 << (ebits),\ },\ .min_uV = (min) * 1000,\ .max_uV = (max) * 1000,\ .step_uV = (step) * 1000,\ .volt_shift = (sbits),\ - .en_bit = (ebits),\ .activate_bit = (abits),\ } @@ -429,6 +394,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev) config.dev = &pdev->dev; config.driver_data = regulator; + config.regmap = da9052->regmap; if (pdata && pdata->regulators) { config.init_data = pdata->regulators[pdev->id]; } else { |