summaryrefslogtreecommitdiff
path: root/drivers/mfd/twl4030-power.c
diff options
context:
space:
mode:
authorFlorian Vaussard <florian.vaussard@epfl.ch>2013-06-18 15:17:56 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-19 10:19:39 +0200
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)
pr_err("TWL4030 Unable to power off\n");
}
-void twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
+int twl4030_power_probe(struct platform_device *pdev)
{
+ struct twl4030_power_data *pdata = pdev->dev.platform_data;
int err = 0;
int i;
struct twl4030_resconfig *resconfig;
@@ -524,14 +525,14 @@ void twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
if (err)
goto unlock;
- for (i = 0; i < twl4030_scripts->num; i++) {
- err = load_twl4030_script(twl4030_scripts->scripts[i], address);
+ for (i = 0; i < pdata->num; i++) {
+ err = load_twl4030_script(pdata->scripts[i], address);
if (err)
goto load;
- address += twl4030_scripts->scripts[i]->size;
+ address += pdata->scripts[i]->size;
}
- resconfig = twl4030_scripts->resource_config;
+ resconfig = pdata->resource_config;
if (resconfig) {
while (resconfig->resource) {
err = twl4030_configure_resource(resconfig);
@@ -543,7 +544,7 @@ void twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
}
/* Board has to be wired properly to use this feature */
- if (twl4030_scripts->use_poweroff && !pm_power_off) {
+ if (pdata->use_poweroff && !pm_power_off) {
/* Default for SEQ_OFFSYNC is set, lets ensure this */
err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
TWL4030_PM_MASTER_CFG_P123_TRANSITION);
@@ -568,18 +569,40 @@ relock:
TWL4030_PM_MASTER_PROTECT_KEY);
if (err)
pr_err("TWL4030 Unable to relock registers\n");
- return;
+ return err;
unlock:
if (err)
pr_err("TWL4030 Unable to unlock registers\n");
- return;
+ return err;
load:
if (err)
pr_err("TWL4030 failed to load scripts\n");
- return;
+ return err;
resource:
if (err)
pr_err("TWL4030 failed to configure resource\n");
- return;
+ return err;
+}
+
+static int twl4030_power_remove(struct platform_device *pdev)
+{
+ return 0;
}
+
+static struct platform_driver twl4030_power_driver = {
+ .driver = {
+ .name = "twl4030_power",
+ .owner = THIS_MODULE,
+ },
+ .probe = twl4030_power_probe,
+ .remove = twl4030_power_remove,
+};
+
+module_platform_driver(twl4030_power_driver);
+
+MODULE_AUTHOR("Nokia Corporation");
+MODULE_AUTHOR("Texas Instruments, Inc.");
+MODULE_DESCRIPTION("Power management for TWL4030");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:twl4030_power");