aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-17 02:11:31 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-23 08:19:50 -0400
commit5bb6936c060aa054fa814fd29196d9f88f035637 (patch)
treefd3c24387cbde5dc27940adb07cb7bdecac49740 /drivers
parent06c4998be96f2e1f304cf79d5e9d1662d864f7d1 (diff)
regulator: rc5t583: 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')
-rw-r--r--drivers/regulator/rc5t583-regulator.c63
1 files changed, 6 insertions, 57 deletions
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index b567c9ec47c1..81a74d1d15a9 100644
--- a/drivers/regulator/rc5t583-regulator.c
+++ b/drivers/regulator/rc5t583-regulator.c
@@ -37,8 +37,6 @@ struct rc5t583_regulator_info {
37 int deepsleep_id; 37 int deepsleep_id;
38 38
39 /* Regulator register address.*/ 39 /* Regulator register address.*/
40 uint8_t reg_en_reg;
41 uint8_t en_bit;
42 uint8_t reg_disc_reg; 40 uint8_t reg_disc_reg;
43 uint8_t disc_bit; 41 uint8_t disc_bit;
44 uint8_t vout_reg; 42 uint8_t vout_reg;
@@ -67,56 +65,6 @@ struct rc5t583_regulator {
67 struct regulator_dev *rdev; 65 struct regulator_dev *rdev;
68}; 66};
69 67
70static int rc5t583_reg_is_enabled(struct regulator_dev *rdev)
71{
72 struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
73 struct rc5t583_regulator_info *ri = reg->reg_info;
74 uint8_t control;
75 int ret;
76
77 ret = rc5t583_read(reg->mfd->dev, ri->reg_en_reg, &control);
78 if (ret < 0) {
79 dev_err(&rdev->dev,
80 "Error in reading the control register 0x%02x\n",
81 ri->reg_en_reg);
82 return ret;
83 }
84 return !!(control & BIT(ri->en_bit));
85}
86
87static int rc5t583_reg_enable(struct regulator_dev *rdev)
88{
89 struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
90 struct rc5t583_regulator_info *ri = reg->reg_info;
91 int ret;
92
93 ret = rc5t583_set_bits(reg->mfd->dev, ri->reg_en_reg,
94 (1 << ri->en_bit));
95 if (ret < 0) {
96 dev_err(&rdev->dev,
97 "Error in setting bit of STATE register 0x%02x\n",
98 ri->reg_en_reg);
99 return ret;
100 }
101 return ret;
102}
103
104static int rc5t583_reg_disable(struct regulator_dev *rdev)
105{
106 struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
107 struct rc5t583_regulator_info *ri = reg->reg_info;
108 int ret;
109
110 ret = rc5t583_clear_bits(reg->mfd->dev, ri->reg_en_reg,
111 (1 << ri->en_bit));
112 if (ret < 0)
113 dev_err(&rdev->dev,
114 "Error in clearing bit of STATE register 0x%02x\n",
115 ri->reg_en_reg);
116
117 return ret;
118}
119
120static int rc5t583_list_voltage(struct regulator_dev *rdev, unsigned selector) 68static int rc5t583_list_voltage(struct regulator_dev *rdev, unsigned selector)
121{ 69{
122 struct rc5t583_regulator *reg = rdev_get_drvdata(rdev); 70 struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
@@ -193,9 +141,9 @@ static int rc5t583_set_voltage_time_sel(struct regulator_dev *rdev,
193 141
194 142
195static struct regulator_ops rc5t583_ops = { 143static struct regulator_ops rc5t583_ops = {
196 .is_enabled = rc5t583_reg_is_enabled, 144 .is_enabled = regulator_is_enabled_regmap,
197 .enable = rc5t583_reg_enable, 145 .enable = regulator_enable_regmap,
198 .disable = rc5t583_reg_disable, 146 .disable = regulator_disable_regmap,
199 .enable_time = rc5t583_regulator_enable_time, 147 .enable_time = rc5t583_regulator_enable_time,
200 .get_voltage_sel = rc5t583_get_voltage_sel, 148 .get_voltage_sel = rc5t583_get_voltage_sel,
201 .set_voltage = rc5t583_set_voltage, 149 .set_voltage = rc5t583_set_voltage,
@@ -206,8 +154,6 @@ static struct regulator_ops rc5t583_ops = {
206#define RC5T583_REG(_id, _en_reg, _en_bit, _disc_reg, _disc_bit, \ 154#define RC5T583_REG(_id, _en_reg, _en_bit, _disc_reg, _disc_bit, \
207 _vout_mask, _min_mv, _max_mv, _step_uV, _enable_mv) \ 155 _vout_mask, _min_mv, _max_mv, _step_uV, _enable_mv) \
208{ \ 156{ \
209 .reg_en_reg = RC5T583_REG_##_en_reg, \
210 .en_bit = _en_bit, \
211 .reg_disc_reg = RC5T583_REG_##_disc_reg, \ 157 .reg_disc_reg = RC5T583_REG_##_disc_reg, \
212 .disc_bit = _disc_bit, \ 158 .disc_bit = _disc_bit, \
213 .vout_reg = RC5T583_REG_##_id##DAC, \ 159 .vout_reg = RC5T583_REG_##_id##DAC, \
@@ -226,6 +172,8 @@ static struct regulator_ops rc5t583_ops = {
226 .ops = &rc5t583_ops, \ 172 .ops = &rc5t583_ops, \
227 .type = REGULATOR_VOLTAGE, \ 173 .type = REGULATOR_VOLTAGE, \
228 .owner = THIS_MODULE, \ 174 .owner = THIS_MODULE, \
175 .enable_reg = RC5T583_REG_##_en_reg, \
176 .enable_mask = BIT(_en_bit), \
229 }, \ 177 }, \
230} 178}
231 179
@@ -304,6 +252,7 @@ skip_ext_pwr_config:
304 config.dev = &pdev->dev; 252 config.dev = &pdev->dev;
305 config.init_data = reg_data; 253 config.init_data = reg_data;
306 config.driver_data = reg; 254 config.driver_data = reg;
255 config.regmap = rc5t583->regmap;
307 256
308 rdev = regulator_register(&ri->desc, &config); 257 rdev = regulator_register(&ri->desc, &config);
309 if (IS_ERR(rdev)) { 258 if (IS_ERR(rdev)) {