aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/ab3100.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/ab3100.c')
-rw-r--r--drivers/regulator/ab3100.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
index 7de950959ed2..7b14a67bdca2 100644
--- a/drivers/regulator/ab3100.c
+++ b/drivers/regulator/ab3100.c
@@ -16,7 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/regulator/driver.h> 18#include <linux/regulator/driver.h>
19#include <linux/mfd/ab3100.h> 19#include <linux/mfd/abx500.h>
20 20
21/* LDO registers and some handy masking definitions for AB3100 */ 21/* LDO registers and some handy masking definitions for AB3100 */
22#define AB3100_LDO_A 0x40 22#define AB3100_LDO_A 0x40
@@ -41,7 +41,7 @@
41 * struct ab3100_regulator 41 * struct ab3100_regulator
42 * A struct passed around the individual regulator functions 42 * A struct passed around the individual regulator functions
43 * @platform_device: platform device holding this regulator 43 * @platform_device: platform device holding this regulator
44 * @ab3100: handle to the AB3100 parent chip 44 * @dev: handle to the device
45 * @plfdata: AB3100 platform data passed in at probe time 45 * @plfdata: AB3100 platform data passed in at probe time
46 * @regreg: regulator register number in the AB3100 46 * @regreg: regulator register number in the AB3100
47 * @fixed_voltage: a fixed voltage for this regulator, if this 47 * @fixed_voltage: a fixed voltage for this regulator, if this
@@ -52,7 +52,7 @@
52 */ 52 */
53struct ab3100_regulator { 53struct ab3100_regulator {
54 struct regulator_dev *rdev; 54 struct regulator_dev *rdev;
55 struct ab3100 *ab3100; 55 struct device *dev;
56 struct ab3100_platform_data *plfdata; 56 struct ab3100_platform_data *plfdata;
57 u8 regreg; 57 u8 regreg;
58 int fixed_voltage; 58 int fixed_voltage;
@@ -183,7 +183,7 @@ static int ab3100_enable_regulator(struct regulator_dev *reg)
183 int err; 183 int err;
184 u8 regval; 184 u8 regval;
185 185
186 err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg, 186 err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg,
187 &regval); 187 &regval);
188 if (err) { 188 if (err) {
189 dev_warn(&reg->dev, "failed to get regid %d value\n", 189 dev_warn(&reg->dev, "failed to get regid %d value\n",
@@ -197,7 +197,7 @@ static int ab3100_enable_regulator(struct regulator_dev *reg)
197 197
198 regval |= AB3100_REG_ON_MASK; 198 regval |= AB3100_REG_ON_MASK;
199 199
200 err = ab3100_set_register_interruptible(abreg->ab3100, abreg->regreg, 200 err = abx500_set_register_interruptible(abreg->dev, 0, abreg->regreg,
201 regval); 201 regval);
202 if (err) { 202 if (err) {
203 dev_warn(&reg->dev, "failed to set regid %d value\n", 203 dev_warn(&reg->dev, "failed to set regid %d value\n",
@@ -245,14 +245,14 @@ static int ab3100_disable_regulator(struct regulator_dev *reg)
245 if (abreg->regreg == AB3100_LDO_D) { 245 if (abreg->regreg == AB3100_LDO_D) {
246 dev_info(&reg->dev, "disabling LDO D - shut down system\n"); 246 dev_info(&reg->dev, "disabling LDO D - shut down system\n");
247 /* Setting LDO D to 0x00 cuts the power to the SoC */ 247 /* Setting LDO D to 0x00 cuts the power to the SoC */
248 return ab3100_set_register_interruptible(abreg->ab3100, 248 return abx500_set_register_interruptible(abreg->dev, 0,
249 AB3100_LDO_D, 0x00U); 249 AB3100_LDO_D, 0x00U);
250 } 250 }
251 251
252 /* 252 /*
253 * All other regulators are handled here 253 * All other regulators are handled here
254 */ 254 */
255 err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg, 255 err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg,
256 &regval); 256 &regval);
257 if (err) { 257 if (err) {
258 dev_err(&reg->dev, "unable to get register 0x%x\n", 258 dev_err(&reg->dev, "unable to get register 0x%x\n",
@@ -260,7 +260,7 @@ static int ab3100_disable_regulator(struct regulator_dev *reg)
260 return err; 260 return err;
261 } 261 }
262 regval &= ~AB3100_REG_ON_MASK; 262 regval &= ~AB3100_REG_ON_MASK;
263 return ab3100_set_register_interruptible(abreg->ab3100, abreg->regreg, 263 return abx500_set_register_interruptible(abreg->dev, 0, abreg->regreg,
264 regval); 264 regval);
265} 265}
266 266
@@ -270,7 +270,7 @@ static int ab3100_is_enabled_regulator(struct regulator_dev *reg)
270 u8 regval; 270 u8 regval;
271 int err; 271 int err;
272 272
273 err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg, 273 err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg,
274 &regval); 274 &regval);
275 if (err) { 275 if (err) {
276 dev_err(&reg->dev, "unable to get register 0x%x\n", 276 dev_err(&reg->dev, "unable to get register 0x%x\n",
@@ -305,7 +305,7 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
305 * For variable types, read out setting and index into 305 * For variable types, read out setting and index into
306 * supplied voltage list. 306 * supplied voltage list.
307 */ 307 */
308 err = ab3100_get_register_interruptible(abreg->ab3100, 308 err = abx500_get_register_interruptible(abreg->dev, 0,
309 abreg->regreg, &regval); 309 abreg->regreg, &regval);
310 if (err) { 310 if (err) {
311 dev_warn(&reg->dev, 311 dev_warn(&reg->dev,
@@ -373,7 +373,7 @@ static int ab3100_set_voltage_regulator(struct regulator_dev *reg,
373 if (bestindex < 0) 373 if (bestindex < 0)
374 return bestindex; 374 return bestindex;
375 375
376 err = ab3100_get_register_interruptible(abreg->ab3100, 376 err = abx500_get_register_interruptible(abreg->dev, 0,
377 abreg->regreg, &regval); 377 abreg->regreg, &regval);
378 if (err) { 378 if (err) {
379 dev_warn(&reg->dev, 379 dev_warn(&reg->dev,
@@ -386,7 +386,7 @@ static int ab3100_set_voltage_regulator(struct regulator_dev *reg,
386 regval &= ~0xE0; 386 regval &= ~0xE0;
387 regval |= (bestindex << 5); 387 regval |= (bestindex << 5);
388 388
389 err = ab3100_set_register_interruptible(abreg->ab3100, 389 err = abx500_set_register_interruptible(abreg->dev, 0,
390 abreg->regreg, regval); 390 abreg->regreg, regval);
391 if (err) 391 if (err)
392 dev_warn(&reg->dev, "failed to set regulator register %02x\n", 392 dev_warn(&reg->dev, "failed to set regulator register %02x\n",
@@ -414,7 +414,7 @@ static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg,
414 /* LDO E and BUCK have special suspend voltages you can set */ 414 /* LDO E and BUCK have special suspend voltages you can set */
415 bestindex = ab3100_get_best_voltage_index(reg, uV, uV); 415 bestindex = ab3100_get_best_voltage_index(reg, uV, uV);
416 416
417 err = ab3100_get_register_interruptible(abreg->ab3100, 417 err = abx500_get_register_interruptible(abreg->dev, 0,
418 targetreg, &regval); 418 targetreg, &regval);
419 if (err) { 419 if (err) {
420 dev_warn(&reg->dev, 420 dev_warn(&reg->dev,
@@ -427,7 +427,7 @@ static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg,
427 regval &= ~0xE0; 427 regval &= ~0xE0;
428 regval |= (bestindex << 5); 428 regval |= (bestindex << 5);
429 429
430 err = ab3100_set_register_interruptible(abreg->ab3100, 430 err = abx500_set_register_interruptible(abreg->dev, 0,
431 targetreg, regval); 431 targetreg, regval);
432 if (err) 432 if (err)
433 dev_warn(&reg->dev, "failed to set regulator register %02x\n", 433 dev_warn(&reg->dev, "failed to set regulator register %02x\n",
@@ -492,18 +492,21 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
492 .id = AB3100_LDO_A, 492 .id = AB3100_LDO_A,
493 .ops = &regulator_ops_fixed, 493 .ops = &regulator_ops_fixed,
494 .type = REGULATOR_VOLTAGE, 494 .type = REGULATOR_VOLTAGE,
495 .owner = THIS_MODULE,
495 }, 496 },
496 { 497 {
497 .name = "LDO_C", 498 .name = "LDO_C",
498 .id = AB3100_LDO_C, 499 .id = AB3100_LDO_C,
499 .ops = &regulator_ops_fixed, 500 .ops = &regulator_ops_fixed,
500 .type = REGULATOR_VOLTAGE, 501 .type = REGULATOR_VOLTAGE,
502 .owner = THIS_MODULE,
501 }, 503 },
502 { 504 {
503 .name = "LDO_D", 505 .name = "LDO_D",
504 .id = AB3100_LDO_D, 506 .id = AB3100_LDO_D,
505 .ops = &regulator_ops_fixed, 507 .ops = &regulator_ops_fixed,
506 .type = REGULATOR_VOLTAGE, 508 .type = REGULATOR_VOLTAGE,
509 .owner = THIS_MODULE,
507 }, 510 },
508 { 511 {
509 .name = "LDO_E", 512 .name = "LDO_E",
@@ -511,6 +514,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
511 .ops = &regulator_ops_variable_sleepable, 514 .ops = &regulator_ops_variable_sleepable,
512 .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages), 515 .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages),
513 .type = REGULATOR_VOLTAGE, 516 .type = REGULATOR_VOLTAGE,
517 .owner = THIS_MODULE,
514 }, 518 },
515 { 519 {
516 .name = "LDO_F", 520 .name = "LDO_F",
@@ -518,6 +522,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
518 .ops = &regulator_ops_variable, 522 .ops = &regulator_ops_variable,
519 .n_voltages = ARRAY_SIZE(ldo_f_typ_voltages), 523 .n_voltages = ARRAY_SIZE(ldo_f_typ_voltages),
520 .type = REGULATOR_VOLTAGE, 524 .type = REGULATOR_VOLTAGE,
525 .owner = THIS_MODULE,
521 }, 526 },
522 { 527 {
523 .name = "LDO_G", 528 .name = "LDO_G",
@@ -525,6 +530,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
525 .ops = &regulator_ops_variable, 530 .ops = &regulator_ops_variable,
526 .n_voltages = ARRAY_SIZE(ldo_g_typ_voltages), 531 .n_voltages = ARRAY_SIZE(ldo_g_typ_voltages),
527 .type = REGULATOR_VOLTAGE, 532 .type = REGULATOR_VOLTAGE,
533 .owner = THIS_MODULE,
528 }, 534 },
529 { 535 {
530 .name = "LDO_H", 536 .name = "LDO_H",
@@ -532,6 +538,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
532 .ops = &regulator_ops_variable, 538 .ops = &regulator_ops_variable,
533 .n_voltages = ARRAY_SIZE(ldo_h_typ_voltages), 539 .n_voltages = ARRAY_SIZE(ldo_h_typ_voltages),
534 .type = REGULATOR_VOLTAGE, 540 .type = REGULATOR_VOLTAGE,
541 .owner = THIS_MODULE,
535 }, 542 },
536 { 543 {
537 .name = "LDO_K", 544 .name = "LDO_K",
@@ -539,12 +546,14 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
539 .ops = &regulator_ops_variable, 546 .ops = &regulator_ops_variable,
540 .n_voltages = ARRAY_SIZE(ldo_k_typ_voltages), 547 .n_voltages = ARRAY_SIZE(ldo_k_typ_voltages),
541 .type = REGULATOR_VOLTAGE, 548 .type = REGULATOR_VOLTAGE,
549 .owner = THIS_MODULE,
542 }, 550 },
543 { 551 {
544 .name = "LDO_EXT", 552 .name = "LDO_EXT",
545 .id = AB3100_LDO_EXT, 553 .id = AB3100_LDO_EXT,
546 .ops = &regulator_ops_external, 554 .ops = &regulator_ops_external,
547 .type = REGULATOR_VOLTAGE, 555 .type = REGULATOR_VOLTAGE,
556 .owner = THIS_MODULE,
548 }, 557 },
549 { 558 {
550 .name = "BUCK", 559 .name = "BUCK",
@@ -552,6 +561,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
552 .ops = &regulator_ops_variable_sleepable, 561 .ops = &regulator_ops_variable_sleepable,
553 .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages), 562 .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages),
554 .type = REGULATOR_VOLTAGE, 563 .type = REGULATOR_VOLTAGE,
564 .owner = THIS_MODULE,
555 }, 565 },
556}; 566};
557 567
@@ -564,13 +574,12 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
564static int __devinit ab3100_regulators_probe(struct platform_device *pdev) 574static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
565{ 575{
566 struct ab3100_platform_data *plfdata = pdev->dev.platform_data; 576 struct ab3100_platform_data *plfdata = pdev->dev.platform_data;
567 struct ab3100 *ab3100 = platform_get_drvdata(pdev);
568 int err = 0; 577 int err = 0;
569 u8 data; 578 u8 data;
570 int i; 579 int i;
571 580
572 /* Check chip state */ 581 /* Check chip state */
573 err = ab3100_get_register_interruptible(ab3100, 582 err = abx500_get_register_interruptible(&pdev->dev, 0,
574 AB3100_LDO_D, &data); 583 AB3100_LDO_D, &data);
575 if (err) { 584 if (err) {
576 dev_err(&pdev->dev, "could not read initial status of LDO_D\n"); 585 dev_err(&pdev->dev, "could not read initial status of LDO_D\n");
@@ -585,7 +594,7 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
585 594
586 /* Set up regulators */ 595 /* Set up regulators */
587 for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) { 596 for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) {
588 err = ab3100_set_register_interruptible(ab3100, 597 err = abx500_set_register_interruptible(&pdev->dev, 0,
589 ab3100_reg_init_order[i], 598 ab3100_reg_init_order[i],
590 plfdata->reg_initvals[i]); 599 plfdata->reg_initvals[i]);
591 if (err) { 600 if (err) {
@@ -607,7 +616,7 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
607 * see what it looks like for a certain machine, go 616 * see what it looks like for a certain machine, go
608 * into the machine I2C setup. 617 * into the machine I2C setup.
609 */ 618 */
610 reg->ab3100 = ab3100; 619 reg->dev = &pdev->dev;
611 reg->plfdata = plfdata; 620 reg->plfdata = plfdata;
612 621
613 /* 622 /*