aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/twl4030-power.c
diff options
context:
space:
mode:
authorFlorian Vaussard <florian.vaussard@epfl.ch>2013-06-18 09:17:56 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-19 04:19:39 -0400
commit637d6895f8f5ecc041ca6f521f544bb3d5699416 (patch)
tree22954c8310e695cb275f957c801431a3717d82e8 /drivers/mfd/twl4030-power.c
parente578438820cdca91cb5eab477ec062236433ce5f (diff)
mfd: twl4030-power: Split from twl-core into a dedicated module
For now, the call to twl4030-power is hard-wired inside twl-core. To ease the future transition to DT, make twl4030-power as a separate module, like what is already done for twl4030-audio and others. Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/twl4030-power.c')
-rw-r--r--drivers/mfd/twl4030-power.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index dd362c1078e1..94bcbeed1d62 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -507,8 +507,9 @@ void twl4030_power_off(void)
507 pr_err("TWL4030 Unable to power off\n"); 507 pr_err("TWL4030 Unable to power off\n");
508} 508}
509 509
510void twl4030_power_init(struct twl4030_power_data *twl4030_scripts) 510int twl4030_power_probe(struct platform_device *pdev)
511{ 511{
512 struct twl4030_power_data *pdata = pdev->dev.platform_data;
512 int err = 0; 513 int err = 0;
513 int i; 514 int i;
514 struct twl4030_resconfig *resconfig; 515 struct twl4030_resconfig *resconfig;
@@ -524,14 +525,14 @@ void twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
524 if (err) 525 if (err)
525 goto unlock; 526 goto unlock;
526 527
527 for (i = 0; i < twl4030_scripts->num; i++) { 528 for (i = 0; i < pdata->num; i++) {
528 err = load_twl4030_script(twl4030_scripts->scripts[i], address); 529 err = load_twl4030_script(pdata->scripts[i], address);
529 if (err) 530 if (err)
530 goto load; 531 goto load;
531 address += twl4030_scripts->scripts[i]->size; 532 address += pdata->scripts[i]->size;
532 } 533 }
533 534
534 resconfig = twl4030_scripts->resource_config; 535 resconfig = pdata->resource_config;
535 if (resconfig) { 536 if (resconfig) {
536 while (resconfig->resource) { 537 while (resconfig->resource) {
537 err = twl4030_configure_resource(resconfig); 538 err = twl4030_configure_resource(resconfig);
@@ -543,7 +544,7 @@ void twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
543 } 544 }
544 545
545 /* Board has to be wired properly to use this feature */ 546 /* Board has to be wired properly to use this feature */
546 if (twl4030_scripts->use_poweroff && !pm_power_off) { 547 if (pdata->use_poweroff && !pm_power_off) {
547 /* Default for SEQ_OFFSYNC is set, lets ensure this */ 548 /* Default for SEQ_OFFSYNC is set, lets ensure this */
548 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val, 549 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
549 TWL4030_PM_MASTER_CFG_P123_TRANSITION); 550 TWL4030_PM_MASTER_CFG_P123_TRANSITION);
@@ -568,18 +569,40 @@ relock:
568 TWL4030_PM_MASTER_PROTECT_KEY); 569 TWL4030_PM_MASTER_PROTECT_KEY);
569 if (err) 570 if (err)
570 pr_err("TWL4030 Unable to relock registers\n"); 571 pr_err("TWL4030 Unable to relock registers\n");
571 return; 572 return err;
572 573
573unlock: 574unlock:
574 if (err) 575 if (err)
575 pr_err("TWL4030 Unable to unlock registers\n"); 576 pr_err("TWL4030 Unable to unlock registers\n");
576 return; 577 return err;
577load: 578load:
578 if (err) 579 if (err)
579 pr_err("TWL4030 failed to load scripts\n"); 580 pr_err("TWL4030 failed to load scripts\n");
580 return; 581 return err;
581resource: 582resource:
582 if (err) 583 if (err)
583 pr_err("TWL4030 failed to configure resource\n"); 584 pr_err("TWL4030 failed to configure resource\n");
584 return; 585 return err;
586}
587
588static int twl4030_power_remove(struct platform_device *pdev)
589{
590 return 0;
585} 591}
592
593static struct platform_driver twl4030_power_driver = {
594 .driver = {
595 .name = "twl4030_power",
596 .owner = THIS_MODULE,
597 },
598 .probe = twl4030_power_probe,
599 .remove = twl4030_power_remove,
600};
601
602module_platform_driver(twl4030_power_driver);
603
604MODULE_AUTHOR("Nokia Corporation");
605MODULE_AUTHOR("Texas Instruments, Inc.");
606MODULE_DESCRIPTION("Power management for TWL4030");
607MODULE_LICENSE("GPL");
608MODULE_ALIAS("platform:twl4030_power");