diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-17 05:08:56 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-18 12:42:04 -0400 |
commit | 06c4998be96f2e1f304cf79d5e9d1662d864f7d1 (patch) | |
tree | 9a898aa3617998d8708d83c04a89da0044740a56 /drivers/regulator/tps65090-regulator.c | |
parent | ee7b19142d0e7b88a981fd50b9b8758f697b459e (diff) |
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.c | 64 |
1 files changed, 7 insertions, 57 deletions
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 6bbf760be80..661fcecd1ce 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c | |||
@@ -29,10 +29,6 @@ | |||
29 | 29 | ||
30 | struct tps65090_regulator { | 30 | struct tps65090_regulator { |
31 | int id; | 31 | int id; |
32 | /* Regulator register address.*/ | ||
33 | u8 reg_en_reg; | ||
34 | u8 en_bit; | ||
35 | |||
36 | /* used by regulator core */ | 32 | /* used by regulator core */ |
37 | struct regulator_desc desc; | 33 | struct regulator_desc desc; |
38 | 34 | ||
@@ -40,64 +36,14 @@ struct tps65090_regulator { | |||
40 | struct device *dev; | 36 | struct device *dev; |
41 | }; | 37 | }; |
42 | 38 | ||
43 | static inline struct device *to_tps65090_dev(struct regulator_dev *rdev) | ||
44 | { | ||
45 | return rdev_get_dev(rdev)->parent->parent; | ||
46 | } | ||
47 | |||
48 | static int tps65090_reg_is_enabled(struct regulator_dev *rdev) | ||
49 | { | ||
50 | struct tps65090_regulator *ri = rdev_get_drvdata(rdev); | ||
51 | struct device *parent = to_tps65090_dev(rdev); | ||
52 | uint8_t control; | ||
53 | int ret; | ||
54 | |||
55 | ret = tps65090_read(parent, ri->reg_en_reg, &control); | ||
56 | if (ret < 0) { | ||
57 | dev_err(&rdev->dev, "Error in reading reg 0x%x\n", | ||
58 | ri->reg_en_reg); | ||
59 | return ret; | ||
60 | } | ||
61 | return (((control >> ri->en_bit) & 1) == 1); | ||
62 | } | ||
63 | |||
64 | static int tps65090_reg_enable(struct regulator_dev *rdev) | ||
65 | { | ||
66 | struct tps65090_regulator *ri = rdev_get_drvdata(rdev); | ||
67 | struct device *parent = to_tps65090_dev(rdev); | ||
68 | int ret; | ||
69 | |||
70 | ret = tps65090_set_bits(parent, ri->reg_en_reg, ri->en_bit); | ||
71 | if (ret < 0) | ||
72 | dev_err(&rdev->dev, "Error in updating reg 0x%x\n", | ||
73 | ri->reg_en_reg); | ||
74 | return ret; | ||
75 | } | ||
76 | |||
77 | static int tps65090_reg_disable(struct regulator_dev *rdev) | ||
78 | { | ||
79 | struct tps65090_regulator *ri = rdev_get_drvdata(rdev); | ||
80 | struct device *parent = to_tps65090_dev(rdev); | ||
81 | int ret; | ||
82 | |||
83 | ret = tps65090_clr_bits(parent, ri->reg_en_reg, ri->en_bit); | ||
84 | if (ret < 0) | ||
85 | dev_err(&rdev->dev, "Error in updating reg 0x%x\n", | ||
86 | ri->reg_en_reg); | ||
87 | |||
88 | return ret; | ||
89 | } | ||
90 | |||
91 | static struct regulator_ops tps65090_ops = { | 39 | static struct regulator_ops tps65090_ops = { |
92 | .enable = tps65090_reg_enable, | 40 | .enable = regulator_enable_regmap, |
93 | .disable = tps65090_reg_disable, | 41 | .disable = regulator_disable_regmap, |
94 | .is_enabled = tps65090_reg_is_enabled, | 42 | .is_enabled = regulator_is_enabled_regmap, |
95 | }; | 43 | }; |
96 | 44 | ||
97 | #define tps65090_REG(_id) \ | 45 | #define tps65090_REG(_id) \ |
98 | { \ | 46 | { \ |
99 | .reg_en_reg = (TPS65090_ID_##_id) + 12, \ | ||
100 | .en_bit = 0, \ | ||
101 | .id = TPS65090_ID_##_id, \ | 47 | .id = TPS65090_ID_##_id, \ |
102 | .desc = { \ | 48 | .desc = { \ |
103 | .name = tps65090_rails(_id), \ | 49 | .name = tps65090_rails(_id), \ |
@@ -105,6 +51,8 @@ static struct regulator_ops tps65090_ops = { | |||
105 | .ops = &tps65090_ops, \ | 51 | .ops = &tps65090_ops, \ |
106 | .type = REGULATOR_VOLTAGE, \ | 52 | .type = REGULATOR_VOLTAGE, \ |
107 | .owner = THIS_MODULE, \ | 53 | .owner = THIS_MODULE, \ |
54 | .enable_reg = (TPS65090_ID_##_id) + 12, \ | ||
55 | .enable_mask = BIT(0), \ | ||
108 | }, \ | 56 | }, \ |
109 | } | 57 | } |
110 | 58 | ||
@@ -136,6 +84,7 @@ static inline struct tps65090_regulator *find_regulator_info(int id) | |||
136 | 84 | ||
137 | static int __devinit tps65090_regulator_probe(struct platform_device *pdev) | 85 | static int __devinit tps65090_regulator_probe(struct platform_device *pdev) |
138 | { | 86 | { |
87 | struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev->dev.parent); | ||
139 | struct tps65090_regulator *ri = NULL; | 88 | struct tps65090_regulator *ri = NULL; |
140 | struct regulator_config config = { }; | 89 | struct regulator_config config = { }; |
141 | struct regulator_dev *rdev; | 90 | struct regulator_dev *rdev; |
@@ -155,6 +104,7 @@ static int __devinit tps65090_regulator_probe(struct platform_device *pdev) | |||
155 | config.dev = &pdev->dev; | 104 | config.dev = &pdev->dev; |
156 | config.init_data = &tps_pdata->regulator; | 105 | config.init_data = &tps_pdata->regulator; |
157 | config.driver_data = ri; | 106 | config.driver_data = ri; |
107 | config.regmap = tps65090_mfd->rmap; | ||
158 | 108 | ||
159 | rdev = regulator_register(&ri->desc, &config); | 109 | rdev = regulator_register(&ri->desc, &config); |
160 | if (IS_ERR(rdev)) { | 110 | if (IS_ERR(rdev)) { |