regulator: palmas: add config flags to configure regulator behavior
Laxman Dewangan [Thu, 9 May 2013 15:12:54 +0000 (20:12 +0530)]
Add the config variable on regulator init data to configure the rails
behavior like force off on suspend etc.

bug 1278567

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

drivers/regulator/palmas-regulator.c
include/linux/mfd/palmas.h

index c6e7a01..8d9b69f 100644 (file)
@@ -1458,8 +1458,10 @@ static __devinit int palmas_probe(struct platform_device *pdev)
                        goto err_unregister_regulator;
                }
 
-               if (reg_init && reg_data)
+               if (reg_init && reg_data) {
                        pmic->roof_floor[id] = reg_init->roof_floor;
+                       pmic->config_flags[id] = reg_init->config_flags;
+               }
 
                /* Save regulator for cleanup */
                pmic->rdev[id] = rdev;
@@ -1510,6 +1512,8 @@ static __devinit int palmas_probe(struct platform_device *pdev)
                        reg_init = pdata->reg_init[id];
                        if (reg_init) {
                                pmic->roof_floor[id] = reg_init->roof_floor;
+                               pmic->config_flags[id] = reg_init->config_flags;
+
                                if (id < PALMAS_REG_REGEN1)
                                        ret = palmas_ldo_init(palmas, id,
                                                                reg_init);
@@ -1558,6 +1562,7 @@ static int palmas_suspend(struct device *dev)
        struct palmas *palmas = dev_get_drvdata(dev->parent);
        struct palmas_pmic *pmic = dev_get_drvdata(dev);
        struct palmas_pmic_platform_data *pdata = dev_get_platdata(dev);
+       int id;
 
        /* Check if LDO8 is in tracking mode disable in suspend or not */
        if (pdata->enable_ldo8_tracking && pdata->disabe_ldo8_tracking_suspend)
@@ -1566,6 +1571,14 @@ static int palmas_suspend(struct device *dev)
        if (pdata->disable_smps10_boost_suspend &&
                        !pmic->smps10_regulator_enabled)
                palmas_disable_smps10_boost(palmas);
+
+       for (id = 0; id < PALMAS_NUM_REGS; id++) {
+               if (pmic->config_flags[id] &
+                       PALMAS_REGULATOR_CONFIG_SUSPEND_FORCE_OFF) {
+                       if (pmic->desc[id].ops->disable)
+                               pmic->desc[id].ops->disable(pmic->rdev[id]);
+               }
+       }
        return 0;
 }
 
@@ -1574,6 +1587,7 @@ static int palmas_resume(struct device *dev)
        struct palmas *palmas = dev_get_drvdata(dev->parent);
        struct palmas_pmic *pmic = dev_get_drvdata(dev);
        struct palmas_pmic_platform_data *pdata = dev_get_platdata(dev);
+       int id;
 
        /* Check if LDO8 is in tracking mode disable in suspend or not */
        if (pdata->enable_ldo8_tracking && pdata->disabe_ldo8_tracking_suspend)
@@ -1582,6 +1596,14 @@ static int palmas_resume(struct device *dev)
        if (pdata->disable_smps10_boost_suspend &&
                        !pmic->smps10_regulator_enabled)
                palmas_enable_smps10_boost(palmas);
+
+       for (id = 0; id < PALMAS_NUM_REGS; id++) {
+               if (pmic->config_flags[id] &
+                       PALMAS_REGULATOR_CONFIG_SUSPEND_FORCE_OFF) {
+                       if (pmic->desc[id].ops->enable)
+                               pmic->desc[id].ops->enable(pmic->rdev[id]);
+               }
+       }
        return 0;
 }
 #endif
index 5bad75c..cce2e35 100644 (file)
@@ -114,6 +114,8 @@ struct palmas_reg_init {
         */
        u8 vsel;
 
+       /* Configuration flags */
+       unsigned int config_flags;
 };
 
 enum palmas_regulators {
@@ -310,6 +312,7 @@ struct palmas_pmic {
 
        int range[PALMAS_REG_SMPS10];
        unsigned long roof_floor[PALMAS_NUM_REGS];
+       unsigned long config_flags[PALMAS_NUM_REGS];
 };
 
 /* defines so we can store the mux settings */
@@ -2735,6 +2738,14 @@ enum {
        PALMAS_EXT_CONTROL_NSLEEP       = 0x4,
 };
 
+/**
+ * Palmas regulator configs
+ * PALMAS_REGULATOR_CONFIG_SUSPEND_FORCE_OFF: Force off on suspend
+ */
+enum {
+       PALMAS_REGULATOR_CONFIG_SUSPEND_FORCE_OFF = 0x1,
+};
+
 /*
  *PALMAS GPIOs
  */