diff options
-rw-r--r-- | drivers/regulator/tps6586x-regulator.c | 36 | ||||
-rw-r--r-- | include/linux/mfd/tps6586x.h | 15 |
2 files changed, 50 insertions, 1 deletions
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index cf9ed5349383..54de4c3a3d13 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c @@ -336,6 +336,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; @@ -378,7 +412,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) diff --git a/include/linux/mfd/tps6586x.h b/include/linux/mfd/tps6586x.h index 9002714f1f68..c98b6fa4148b 100644 --- a/include/linux/mfd/tps6586x.h +++ b/include/linux/mfd/tps6586x.h @@ -1,6 +1,10 @@ #ifndef __LINUX_MFD_TPS6586X_H #define __LINUX_MFD_TPS6586X_H +#define SM0_PWM_BIT 0 +#define SM1_PWM_BIT 1 +#define SM2_PWM_BIT 2 + enum { TPS6586X_ID_SM_0, TPS6586X_ID_SM_1, @@ -48,6 +52,17 @@ enum { TPS6586X_INT_RTC_ALM2, }; +enum pwm_pfm_mode { + PWM_ONLY, + AUTO_PWM_PFM, + NOT_CONFIGURABLE +}; + +struct tps6586x_settings { + /* SM0, SM1 and SM2 have PWM-only and auto PWM/PFM mode */ + enum pwm_pfm_mode sm_pwm_mode; +}; + struct tps6586x_subdev_info { int id; const char *name; |