From 1a6095ddd2615bd6f4a0582a5b6f86fa0ba3f69d Mon Sep 17 00:00:00 2001 From: Xin Xie Date: Fri, 11 Mar 2011 19:04:15 -0800 Subject: 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 Tested-by: Varun Colbert Reviewed-by: Xin Xie Tested-by: Xin Xie Rebase-Id: R2f74b345bc3ea3adc22adcab40ee407c3e65cae9 --- drivers/regulator/tps6586x-regulator.c | 36 +++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'drivers/regulator/tps6586x-regulator.c') 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) -- cgit v1.2.3