diff options
Diffstat (limited to 'drivers/regulator/mc13783-regulator.c')
-rw-r--r-- | drivers/regulator/mc13783-regulator.c | 89 |
1 files changed, 74 insertions, 15 deletions
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index 4932e3449fe1..0801a6d0c122 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c | |||
@@ -21,6 +21,30 @@ | |||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include "mc13xxx.h" | 22 | #include "mc13xxx.h" |
23 | 23 | ||
24 | #define MC13783_REG_SWITCHERS0 24 | ||
25 | /* Enable does not exist for SW1A */ | ||
26 | #define MC13783_REG_SWITCHERS0_SW1AEN 0 | ||
27 | #define MC13783_REG_SWITCHERS0_SW1AVSEL 0 | ||
28 | #define MC13783_REG_SWITCHERS0_SW1AVSEL_M (63 << 0) | ||
29 | |||
30 | #define MC13783_REG_SWITCHERS1 25 | ||
31 | /* Enable does not exist for SW1B */ | ||
32 | #define MC13783_REG_SWITCHERS1_SW1BEN 0 | ||
33 | #define MC13783_REG_SWITCHERS1_SW1BVSEL 0 | ||
34 | #define MC13783_REG_SWITCHERS1_SW1BVSEL_M (63 << 0) | ||
35 | |||
36 | #define MC13783_REG_SWITCHERS2 26 | ||
37 | /* Enable does not exist for SW2A */ | ||
38 | #define MC13783_REG_SWITCHERS2_SW2AEN 0 | ||
39 | #define MC13783_REG_SWITCHERS2_SW2AVSEL 0 | ||
40 | #define MC13783_REG_SWITCHERS2_SW2AVSEL_M (63 << 0) | ||
41 | |||
42 | #define MC13783_REG_SWITCHERS3 27 | ||
43 | /* Enable does not exist for SW2B */ | ||
44 | #define MC13783_REG_SWITCHERS3_SW2BEN 0 | ||
45 | #define MC13783_REG_SWITCHERS3_SW2BVSEL 0 | ||
46 | #define MC13783_REG_SWITCHERS3_SW2BVSEL_M (63 << 0) | ||
47 | |||
24 | #define MC13783_REG_SWITCHERS5 29 | 48 | #define MC13783_REG_SWITCHERS5 29 |
25 | #define MC13783_REG_SWITCHERS5_SW3EN (1 << 20) | 49 | #define MC13783_REG_SWITCHERS5_SW3EN (1 << 20) |
26 | #define MC13783_REG_SWITCHERS5_SW3VSEL 18 | 50 | #define MC13783_REG_SWITCHERS5_SW3VSEL 18 |
@@ -93,6 +117,44 @@ | |||
93 | 117 | ||
94 | 118 | ||
95 | /* Voltage Values */ | 119 | /* Voltage Values */ |
120 | static const int mc13783_sw1x_val[] = { | ||
121 | 900000, 925000, 950000, 975000, | ||
122 | 1000000, 1025000, 1050000, 1075000, | ||
123 | 1100000, 1125000, 1150000, 1175000, | ||
124 | 1200000, 1225000, 1250000, 1275000, | ||
125 | 1300000, 1325000, 1350000, 1375000, | ||
126 | 1400000, 1425000, 1450000, 1475000, | ||
127 | 1500000, 1525000, 1550000, 1575000, | ||
128 | 1600000, 1625000, 1650000, 1675000, | ||
129 | 1700000, 1700000, 1700000, 1700000, | ||
130 | 1800000, 1800000, 1800000, 1800000, | ||
131 | 1850000, 1850000, 1850000, 1850000, | ||
132 | 2000000, 2000000, 2000000, 2000000, | ||
133 | 2100000, 2100000, 2100000, 2100000, | ||
134 | 2200000, 2200000, 2200000, 2200000, | ||
135 | 2200000, 2200000, 2200000, 2200000, | ||
136 | 2200000, 2200000, 2200000, 2200000, | ||
137 | }; | ||
138 | |||
139 | static const int mc13783_sw2x_val[] = { | ||
140 | 900000, 925000, 950000, 975000, | ||
141 | 1000000, 1025000, 1050000, 1075000, | ||
142 | 1100000, 1125000, 1150000, 1175000, | ||
143 | 1200000, 1225000, 1250000, 1275000, | ||
144 | 1300000, 1325000, 1350000, 1375000, | ||
145 | 1400000, 1425000, 1450000, 1475000, | ||
146 | 1500000, 1525000, 1550000, 1575000, | ||
147 | 1600000, 1625000, 1650000, 1675000, | ||
148 | 1700000, 1700000, 1700000, 1700000, | ||
149 | 1800000, 1800000, 1800000, 1800000, | ||
150 | 1900000, 1900000, 1900000, 1900000, | ||
151 | 2000000, 2000000, 2000000, 2000000, | ||
152 | 2100000, 2100000, 2100000, 2100000, | ||
153 | 2200000, 2200000, 2200000, 2200000, | ||
154 | 2200000, 2200000, 2200000, 2200000, | ||
155 | 2200000, 2200000, 2200000, 2200000, | ||
156 | }; | ||
157 | |||
96 | static const unsigned int mc13783_sw3_val[] = { | 158 | static const unsigned int mc13783_sw3_val[] = { |
97 | 5000000, 5000000, 5000000, 5500000, | 159 | 5000000, 5000000, 5000000, 5500000, |
98 | }; | 160 | }; |
@@ -188,6 +250,10 @@ static struct regulator_ops mc13783_gpo_regulator_ops; | |||
188 | MC13783_DEFINE(REG, _name, _reg, _vsel_reg, _voltages) | 250 | MC13783_DEFINE(REG, _name, _reg, _vsel_reg, _voltages) |
189 | 251 | ||
190 | static struct mc13xxx_regulator mc13783_regulators[] = { | 252 | static struct mc13xxx_regulator mc13783_regulators[] = { |
253 | MC13783_DEFINE_SW(SW1A, SWITCHERS0, SWITCHERS0, mc13783_sw1x_val), | ||
254 | MC13783_DEFINE_SW(SW1B, SWITCHERS1, SWITCHERS1, mc13783_sw1x_val), | ||
255 | MC13783_DEFINE_SW(SW2A, SWITCHERS2, SWITCHERS2, mc13783_sw2x_val), | ||
256 | MC13783_DEFINE_SW(SW2B, SWITCHERS3, SWITCHERS3, mc13783_sw2x_val), | ||
191 | MC13783_DEFINE_SW(SW3, SWITCHERS5, SWITCHERS5, mc13783_sw3_val), | 257 | MC13783_DEFINE_SW(SW3, SWITCHERS5, SWITCHERS5, mc13783_sw3_val), |
192 | 258 | ||
193 | MC13783_FIXED_DEFINE(REG, VAUDIO, REGULATORMODE0, mc13783_vaudio_val), | 259 | MC13783_FIXED_DEFINE(REG, VAUDIO, REGULATORMODE0, mc13783_vaudio_val), |
@@ -238,9 +304,10 @@ static int mc13783_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask, | |||
238 | 304 | ||
239 | BUG_ON(val & ~mask); | 305 | BUG_ON(val & ~mask); |
240 | 306 | ||
307 | mc13xxx_lock(priv->mc13xxx); | ||
241 | ret = mc13xxx_reg_read(mc13783, MC13783_REG_POWERMISC, &valread); | 308 | ret = mc13xxx_reg_read(mc13783, MC13783_REG_POWERMISC, &valread); |
242 | if (ret) | 309 | if (ret) |
243 | return ret; | 310 | goto out; |
244 | 311 | ||
245 | /* Update the stored state for Power Gates. */ | 312 | /* Update the stored state for Power Gates. */ |
246 | priv->powermisc_pwgt_state = | 313 | priv->powermisc_pwgt_state = |
@@ -253,7 +320,10 @@ static int mc13783_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask, | |||
253 | valread = (valread & ~MC13783_REG_POWERMISC_PWGTSPI_M) | | 320 | valread = (valread & ~MC13783_REG_POWERMISC_PWGTSPI_M) | |
254 | priv->powermisc_pwgt_state; | 321 | priv->powermisc_pwgt_state; |
255 | 322 | ||
256 | return mc13xxx_reg_write(mc13783, MC13783_REG_POWERMISC, valread); | 323 | ret = mc13xxx_reg_write(mc13783, MC13783_REG_POWERMISC, valread); |
324 | out: | ||
325 | mc13xxx_unlock(priv->mc13xxx); | ||
326 | return ret; | ||
257 | } | 327 | } |
258 | 328 | ||
259 | static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev) | 329 | static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev) |
@@ -261,7 +331,6 @@ static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev) | |||
261 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | 331 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
262 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; | 332 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; |
263 | int id = rdev_get_id(rdev); | 333 | int id = rdev_get_id(rdev); |
264 | int ret; | ||
265 | u32 en_val = mc13xxx_regulators[id].enable_bit; | 334 | u32 en_val = mc13xxx_regulators[id].enable_bit; |
266 | 335 | ||
267 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); | 336 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); |
@@ -271,12 +340,8 @@ static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev) | |||
271 | id == MC13783_REG_PWGT2SPI) | 340 | id == MC13783_REG_PWGT2SPI) |
272 | en_val = 0; | 341 | en_val = 0; |
273 | 342 | ||
274 | mc13xxx_lock(priv->mc13xxx); | 343 | return mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, |
275 | ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, | ||
276 | en_val); | 344 | en_val); |
277 | mc13xxx_unlock(priv->mc13xxx); | ||
278 | |||
279 | return ret; | ||
280 | } | 345 | } |
281 | 346 | ||
282 | static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev) | 347 | static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev) |
@@ -284,7 +349,6 @@ static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev) | |||
284 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | 349 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
285 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; | 350 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; |
286 | int id = rdev_get_id(rdev); | 351 | int id = rdev_get_id(rdev); |
287 | int ret; | ||
288 | u32 dis_val = 0; | 352 | u32 dis_val = 0; |
289 | 353 | ||
290 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); | 354 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); |
@@ -294,12 +358,8 @@ static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev) | |||
294 | id == MC13783_REG_PWGT2SPI) | 358 | id == MC13783_REG_PWGT2SPI) |
295 | dis_val = mc13xxx_regulators[id].enable_bit; | 359 | dis_val = mc13xxx_regulators[id].enable_bit; |
296 | 360 | ||
297 | mc13xxx_lock(priv->mc13xxx); | 361 | return mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, |
298 | ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, | ||
299 | dis_val); | 362 | dis_val); |
300 | mc13xxx_unlock(priv->mc13xxx); | ||
301 | |||
302 | return ret; | ||
303 | } | 363 | } |
304 | 364 | ||
305 | static int mc13783_gpo_regulator_is_enabled(struct regulator_dev *rdev) | 365 | static int mc13783_gpo_regulator_is_enabled(struct regulator_dev *rdev) |
@@ -330,7 +390,6 @@ static struct regulator_ops mc13783_gpo_regulator_ops = { | |||
330 | .is_enabled = mc13783_gpo_regulator_is_enabled, | 390 | .is_enabled = mc13783_gpo_regulator_is_enabled, |
331 | .list_voltage = regulator_list_voltage_table, | 391 | .list_voltage = regulator_list_voltage_table, |
332 | .set_voltage = mc13xxx_fixed_regulator_set_voltage, | 392 | .set_voltage = mc13xxx_fixed_regulator_set_voltage, |
333 | .get_voltage = mc13xxx_fixed_regulator_get_voltage, | ||
334 | }; | 393 | }; |
335 | 394 | ||
336 | static int __devinit mc13783_regulator_probe(struct platform_device *pdev) | 395 | static int __devinit mc13783_regulator_probe(struct platform_device *pdev) |