aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Vaussard <florian.vaussard@epfl.ch>2013-06-18 09:17:58 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-19 04:19:40 -0400
commitb0fc1da4d0359d3cce8f12e0f014aed0704ae202 (patch)
tree321bd393b7f3d685d43fbef87c8a381a13514113
parentf58cb407632ecf0ec01627b8a61852d5585b573d (diff)
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>
-rw-r--r--Documentation/devicetree/bindings/mfd/twl4030-power.txt28
-rw-r--r--drivers/mfd/twl4030-power.c45
2 files changed, 66 insertions, 7 deletions
diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
new file mode 100644
index 000000000000..8e15ec35ac99
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -0,0 +1,28 @@
1Texas Instruments TWL family (twl4030) reset and power management module
2
3The power management module inside the TWL family provides several facilities
4to control the power resources, including power scripts. For now, the
5binding only supports the complete shutdown of the system after poweroff.
6
7Required properties:
8- compatible : must be "ti,twl4030-power"
9
10Optional properties:
11- ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
12 SLEEP-to-OFF transition when the system poweroffs.
13
14Example:
15&i2c1 {
16 clock-frequency = <2600000>;
17
18 twl: twl@48 {
19 reg = <0x48>;
20 interrupts = <7>; /* SYS_NIRQ cascaded to intc */
21 interrupt-parent = <&intc>;
22
23 twl_power: power {
24 compatible = "ti,twl4030-power";
25 ti,use_poweroff;
26 };
27 };
28};
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 @@
28#include <linux/pm.h> 28#include <linux/pm.h>
29#include <linux/i2c/twl.h> 29#include <linux/i2c/twl.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/of.h>
31 32
32#include <asm/mach-types.h> 33#include <asm/mach-types.h>
33 34
@@ -540,12 +541,30 @@ void twl4030_power_off(void)
540 pr_err("TWL4030 Unable to power off\n"); 541 pr_err("TWL4030 Unable to power off\n");
541} 542}
542 543
544static bool twl4030_power_use_poweroff(struct twl4030_power_data *pdata,
545 struct device_node *node)
546{
547 if (pdata && pdata->use_poweroff)
548 return true;
549
550 if (of_property_read_bool(node, "ti,use_poweroff"))
551 return true;
552
553 return false;
554}
555
543int twl4030_power_probe(struct platform_device *pdev) 556int twl4030_power_probe(struct platform_device *pdev)
544{ 557{
545 struct twl4030_power_data *pdata = pdev->dev.platform_data; 558 struct twl4030_power_data *pdata = pdev->dev.platform_data;
559 struct device_node *node = pdev->dev.of_node;
546 int err = 0; 560 int err = 0;
547 u8 val; 561 u8 val;
548 562
563 if (!pdata && !node) {
564 dev_err(&pdev->dev, "Platform data is missing\n");
565 return -EINVAL;
566 }
567
549 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, 568 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
550 TWL4030_PM_MASTER_PROTECT_KEY); 569 TWL4030_PM_MASTER_PROTECT_KEY);
551 if (err) 570 if (err)
@@ -556,15 +575,18 @@ int twl4030_power_probe(struct platform_device *pdev)
556 if (err) 575 if (err)
557 goto unlock; 576 goto unlock;
558 577
559 err = twl4030_power_configure_scripts(pdata); 578 if (pdata) {
560 if (err) 579 /* TODO: convert to device tree */
561 goto load; 580 err = twl4030_power_configure_scripts(pdata);
562 err = twl4030_power_configure_resources(pdata); 581 if (err)
563 if (err) 582 goto load;
564 goto resource; 583 err = twl4030_power_configure_resources(pdata);
584 if (err)
585 goto resource;
586 }
565 587
566 /* Board has to be wired properly to use this feature */ 588 /* Board has to be wired properly to use this feature */
567 if (pdata->use_poweroff && !pm_power_off) { 589 if (twl4030_power_use_poweroff(pdata, node) && !pm_power_off) {
568 /* Default for SEQ_OFFSYNC is set, lets ensure this */ 590 /* Default for SEQ_OFFSYNC is set, lets ensure this */
569 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val, 591 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
570 TWL4030_PM_MASTER_CFG_P123_TRANSITION); 592 TWL4030_PM_MASTER_CFG_P123_TRANSITION);
@@ -610,10 +632,19 @@ static int twl4030_power_remove(struct platform_device *pdev)
610 return 0; 632 return 0;
611} 633}
612 634
635#ifdef CONFIG_OF
636static const struct of_device_id twl4030_power_of_match[] = {
637 {.compatible = "ti,twl4030-power", },
638 { },
639};
640MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
641#endif
642
613static struct platform_driver twl4030_power_driver = { 643static struct platform_driver twl4030_power_driver = {
614 .driver = { 644 .driver = {
615 .name = "twl4030_power", 645 .name = "twl4030_power",
616 .owner = THIS_MODULE, 646 .owner = THIS_MODULE,
647 .of_match_table = of_match_ptr(twl4030_power_of_match),
617 }, 648 },
618 .probe = twl4030_power_probe, 649 .probe = twl4030_power_probe,
619 .remove = twl4030_power_remove, 650 .remove = twl4030_power_remove,