summaryrefslogtreecommitdiff
path: root/drivers/regulator/tps6586x-regulator.c
diff options
context:
space:
mode:
authorXin Xie <xxie@nvidia.com>2011-03-11 19:04:15 -0800
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:43:09 -0800
commit1a6095ddd2615bd6f4a0582a5b6f86fa0ba3f69d (patch)
tree76658832ecc65eafbfedbd522cb84dc0f03fd93f /drivers/regulator/tps6586x-regulator.c
parentaeba0f4b9244146a3206f8bb9a13c3e29b294a99 (diff)
regulator: tps6586x: add PFM/PWM options on SMs supply
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
Diffstat (limited to 'drivers/regulator/tps6586x-regulator.c')
-rw-r--r--drivers/regulator/tps6586x-regulator.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index 8c33fea313f8..62bad442ed2a 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -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)