Commit a0a7014cd40b1d1d13e121e5083bd3b2bbffe348

Authored by Linus Walleij
Committed by Mark Brown
1 parent db55168265

regulator: ab8500: provide per-regulator shift

This encodes the voltage shifts (the number of bits to shift
the register to get to the selector) into the regulator info.
We have several new variants of the AB8500 so this varies a
lot.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Showing 1 changed file with 10 additions and 10 deletions Side-by-side Diff

drivers/regulator/ab8500.c
... ... @@ -37,6 +37,7 @@
37 37 * @voltage_bank: bank to control regulator voltage
38 38 * @voltage_reg: register to control regulator voltage
39 39 * @voltage_mask: mask to control regulator voltage
  40 + * @voltage_shift: shift to control regulator voltage
40 41 * @delay: startup/set voltage delay in us
41 42 */
42 43 struct ab8500_regulator_info {
... ... @@ -50,6 +51,7 @@
50 51 u8 voltage_bank;
51 52 u8 voltage_reg;
52 53 u8 voltage_mask;
  54 + u8 voltage_shift;
53 55 unsigned int delay;
54 56 };
55 57  
56 58  
57 59  
... ... @@ -195,17 +197,14 @@
195 197 }
196 198  
197 199 dev_vdbg(rdev_get_dev(rdev),
198   - "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
199   - " 0x%x\n",
200   - info->desc.name, info->voltage_bank, info->voltage_reg,
201   - info->voltage_mask, regval);
  200 + "%s-get_voltage (bank, reg, mask, shift, value): "
  201 + "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
  202 + info->desc.name, info->voltage_bank,
  203 + info->voltage_reg, info->voltage_mask,
  204 + info->voltage_shift, regval);
202 205  
203   - /* vintcore has a different layout */
204 206 val = regval & info->voltage_mask;
205   - if (info->desc.id == AB8500_LDO_INTCORE)
206   - return val >> 0x3;
207   - else
208   - return val;
  207 + return val >> info->voltage_shift;
209 208 }
210 209  
211 210 static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
... ... @@ -221,7 +220,7 @@
221 220 }
222 221  
223 222 /* set the registers for the request */
224   - regval = (u8)selector;
  223 + regval = (u8)selector << info->voltage_shift;
225 224 ret = abx500_mask_and_set_register_interruptible(info->dev,
226 225 info->voltage_bank, info->voltage_reg,
227 226 info->voltage_mask, regval);
... ... @@ -343,6 +342,7 @@
343 342 .voltage_bank = 0x03,
344 343 .voltage_reg = 0x80,
345 344 .voltage_mask = 0x38,
  345 + .voltage_shift = 3,
346 346 },
347 347  
348 348 /*