power: reset: palmas: add DT support
Laxman Dewangan [Thu, 26 Sep 2013 11:03:46 +0000 (16:03 +0530)]
Add DT support on palmas power-off driver.

Change-Id: Ie1ab874ae2b49f9e564101d70b24862a2c7a910e
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
(cherry picked from commit 808d2d9c09ba2e125659642d66ededab8cd99ca9)
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>

Documentation/devicetree/bindings/power/reset/palmas-poweroff.txt [new file with mode: 0644]
drivers/mfd/palmas.c
drivers/power/reset/palmas-poweroff.c

diff --git a/Documentation/devicetree/bindings/power/reset/palmas-poweroff.txt b/Documentation/devicetree/bindings/power/reset/palmas-poweroff.txt
new file mode 100644 (file)
index 0000000..61beae9
--- /dev/null
@@ -0,0 +1,15 @@
+Power off for Palmas series devices.
+
+Required Properties:
+ - compatible : Must be "ti,palmas-pm"
+
+Optional Properties:
+ - system-pmic-power-off : Use system PMIC to power off device.
+ - system-pmic-power-reset : Use system PMIC to power reset device.
+
+Example:
+palmas_power {
+       compatible = "ti,palmas-pm";
+       system-pmic-power-off;
+       system-pmic-power-reset;
+};
index ab235c8..fa28915 100644 (file)
@@ -964,25 +964,6 @@ static int palmas_set_pdata_irq_flag(struct i2c_client *i2c,
        return 0;
 }
 
-static void palmas_dt_to_pdata(struct i2c_client *i2c,
-               struct palmas_platform_data *pdata)
-{
-       struct device_node *node = i2c->dev.of_node;
-       int ret;
-       u32 prop;
-
-       /* The default for this register is all masked */
-       ret = of_property_read_u32(node, "ti,power-ctrl", &prop);
-       if (!ret)
-               pdata->power_ctrl = prop;
-       else
-               pdata->power_ctrl = PALMAS_POWER_CTRL_NSLEEP_MASK |
-                                       PALMAS_POWER_CTRL_ENABLE1_MASK |
-                                       PALMAS_POWER_CTRL_ENABLE2_MASK;
-       if (i2c->irq)
-               palmas_set_pdata_irq_flag(i2c, pdata);
-}
-
 static int palmas_read_version_information(struct palmas *palmas)
 {
        unsigned int sw_rev, des_rev;
@@ -1040,20 +1021,6 @@ static int palmas_read_version_information(struct palmas *palmas)
        return 0;
 }
 
-static int palmas_set_pdata_irq_flag(struct i2c_client *i2c,
-               struct palmas_platform_data *pdata)
-{
-       struct irq_data *irq_data = irq_get_irq_data(i2c->irq);
-       if (!irq_data) {
-               dev_err(&i2c->dev, "Invalid IRQ: %d\n", i2c->irq);
-               return -EINVAL;
-       }
-
-       pdata->irq_type = irqd_get_trigger_type(irq_data);
-       dev_info(&i2c->dev, "Irq flag is 0x%08x\n", pdata->irq_type);
-       return 0;
-}
-
 static void palmas_dt_to_pdata(struct i2c_client *i2c,
                struct palmas_platform_data *pdata)
 {
index 6538232..cc0e2ec 100644 (file)
@@ -26,6 +26,8 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/palmas.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
 #include <linux/power/reset/system-pmic.h>
 
 struct palmas_pm {
@@ -166,6 +168,7 @@ static int palmas_pm_probe(struct platform_device *pdev)
        struct palmas_platform_data *palmas_pdata;
        struct palmas_pm_platform_data *pm_pdata = NULL;
        struct system_pmic_config config;
+       struct device_node *node = pdev->dev.of_node;
        int i;
 
        palmas_pm = devm_kzalloc(&pdev->dev, sizeof(*palmas_pm),
@@ -206,8 +209,15 @@ static int palmas_pm_probe(struct platform_device *pdev)
                config.allow_power_off = pm_pdata->use_power_off;
                config.allow_power_reset = pm_pdata->use_power_reset;
        } else {
-               config.allow_power_off = true;
-               config.allow_power_reset = false;
+               if (node) {
+                       config.allow_power_off = of_property_read_bool(node,
+                               "system-pmic-power-off");
+                       config.allow_power_reset = of_property_read_bool(node,
+                               "system-pmic-power-reset");
+               } else {
+                       config.allow_power_off = true;
+                       config.allow_power_reset = false;
+               }
        }
 
        palmas_pm->system_pmic_dev = system_pmic_register(&pdev->dev,
@@ -229,12 +239,19 @@ static int palmas_pm_remove(struct platform_device *pdev)
        return 0;
 }
 
+static struct of_device_id of_palmas_pm_match_tbl[] = {
+       { .compatible = "ti,palmas-pm", },
+       { /* end */ }
+};
+MODULE_DEVICE_TABLE(of, of_palmas_pm_match_tbl);
+
 static struct platform_driver palmas_pm_driver = {
        .probe          = palmas_pm_probe,
        .remove         = palmas_pm_remove,
        .driver         = {
                .owner  = THIS_MODULE,
                .name   = "palmas-pm",
+               .of_match_table = of_palmas_pm_match_tbl,
        },
 };