diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-03-09 21:59:43 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-03-14 10:10:41 -0400 |
commit | 0a41685fd58f8a4fe097449063764420ebb7ed93 (patch) | |
tree | 1066a384af8f2b0678b6a702508da899e1665d34 /drivers/regulator/s5m8767.c | |
parent | 6c4efe2474d233f439540f1fa364d8a7e48c5cdf (diff) |
regulator: Make s5m8767_get_voltage_register always return correct register
Check s5m8767->buck[2|3|4]_gpiodvs status in s5m8767_get_voltage_register
and return correct register accordingly.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Sangbeom Kim <sbkim73@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/s5m8767.c')
-rw-r--r-- | drivers/regulator/s5m8767.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 611d02d70b6d..58447db15de1 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
@@ -219,6 +219,7 @@ static int s5m8767_reg_disable(struct regulator_dev *rdev) | |||
219 | 219 | ||
220 | static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg) | 220 | static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg) |
221 | { | 221 | { |
222 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); | ||
222 | int reg_id = rdev_get_id(rdev); | 223 | int reg_id = rdev_get_id(rdev); |
223 | int reg; | 224 | int reg; |
224 | 225 | ||
@@ -234,12 +235,18 @@ static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg) | |||
234 | break; | 235 | break; |
235 | case S5M8767_BUCK2: | 236 | case S5M8767_BUCK2: |
236 | reg = S5M8767_REG_BUCK2DVS1; | 237 | reg = S5M8767_REG_BUCK2DVS1; |
238 | if (s5m8767->buck2_gpiodvs) | ||
239 | reg += s5m8767->buck_gpioindex; | ||
237 | break; | 240 | break; |
238 | case S5M8767_BUCK3: | 241 | case S5M8767_BUCK3: |
239 | reg = S5M8767_REG_BUCK3DVS1; | 242 | reg = S5M8767_REG_BUCK3DVS1; |
243 | if (s5m8767->buck3_gpiodvs) | ||
244 | reg += s5m8767->buck_gpioindex; | ||
240 | break; | 245 | break; |
241 | case S5M8767_BUCK4: | 246 | case S5M8767_BUCK4: |
242 | reg = S5M8767_REG_BUCK4DVS1; | 247 | reg = S5M8767_REG_BUCK4DVS1; |
248 | if (s5m8767->buck4_gpiodvs) | ||
249 | reg += s5m8767->buck_gpioindex; | ||
243 | break; | 250 | break; |
244 | case S5M8767_BUCK5: | 251 | case S5M8767_BUCK5: |
245 | reg = S5M8767_REG_BUCK5CTRL2; | 252 | reg = S5M8767_REG_BUCK5CTRL2; |
@@ -259,7 +266,7 @@ static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg) | |||
259 | static int s5m8767_get_voltage_sel(struct regulator_dev *rdev) | 266 | static int s5m8767_get_voltage_sel(struct regulator_dev *rdev) |
260 | { | 267 | { |
261 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); | 268 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); |
262 | int reg, mask = 0xff, ret; | 269 | int reg, mask, ret; |
263 | int reg_id = rdev_get_id(rdev); | 270 | int reg_id = rdev_get_id(rdev); |
264 | u8 val; | 271 | u8 val; |
265 | 272 | ||
@@ -267,23 +274,7 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev) | |||
267 | if (ret) | 274 | if (ret) |
268 | return ret; | 275 | return ret; |
269 | 276 | ||
270 | switch (reg_id) { | 277 | mask = (reg_id < S5M8767_BUCK1) ? 0x3f : 0xff; |
271 | case S5M8767_LDO1 ... S5M8767_LDO28: | ||
272 | mask = 0x3f; | ||
273 | break; | ||
274 | case S5M8767_BUCK2: | ||
275 | if (s5m8767->buck2_gpiodvs) | ||
276 | reg += s5m8767->buck_gpioindex; | ||
277 | break; | ||
278 | case S5M8767_BUCK3: | ||
279 | if (s5m8767->buck3_gpiodvs) | ||
280 | reg += s5m8767->buck_gpioindex; | ||
281 | break; | ||
282 | case S5M8767_BUCK4: | ||
283 | if (s5m8767->buck4_gpiodvs) | ||
284 | reg += s5m8767->buck_gpioindex; | ||
285 | break; | ||
286 | } | ||
287 | 278 | ||
288 | ret = s5m_reg_read(s5m8767->iodev, reg, &val); | 279 | ret = s5m_reg_read(s5m8767->iodev, reg, &val); |
289 | if (ret) | 280 | if (ret) |