regulator: tps6586x: add PFM/PWM options on SMs supply
Xin Xie [Sat, 12 Mar 2011 03:04:15 +0000 (19:04 -0800)]
TPS6586x SM0, SM1 and SM2 port have 2 power switching modes:
 - PWM only, or
 - PMW-PFM auto mode

Some of TPS6586x have voltage spike in PFM-to-FWM transition can lockup
the CPU if choose PWM-PFM auto mode.

This patch enables such mode selection on SMs ports from the board level
power configuration file.

BUG 796364

Original-Change-Id: I7015798151d6753ff5dcc329703338fde105e2b0
Reviewed-on: http://git-master/r/22701
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
Reviewed-by: Xin Xie <xxie@nvidia.com>
Tested-by: Xin Xie <xxie@nvidia.com>

Rebase-Id: R2f74b345bc3ea3adc22adcab40ee407c3e65cae9

drivers/regulator/tps6586x-regulator.c

index 8c33fea..62bad44 100644 (file)
@@ -341,6 +341,40 @@ static inline int tps6586x_regulator_preinit(struct device *parent,
                                 1 << ri->enable_bit[1]);
 }
 
+static inline int tps6586x_regulator_set_pwm_mode(struct platform_device *pdev)
+{
+       struct device *parent = pdev->dev.parent;
+       struct regulator_init_data *p = pdev->dev.platform_data;
+       struct tps6586x_settings *setting = p->driver_data;
+       int ret = 0;
+       uint8_t mask;
+
+       if (setting == NULL)
+               return 0;
+
+       switch (pdev->id) {
+       case TPS6586X_ID_SM_0:
+               mask = 1 << SM0_PWM_BIT;
+               break;
+       case TPS6586X_ID_SM_1:
+               mask = 1 << SM1_PWM_BIT;
+               break;
+       case TPS6586X_ID_SM_2:
+               mask = 1 << SM2_PWM_BIT;
+               break;
+       default:
+               /* not all regulators have PWM/PFM option */
+               return 0;
+       }
+
+       if (setting->sm_pwm_mode == PWM_ONLY)
+               ret = tps6586x_set_bits(parent, TPS6586X_SMODE1, mask);
+       else if (setting->sm_pwm_mode == AUTO_PWM_PFM)
+               ret = tps6586x_clr_bits(parent, TPS6586X_SMODE1, mask);
+
+       return ret;
+}
+
 static inline struct tps6586x_regulator *find_regulator_info(int id)
 {
        struct tps6586x_regulator *ri;
@@ -383,7 +417,7 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, rdev);
 
-       return 0;
+       return tps6586x_regulator_set_pwm_mode(pdev);
 }
 
 static int __devexit tps6586x_regulator_remove(struct platform_device *pdev)