diff options
author | Florian Vaussard <florian.vaussard@epfl.ch> | 2013-06-18 17:17:58 +0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-06-19 12:19:40 +0400 |
commit | b0fc1da4d0359d3cce8f12e0f014aed0704ae202 (patch) | |
tree | 321bd393b7f3d685d43fbef87c8a381a13514113 /drivers/mfd/twl4030-power.c | |
parent | f58cb407632ecf0ec01627b8a61852d5585b573d (diff) | |
download | linux-b0fc1da4d0359d3cce8f12e0f014aed0704ae202.tar.xz |
mfd: twl4030-power: Start transition to DT
Support for loading twl4030-power module via devicetree.
For now, when booting with a DT, only the poweroff callback
feature is supported through the ti,use_poweroff property.
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.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c index d36622d0f98a..5b2848280f4b 100644 --- a/drivers/mfd/twl4030-power.c +++ b/drivers/mfd/twl4030-power.c @@ -28,6 +28,7 @@ #include <linux/pm.h> #include <linux/i2c/twl.h> #include <linux/platform_device.h> +#include <linux/of.h> #include <asm/mach-types.h> @@ -540,12 +541,30 @@ void twl4030_power_off(void) pr_err("TWL4030 Unable to power off\n"); } +static bool twl4030_power_use_poweroff(struct twl4030_power_data *pdata, + struct device_node *node) +{ + if (pdata && pdata->use_poweroff) + return true; + + if (of_property_read_bool(node, "ti,use_poweroff")) + return true; + + return false; +} + int twl4030_power_probe(struct platform_device *pdev) { struct twl4030_power_data *pdata = pdev->dev.platform_data; + struct device_node *node = pdev->dev.of_node; int err = 0; u8 val; + if (!pdata && !node) { + dev_err(&pdev->dev, "Platform data is missing\n"); + return -EINVAL; + } + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, TWL4030_PM_MASTER_PROTECT_KEY); if (err) @@ -556,15 +575,18 @@ int twl4030_power_probe(struct platform_device *pdev) if (err) goto unlock; - err = twl4030_power_configure_scripts(pdata); - if (err) - goto load; - err = twl4030_power_configure_resources(pdata); - if (err) - goto resource; + if (pdata) { + /* TODO: convert to device tree */ + err = twl4030_power_configure_scripts(pdata); + if (err) + goto load; + err = twl4030_power_configure_resources(pdata); + if (err) + goto resource; + } /* Board has to be wired properly to use this feature */ - if (pdata->use_poweroff && !pm_power_off) { + if (twl4030_power_use_poweroff(pdata, node) && !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); @@ -610,10 +632,19 @@ static int twl4030_power_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id twl4030_power_of_match[] = { + {.compatible = "ti,twl4030-power", }, + { }, +}; +MODULE_DEVICE_TABLE(of, twl4030_power_of_match); +#endif + static struct platform_driver twl4030_power_driver = { .driver = { .name = "twl4030_power", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(twl4030_power_of_match), }, .probe = twl4030_power_probe, .remove = twl4030_power_remove, |