summaryrefslogtreecommitdiff
path: root/drivers/regulator/tps65090-regulator.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-17 13:08:56 +0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-18 20:42:04 +0400
commit06c4998be96f2e1f304cf79d5e9d1662d864f7d1 (patch)
tree9a898aa3617998d8708d83c04a89da0044740a56 /drivers/regulator/tps65090-regulator.c
parentee7b19142d0e7b88a981fd50b9b8758f697b459e (diff)
downloadlinux-06c4998be96f2e1f304cf79d5e9d1662d864f7d1.tar.xz
regulator: tps65090: Use generic regmap enable/disable operations
This patch converts tps65090 regulator driver to use generic regmap enable/disable operations. Also move struct tps65090 to include/linux/mfd/tps65090.h because the regulator driver needs to access the rmap field of struct tps65090. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Venu Byravarasu <vbyravarasu@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/tps65090-regulator.c')
-rw-r--r--drivers/regulator/tps65090-regulator.c64
1 files changed, 7 insertions, 57 deletions
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c
index 6bbf760be80a..661fcecd1cec 100644
--- a/drivers/regulator/tps65090-regulator.c
+++ b/drivers/regulator/tps65090-regulator.c
@@ -29,10 +29,6 @@
struct tps65090_regulator {
int id;
- /* Regulator register address.*/
- u8 reg_en_reg;
- u8 en_bit;
-
/* used by regulator core */
struct regulator_desc desc;
@@ -40,64 +36,14 @@ struct tps65090_regulator {
struct device *dev;
};
-static inline struct device *to_tps65090_dev(struct regulator_dev *rdev)
-{
- return rdev_get_dev(rdev)->parent->parent;
-}
-
-static int tps65090_reg_is_enabled(struct regulator_dev *rdev)
-{
- struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
- struct device *parent = to_tps65090_dev(rdev);
- uint8_t control;
- int ret;
-
- ret = tps65090_read(parent, ri->reg_en_reg, &control);
- if (ret < 0) {
- dev_err(&rdev->dev, "Error in reading reg 0x%x\n",
- ri->reg_en_reg);
- return ret;
- }
- return (((control >> ri->en_bit) & 1) == 1);
-}
-
-static int tps65090_reg_enable(struct regulator_dev *rdev)
-{
- struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
- struct device *parent = to_tps65090_dev(rdev);
- int ret;
-
- ret = tps65090_set_bits(parent, ri->reg_en_reg, ri->en_bit);
- if (ret < 0)
- dev_err(&rdev->dev, "Error in updating reg 0x%x\n",
- ri->reg_en_reg);
- return ret;
-}
-
-static int tps65090_reg_disable(struct regulator_dev *rdev)
-{
- struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
- struct device *parent = to_tps65090_dev(rdev);
- int ret;
-
- ret = tps65090_clr_bits(parent, ri->reg_en_reg, ri->en_bit);
- if (ret < 0)
- dev_err(&rdev->dev, "Error in updating reg 0x%x\n",
- ri->reg_en_reg);
-
- return ret;
-}
-
static struct regulator_ops tps65090_ops = {
- .enable = tps65090_reg_enable,
- .disable = tps65090_reg_disable,
- .is_enabled = tps65090_reg_is_enabled,
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
};
#define tps65090_REG(_id) \
{ \
- .reg_en_reg = (TPS65090_ID_##_id) + 12, \
- .en_bit = 0, \
.id = TPS65090_ID_##_id, \
.desc = { \
.name = tps65090_rails(_id), \
@@ -105,6 +51,8 @@ static struct regulator_ops tps65090_ops = {
.ops = &tps65090_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
+ .enable_reg = (TPS65090_ID_##_id) + 12, \
+ .enable_mask = BIT(0), \
}, \
}
@@ -136,6 +84,7 @@ static inline struct tps65090_regulator *find_regulator_info(int id)
static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
{
+ struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev->dev.parent);
struct tps65090_regulator *ri = NULL;
struct regulator_config config = { };
struct regulator_dev *rdev;
@@ -155,6 +104,7 @@ static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
config.dev = &pdev->dev;
config.init_data = &tps_pdata->regulator;
config.driver_data = ri;
+ config.regmap = tps65090_mfd->rmap;
rdev = regulator_register(&ri->desc, &config);
if (IS_ERR(rdev)) {