diff options
Diffstat (limited to 'drivers/regulator/ab8500.c')
-rw-r--r-- | drivers/regulator/ab8500.c | 86 |
1 files changed, 50 insertions, 36 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 28c7ae67cec9..db6b70f20511 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/mfd/ab8500.h> | 23 | #include <linux/mfd/ab8500.h> |
24 | #include <linux/mfd/abx500.h> | ||
24 | #include <linux/regulator/driver.h> | 25 | #include <linux/regulator/driver.h> |
25 | #include <linux/regulator/machine.h> | 26 | #include <linux/regulator/machine.h> |
26 | #include <linux/regulator/ab8500.h> | 27 | #include <linux/regulator/ab8500.h> |
@@ -33,9 +34,11 @@ | |||
33 | * @max_uV: maximum voltage (for variable voltage supplies) | 34 | * @max_uV: maximum voltage (for variable voltage supplies) |
34 | * @min_uV: minimum voltage (for variable voltage supplies) | 35 | * @min_uV: minimum voltage (for variable voltage supplies) |
35 | * @fixed_uV: typical voltage (for fixed voltage supplies) | 36 | * @fixed_uV: typical voltage (for fixed voltage supplies) |
37 | * @update_bank: bank to control on/off | ||
36 | * @update_reg: register to control on/off | 38 | * @update_reg: register to control on/off |
37 | * @mask: mask to enable/disable regulator | 39 | * @mask: mask to enable/disable regulator |
38 | * @enable: bits to enable the regulator in normal(high power) mode | 40 | * @enable: bits to enable the regulator in normal(high power) mode |
41 | * @voltage_bank: bank to control regulator voltage | ||
39 | * @voltage_reg: register to control regulator voltage | 42 | * @voltage_reg: register to control regulator voltage |
40 | * @voltage_mask: mask to control regulator voltage | 43 | * @voltage_mask: mask to control regulator voltage |
41 | * @supported_voltages: supported voltage table | 44 | * @supported_voltages: supported voltage table |
@@ -49,11 +52,13 @@ struct ab8500_regulator_info { | |||
49 | int max_uV; | 52 | int max_uV; |
50 | int min_uV; | 53 | int min_uV; |
51 | int fixed_uV; | 54 | int fixed_uV; |
52 | int update_reg; | 55 | u8 update_bank; |
53 | int mask; | 56 | u8 update_reg; |
54 | int enable; | 57 | u8 mask; |
55 | int voltage_reg; | 58 | u8 enable; |
56 | int voltage_mask; | 59 | u8 voltage_bank; |
60 | u8 voltage_reg; | ||
61 | u8 voltage_mask; | ||
57 | int const *supported_voltages; | 62 | int const *supported_voltages; |
58 | int voltages_len; | 63 | int voltages_len; |
59 | }; | 64 | }; |
@@ -97,8 +102,8 @@ static int ab8500_regulator_enable(struct regulator_dev *rdev) | |||
97 | if (regulator_id >= AB8500_NUM_REGULATORS) | 102 | if (regulator_id >= AB8500_NUM_REGULATORS) |
98 | return -EINVAL; | 103 | return -EINVAL; |
99 | 104 | ||
100 | ret = ab8500_set_bits(info->ab8500, info->update_reg, | 105 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
101 | info->mask, info->enable); | 106 | info->update_bank, info->update_reg, info->mask, info->enable); |
102 | if (ret < 0) | 107 | if (ret < 0) |
103 | dev_err(rdev_get_dev(rdev), | 108 | dev_err(rdev_get_dev(rdev), |
104 | "couldn't set enable bits for regulator\n"); | 109 | "couldn't set enable bits for regulator\n"); |
@@ -114,8 +119,8 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev) | |||
114 | if (regulator_id >= AB8500_NUM_REGULATORS) | 119 | if (regulator_id >= AB8500_NUM_REGULATORS) |
115 | return -EINVAL; | 120 | return -EINVAL; |
116 | 121 | ||
117 | ret = ab8500_set_bits(info->ab8500, info->update_reg, | 122 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
118 | info->mask, 0x0); | 123 | info->update_bank, info->update_reg, info->mask, 0x0); |
119 | if (ret < 0) | 124 | if (ret < 0) |
120 | dev_err(rdev_get_dev(rdev), | 125 | dev_err(rdev_get_dev(rdev), |
121 | "couldn't set disable bits for regulator\n"); | 126 | "couldn't set disable bits for regulator\n"); |
@@ -126,19 +131,21 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) | |||
126 | { | 131 | { |
127 | int regulator_id, ret; | 132 | int regulator_id, ret; |
128 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 133 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
134 | u8 value; | ||
129 | 135 | ||
130 | regulator_id = rdev_get_id(rdev); | 136 | regulator_id = rdev_get_id(rdev); |
131 | if (regulator_id >= AB8500_NUM_REGULATORS) | 137 | if (regulator_id >= AB8500_NUM_REGULATORS) |
132 | return -EINVAL; | 138 | return -EINVAL; |
133 | 139 | ||
134 | ret = ab8500_read(info->ab8500, info->update_reg); | 140 | ret = abx500_get_register_interruptible(info->dev, |
141 | info->update_bank, info->update_reg, &value); | ||
135 | if (ret < 0) { | 142 | if (ret < 0) { |
136 | dev_err(rdev_get_dev(rdev), | 143 | dev_err(rdev_get_dev(rdev), |
137 | "couldn't read 0x%x register\n", info->update_reg); | 144 | "couldn't read 0x%x register\n", info->update_reg); |
138 | return ret; | 145 | return ret; |
139 | } | 146 | } |
140 | 147 | ||
141 | if (ret & info->mask) | 148 | if (value & info->mask) |
142 | return true; | 149 | return true; |
143 | else | 150 | else |
144 | return false; | 151 | return false; |
@@ -165,14 +172,16 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector) | |||
165 | 172 | ||
166 | static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) | 173 | static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) |
167 | { | 174 | { |
168 | int regulator_id, ret, val; | 175 | int regulator_id, ret; |
169 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 176 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
177 | u8 value; | ||
170 | 178 | ||
171 | regulator_id = rdev_get_id(rdev); | 179 | regulator_id = rdev_get_id(rdev); |
172 | if (regulator_id >= AB8500_NUM_REGULATORS) | 180 | if (regulator_id >= AB8500_NUM_REGULATORS) |
173 | return -EINVAL; | 181 | return -EINVAL; |
174 | 182 | ||
175 | ret = ab8500_read(info->ab8500, info->voltage_reg); | 183 | ret = abx500_get_register_interruptible(info->dev, info->voltage_bank, |
184 | info->voltage_reg, &value); | ||
176 | if (ret < 0) { | 185 | if (ret < 0) { |
177 | dev_err(rdev_get_dev(rdev), | 186 | dev_err(rdev_get_dev(rdev), |
178 | "couldn't read voltage reg for regulator\n"); | 187 | "couldn't read voltage reg for regulator\n"); |
@@ -180,11 +189,11 @@ static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) | |||
180 | } | 189 | } |
181 | 190 | ||
182 | /* vintcore has a different layout */ | 191 | /* vintcore has a different layout */ |
183 | val = ret & info->voltage_mask; | 192 | value &= info->voltage_mask; |
184 | if (regulator_id == AB8500_LDO_INTCORE) | 193 | if (regulator_id == AB8500_LDO_INTCORE) |
185 | ret = info->supported_voltages[val >> 0x3]; | 194 | ret = info->supported_voltages[value >> 0x3]; |
186 | else | 195 | else |
187 | ret = info->supported_voltages[val]; | 196 | ret = info->supported_voltages[value]; |
188 | 197 | ||
189 | return ret; | 198 | return ret; |
190 | } | 199 | } |
@@ -224,8 +233,9 @@ static int ab8500_regulator_set_voltage(struct regulator_dev *rdev, | |||
224 | } | 233 | } |
225 | 234 | ||
226 | /* set the registers for the request */ | 235 | /* set the registers for the request */ |
227 | ret = ab8500_set_bits(info->ab8500, info->voltage_reg, | 236 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
228 | info->voltage_mask, ret); | 237 | info->voltage_bank, info->voltage_reg, |
238 | info->voltage_mask, (u8)ret); | ||
229 | if (ret < 0) | 239 | if (ret < 0) |
230 | dev_err(rdev_get_dev(rdev), | 240 | dev_err(rdev_get_dev(rdev), |
231 | "couldn't set voltage reg for regulator\n"); | 241 | "couldn't set voltage reg for regulator\n"); |
@@ -262,9 +272,9 @@ static struct regulator_ops ab8500_ldo_fixed_ops = { | |||
262 | .list_voltage = ab8500_list_voltage, | 272 | .list_voltage = ab8500_list_voltage, |
263 | }; | 273 | }; |
264 | 274 | ||
265 | #define AB8500_LDO(_id, min, max, reg, reg_mask, reg_enable, \ | 275 | #define AB8500_LDO(_id, min, max, bank, reg, reg_mask, \ |
266 | volt_reg, volt_mask, voltages, \ | 276 | reg_enable, volt_bank, volt_reg, volt_mask, \ |
267 | len_volts) \ | 277 | voltages, len_volts) \ |
268 | { \ | 278 | { \ |
269 | .desc = { \ | 279 | .desc = { \ |
270 | .name = "LDO-" #_id, \ | 280 | .name = "LDO-" #_id, \ |
@@ -275,9 +285,11 @@ static struct regulator_ops ab8500_ldo_fixed_ops = { | |||
275 | }, \ | 285 | }, \ |
276 | .min_uV = (min) * 1000, \ | 286 | .min_uV = (min) * 1000, \ |
277 | .max_uV = (max) * 1000, \ | 287 | .max_uV = (max) * 1000, \ |
288 | .update_bank = bank, \ | ||
278 | .update_reg = reg, \ | 289 | .update_reg = reg, \ |
279 | .mask = reg_mask, \ | 290 | .mask = reg_mask, \ |
280 | .enable = reg_enable, \ | 291 | .enable = reg_enable, \ |
292 | .voltage_bank = volt_bank, \ | ||
281 | .voltage_reg = volt_reg, \ | 293 | .voltage_reg = volt_reg, \ |
282 | .voltage_mask = volt_mask, \ | 294 | .voltage_mask = volt_mask, \ |
283 | .supported_voltages = voltages, \ | 295 | .supported_voltages = voltages, \ |
@@ -285,8 +297,8 @@ static struct regulator_ops ab8500_ldo_fixed_ops = { | |||
285 | .fixed_uV = 0, \ | 297 | .fixed_uV = 0, \ |
286 | } | 298 | } |
287 | 299 | ||
288 | #define AB8500_FIXED_LDO(_id, fixed, reg, reg_mask, \ | 300 | #define AB8500_FIXED_LDO(_id, fixed, bank, reg, \ |
289 | reg_enable) \ | 301 | reg_mask, reg_enable) \ |
290 | { \ | 302 | { \ |
291 | .desc = { \ | 303 | .desc = { \ |
292 | .name = "LDO-" #_id, \ | 304 | .name = "LDO-" #_id, \ |
@@ -296,6 +308,7 @@ static struct regulator_ops ab8500_ldo_fixed_ops = { | |||
296 | .owner = THIS_MODULE, \ | 308 | .owner = THIS_MODULE, \ |
297 | }, \ | 309 | }, \ |
298 | .fixed_uV = fixed * 1000, \ | 310 | .fixed_uV = fixed * 1000, \ |
311 | .update_bank = bank, \ | ||
299 | .update_reg = reg, \ | 312 | .update_reg = reg, \ |
300 | .mask = reg_mask, \ | 313 | .mask = reg_mask, \ |
301 | .enable = reg_enable, \ | 314 | .enable = reg_enable, \ |
@@ -304,28 +317,29 @@ static struct regulator_ops ab8500_ldo_fixed_ops = { | |||
304 | static struct ab8500_regulator_info ab8500_regulator_info[] = { | 317 | static struct ab8500_regulator_info ab8500_regulator_info[] = { |
305 | /* | 318 | /* |
306 | * Variable Voltage LDOs | 319 | * Variable Voltage LDOs |
307 | * name, min uV, max uV, ctrl reg, reg mask, enable mask, | 320 | * name, min uV, max uV, ctrl bank, ctrl reg, reg mask, enable mask, |
308 | * volt ctrl reg, volt ctrl mask, volt table, num supported volts | 321 | * volt ctrl bank, volt ctrl reg, volt ctrl mask, volt table, |
322 | * num supported volts | ||
309 | */ | 323 | */ |
310 | AB8500_LDO(AUX1, 1100, 3300, 0x0409, 0x3, 0x1, 0x041f, 0xf, | 324 | AB8500_LDO(AUX1, 1100, 3300, 0x04, 0x09, 0x3, 0x1, 0x04, 0x1f, 0xf, |
311 | ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), | 325 | ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), |
312 | AB8500_LDO(AUX2, 1100, 3300, 0x0409, 0xc, 0x4, 0x0420, 0xf, | 326 | AB8500_LDO(AUX2, 1100, 3300, 0x04, 0x09, 0xc, 0x4, 0x04, 0x20, 0xf, |
313 | ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), | 327 | ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), |
314 | AB8500_LDO(AUX3, 1100, 3300, 0x040a, 0x3, 0x1, 0x0421, 0xf, | 328 | AB8500_LDO(AUX3, 1100, 3300, 0x04, 0x0a, 0x3, 0x1, 0x04, 0x21, 0xf, |
315 | ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), | 329 | ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), |
316 | AB8500_LDO(INTCORE, 1100, 3300, 0x0380, 0x4, 0x4, 0x0380, 0x38, | 330 | AB8500_LDO(INTCORE, 1100, 3300, 0x03, 0x80, 0x4, 0x4, 0x03, 0x80, 0x38, |
317 | ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)), | 331 | ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)), |
318 | 332 | ||
319 | /* | 333 | /* |
320 | * Fixed Voltage LDOs | 334 | * Fixed Voltage LDOs |
321 | * name, o/p uV, ctrl reg, enable, disable | 335 | * name, o/p uV, ctrl bank, ctrl reg, enable, disable |
322 | */ | 336 | */ |
323 | AB8500_FIXED_LDO(TVOUT, 2000, 0x0380, 0x2, 0x2), | 337 | AB8500_FIXED_LDO(TVOUT, 2000, 0x03, 0x80, 0x2, 0x2), |
324 | AB8500_FIXED_LDO(AUDIO, 2000, 0x0383, 0x2, 0x2), | 338 | AB8500_FIXED_LDO(AUDIO, 2000, 0x03, 0x83, 0x2, 0x2), |
325 | AB8500_FIXED_LDO(ANAMIC1, 2050, 0x0383, 0x4, 0x4), | 339 | AB8500_FIXED_LDO(ANAMIC1, 2050, 0x03, 0x83, 0x4, 0x4), |
326 | AB8500_FIXED_LDO(ANAMIC2, 2050, 0x0383, 0x8, 0x8), | 340 | AB8500_FIXED_LDO(ANAMIC2, 2050, 0x03, 0x83, 0x8, 0x8), |
327 | AB8500_FIXED_LDO(DMIC, 1800, 0x0383, 0x10, 0x10), | 341 | AB8500_FIXED_LDO(DMIC, 1800, 0x03, 0x83, 0x10, 0x10), |
328 | AB8500_FIXED_LDO(ANA, 1200, 0x0383, 0xc, 0x4), | 342 | AB8500_FIXED_LDO(ANA, 1200, 0x03, 0x83, 0xc, 0x4), |
329 | }; | 343 | }; |
330 | 344 | ||
331 | static inline struct ab8500_regulator_info *find_regulator_info(int id) | 345 | static inline struct ab8500_regulator_info *find_regulator_info(int id) |