regulator: palmas: add DT support
Laxman Dewangan [Fri, 6 Sep 2013 11:24:41 +0000 (16:24 +0530)]
Add DT support for palmas regulators.

Change-Id: Ia453390de433a0bc9ca75daf2afe55523b415726
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/271501

Documentation/devicetree/bindings/regulator/palmas-pmic.txt [new file with mode: 0644]
drivers/regulator/palmas-regulator.c

diff --git a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
new file mode 100644 (file)
index 0000000..daa3ee2
--- /dev/null
@@ -0,0 +1,89 @@
+* palmas regulator IP block devicetree bindings
+
+Required properties:
+- compatible : Should be from the list
+  ti,twl6035-pmic
+  ti,twl6036-pmic
+  ti,twl6037-pmic
+  ti,tps65913-pmic
+  ti,tps65914-pmic
+  ti,tps80036-pmic
+and also the generic series names
+  ti,palmas-pmic
+- interrupt-parent : The parent interrupt controller which is palmas.
+- interrupts : The interrupt number and the type which can be looked up here:
+              arch/arm/boot/dts/include/dt-bindings/interrupt-controller/irq.h
+- interrupts-name: The names of the individual interrupts.
+
+Optional properties:
+- ti,ldo6-vibrator : ldo6 is in vibrator mode
+- ti,config_flags: Configuration flags.
+               0x1: Force off on suspendi.
+               0x2: Trackign enable.
+               0x4: Tracking disable on suspend.
+- ti,tracking-regulator: Tracking regulator phandle.
+- gpio-extcontrol: GPIO for external control.
+
+Optional nodes:
+- regulators : Must contain a sub-node per regulator from the list below.
+              Each sub-node should contain the constraints and initialization
+              information for that regulator. See regulator.txt for a
+              description of standard properties for these sub-nodes.
+              Additional custom properties  are listed below.
+
+              For ti,palmas-pmic - smps12, smps123, smps3 depending on OTP,
+              smps45, smps457, smps7 depending on variant, smps6, smps[8-9],
+              smps10_out2, smps10_out1, ldo[1-14], ldoln, ldousb, regen[1-5],
+              regen7, sysen1, sysen2.
+
+              Optional sub-node properties:
+              ti,warm-reset - maintain voltage during warm reset(boolean)
+              ti,roof-floor - This takes as optional argument on platform supporting
+              the rail from desired external control. If there is no argument then
+              it will be assume that it is controlled by NSLEEP pin.
+              The valid value for external pins are:
+                       ENABLE1 then 1,
+                       ENABLE2 then 2 or
+                       NSLEEP then 3.
+              ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto,
+              2 - eco, 3 - forced pwm
+              ti,smps-range - OTP has the wrong range set for the hardware so override
+              0 - low range, 1 - high range.
+
+- ti,system-power-controller: Telling whether or not this pmic is controlling
+                             the system power.
+
+Example:
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+pmic {
+       compatible = "ti,twl6035-pmic", "ti,palmas-pmic";
+       interrupt-parent = <&palmas>;
+       interrupts = <14 IRQ_TYPE_NONE>;
+       interrupts-name = "short-irq";
+
+       ti,ldo6-vibrator;
+
+       ti,system-power-controller;
+
+       regulators {
+               smps12_reg : smps12 {
+                       regulator-name = "smps12";
+                       regulator-min-microvolt = < 600000>;
+                       regulator-max-microvolt = <1500000>;
+                       regulator-always-on;
+                       regulator-boot-on;
+                       ti,warm-reset;
+                       ti,roof-floor = <1>; /* ENABLE1 control */
+                       ti,mode-sleep = <0>;
+                       ti,smps-range = <1>;
+               };
+
+               ldo1_reg: ldo1 {
+                       regulator-name = "ldo1";
+                       regulator-min-microvolt = <2800000>;
+                       regulator-max-microvolt = <2800000>;
+               };
+       };
+};
index 411e9a7..5a6234e 100644 (file)
@@ -125,7 +125,7 @@ static const struct regs_info palmas_regs_info[] = {
        },
        {
                .name           = "SMPS10_OUT1",
-               .sname          = "smps10-in",
+               .sname          = "smps10-out2",
                .ctrl_addr      = PALMAS_SMPS10_CTRL,
                .sleep_id       = PALMAS_SLEEP_REQSTR_ID_SMPS10,
        },
@@ -194,30 +194,35 @@ static const struct regs_info palmas_regs_info[] = {
        },
        {
                .name           = "LDO10",
+               .sname          = "ldo10-in",
                .vsel_addr      = PALMAS_LDO10_VOLTAGE,
                .ctrl_addr      = PALMAS_LDO10_CTRL,
                .sleep_id       = PALMAS_SLEEP_REQSTR_ID_LDO10,
        },
        {
                .name           = "LDO11",
+               .sname          = "ldo11-in",
                .vsel_addr      = PALMAS_LDO11_VOLTAGE,
                .ctrl_addr      = PALMAS_LDO11_CTRL,
                .sleep_id       = PALMAS_SLEEP_REQSTR_ID_LDO11,
        },
        {
                .name           = "LDO12",
+               .sname          = "ldo12-in",
                .vsel_addr      = PALMAS_LDO12_VOLTAGE,
                .ctrl_addr      = PALMAS_LDO12_CTRL,
                .sleep_id       = PALMAS_SLEEP_REQSTR_ID_LDO12,
        },
        {
                .name           = "LDO13",
+               .sname          = "ldo13-in",
                .vsel_addr      = PALMAS_LDO13_VOLTAGE,
                .ctrl_addr      = PALMAS_LDO13_CTRL,
                .sleep_id       = PALMAS_SLEEP_REQSTR_ID_LDO13,
        },
        {
                .name           = "LDO14",
+               .sname          = "ldo14-in",
                .vsel_addr      = PALMAS_LDO14_VOLTAGE,
                .ctrl_addr      = PALMAS_LDO14_CTRL,
                .sleep_id       = PALMAS_SLEEP_REQSTR_ID_LDO14,
@@ -1223,7 +1228,8 @@ static struct of_regulator_match palmas_matches[] = {
        { .name = "smps7", },
        { .name = "smps8", },
        { .name = "smps9", },
-       { .name = "smps10", },
+       { .name = "smps10_out2", },
+       { .name = "smps10_out1", },
        { .name = "ldo1", },
        { .name = "ldo2", },
        { .name = "ldo3", },
@@ -1233,13 +1239,22 @@ static struct of_regulator_match palmas_matches[] = {
        { .name = "ldo7", },
        { .name = "ldo8", },
        { .name = "ldo9", },
+       { .name = "ldo10", },
+       { .name = "ldo11", },
+       { .name = "ldo12", },
+       { .name = "ldo13", },
+       { .name = "ldo14", },
        { .name = "ldoln", },
        { .name = "ldousb", },
        { .name = "regen1", },
        { .name = "regen2", },
        { .name = "regen3", },
+       { .name = "regen4", },
+       { .name = "regen5", },
+       { .name = "regen7", },
        { .name = "sysen1", },
        { .name = "sysen2", },
+       { .name = "charger_pump", },
 };
 
 static void palmas_dt_to_pdata(struct device *dev,
@@ -1279,9 +1294,35 @@ static void palmas_dt_to_pdata(struct device *dev,
                        of_property_read_bool(palmas_matches[idx].of_node,
                                             "ti,warm-reset");
 
-               pdata->reg_init[idx]->roof_floor =
-                       of_property_read_bool(palmas_matches[idx].of_node,
-                                             "ti,roof-floor");
+               ret = of_property_read_u32(palmas_matches[idx].of_node,
+                                             "ti,roof-floor", &prop);
+               /* EINVAL: Property not found */
+               if (ret != -EINVAL) {
+                       int econtrol;
+
+                       /* use default value, when no value is specified */
+                       econtrol = PALMAS_EXT_CONTROL_NSLEEP;
+                       if (!ret) {
+                               switch (prop) {
+                               case 1:
+                                       econtrol = PALMAS_EXT_CONTROL_ENABLE1;
+                                       break;
+                               case 2:
+                                       econtrol = PALMAS_EXT_CONTROL_ENABLE2;
+                                       break;
+                               case 3:
+                                       econtrol = PALMAS_EXT_CONTROL_NSLEEP;
+                                       break;
+                               default:
+                                       WARN_ON(1);
+                                       dev_warn(dev,
+                                       "%s: Invalid roof-floor option: %u\n",
+                                            palmas_matches[idx].name, prop);
+                                       break;
+                               }
+                       }
+                       pdata->reg_init[idx]->roof_floor = econtrol;
+               }
 
                ret = of_property_read_u32(palmas_matches[idx].of_node,
                                "ti,mode-sleep", &prop);
@@ -1301,6 +1342,11 @@ static void palmas_dt_to_pdata(struct device *dev,
                                        PALMAS_REGULATOR_CONFIG_TRACKING_ENABLE;
                        }
                }
+
+               ret = of_property_read_u32(palmas_matches[idx].of_node,
+                               "ti,config-flags", &prop);
+               if (!ret)
+                       pdata->reg_init[idx]->config_flags = prop;
        }
 
        pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator");
@@ -1310,7 +1356,7 @@ static void palmas_dt_to_pdata(struct device *dev,
 static int palmas_regulators_probe(struct platform_device *pdev)
 {
        struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
-       struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data;
+       struct palmas_pmic_platform_data *pdata = dev_get_platdata(&pdev->dev);
        struct device_node *node = pdev->dev.of_node;
        struct regulator_dev *rdev;
        struct regulator_config config = { };
@@ -1489,6 +1535,7 @@ static int palmas_regulators_probe(struct platform_device *pdev)
 
                pmic->desc[id].type = REGULATOR_VOLTAGE;
                pmic->desc[id].owner = THIS_MODULE;
+               pmic->desc[id].supply_name = palmas_regs_info[id].sname;
 
                if (pdata)
                        config.init_data = pdata->reg_data[id];
@@ -1496,7 +1543,7 @@ static int palmas_regulators_probe(struct platform_device *pdev)
                        config.init_data = NULL;
 
                pmic->desc[id].supply_name = palmas_regs_info[id].sname;
-               config.of_node = NULL;//palmas_matches[id].of_node;
+               config.of_node = palmas_matches[id].of_node;
                if (roof_floor & EXT_PWR_REQ) {
                        config.ena_gpio = reg_init->enable_gpio;
                        config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
@@ -1553,6 +1600,7 @@ static int palmas_regulators_probe(struct platform_device *pdev)
                pmic->desc[id].id = id;
                pmic->desc[id].type = REGULATOR_VOLTAGE;
                pmic->desc[id].owner = THIS_MODULE;
+               pmic->desc[id].supply_name = palmas_regs_info[id].sname;
 
                if (id < PALMAS_REG_REGEN1) {
                        pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES;
@@ -1603,7 +1651,7 @@ static int palmas_regulators_probe(struct platform_device *pdev)
                        config.init_data = NULL;
 
                pmic->desc[id].supply_name = palmas_regs_info[id].sname;
-               config.of_node = NULL; //palmas_matches[id].of_node;
+               config.of_node = palmas_matches[id].of_node;
                if (roof_floor) {
                        config.ena_gpio = reg_init->enable_gpio;
                        config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
@@ -1664,6 +1712,7 @@ static struct of_device_id of_palmas_match_tbl[] = {
        { .compatible = "ti,tps65913-pmic", },
        { .compatible = "ti,tps65914-pmic", },
        { .compatible = "ti,tps80036-pmic", },
+       { .compatible = "ti,tps659038-pmic", },
        { /* end */ }
 };
 
@@ -1720,7 +1769,6 @@ static const struct dev_pm_ops palmas_pm_ops = {
        SET_SYSTEM_SLEEP_PM_OPS(palmas_suspend, palmas_resume)
 };
 
-
 static struct platform_driver palmas_driver = {
        .driver = {
                .name = "palmas-pmic",